1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __CTBronchi__MoriLabelling__h__
6 #define __CTBronchi__MoriLabelling__h__
8 #include <itkMinimumMaximumImageCalculator.h>
9 #include <fpa/Filters/BaseMarksInterface.h>
10 #include <fpa/Filters/Image/SeedsFromLabelsInterface.h>
11 #include <fpa/Filters/Image/DefaultTraits.h>
12 #include <fpa/Filters/Image/RegionGrow.h>
13 #include <fpa/Functors/RegionGrow/BinaryThreshold.h>
19 template< class _TImage, class _TLabels >
20 class MoriLabellingTraits
21 : public fpa::Filters::Image::DefaultTraits< _TImage, _TLabels, typename _TLabels::PixelType >
24 typedef fpa::Filters::Image::DefaultTraits< _TImage, _TLabels, typename _TLabels::PixelType > Superclass;
25 typedef typename Superclass::TInternalTraits TInternalTraits;
26 typedef typename Superclass::TMarksImage TMarksImage;
27 typedef typename Superclass::TFilterInterface TFilterInterface;
29 typedef fpa::Filters::BaseMarksInterface< TInternalTraits > TMarksInterface;
30 typedef fpa::Filters::Image::SeedsFromLabelsInterface< TInternalTraits > TSeedsInterface;
35 template< class _TImage, class _TLabels, class _TScalarImage >
37 : public fpa::Filters::Image::RegionGrow< _TImage, _TLabels, typename _TLabels::PixelType, CTBronchi::MoriLabellingTraits< _TImage, _TLabels > >
40 typedef CTBronchi::MoriLabellingTraits< _TImage, _TLabels > TTraits;
41 fpaTraitsMacro( typename TTraits );
43 typedef fpa::Filters::Image::RegionGrow< _TImage, _TLabels, TMark, TTraits > Superclass;
44 typedef MoriLabelling Self;
45 typedef itk::SmartPointer< Self > Pointer;
46 typedef itk::SmartPointer< const Self > ConstPointer;
48 typedef fpa::Functors::RegionGrow::BinaryThreshold< TInputValue > TFunctor;
52 itkTypeMacro( MoriLabelling, fpa::Filters::Image::RegionGrow );
54 itkGetConstMacro( VesselnessThreshold, double );
55 itkSetMacro( VesselnessThreshold, double );
57 itkGetConstMacro( UpperThreshold, TInputValue );
58 itkSetMacro( UpperThreshold, TInputValue );
60 ivqITKInputMacro( InputLabels, _TLabels );
61 ivqITKInputMacro( InputVesselness, _TScalarImage );
66 m_VesselnessThreshold( 5 ),
67 m_UpperThreshold( -650 )
69 ivqITKInputConfigureMacro( InputLabels, _TLabels );
70 ivqITKInputConfigureMacro( InputVesselness, _TScalarImage );
71 this->m_Functor = TFunctor::New( );
72 this->SetPredicate( this->m_Functor );
75 virtual ~MoriLabelling( )
79 virtual const itk::DataObject* _GetReferenceInput( ) const override
81 return( this->GetInputLabels( ) );
83 virtual void _BeforeGenerateData( ) override
85 this->Superclass::_BeforeGenerateData( );
87 this->m_Functor->SetUpperThreshold( this->m_UpperThreshold );
89 typedef itk::MinimumMaximumImageCalculator< _TScalarImage > _TMinMax;
90 typename _TMinMax::Pointer minMax = _TMinMax::New( );
91 minMax->SetImage( this->GetInputVesselness( ) );
93 this->m_MinVesselness =
94 ( this->m_VesselnessThreshold / double( 100 ) ) *
95 double( minMax->GetMaximum( ) );
98 virtual void _PostComputeOutputValue( TNode& n ) override
100 this->Superclass::_PostComputeOutputValue( n );
101 if( n.Value == this->GetInsideValue( ) )
103 const _TLabels* labels = this->GetInputLabels( );
104 const _TScalarImage* vesselness = this->GetInputVesselness( );
105 if( labels->GetPixel( n.Vertex ) == 0 )
107 if( this->m_MinVesselness < vesselness->GetPixel( n.Vertex ) )
108 n.Value = this->GetInsideValue( );
118 // Purposely not implemented.
119 MoriLabelling( const Self& other );
120 Self& operator=( const Self& other );
123 typename TFunctor::Pointer m_Functor;
124 double m_VesselnessThreshold;
125 double m_MinVesselness;
126 TInputValue m_UpperThreshold;
131 #endif // __CTBronchi__Functions__h__