1 #ifndef __FPA__IMAGE__ALGORITHM__H__
2 #define __FPA__IMAGE__ALGORITHM__H__
5 #include <itkFunctionBase.h>
15 template< class VV, class C >
16 class CastVertexValueToCost
17 : public itk::FunctionBase< VV, C >
20 // Type-related and pointers
21 typedef CastVertexValueToCost Self;
22 typedef itk::FunctionBase< VV, C > Superclass;
23 typedef itk::SmartPointer< Self > Pointer;
24 typedef itk::SmartPointer< const Self > ConstPointer;
28 itkTypeMacro( CastVertexValueToCost, itkFunctionBase );
31 virtual C Evaluate( const VV& v ) const
35 CastVertexValueToCost( )
38 virtual ~CastVertexValueToCost( )
42 // Purposely not implemented
43 CastVertexValueToCost( const Self& );
44 void operator=( const Self& );
49 template< class VV, class C >
50 class CastVertexValueToConstantCost
51 : public itk::FunctionBase< VV, C >
54 // Type-related and pointers
55 typedef CastVertexValueToConstantCost Self;
56 typedef itk::FunctionBase< VV, C > Superclass;
57 typedef itk::SmartPointer< Self > Pointer;
58 typedef itk::SmartPointer< const Self > ConstPointer;
62 itkTypeMacro( CastVertexValueToConstantCost, itkFunctionBase );
65 virtual C Evaluate( const VV& v ) const
69 CastVertexValueToConstantCost( )
72 virtual ~CastVertexValueToConstantCost( )
76 // Purposely not implemented
77 CastVertexValueToConstantCost( const Self& );
78 void operator=( const Self& );
84 * A generic front propagation algorithm were vertices are image pixels.
86 * @param I Input image type
87 * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching)
89 template< class I, class A, class CC >
94 /// Standard class typdedefs
95 typedef Algorithm Self;
97 typedef itk::SmartPointer< Self > Pointer;
98 typedef itk::SmartPointer< const Self > ConstPointer;
100 /// Template input values
101 typedef I TInputImage;
102 typedef A TBaseAlgorithm;
103 typedef CC TCostConversionFunction;
105 typedef typename A::TTraits TTraits;
106 typedef typename TTraits::TCost TCost;
107 typedef typename TTraits::TResult TResult;
108 typedef typename TTraits::TVertex TVertex;
109 typedef typename TTraits::TVertexValue TVertexValue;
111 typedef itk::Image< TResult, I::ImageDimension > TOutputImage;
114 typedef typename TTraits::TFrontId _TFrontId;
115 typedef typename TTraits::TNode _TNode;
116 typedef typename TTraits::TNodes _TNodes;
119 typedef itk::Image< bool, I::ImageDimension > _TMarks;
120 typedef itk::Image< _TFrontId, I::ImageDimension > _TFrontsIds;
121 typedef itk::Image< TVertex, I::ImageDimension > _TParents;
124 itkTypeMacro( Algorithm, TAlgorithm );
127 itkGetConstMacro( NeighborhoodOrder, unsigned int );
128 itkGetConstObjectMacro( CostConversion, TCostConversionFunction );
129 itkGetObjectMacro( CostConversion, TCostConversionFunction );
131 itkSetMacro( NeighborhoodOrder, unsigned int );
132 itkSetObjectMacro( CostConversion, TCostConversionFunction );
136 virtual ~Algorithm( );
139 virtual bool _UpdateResult( _TNode& n );
141 /// Pure virtual interface: vertices
142 virtual unsigned long _NumberOfVertices ( ) const;
143 virtual TVertexValue _Value ( const TVertex& v ) const;
144 virtual TResult _Result ( const TVertex& v ) const;
146 /// Pure virtual interface: edges
147 virtual double _Norm ( const TVertex& a, const TVertex& b ) const;
148 virtual bool _Edge ( const TVertex& a, const TVertex& b ) const;
149 virtual TCost _Cost ( const TVertex& a, const TVertex& b ) const;
151 /// Pure virtual interface: neighborhood
152 virtual void _Neighs ( const _TNode& n, _TNodes& N ) const;
153 virtual void _NeighsInDim ( const _TNode& n,
154 const unsigned int& d,
157 /// Pure virtual interface: results
158 virtual void _InitializeResults ( );
161 Algorithm( const Self& ); // Not impl.
162 void operator=( const Self& ); // Not impl.
165 unsigned int m_NeighborhoodOrder;
166 typename TCostConversionFunction::Pointer m_CostConversion;
173 #include <fpa/Image/Algorithm.hxx>
175 #endif // __FPA__IMAGE__ALGORITHM__H__