]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/RegionGrowThresholdFunction.h
4ec4bbfb520ccacaa9cc83a38fee270173125e98
[FrontAlgorithms.git] / lib / fpa / Image / Functors / RegionGrowThresholdFunction.h
1 #ifndef __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__
2 #define __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__
3
4 #include <itkNumericTraits.h>
5 #include <fpa/Image/Functors/RegionGrowAllBelongsFunction.h>
6
7 namespace fpa
8 {
9   namespace Image
10   {
11     namespace Functors
12     {
13       /**
14        */
15       template< class I >
16       class RegionGrowThresholdFunction
17         : public RegionGrowAllBelongsFunction< I >
18       {
19       public:
20         /// Type-related and pointers
21         typedef RegionGrowThresholdFunction       Self;
22         typedef RegionGrowAllBelongsFunction< I > Superclass;
23         typedef itk::SmartPointer< Self >         Pointer;
24         typedef itk::SmartPointer< const Self >   ConstPointer;
25
26         // Superclass' types
27         typedef I                     TInputImage;
28         typedef typename I::IndexType TIndex;
29         typedef typename I::PixelType TPixel;
30
31       public:
32         itkNewMacro( Self );
33         itkTypeMacro(
34           RegionGrowThresholdFunction,
35           RegionGrowAllBelongsFunction
36           );
37
38         itkGetConstMacro( LowerThreshold, TPixel );
39         itkGetConstMacro( UpperThreshold, TPixel );
40
41         itkSetMacro( LowerThreshold, TPixel );
42         itkSetMacro( UpperThreshold, TPixel );
43
44       public:
45         virtual bool Evaluate( const TIndex& idx ) const ITK_OVERRIDE
46           {
47             const I* img = this->GetSpace( );
48
49             if( img != NULL )
50             {
51               TPixel v = img->GetPixel( idx );
52               return(
53                 !( v < this->m_LowerThreshold || this->m_UpperThreshold < v )
54                 );
55
56             } // fi
57             return( false );
58           }
59
60       protected:
61         RegionGrowThresholdFunction( )
62           : Superclass( )
63           {
64             itk::NumericTraits< TPixel >::min( this->m_LowerThreshold );
65             itk::NumericTraits< TPixel >::max( this->m_UpperThreshold );
66           }
67         virtual ~RegionGrowThresholdFunction( )
68           { }
69
70       private:
71         // Purposely not implemented
72         RegionGrowThresholdFunction( const Self& );
73         void operator=( const Self& );
74
75       protected:
76         TPixel m_LowerThreshold;
77         TPixel m_UpperThreshold;
78       };
79
80     } // ecapseman
81
82   } // ecapseman
83
84 } // ecapseman
85
86 #endif // __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__
87
88 // eof - $RCSfile$