]> Creatis software - FrontAlgorithms.git/blob - appli/CTBronchi/MoriLabelling.h
f1ac2ea9a4c1072da4004b09e993bac8c326f7de
[FrontAlgorithms.git] / appli / CTBronchi / MoriLabelling.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __CTBronchi__MoriLabelling__h__
7 #define __CTBronchi__MoriLabelling__h__
8
9 #include <itkImageToImageFilter.h>
10 #include <itkHessianRecursiveGaussianImageFilter.h>
11 #include <itkHessian3DToVesselnessMeasureImageFilter.h>
12
13 #include <itkImageFileWriter.h>
14
15
16 namespace CTBronchi
17 {
18   /**
19    */
20   template< class _TInputImage, class _TLabelImage >
21   class MoriLabelling
22     : public itk::ImageToImageFilter< _TLabelImage, _TLabelImage >
23   {
24   public:
25     typedef MoriLabelling                                         Self;
26     typedef itk::ImageToImageFilter< _TLabelImage, _TLabelImage > Superclass;
27     typedef itk::SmartPointer< Self >                             Pointer;
28     typedef itk::SmartPointer< const Self >                       ConstPointer;
29
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;
35
36   public:
37     itkNewMacro( Self );
38     itkTypeMacro( MoriLabelling, itk::ImageToImageFilter );
39
40     itkGetConstMacro( UpperThreshold, TPixel );
41     itkSetMacro( UpperThreshold, TPixel );
42
43     itkGetConstMacro( InsideValue, TLabel );
44     itkSetMacro( InsideValue, TLabel );
45
46     itkGetConstMacro( InsideLabel, TLabel );
47     itkSetMacro( InsideLabel, TLabel );
48
49     itkGetConstMacro( OutsideLabel, TLabel );
50     itkSetMacro( OutsideLabel, TLabel );
51
52   public:
53     const TLabelImage* GetInputLabelImage( ) const;
54     void SetInputLabelImage( TLabelImage* image );
55
56     const TInputImage* GetInputRawImage( ) const;
57     void SetInputRawImage( TInputImage* image );
58
59   protected:
60     MoriLabelling( );
61     virtual ~MoriLabelling( );
62
63     virtual void BeforeThreadedGenerateData( ) override
64       {
65         this->Superclass::BeforeThreadedGenerateData( );
66
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;
72         sigma *= 1.5;
73
74         typedef itk::HessianRecursiveGaussianImageFilter< TInputImage > _THessian;
75         typename _THessian::Pointer hessian = _THessian::New( );
76         hessian->SetInput( raw );
77         hessian->SetSigma( sigma );
78
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 );
84
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" );
89         w->Update( );
90       }
91
92     virtual void ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) override;
93
94   private:
95     // Purposely not implemented.
96     MoriLabelling( const Self& other );
97     Self& operator=( const Self& other );
98
99   protected:
100     TPixel m_UpperThreshold;
101     TLabel m_InsideValue;
102     TLabel m_InsideLabel;
103     TLabel m_OutsideLabel;
104   };
105
106 } // ecapseman
107
108 #ifndef ITK_MANUAL_INSTANTIATION
109 #  include <CTBronchi/MoriLabelling.hxx>
110 #endif // ITK_MANUAL_INSTANTIATION
111
112 #endif // __CTBronchi__MoriLabelling__h__
113
114 // eof - $RCSfile$