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