+
+// -------------------------------------------------------------------------
+template< class I >
+void fpa::Image::RegionGrowWithMultipleThresholds< I >::
+_Mark( const _TNode& n )
+{
+ this->Superclass::_Mark( n );
+
+ // Check if the histogram's support is enough
+ if( this->m_Histogram.size( ) < 2 )
+ return;
+ typename THistogram::const_reverse_iterator hIt =
+ this->m_Histogram.rbegin( );
+
+ // Get the actual function
+ TFunction* f =
+ dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) );
+ if( f == NULL )
+ return;
+
+ // Previous pixel count
+ unsigned long prev_aCount = hIt->second;
+ double prev_p = double( prev_aCount ) / double( this->m_TotalCount );
+
+ // Actual pixel count
+ unsigned long aCount = this->m_Marks.size( );
+ double p = double( aCount ) / double( this->m_TotalCount );
+
+ // Loop over, at least, 0.1% of the total number of pixels before
+ // performing stop analysis
+ if( double( 1e-3 ) < p && double( 1e-3 ) < prev_p )
+ {
+ // Does the difference is worthy to be analyzed?
+ if( aCount > hIt->second )
+ {
+ // Compute finite difference and compare it to the previous one
+ double diff = double( aCount ) - double( hIt->second );
+ diff /= double( f->GetUpperThreshold( ) ) - double( hIt->first );
+ if( diff > this->m_LastDiff )
+ {
+ this->m_StopForced = true;
+ this->m_StopThreshold = hIt->first;
+
+ } // fi
+
+ } // fi
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+bool fpa::Image::RegionGrowWithMultipleThresholds< I >::
+_CheckStopCondition( )
+{
+ return( this->m_StopForced );
+}
+