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 )
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 )
{
this->m_Queue = this->m_NextQueue;
while( this->m_NextQueue.size( ) > 0 )
this->m_NextQueue.pop( );
- return( true );
+ return( !stop );
}
else
return( false );
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 );