]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/RegionGrowThresholdFunction.h
Plugins updated
[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
46           {
47             const I* img = this->GetSpace( );
48             if( img != NULL )
49             {
50               TPixel v = img->GetPixel( idx );
51               return(
52                 !( v < this->m_LowerThreshold || this->m_UpperThreshold < v )
53                 );
54
55             } // fi
56             return( false );
57           }
58
59       protected:
60         RegionGrowThresholdFunction( )
61           : Superclass( )
62           {
63             itk::NumericTraits< TPixel >::min( this->m_LowerThreshold );
64             itk::NumericTraits< TPixel >::max( this->m_UpperThreshold );
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$