#define __fpa__Image__MoriRegionGrow__hxx__
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-MoriRegionGrow( )
- : Superclass( ),
- m_Step( TPixel( 1 ) ),
- m_Sensitivity( double( 1 ) )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+typename
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+TAuxImage*
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+GetAuxiliaryImage( )
{
- this->m_Upper = std::numeric_limits< TPixel >::max( );
- if( std::numeric_limits< TPixel >::is_integer )
- this->m_Lower = std::numeric_limits< TPixel >::min( );
- else
- this->m_Lower = -this->m_Upper;
- typename TBinThresholdFunction::Pointer functor =
- TBinThresholdFunction::New( );
- this->SetGrowFunction( functor );
+ return( this->m_Helper->GetOutput( ) );
}
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-~MoriRegionGrow( )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+const typename
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+TAuxImage*
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+GetAuxiliaryImage( ) const
+{
+ return( this->m_Helper->GetOutput( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+typename
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+TInputPixel
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+GetLower( ) const
+{
+ return( this->m_Helper->GetLower( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+typename
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+TInputPixel
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+GetUpper( ) const
+{
+ return( this->m_Helper->GetUpper( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+typename
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+TInputPixel
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+GetStep( ) const
{
+ return( this->m_Helper->GetStep( ) );
}
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-bool fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-_ContinueGenerateData( )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+typename
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+TOutputPixel
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+GetInsideValue( ) const
{
- TBinThresholdFunction* functor =
- dynamic_cast< TBinThresholdFunction* >( this->GetGrowFunction( ) );
- TPixel u = functor->GetUpper( );
-
- // Analyze flooding
- bool stop = false;
- if( this->m_N > double( 10 ) )
- {
- 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 );
-
- std::cout << u << " " << this->m_ActualCount << " " << this->m_STD << std::endl;
-
- if( u < this->m_Upper )
- {
- u += this->m_Step;
- if( u > this->m_Upper )
- u = this->m_Upper;
- functor->SetUpper( u );
- this->m_Queue = this->m_NextQueue;
- while( this->m_NextQueue.size( ) > 0 )
- this->m_NextQueue.pop( );
- return( !stop );
- }
- else
- return( false );
+ return( this->m_Threshold->GetInsideValue( ) );
}
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-_BeforeGenerateData( )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+typename
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+TOutputPixel
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+GetOutsideValue( ) const
{
- this->Superclass::_BeforeGenerateData( );
-
- 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 );
- functor->SetUpper( this->m_Lower + this->m_Step );
+ return( this->m_Threshold->GetInsideValue( ) );
}
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-_AfterGenerateData( )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+SetLower( const TInputPixel& v )
{
- this->Superclass::_AfterGenerateData( );
- while( this->m_NextQueue.size( ) > 0 )
- this->m_NextQueue.pop( );
+ this->m_Helper->SetLower( v );
+ this->Modified( );
}
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-_BeforeLoop( )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+SetUpper( const TInputPixel& v )
{
- this->Superclass::_BeforeLoop( );
+ this->m_Helper->SetUpper( v );
+ this->Modified( );
}
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-_AfterLoop( )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+SetStep( const TInputPixel& v )
{
- this->Superclass::_AfterLoop( );
+ this->m_Helper->SetStep( v );
+ this->Modified( );
}
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-bool fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+SetInsideValue( const TOutputPixel& v )
+{
+ this->m_Threshold->SetInsideValue( v );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+SetOutsideValue( const TOutputPixel& v )
+{
+ this->m_Threshold->SetOutsideValue( v );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+MoriRegionGrow( )
+ : Superclass( )
+{
+ this->m_Helper = THelper::New( );
+ this->m_Threshold = TThreshold::New( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+~MoriRegionGrow( )
{
- bool ret = this->Superclass::_UpdateValue( v, p );
- if( !ret )
- {
- v.Result = this->m_InsideValue;
- this->m_NextQueue.push( v );
-
- } // fi
- return( ret );
}
// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
-_UpdateResult( const _TQueueNode& n )
+template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
+void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage, _TAuxPixel >::
+GenerateData( )
{
- this->Superclass::_UpdateResult( n );
- this->m_ActualCount += 1;
+ this->m_Helper->ClearSeeds( );
+ this->m_Helper->AddSeed( this->m_Seed, 0 );
+ this->m_Helper->SetInput( this->GetInput( ) );
+ this->m_Helper->Update( );
+
+ this->m_Threshold->SetInput( this->m_Helper->GetOutput( ) );
+ this->m_Threshold->SetLowerThreshold( std::numeric_limits< _TAuxPixel >::min( ) );
+ this->m_Threshold->SetUpperThreshold( this->m_Helper->GetOptimumThreshold( ) );
+ this->m_Threshold->Update( );
+ this->GetOutput( )->Graft( this->m_Threshold->GetOutput( ) );
}
#endif // __fpa__Image__MoriRegionGrow__hxx__