// ========================================================================= // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= #ifndef __CTBronchi__MoriLabelling__hxx__ #define __CTBronchi__MoriLabelling__hxx__ #include #include // ------------------------------------------------------------------------- template< class _TInputImage, class _TLabelImage > const _TLabelImage* CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >:: GetInputLabelImage( ) const { return( this->GetInput( ) ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TLabelImage > void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >:: SetInputLabelImage( TLabelImage* image ) { this->SetInput( image ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TLabelImage > const _TInputImage* CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >:: GetInputRawImage( ) const { return( dynamic_cast< const TInputImage* >( this->itk::ProcessObject::GetInput( 1 ) ) ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TLabelImage > void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >:: SetInputRawImage( TInputImage* image ) { this->itk::ProcessObject::SetNthInput( 1, image ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TLabelImage > CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >:: MoriLabelling( ) : Superclass( ), m_UpperThreshold( TLabel( 0 ) ), m_InsideValue( TLabel( 0 ) ), m_InsideLabel( TLabel( 0 ) ), m_OutsideLabel( TLabel( 0 ) ) { this->SetNumberOfRequiredInputs( 2 ); } // ------------------------------------------------------------------------- template< class _TInputImage, class _TLabelImage > CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >:: ~MoriLabelling( ) { } // ------------------------------------------------------------------------- template< class _TInputImage, class _TLabelImage > void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >:: ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) { itk::ImageRegionConstIterator< TLabelImage > lIt( this->GetInputLabelImage( ), region ); itk::ImageRegionConstIterator< TInputImage > iIt( this->GetInputRawImage( ), region ); itk::ImageRegionIterator< TLabelImage > oIt( this->GetOutput( ), region ); lIt.GoToBegin( ); iIt.GoToBegin( ); oIt.GoToBegin( ); while( !( lIt.IsAtEnd( ) || iIt.IsAtEnd( ) || oIt.IsAtEnd( ) ) ) { if( lIt.Get( ) != this->m_InsideValue ) { if( this->m_UpperThreshold < iIt.Get( ) ) oIt.Set( this->m_OutsideLabel ); else oIt.Set( TLabel( 0 ) ); } else oIt.Set( this->m_InsideLabel ); ++lIt; ++iIt; ++oIt; } // elihw } #endif // __CTBronchi__MoriLabelling__hxx__ // eof - $RCSfile$