X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FRegionGrowWithMultipleThresholds.hxx;fp=lib%2Ffpa%2FImage%2FRegionGrowWithMultipleThresholds.hxx;h=51e474b958b9f41e8caf9c4e3a91dc5990a27a67;hb=2479b55370fe1bec58d94faa3cc268bac419f6d6;hp=def89d95dc4dfac6c1d6de976b04b48ce31d81e6;hpb=56882b09aa679c7d85e3f21bf9e45df78340a253;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx index def89d9..51e474b 100644 --- a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx +++ b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx @@ -1,6 +1,7 @@ #ifndef __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ #define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ +#include #include // ------------------------------------------------------------------------- @@ -8,22 +9,35 @@ template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: AddThreshold( const TPixel& v ) { - this->m_Histogram[ v ] = 0; + typedef + fpa::Image::Functors::RegionGrowThresholdFunction< I > + TFunction; + typename TFunction::Pointer function = TFunction::New( ); + + if( this->GetNumberOfMembershipFunctions( ) > 0 ) + { + } + else + function->SetLowerThreshold( std::numeric_limits< TPixel >::min( ) ); + std::cout + << typeid( TPixel ).name( ) << " " + << function->GetLowerThreshold( ) + << std::endl; + function->SetUpperThreshold( v ); + this->AddMembershipFunction( function ); /* TODO - typedef - fpa::Image::Functors::RegionGrowThresholdFunction< I > - TFunction; + this->m_Histogram[ v ] = 0; + TFunction* function = dynamic_cast< TFunction* >( this->GetMembershipFunction( ) ); if( function != NULL ) { function->SetLowerThreshold( this->m_Histogram.begin( )->first ); - function->SetUpperThreshold( this->m_Histogram.rbegin( )->first ); } // fi + this->Modified( ); */ - this->Modified( ); } // ------------------------------------------------------------------------- @@ -43,11 +57,13 @@ RegionGrowWithMultipleThresholds( ) : Superclass( ), m_DerivativeThreshold( double( 3 ) ) { - typedef - fpa::Image::Functors::RegionGrowThresholdFunction< I > - TFunction; - typename TFunction::Pointer function = TFunction::New( ); - this->SetMembershipFunction( function ); + /* TODO + typedef + fpa::Image::Functors::RegionGrowThresholdFunction< I > + TFunction; + typename TFunction::Pointer function = TFunction::New( ); + this->SetMembershipFunction( function ); + */ } // ------------------------------------------------------------------------- @@ -64,28 +80,50 @@ _UpdateResult( _TNode& n ) { bool ret = this->Superclass::_UpdateResult( n ); - if( ret ) - { - TPixel v = TPixel( this->_Cost( n.Vertex, n.Vertex ) ); + /* 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 + 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( ) +{ + std::cout << "**1" << std::endl; + const I* img = this->GetInput( ); + std::cout << "**2" << std::endl; + typename TFunctions::iterator fIt = this->m_Functions.begin( ); + for( ; fIt != this->m_Functions.end( ); ++fIt ) + { + TMembershipFunction* f = + dynamic_cast< TMembershipFunction* >( fIt->GetPointer( ) ); + if( f != NULL ) + f->SetInputImage( this->GetInput( ) ); + + } // rof + this->Superclass::_BeforeLoop( ); +} + // ------------------------------------------------------------------------- template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >::