]> Creatis software - FrontAlgorithms.git/blob - appli/CTBronchi/MoriLabelling.hxx
...
[FrontAlgorithms.git] / appli / CTBronchi / MoriLabelling.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __CTBronchi__MoriLabelling__hxx__
7 #define __CTBronchi__MoriLabelling__hxx__
8
9 #include <itkImageRegionConstIterator.h>
10 #include <itkImageRegionIterator.h>
11
12 // -------------------------------------------------------------------------
13 template< class _TInputImage, class _TLabelImage >
14 const _TLabelImage*
15 CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
16 GetInputLabelImage( ) const
17 {
18   return( this->GetInput( ) );
19 }
20
21 // -------------------------------------------------------------------------
22 template< class _TInputImage, class _TLabelImage >
23 void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
24 SetInputLabelImage( TLabelImage* image )
25 {
26   this->SetInput( image );
27 }
28
29 // -------------------------------------------------------------------------
30 template< class _TInputImage, class _TLabelImage >
31 const _TInputImage*
32 CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
33 GetInputRawImage( ) const
34 {
35   return(
36     dynamic_cast< const TInputImage* >(
37       this->itk::ProcessObject::GetInput( 1 )
38       )
39     );
40 }
41
42 // -------------------------------------------------------------------------
43 template< class _TInputImage, class _TLabelImage >
44 void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
45 SetInputRawImage( TInputImage* image )
46 {
47   this->itk::ProcessObject::SetNthInput( 1, image );
48 }
49
50 // -------------------------------------------------------------------------
51 template< class _TInputImage, class _TLabelImage >
52 CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
53 MoriLabelling( )
54   : Superclass( ),
55     m_UpperThreshold( TLabel( 0 ) ),
56     m_InsideValue( TLabel( 0 ) ),
57     m_InsideLabel( TLabel( 0 ) ),
58     m_OutsideLabel( TLabel( 0 ) )
59 {
60   this->SetNumberOfRequiredInputs( 2 );
61 }
62
63 // -------------------------------------------------------------------------
64 template< class _TInputImage, class _TLabelImage >
65 CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
66 ~MoriLabelling( )
67 {
68 }
69
70 // -------------------------------------------------------------------------
71 template< class _TInputImage, class _TLabelImage >
72 void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
73 ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId )
74 {
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 );
81
82   lIt.GoToBegin( );
83   iIt.GoToBegin( );
84   oIt.GoToBegin( );
85   while( !( lIt.IsAtEnd( ) || iIt.IsAtEnd( ) || oIt.IsAtEnd( ) ) )
86   {
87     if( lIt.Get( ) != this->m_InsideValue )
88     {
89       if( this->m_UpperThreshold < iIt.Get( ) )
90         oIt.Set( this->m_OutsideLabel );
91       else
92         oIt.Set( TLabel( 0 ) );
93     }
94     else
95       oIt.Set( this->m_InsideLabel );
96     ++lIt;
97     ++iIt;
98     ++oIt;
99
100   } // elihw
101 }
102
103 #endif // __CTBronchi__MoriLabelling__hxx__
104
105 // eof - $RCSfile$