X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FMoriRegionGrow.hxx;h=c414f25d92d8580d1d0008fb298cacdc4ed242f6;hb=29fc5ba2975e744511939c60c53c90a0481207ee;hp=3b06e41cdd463dce08115f3e6cdf7eb8011442a8;hpb=a446849d62347e0401f681748ca13289091ac3b9;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/MoriRegionGrow.hxx b/lib/fpa/Image/MoriRegionGrow.hxx index 3b06e41..c414f25 100644 --- a/lib/fpa/Image/MoriRegionGrow.hxx +++ b/lib/fpa/Image/MoriRegionGrow.hxx @@ -6,7 +6,8 @@ template< class _TInputImage, class _TOutputImage > fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: MoriRegionGrow( ) : Superclass( ), - m_Step( TPixel( 1 ) ) + m_Step( TPixel( 1 ) ), + m_Sensitivity( double( 1 ) ) { this->m_Upper = std::numeric_limits< TPixel >::max( ); if( std::numeric_limits< TPixel >::is_integer ) @@ -34,7 +35,32 @@ _ContinueGenerateData( ) dynamic_cast< TBinThresholdFunction* >( this->GetGrowFunction( ) ); TPixel u = functor->GetUpper( ); - std::cout << long( u ) << " " << this->m_ActualCount << std::endl; + // Analyze flooding + bool stop = false; + if( this->m_N > double( 1 ) ) + { + double Q = double( this->m_PrevCount ); + Q += ( this->m_STD * this->m_Sensitivity ); + if( double( this->m_ActualCount ) > Q ) + stop = true; + + } // fi + double v; + if( this->m_PrevCount > 0 ) + v = double( this->m_ActualCount ) - double( this->m_PrevCount ); + else + v = double( 0 ); + this->m_PrevCount = this->m_ActualCount; + this->m_N += double( 1 ); + this->m_S1 += v; + this->m_S2 += v * v; + if( this->m_N > double( 1 ) ) + this->m_STD = + ( this->m_S2 - ( ( this->m_S1 * this->m_S1 ) / this->m_N ) ) / + ( this->m_N - double( 1 ) ); + else + this->m_STD = double( 0 ); + this->m_STD = std::sqrt( this->m_STD ); if( u < this->m_Upper ) { @@ -45,7 +71,7 @@ _ContinueGenerateData( ) this->m_Queue = this->m_NextQueue; while( this->m_NextQueue.size( ) > 0 ) this->m_NextQueue.pop( ); - return( true ); + return( !stop ); } else return( false ); @@ -61,6 +87,11 @@ _BeforeGenerateData( ) while( this->m_NextQueue.size( ) > 0 ) this->m_NextQueue.pop( ); this->m_ActualCount = 0; + this->m_PrevCount = 0; + this->m_N = double( 0 ); + this->m_S1 = double( 0 ); + this->m_S2 = double( 0 ); + this->m_STD = double( 0 ); TBinThresholdFunction* functor = dynamic_cast< TBinThresholdFunction* >( this->GetGrowFunction( ) ); functor->SetLower( this->m_Lower );