#ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ #define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ #include // ------------------------------------------------------------------------- template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: AddThreshold( const TPixel& v ) { this->m_Thresholds.insert( v ); this->Modified( ); } // ------------------------------------------------------------------------- template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: AddThresholds( const TPixel& t0, const TPixel& t1, const unsigned int& s ) { double o = ( double( t1 ) - double( t0 ) ) / ( double( s ) - double( 1 ) ); for( unsigned int i = 0; i < s; i++ ) this->AddThreshold( TPixel( ( double( i ) * o ) + double( t0 ) ) ); } // ------------------------------------------------------------------------- template< class I > fpa::Image::RegionGrowWithMultipleThresholds< I >:: RegionGrowWithMultipleThresholds( ) : Superclass( ), m_DerivativeThreshold( double( 3 ) ) { } // ------------------------------------------------------------------------- template< class I > fpa::Image::RegionGrowWithMultipleThresholds< I >:: ~RegionGrowWithMultipleThresholds( ) { } // ------------------------------------------------------------------------- template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: _BeforeMainLoop( ) { const I* img = this->GetInput( ); this->ClearMembershipFunctions( ); typename TThresholds::const_iterator tIt = this->m_Thresholds.begin( ); TPixel min_thr = *tIt; for( ++tIt; tIt != this->m_Thresholds.end( ); ++tIt ) { typename TFunction::Pointer function = TFunction::New( ); function->SetInputImage( img ); function->SetLowerThreshold( min_thr ); function->SetUpperThreshold( *tIt ); this->AddMembershipFunction( function ); } // rof this->Superclass::_BeforeMainLoop( ); } // ------------------------------------------------------------------------- template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: _AfterLoop( ) { if( this->m_ActualFunction != this->m_Functions.end( ) ) { TFunction* f = dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) ); // std::cout << f->GetUpperThreshold( ) << " " << this->m_Marks.size( ) << std::endl; } // fi this->Superclass::_AfterLoop( ); } // ------------------------------------------------------------------------- template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: _AfterMainLoop( ) { this->Superclass::_AfterMainLoop( ); } // ------------------------------------------------------------------------- template< class I > bool fpa::Image::RegionGrowWithMultipleThresholds< I >:: _UpdateResult( _TNode& n ) { #error ACA VOY -> explicar esto!!!! cambiar salida por una especie de curva de nivel bool ret = this->Superclass::_UpdateResult( n ); if( this->m_ActualFunction != this->m_Functions.end( ) ) { TFunction* f = dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) ); this->GetOutput( )->SetPixel( n.Vertex, f->GetUpperThreshold( ) ); } // fi return( ret ); } #endif // __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ // eof - $RCSfile$