+ // Correct seeds
+ typename I::SizeType radius;
+ radius.Fill( 3 );
+ itk::ConstNeighborhoodIterator< I > it(
+ radius, img, img->GetRequestedRegion( )
+ );
+ for( unsigned int s = 0; s < this->m_Seeds.size( ); ++s )
+ {
+ _TNode seed = this->m_Seeds[ s ];
+ it.SetLocation( seed.Vertex );
+
+ typename I::SizeType size = it.GetSize( );
+ unsigned int nN = 1;
+ for( unsigned int d = 0; d < I::ImageDimension; ++d )
+ nN *= size[ d ];
+ TPixel min_value = img->GetPixel( seed.Vertex );
+ for( unsigned int i = 0; i < nN; ++i )
+ {
+ if( it.GetPixel( i ) < min_value )
+ {
+ seed.Vertex = it.GetIndex( i );
+ seed.Parent = seed.Vertex;
+ min_value = it.GetPixel( i );
+
+ } // fi
+
+ } // rof
+ this->m_Seeds[ s ] = seed;
+
+ } // rof
+
+ // Continue all initializations
+ this->Superclass::_BeforeMainLoop( );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+void fpa::Image::RegionGrowWithMultipleThresholds< I >::
+_AfterMainLoop( )
+{
+ typedef itk::BinaryThresholdImageFilter< I, I > _TBinFilter;
+
+ // Binarize, inplace, the grown region
+ if( this->m_Histogram.size( ) > 1 )
+ {
+ typename _TBinFilter::Pointer bin = _TBinFilter::New( );
+ bin->SetInput( this->GetOutput( ) );
+ bin->SetInsideValue( this->m_InsideValue );
+ bin->SetOutsideValue( this->m_OutsideValue );
+ bin->InPlaceOn( );
+ if( this->m_StopForced )
+ bin->SetUpperThreshold( this->m_StopThreshold );
+ else
+ bin->SetUpperThreshold( this->m_Histogram.rbegin( )->first );
+ bin->GraftOutput( this->GetOutput( ) );
+ bin->Update( );
+ this->GraftOutput( bin->GetOutput( ) );
+
+ } // fi
+
+ this->Superclass::_AfterMainLoop( );