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