1 /* =======================================================================
2 * @author: Leonardo Florez-Valencia
3 * @email: florez-l@javeriana.edu.co
4 * =======================================================================
7 #ifndef __ivq__ITK__ThresholdFunction__hxx__
8 #define __ivq__ITK__ThresholdFunction__hxx__
12 // -------------------------------------------------------------------------
13 template< class _TIn, class _TOut >
14 void ivq::ITK::ThresholdFunction< _TIn, _TOut >::
15 SetBetween( const _TIn& lower, const _TIn& upper )
17 this->SetLowerThreshold( lower );
18 this->SetUpperThreshold( upper );
21 // -------------------------------------------------------------------------
22 template< class _TIn, class _TOut >
23 void ivq::ITK::ThresholdFunction< _TIn, _TOut >::
24 SetBelow( const _TIn& value )
26 typedef std::numeric_limits< _TIn > _TTraits;
27 if( _TTraits::is_signed )
28 this->SetLowerThreshold( -_TTraits::max( ) );
30 this->SetLowerThreshold( _TIn( 0 ) );
31 this->SetUpperThreshold( value );
34 // -------------------------------------------------------------------------
35 template< class _TIn, class _TOut >
36 void ivq::ITK::ThresholdFunction< _TIn, _TOut >::
37 SetAbove( const _TIn& value )
39 typedef std::numeric_limits< _TIn > _TTraits;
40 this->SetLowerThreshold( value );
41 this->SetUpperThreshold( _TTraits::max( ) );
44 // -------------------------------------------------------------------------
45 template< class _TIn, class _TOut >
46 _TOut ivq::ITK::ThresholdFunction< _TIn, _TOut >::
47 Evaluate( const _TIn& in ) const
53 inside = ( this->m_LowerThreshold < in );
54 inside &= ( in < this->m_UpperThreshold );
58 inside = ( this->m_LowerThreshold <= in );
59 inside &= ( in <= this->m_UpperThreshold );
67 return( this->m_InsideValue );
69 return( _TOut( in ) );
72 return( this->m_OutsideValue );
75 // -------------------------------------------------------------------------
76 template< class _TIn, class _TOut >
77 ivq::ITK::ThresholdFunction< _TIn, _TOut >::
80 m_LowerThreshold( _TIn( 0 ) ),
81 m_UpperThreshold( std::numeric_limits< _TIn >::max( ) ),
84 m_InsideValue( std::numeric_limits< _TOut >::max( ) ),
85 m_OutsideValue( _TOut( 0 ) )
89 // -------------------------------------------------------------------------
90 template< class _TIn, class _TOut >
91 ivq::ITK::ThresholdFunction< _TIn, _TOut >::
96 #endif // __ivq__ITK__ThresholdFunction__hxx__