1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
6 #ifndef __CTBronchi__MoriLabelling__h__
7 #define __CTBronchi__MoriLabelling__h__
9 #include <itkImageToImageFilter.h>
10 #include <itkHessianRecursiveGaussianImageFilter.h>
11 #include <itkHessian3DToVesselnessMeasureImageFilter.h>
13 #include <itkImageFileWriter.h>
20 template< class _TInputImage, class _TLabelImage >
22 : public itk::ImageToImageFilter< _TLabelImage, _TLabelImage >
25 typedef MoriLabelling Self;
26 typedef itk::ImageToImageFilter< _TLabelImage, _TLabelImage > Superclass;
27 typedef itk::SmartPointer< Self > Pointer;
28 typedef itk::SmartPointer< const Self > ConstPointer;
30 typedef _TInputImage TInputImage;
31 typedef _TLabelImage TLabelImage;
32 typedef typename TInputImage::PixelType TPixel;
33 typedef typename TLabelImage::PixelType TLabel;
34 typedef typename TLabelImage::RegionType TRegion;
38 itkTypeMacro( MoriLabelling, itk::ImageToImageFilter );
40 itkGetConstMacro( UpperThreshold, TPixel );
41 itkSetMacro( UpperThreshold, TPixel );
43 itkGetConstMacro( InsideValue, TLabel );
44 itkSetMacro( InsideValue, TLabel );
46 itkGetConstMacro( InsideLabel, TLabel );
47 itkSetMacro( InsideLabel, TLabel );
49 itkGetConstMacro( OutsideLabel, TLabel );
50 itkSetMacro( OutsideLabel, TLabel );
53 const TLabelImage* GetInputLabelImage( ) const;
54 void SetInputLabelImage( TLabelImage* image );
56 const TInputImage* GetInputRawImage( ) const;
57 void SetInputRawImage( TInputImage* image );
61 virtual ~MoriLabelling( );
63 virtual void BeforeThreadedGenerateData( ) override
65 this->Superclass::BeforeThreadedGenerateData( );
67 const TInputImage* raw = this->GetInputRawImage( );
68 typename TInputImage::SpacingType spac = raw->GetSpacing( );
69 double sigma = spac[ 0 ];
70 for( unsigned int d = 1; d < TInputImage::ImageDimension; ++d )
71 sigma = ( spac[ d ] < sigma )? spac[ d ]: sigma;
74 typedef itk::HessianRecursiveGaussianImageFilter< TInputImage > _THessian;
75 typename _THessian::Pointer hessian = _THessian::New( );
76 hessian->SetInput( raw );
77 hessian->SetSigma( sigma );
79 typedef itk::Hessian3DToVesselnessMeasureImageFilter< double > _TVesselness;
80 typename _TVesselness::Pointer vesselness = _TVesselness::New( );
81 vesselness->SetInput( hessian->GetOutput( ) );
82 vesselness->SetAlpha1( 0.5 );
83 vesselness->SetAlpha2( 2.0 );
85 typename itk::ImageFileWriter< typename _TVesselness::OutputImageType >::Pointer w =
86 itk::ImageFileWriter< typename _TVesselness::OutputImageType >::New( );
87 w->SetInput( vesselness->GetOutput( ) );
88 w->SetFileName( "vessel.mhd" );
92 virtual void ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) override;
95 // Purposely not implemented.
96 MoriLabelling( const Self& other );
97 Self& operator=( const Self& other );
100 TPixel m_UpperThreshold;
101 TLabel m_InsideValue;
102 TLabel m_InsideLabel;
103 TLabel m_OutsideLabel;
108 #ifndef ITK_MANUAL_INSTANTIATION
109 # include <CTBronchi/MoriLabelling.hxx>
110 #endif // ITK_MANUAL_INSTANTIATION
112 #endif // __CTBronchi__MoriLabelling__h__