From: Leonardo Florez-Valencia Date: Fri, 30 Jan 2015 21:10:05 +0000 (-0500) Subject: Filter updated X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=56882b09aa679c7d85e3f21bf9e45df78340a253;p=FrontAlgorithms.git Filter updated --- diff --git a/lib/fpa/Image/RegionGrowWithMultipleThresholds.h b/lib/fpa/Image/RegionGrowWithMultipleThresholds.h index 11066fe..3efd87a 100644 --- a/lib/fpa/Image/RegionGrowWithMultipleThresholds.h +++ b/lib/fpa/Image/RegionGrowWithMultipleThresholds.h @@ -39,8 +39,9 @@ namespace fpa public: void AddThreshold( const TPixel& v ); void AddThresholds( - const TPixel& t0, const TPixel& t1, - const unsigned int& samples + const TPixel& t0, + const TPixel& t1, + const unsigned int& s ); protected: diff --git a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx index b4d4331..def89d9 100644 --- a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx +++ b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx @@ -10,33 +10,30 @@ AddThreshold( const TPixel& v ) { this->m_Histogram[ v ] = 0; - typedef - fpa::Image::Functors::RegionGrowThresholdFunction< I > - TFunction; - 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 + /* TODO + typedef + fpa::Image::Functors::RegionGrowThresholdFunction< I > + TFunction; + 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( ); } // ------------------------------------------------------------------------- template< class I > void fpa::Image::RegionGrowWithMultipleThresholds< I >:: -AddThresholds( - const TPixel& t0, - const TPixel& t1, - const unsigned int& samples - ) +AddThresholds( const TPixel& t0, const TPixel& t1, const unsigned int& s ) { - double off = - ( double( t1 ) - double( t0 ) ) / ( double( samples ) - double( 1 ) ); - for( unsigned int s = 0; s < samples; s++ ) - this->AddThreshold( TPixel( ( double( s ) * off ) + double( t0 ) ) ); + 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 ) ) ); } // ------------------------------------------------------------------------- @@ -94,25 +91,26 @@ 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 ) - { + /* + 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; + << currIt->first << " " + << currIt->second << " " + << d1 << " " + << ( d1 - prev_d1 ) << std::endl; prev_d1 = d1; - } // rof - + } // rof + */ /* double prev = double( 0 );