1 #ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__
2 #define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__
6 // -------------------------------------------------------------------------
8 void fpa::Image::RegionGrowWithMultipleThresholds< I >::
9 AddThreshold( const TPixel& v )
11 this->m_Thresholds.insert( v );
15 // -------------------------------------------------------------------------
17 void fpa::Image::RegionGrowWithMultipleThresholds< I >::
18 AddThresholds( const TPixel& t0, const TPixel& t1, const unsigned int& s )
20 double o = ( double( t1 ) - double( t0 ) ) / ( double( s ) - double( 1 ) );
21 for( unsigned int i = 0; i < s; i++ )
22 this->AddThreshold( TPixel( ( double( i ) * o ) + double( t0 ) ) );
25 // -------------------------------------------------------------------------
27 fpa::Image::RegionGrowWithMultipleThresholds< I >::
28 RegionGrowWithMultipleThresholds( )
30 m_DerivativeThreshold( double( 3 ) )
34 // -------------------------------------------------------------------------
36 fpa::Image::RegionGrowWithMultipleThresholds< I >::
37 ~RegionGrowWithMultipleThresholds( )
41 // -------------------------------------------------------------------------
43 void fpa::Image::RegionGrowWithMultipleThresholds< I >::
46 const I* img = this->GetInput( );
48 this->ClearMembershipFunctions( );
49 typename TThresholds::const_iterator tIt = this->m_Thresholds.begin( );
50 TPixel min_thr = *tIt;
51 for( ++tIt; tIt != this->m_Thresholds.end( ); ++tIt )
53 typename TFunction::Pointer function = TFunction::New( );
54 function->SetInputImage( img );
55 function->SetLowerThreshold( min_thr );
56 function->SetUpperThreshold( *tIt );
57 this->AddMembershipFunction( function );
61 this->Superclass::_BeforeMainLoop( );
64 // -------------------------------------------------------------------------
66 void fpa::Image::RegionGrowWithMultipleThresholds< I >::
69 if( this->m_ActualFunction != this->m_Functions.end( ) )
72 dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) );
73 // std::cout << f->GetUpperThreshold( ) << " " << this->m_Marks.size( ) << std::endl;
76 this->Superclass::_AfterLoop( );
79 // -------------------------------------------------------------------------
81 void fpa::Image::RegionGrowWithMultipleThresholds< I >::
84 this->Superclass::_AfterMainLoop( );
87 // -------------------------------------------------------------------------
89 bool fpa::Image::RegionGrowWithMultipleThresholds< I >::
90 _UpdateResult( _TNode& n )
92 #error ACA VOY -> explicar esto!!!! cambiar salida por una especie de curva de nivel
93 bool ret = this->Superclass::_UpdateResult( n );
94 if( this->m_ActualFunction != this->m_Functions.end( ) )
97 dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) );
98 this->GetOutput( )->SetPixel( n.Vertex, f->GetUpperThreshold( ) );
103 #endif // __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__