]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Functors/RegionGrow/BinaryThreshold.h
ce533f69f14d979035a2cfe09b9f64378a556892
[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           itkGetConstMacro( Lower, _TValue );
40           itkGetConstMacro( Upper, _TValue );
41
42           itkSetMacro( Lower, _TValue );
43           itkSetMacro( Upper, _TValue );
44
45         public:
46           virtual bool Evaluate( const _TValue& input ) const override
47             {
48               return( this->m_Lower < input && input < this->m_Upper );
49             }
50
51         protected:
52           BinaryThreshold( )
53             : Superclass( )
54             {
55               this->m_Upper = std::numeric_limits< _TValue >::max( );
56               if( std::numeric_limits< _TValue >::is_integer )
57                 this->m_Lower = std::numeric_limits< _TValue >::min( );
58               else
59                 this->m_Lower = -this->m_Upper;
60             }
61
62           virtual ~BinaryThreshold( )
63             {
64             }
65
66         private:
67           // Purposely not implemented
68           BinaryThreshold( const Self& other );
69           Self& operator=( const Self& other );
70
71         protected:
72           _TValue m_Lower;
73           _TValue m_Upper;
74         };
75
76       } // ecapseman
77
78     } // ecapseman
79
80   } // ecapseman
81
82 } // ecapseman
83
84 #endif // __fpa__Base__Functors__RegionGrow__BinaryThreshold__h__
85
86 // eof - $RCSfile$