]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/GradientImageFunctionBase.h
yet another refactoring
[cpPlugins.git] / lib / cpExtensions / Algorithms / GradientImageFunctionBase.h
1 #ifndef __CPEXTENSIONS__ALGORITHMS__GRADIENTIMAGEFUNCTIONBASE__H__
2 #define __CPEXTENSIONS__ALGORITHMS__GRADIENTIMAGEFUNCTIONBASE__H__
3
4 #include <cpExtensions/Config.h>
5 #include <itkImage.h>
6 #include <itkImageFunction.h>
7
8 namespace cpExtensions
9 {
10   namespace Algorithms
11   {
12     /**
13      * Base class to compute values based on image gradients (vector).
14      */
15     template< class _TGradient, class _TMask = itk::Image< unsigned char, _TGradient::ImageDimension > >
16     class GradientImageFunctionBase
17       : public itk::ImageFunction< _TGradient, typename _TGradient::PixelType::ValueType, typename _TGradient::PixelType::ValueType >
18     {
19     public:
20       // Types from input arguments
21       typedef _TGradient                     TGradient;
22       typedef _TMask                         TMask;
23       typedef typename _TGradient::PixelType TVector;
24       typedef typename TVector::ValueType    TScalar;
25       itkStaticConstMacro(
26         Dimension, unsigned int, _TGradient::ImageDimension
27         );
28
29       // Standard itk types
30       typedef GradientImageFunctionBase                          Self;
31       typedef itk::ImageFunction< _TGradient, TScalar, TScalar > Superclass;
32       typedef itk::SmartPointer< Self >                          Pointer;
33       typedef itk::SmartPointer< const Self >                    ConstPointer;
34
35       // Types from base itk::ImageFunction
36       typedef typename Superclass::InputType           TInput;
37       typedef typename Superclass::OutputType          TOutput;
38       typedef typename Superclass::PointType           TPoint;
39       typedef typename Superclass::ContinuousIndexType TContIndex;
40       typedef typename Superclass::IndexType           TIndex;
41
42     public:
43       itkTypeMacro( GradientImageFunctionBase, itkImageFunction );
44
45       itkGetConstObjectMacro( Mask, TMask );
46       itkSetConstObjectMacro( Mask, TMask );
47
48     public:
49       virtual void Prepare( ) const;
50       virtual TOutput Evaluate( const TPoint& p ) const cpExtensions_OVERRIDE;
51       virtual TOutput EvaluateAtIndex( const TIndex& i ) const cpExtensions_OVERRIDE;
52       virtual TOutput EvaluateAtContinuousIndex( const TContIndex& i ) const cpExtensions_OVERRIDE;
53
54     protected:
55       GradientImageFunctionBase( );
56       virtual ~GradientImageFunctionBase( );
57
58       virtual TOutput _Evaluate( const TIndex& i ) const = 0;
59
60     private:
61       // Purposely not implemented.
62       GradientImageFunctionBase( const Self& );
63       void operator=( const Self& );
64
65     protected:
66       typename _TMask::ConstPointer m_Mask;
67     };
68
69   } // ecapseman
70
71 } // ecapseman
72
73 #ifndef ITK_MANUAL_INSTANTIATION
74 #  include <cpExtensions/Algorithms/GradientImageFunctionBase.hxx>
75 #endif // ITK_MANUAL_INSTANTIATION
76
77 #endif // __CPEXTENSIONS__ALGORITHMS__GRADIENTIMAGEFUNCTIONBASE__H__
78
79 // eof - $RCSfile$