X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FRegionGrowWithMultipleThresholds.hxx;h=4725c549102e042b1155d4951cb709b237813231;hb=1aff59e7c480d7448c63694da6f30e3dfb022edf;hp=387a833bcab9bda89bba8d05e36eb9ec76fdeeae;hpb=c9880eac7f555da20538eb0eb95aa7e31fab3d51;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx index 387a833..4725c54 100644 --- a/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx +++ b/lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx @@ -2,6 +2,7 @@ #define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__ #include +#include #include // ------------------------------------------------------------------------- @@ -27,6 +28,8 @@ template< class I > fpa::Image::RegionGrowWithMultipleThresholds< I >:: RegionGrowWithMultipleThresholds( ) : Superclass( ), + m_InsideValue( TPixel( 1 ) ), + m_OutsideValue( TPixel( 0 ) ), m_DifferenceThreshold( double( 3 ) ), m_TotalCount( 0 ), m_LastDiff( double( 0 ) ), @@ -90,6 +93,7 @@ _BeforeMainLoop( ) if( it.GetPixel( i ) < min_value ) { seed.Vertex = it.GetIndex( i ); + seed.Parent = seed.Vertex; min_value = it.GetPixel( i ); } // fi @@ -108,6 +112,26 @@ 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( ); } @@ -207,6 +231,8 @@ _Mark( const _TNode& n ) diff /= double( f->GetUpperThreshold( ) ) - double( hIt->first ); if( diff > this->m_LastDiff ) { + /* TODO: comment this for demo purposes + */ this->m_StopForced = true; this->m_StopThreshold = hIt->first;