1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
6 #ifndef __CTBronchi__MoriLabelling__hxx__
7 #define __CTBronchi__MoriLabelling__hxx__
9 #include <itkImageRegionConstIterator.h>
10 #include <itkImageRegionIterator.h>
12 // -------------------------------------------------------------------------
13 template< class _TInputImage, class _TLabelImage >
15 CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
16 GetInputLabelImage( ) const
18 return( this->GetInput( ) );
21 // -------------------------------------------------------------------------
22 template< class _TInputImage, class _TLabelImage >
23 void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
24 SetInputLabelImage( TLabelImage* image )
26 this->SetInput( image );
29 // -------------------------------------------------------------------------
30 template< class _TInputImage, class _TLabelImage >
32 CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
33 GetInputRawImage( ) const
36 dynamic_cast< const TInputImage* >(
37 this->itk::ProcessObject::GetInput( 1 )
42 // -------------------------------------------------------------------------
43 template< class _TInputImage, class _TLabelImage >
44 void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
45 SetInputRawImage( TInputImage* image )
47 this->itk::ProcessObject::SetNthInput( 1, image );
50 // -------------------------------------------------------------------------
51 template< class _TInputImage, class _TLabelImage >
52 CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
55 m_UpperThreshold( TLabel( 0 ) ),
56 m_InsideValue( TLabel( 0 ) ),
57 m_InsideLabel( TLabel( 0 ) ),
58 m_OutsideLabel( TLabel( 0 ) )
60 this->SetNumberOfRequiredInputs( 2 );
63 // -------------------------------------------------------------------------
64 template< class _TInputImage, class _TLabelImage >
65 CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
70 // -------------------------------------------------------------------------
71 template< class _TInputImage, class _TLabelImage >
72 void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
73 ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId )
75 itk::ImageRegionConstIterator< TLabelImage >
76 lIt( this->GetInputLabelImage( ), region );
77 itk::ImageRegionConstIterator< TInputImage >
78 iIt( this->GetInputRawImage( ), region );
79 itk::ImageRegionIterator< TLabelImage >
80 oIt( this->GetOutput( ), region );
85 while( !( lIt.IsAtEnd( ) || iIt.IsAtEnd( ) || oIt.IsAtEnd( ) ) )
87 if( lIt.Get( ) != this->m_InsideValue )
89 if( this->m_UpperThreshold < iIt.Get( ) )
90 oIt.Set( this->m_OutsideLabel );
92 oIt.Set( TLabel( 0 ) );
95 oIt.Set( this->m_InsideLabel );
103 #endif // __CTBronchi__MoriLabelling__hxx__