1 /* =======================================================================
2 * @author: Leonardo Florez-Valencia
3 * @email: florez-l@javeriana.edu.co
4 * =======================================================================
7 #ifndef __ivq__ITK__BooleanMapSaliencyFilter__hxx__
8 #define __ivq__ITK__BooleanMapSaliencyFilter__hxx__
10 // -------------------------------------------------------------------------
11 template< class _TIn, class _TOut >
12 _TOut ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
13 Evaluate( const _TIn& in ) const
16 unsigned long count = 0;
17 if( this->m_UseBoundedThresholds )
19 _TIn lower = *( this->m_Thresholds.begin( ) );
20 _TIn upper = *( this->m_Thresholds.rbegin( ) );
21 stop = ( in < lower || in > upper );
24 typename std::set< _TIn >::const_iterator i = this->m_Thresholds.begin( );
25 while( i != this->m_Thresholds.end( ) && !stop )
28 count += ( !stop )? 1: 0;
32 return( _TOut( double( count ) / double( this->m_Thresholds.size( ) ) ) );
35 // -------------------------------------------------------------------------
36 template< class _TIn, class _TOut >
37 unsigned int ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
38 GetNumberOfThresholds( ) const
40 return( this->m_Thresholds.size( ) );
43 // -------------------------------------------------------------------------
44 template< class _TIn, class _TOut >
45 void ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
48 if( this->m_Thresholds.size( ) > 0 )
50 this->m_Thresholds.clear( );
56 // -------------------------------------------------------------------------
57 template< class _TIn, class _TOut >
58 void ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
59 AddThreshold( const _TIn& v )
61 if( this->m_Thresholds.insert( v ).second )
65 // -------------------------------------------------------------------------
66 template< class _TIn, class _TOut >
67 void ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
68 AddThresholds( const _TIn& v_min, const _TIn& v_max, const _TIn& v_delta )
70 for( _TIn v = v_min; v <= v_max; v += v_delta )
71 this->AddThreshold( v );
74 // -------------------------------------------------------------------------
75 template< class _TIn, class _TOut >
76 ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
77 BooleanMapSaliencyFunction( )
79 m_UseBoundedThresholds( false )
83 // -------------------------------------------------------------------------
84 template< class _TIn, class _TOut >
85 ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
86 ~BooleanMapSaliencyFunction( )
90 #endif // __ivq__ITK__BooleanMapSaliencyFilter__hxx__