]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/RegionGrowThresholdFunction.h
44cccc274e083f7408c976569bcfc80ff7a735b3
[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               /* TODO
52                  if( this->IsInsideBuffer( idx ) )
53                  {
54               */
55               TPixel v = img->GetPixel( idx );
56               return(
57                 this->m_LowerThreshold <= v &&
58                 v <= this->m_UpperThreshold
59                 );
60
61               // TODO: } // fi
62
63             } // fi
64             return( false );
65           }
66
67       protected:
68         RegionGrowThresholdFunction( )
69           : Superclass( ),
70             m_LowerThreshold( std::numeric_limits< TPixel >::min( ) ),
71             m_UpperThreshold( std::numeric_limits< TPixel >::max( ) )
72           { }
73         virtual ~RegionGrowThresholdFunction( )
74           { }
75
76       private:
77         // Purposely not implemented
78         RegionGrowThresholdFunction( const Self& );
79         void operator=( const Self& );
80
81       protected:
82         TPixel m_LowerThreshold;
83         TPixel m_UpperThreshold;
84       };
85
86     } // ecapseman
87
88   } // ecapseman
89
90 } // ecapseman
91
92 #endif // __FPA__IMAGE__FUNCTORS__REGIONGROWTHRESHOLDFUNCTION__H__
93
94 // eof - $RCSfile$