]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Functors/RegionGrow/BinaryThreshold.hxx
...
[FrontAlgorithms.git] / lib / fpa / Functors / RegionGrow / BinaryThreshold.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Functors__RegionGrow__BinaryThreshold__hxx__
6 #define __fpa__Functors__RegionGrow__BinaryThreshold__hxx__
7
8 #include <limits>
9
10 // -------------------------------------------------------------------------
11 template< class _TValue >
12 void fpa::Functors::RegionGrow::BinaryThreshold< _TValue >::
13 ThresholdAbove( const TValue& a )
14 {
15   this->SetLowerThreshold( a );
16   this->SetUpperThreshold( std::numeric_limits< _TValue >::max( ) );
17 }
18
19 // -------------------------------------------------------------------------
20 template< class _TValue >
21 void fpa::Functors::RegionGrow::BinaryThreshold< _TValue >::
22 ThresholdBetween( const TValue& a, const TValue& b )
23 {
24   this->SetLowerThreshold( ( a < b )? a: b );
25   this->SetUpperThreshold( ( b < a )? a: b );
26 }
27
28 // -------------------------------------------------------------------------
29 template< class _TValue >
30 void fpa::Functors::RegionGrow::BinaryThreshold< _TValue >::
31 ThresholdBelow( const TValue& a )
32 {
33   if( std::numeric_limits< _TValue >::is_integer )
34     this->SetLowerThreshold( std::numeric_limits< _TValue >::min( ) );
35   else
36     this->SetLowerThreshold( -std::numeric_limits< _TValue >::max( ) );
37   this->SetUpperThreshold( a );
38 }
39
40 // -------------------------------------------------------------------------
41 template< class _TValue >
42 bool fpa::Functors::RegionGrow::BinaryThreshold< _TValue >::
43 Evaluate( const TValue& v ) const
44 {
45   if( this->m_Strict )
46     return( this->m_LowerThreshold < v && v < this->m_UpperThreshold );
47   else
48     return( this->m_LowerThreshold <= v && v <= this->m_UpperThreshold );
49 }
50
51 // -------------------------------------------------------------------------
52 template< class _TValue >
53 fpa::Functors::RegionGrow::BinaryThreshold< _TValue >::
54 BinaryThreshold( )
55   : Superclass( ),
56     m_Strict( true )
57 {
58   this->m_UpperThreshold = std::numeric_limits< _TValue >::max( );
59   if( std::numeric_limits< _TValue >::is_integer )
60     this->m_LowerThreshold = std::numeric_limits< _TValue >::min( );
61   else
62     this->m_LowerThreshold = -this->m_UpperThreshold;
63 }
64
65 // -------------------------------------------------------------------------
66 template< class _TValue >
67 fpa::Functors::RegionGrow::BinaryThreshold< _TValue >::
68 ~BinaryThreshold( )
69 {
70 }
71
72 #endif // __fpa__Functors__RegionGrow__BinaryThreshold__hxx__
73 // eof - $RCSfile$