+// -------------------------------------------------------------------------
+template< class I >
+void fpa::Image::RegionGrowWithMultipleThresholds< I >::
+_AfterLoop( )
+{
+ if( this->m_ActualFunction != this->m_Functions.end( ) )
+ {
+ TFunction* f =
+ dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) );
+ this->m_Histogram[ f->GetUpperThreshold( ) ] = this->m_Marks.size( );
+
+ /* TODO: code to print the signal for demo purposes
+ std::cout
+ << f->GetUpperThreshold( ) << " "
+ << this->m_Marks.size( )
+ << std::endl;
+ */
+
+ // Get the two last complete count, if any, and compute last
+ // finite difference
+ if( this->m_Histogram.size( ) > 1 )
+ {
+ typename THistogram::const_reverse_iterator hIt =
+ this->m_Histogram.rbegin( );
+ typename THistogram::const_reverse_iterator gIt = hIt;
+ gIt++;
+
+ this->m_LastDiff = double( hIt->second ) - double( gIt->second );
+ this->m_LastDiff /= double( hIt->first ) - double( gIt->first );
+ this->m_LastDiff *= m_DifferenceThreshold;
+ }
+ else
+ this->m_LastDiff = double( -1 );
+
+ } // fi
+ this->Superclass::_AfterLoop( );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+bool fpa::Image::RegionGrowWithMultipleThresholds< I >::
+_UpdateResult( _TNode& n )
+{
+ // Here, the output is changed to the threshold used to compute the
+ // growing condition of the actual vertex n
+ bool ret = this->Superclass::_UpdateResult( n );
+ if( this->m_ActualFunction != this->m_Functions.end( ) )
+ {
+ TFunction* f =
+ dynamic_cast< TFunction* >( this->m_ActualFunction->GetPointer( ) );
+ if( f != NULL )
+ this->GetOutput( )->SetPixel( n.Vertex, f->GetUpperThreshold( ) );