]> Creatis software - cpPlugins.git/blob - lib/ivq/ITK/BooleanMapSaliencyFunction.hxx
...
[cpPlugins.git] / lib / ivq / ITK / BooleanMapSaliencyFunction.hxx
1 /* =======================================================================
2  * @author: Leonardo Florez-Valencia
3  * @email: florez-l@javeriana.edu.co
4  * =======================================================================
5  */
6
7 #ifndef __ivq__ITK__BooleanMapSaliencyFilter__hxx__
8 #define __ivq__ITK__BooleanMapSaliencyFilter__hxx__
9
10 // -------------------------------------------------------------------------
11 template< class _TIn, class _TOut >
12 _TOut ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
13 Evaluate( const _TIn& in ) const
14 {
15   bool stop = false;
16   unsigned long count = 0;
17   if( this->m_UseBoundedThresholds )
18   {
19     _TIn lower = *( this->m_Thresholds.begin( ) );
20     _TIn upper = *( this->m_Thresholds.rbegin( ) );
21     stop = ( in < lower || in > upper );
22
23   } // fi
24   typename std::set< _TIn >::const_iterator i = this->m_Thresholds.begin( );
25   while( i != this->m_Thresholds.end( ) && !stop )
26   {
27     stop = ( in < *i );
28     count += ( !stop )? 1: 0;
29     ++i;
30
31   } // elihw
32   return( _TOut( double( count ) / double( this->m_Thresholds.size( ) ) ) );
33 }
34
35 // -------------------------------------------------------------------------
36 template< class _TIn, class _TOut >
37 unsigned int ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
38 GetNumberOfThresholds( ) const
39 {
40   return( this->m_Thresholds.size( ) );
41 }
42
43 // -------------------------------------------------------------------------
44 template< class _TIn, class _TOut >
45 void ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
46 ClearThresholds( )
47 {
48   if( this->m_Thresholds.size( ) > 0 )
49   {
50     this->m_Thresholds.clear( );
51     this->Modified( );
52
53   } // fi
54 }
55
56 // -------------------------------------------------------------------------
57 template< class _TIn, class _TOut >
58 void ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
59 AddThreshold( const _TIn& v )
60 {
61   if( this->m_Thresholds.insert( v ).second )
62     this->Modified( );
63 }
64
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 )
69 {
70   for( _TIn v = v_min; v <= v_max; v += v_delta )
71     this->AddThreshold( v );
72 }
73
74 // -------------------------------------------------------------------------
75 template< class _TIn, class _TOut >
76 ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
77 BooleanMapSaliencyFunction( )
78   : Superclass( ),
79     m_UseBoundedThresholds( false )
80 {
81 }
82
83 // -------------------------------------------------------------------------
84 template< class _TIn, class _TOut >
85 ivq::ITK::BooleanMapSaliencyFunction< _TIn, _TOut >::
86 ~BooleanMapSaliencyFunction( )
87 {
88 }
89
90 #endif // __ivq__ITK__BooleanMapSaliencyFilter__hxx__
91
92 // eof - $RCSfile$