]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/RegionGrowThresholdFunction.h
739dff4c24beb40c6d76c94e3977bef3d02bc588
[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 <limits>
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 typename Superclass::TInputImage  TInputImage;
28         typedef typename Superclass::TOutputValue TOutputValue;
29         typedef typename Superclass::TIndex       TIndex;
30         typedef typename I::PixelType             TPixel;
31
32       public:
33         itkNewMacro( Self );
34         itkTypeMacro(
35           RegionGrowThresholdFunction,
36           RegionGrowAllBelongsFunction
37           );
38
39         itkGetConstMacro( LowerThreshold, TPixel );
40         itkGetConstMacro( UpperThreshold, TPixel );
41
42         itkSetMacro( LowerThreshold, TPixel );
43         itkSetMacro( UpperThreshold, TPixel );
44
45       public:
46         virtual TOutputValue Evaluate( const TIndex& idx ) const
47           {
48             const I* img = this->GetInputImage( );
49             if( img != NULL )
50             {
51               TPixel v = img->GetPixel( idx );
52               return(
53                 this->m_LowerThreshold <= v && v < this->m_UpperThreshold
54                 );
55
56             } // fi
57             return( false );
58           }
59
60       protected:
61         RegionGrowThresholdFunction( )
62           : Superclass( ),
63             m_LowerThreshold( std::numeric_limits< TPixel >::min( ) ),
64             m_UpperThreshold( std::numeric_limits< TPixel >::max( ) )
65           { }
66         virtual ~RegionGrowThresholdFunction( )
67           { }
68
69       private:
70         // Purposely not implemented
71         RegionGrowThresholdFunction( const Self& );
72         void operator=( const Self& );
73
74       protected:
75         TPixel m_LowerThreshold;
76         TPixel m_UpperThreshold;
77       };
78
79     } // ecapseman
80
81   } // ecapseman
82
83 } // ecapseman
84
85 #endif // __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__
86
87 // eof - $RCSfile$