#ifndef __fpa__Image__MoriRegionGrow__hxx__ #define __fpa__Image__MoriRegionGrow__hxx__ // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: MoriRegionGrow( ) : Superclass( ), m_Step( TPixel( 1 ) ) { 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 ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: ~MoriRegionGrow( ) { } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > bool fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: _ContinueGenerateData( ) { TBinThresholdFunction* functor = dynamic_cast< TBinThresholdFunction* >( this->GetGrowFunction( ) ); TPixel u = functor->GetUpper( ); std::cout << long( u ) << " " << this->m_ActualCount << 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( true ); } else return( false ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: _BeforeGenerateData( ) { this->Superclass::_BeforeGenerateData( ); while( this->m_NextQueue.size( ) > 0 ) this->m_NextQueue.pop( ); this->m_ActualCount = 0; TBinThresholdFunction* functor = dynamic_cast< TBinThresholdFunction* >( this->GetGrowFunction( ) ); functor->SetLower( this->m_Lower ); functor->SetUpper( this->m_Lower + this->m_Step ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: _AfterGenerateData( ) { this->Superclass::_AfterGenerateData( ); while( this->m_NextQueue.size( ) > 0 ) this->m_NextQueue.pop( ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: _BeforeLoop( ) { this->Superclass::_BeforeLoop( ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: _AfterLoop( ) { this->Superclass::_AfterLoop( ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TOutputImage > bool fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >:: _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) { 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 ) { this->Superclass::_UpdateResult( n ); this->m_ActualCount += 1; } #endif // __fpa__Image__MoriRegionGrow__hxx__ // eof - $RCSfile$