1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__H__
6 #define __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__H__
9 #include <itkImageFunction.h>
11 namespace cpExtensions
18 class GradientFunctionBase
19 : public itk::ImageFunction< G, typename G::PixelType::ValueType, typename G::PixelType::ValueType >
22 // Types from input arguments
24 typedef typename G::PixelType TVector;
25 typedef typename TVector::ValueType TScalar;
26 itkStaticConstMacro( Dimension, unsigned int, G::ImageDimension );
29 typedef GradientFunctionBase Self;
30 typedef itk::ImageFunction< G, TScalar, TScalar > Superclass;
31 typedef itk::SmartPointer< Self > Pointer;
32 typedef itk::SmartPointer< const Self > ConstPointer;
34 // Types from base itk::ImageFunction
35 typedef typename Superclass::InputType TInput;
36 typedef typename Superclass::OutputType TOutput;
37 typedef typename Superclass::PointType TPoint;
38 typedef typename Superclass::ContinuousIndexType TContIndex;
39 typedef typename Superclass::IndexType TIndex;
42 typedef std::map< TIndex, TOutput, typename TIndex::LexicographicCompare > TBuffer;
45 itkTypeMacro( GradientFunctionBase, itkImageFunction );
47 itkBooleanMacro( BufferResults );
48 itkGetConstMacro( BufferResults, bool );
49 itkSetMacro( BufferResults, bool );
52 virtual void ResetBuffer( );
54 virtual TOutput Evaluate( const TPoint& p ) const;
55 virtual TOutput EvaluateAtIndex( const TIndex& i ) const;
56 virtual TOutput EvaluateAtContinuousIndex( const TContIndex& i ) const;
59 GradientFunctionBase( );
60 virtual ~GradientFunctionBase( );
62 virtual TOutput _Evaluate( const TIndex& i ) const = 0;
65 // Purposely not implemented.
66 GradientFunctionBase( const Self& );
67 void operator=( const Self& );
70 mutable TBuffer m_Buffer;
78 #ifndef ITK_MANUAL_INSTANTIATION
79 #include <cpExtensions/Algorithms/GradientFunctionBase.hxx>
80 #endif // ITK_MANUAL_INSTANTIATION
82 #endif // __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__H__