]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Functors/RegionGrow/BinaryThreshold.h
0ac4618e5bc237910ec919b20d7669e54fbb65e6
[FrontAlgorithms.git] / lib / fpa / Base / Functors / RegionGrow / BinaryThreshold.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__Functors__RegionGrow__BinaryThreshold__h__
7 #define __fpa__Base__Functors__RegionGrow__BinaryThreshold__h__
8
9 #include <limits>
10 #include <itkFunctionBase.h>
11
12 namespace fpa
13 {
14   namespace Base
15   {
16     namespace Functors
17     {
18       namespace RegionGrow
19       {
20         /**
21          */
22         template< class _TValue >
23         class BinaryThreshold
24           : public itk::FunctionBase< _TValue, bool >
25         {
26         public:
27           typedef BinaryThreshold                    Self;
28           typedef itk::FunctionBase< _TValue, bool > Superclass;
29           typedef itk::SmartPointer< Self >          Pointer;
30           typedef itk::SmartPointer< const Self >    ConstPointer;
31
32         public:
33           itkNewMacro( Self );
34           itkTypeMacro(
35             fpa::Base::Functors::RegionGrow::BinaryThreshold,
36             itk::FunctionBase
37             );
38
39           itkBooleanMacro( Strict );
40
41           itkGetConstMacro( Lower, _TValue );
42           itkGetConstMacro( Upper, _TValue );
43           itkGetConstMacro( Strict, bool );
44
45           itkSetMacro( Lower, _TValue );
46           itkSetMacro( Upper, _TValue );
47           itkSetMacro( Strict, bool );
48
49         public:
50           virtual bool Evaluate( const _TValue& input ) const override
51             {
52               if( this->m_Strict )
53                 return( this->m_Lower < input && input < this->m_Upper );
54               else
55                 return( this->m_Lower <= input && input <= this->m_Upper );
56             }
57
58         protected:
59           BinaryThreshold( )
60             : Superclass( ),
61               m_Strict( true )
62             {
63               this->m_Upper = std::numeric_limits< _TValue >::max( );
64               if( std::numeric_limits< _TValue >::is_integer )
65                 this->m_Lower = std::numeric_limits< _TValue >::min( );
66               else
67                 this->m_Lower = -this->m_Upper;
68             }
69
70           virtual ~BinaryThreshold( )
71             {
72             }
73
74         private:
75           // Purposely not implemented
76           BinaryThreshold( const Self& other );
77           Self& operator=( const Self& other );
78
79         protected:
80           _TValue m_Lower;
81           _TValue m_Upper;
82           bool m_Strict;
83         };
84
85       } // ecapseman
86
87     } // ecapseman
88
89   } // ecapseman
90
91 } // ecapseman
92
93 #endif // __fpa__Base__Functors__RegionGrow__BinaryThreshold__h__
94
95 // eof - $RCSfile$