X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FRegionGrowWithMultipleThresholds.hxx;h=0cb1b66598aa225f33799855c44a4435ed376a20;hb=9f7b6541d030299dff60fb93caa4371f8f9825de;hp=a5b2075b3819a45d4eff92e57b347d1a474c4f21;hpb=972dd44060dfff40ba3daab899c6365445f6de7e;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx index a5b2075..0cb1b66 100644 --- a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx +++ b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx @@ -29,13 +29,6 @@ RegionGrowWithMultipleThresholds( ) : Superclass( ), m_DerivativeThreshold( double( 3 ) ) { - /* TODO - typedef - fpa::Image::Functors::RegionGrowThresholdFunction< I > - TFunction; - typename TFunction::Pointer function = TFunction::New( ); - this->SetMembershipFunction( function ); - */ } // ------------------------------------------------------------------------- @@ -45,61 +38,27 @@ fpa::Image::RegionGrowWithMultipleThresholds< I >:: { } -// ------------------------------------------------------------------------- -template< class I > -bool fpa::Image::RegionGrowWithMultipleThresholds< I >:: -_UpdateResult( _TNode& n ) -{ - bool ret = this->Superclass::_UpdateResult( n ); - std::cout << "Image:UpdateResult " << ret << std::endl; - - - /* TODO - if( ret ) - { - TPixel v = TPixel( this->_Cost( n.Vertex, n.Vertex ) ); - - typename THistogram::reverse_iterator hIt = this->m_Histogram.rbegin( ); - while( hIt != this->m_Histogram.rend( ) ) - { - if( v <= hIt->first ) - { - hIt->second += 1; - hIt++; - } - else - hIt = this->m_Histogram.rend( ); - - } // elihw - this->GetOutput( )->SetPixel( n.Vertex, v ); - - } // fi - */ - return( ret ); -} - // ------------------------------------------------------------------------- template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: -_BeforeLoop( ) +_BeforeMainLoop( ) { const I* img = this->GetInput( ); this->ClearMembershipFunctions( ); typename TThresholds::const_iterator tIt = this->m_Thresholds.begin( ); - typename TThresholds::const_iterator prev_tIt = tIt; - for( ++tIt; tIt != this->m_Thresholds.end( ); ++tIt, ++prev_tIt ) + TPixel min_thr = *tIt; + for( ++tIt; tIt != this->m_Thresholds.end( ); ++tIt ) { typename TFunction::Pointer function = TFunction::New( ); function->SetInputImage( img ); - function->SetLowerThreshold( *prev_tIt ); + function->SetLowerThreshold( min_thr ); function->SetUpperThreshold( *tIt ); this->AddMembershipFunction( function ); - std::cout << *prev_tIt << " " << *tIt << std::endl; } // rof - this->Superclass::_BeforeLoop( ); + this->Superclass::_BeforeMainLoop( ); } // ------------------------------------------------------------------------- @@ -107,45 +66,40 @@ template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: _AfterLoop( ) { - /* - typename THistogram::iterator prevIt = this->m_Histogram.begin( ); - typename THistogram::iterator currIt = prevIt; currIt++; - typename THistogram::iterator nextIt = currIt; nextIt++; - double prev_d1 = double( 0 ); - for( ; nextIt != this->m_Histogram.end( ); ++prevIt, ++currIt, ++nextIt ) - { - double d1 = double( nextIt->second ) - double( prevIt->second ); - d1 /= double( nextIt->first ) - double( prevIt->first ); - - std::cout - << currIt->first << " " - << currIt->second << " " - << d1 << " " - << ( d1 - prev_d1 ) << std::endl; - - prev_d1 = d1; - - } // rof - */ + 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; - /* - double prev = double( 0 ); - while( hIt != this->m_Histogram.end( ) ) - { - double curr = double( hIt->second ); - double deri = curr - prev; + } // fi + this->Superclass::_AfterLoop( ); +} - if( hIt != this->m_Histogram.begin( ) ) - std::cout << hIt->first << " " << curr << " " << deri << std::endl; +// ------------------------------------------------------------------------- +template< class I > +void fpa::Image::RegionGrowWithMultipleThresholds< I >:: +_AfterMainLoop( ) +{ + this->Superclass::_AfterMainLoop( ); +} - prev = curr; - hIt++; +// ------------------------------------------------------------------------- +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( ) ); - } // rof - */ - this->Superclass::_AfterLoop( ); + } // fi + return( ret ); } - #endif // __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ // eof - $RCSfile$