X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FCTBronchi%2FMoriLabelling.h;h=ff6553e8419ce05ec3fe151c46721daece56467f;hb=0251081f09de5bd702c01565c9401c1eb1983ae5;hp=105c7d024aa53341795c5d6c8a32041098809004;hpb=6f716a6d2ce76a7bc9abb37406ce3802aa1e4451;p=FrontAlgorithms.git diff --git a/appli/CTBronchi/MoriLabelling.h b/appli/CTBronchi/MoriLabelling.h index 105c7d0..ff6553e 100644 --- a/appli/CTBronchi/MoriLabelling.h +++ b/appli/CTBronchi/MoriLabelling.h @@ -2,60 +2,117 @@ // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= - #ifndef __CTBronchi__MoriLabelling__h__ #define __CTBronchi__MoriLabelling__h__ -#include +#include +#include +#include +#include +#include +#include namespace CTBronchi { /** */ - template< class _TInputImage, class _TLabelImage > - class MoriLabelling - : public itk::ImageToImageFilter< _TLabelImage, _TLabelImage > + template< class _TImage, class _TLabels > + class MoriLabellingTraits + : public fpa::Filters::Image::DefaultTraits< _TImage, _TLabels, typename _TLabels::PixelType > { public: - typedef MoriLabelling Self; - typedef itk::ImageToImageFilter< _TLabelImage, _TLabelImage > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef fpa::Filters::Image::DefaultTraits< _TImage, _TLabels, typename _TLabels::PixelType > Superclass; + typedef typename Superclass::TInternalTraits TInternalTraits; + typedef typename Superclass::TMarksImage TMarksImage; + typedef typename Superclass::TFilterInterface TFilterInterface; - typedef _TInputImage TInputImage; - typedef _TLabelImage TLabelImage; - typedef typename TInputImage::PixelType TPixel; - typedef typename TLabelImage::PixelType TLabel; - typedef typename TLabelImage::RegionType TRegion; + typedef fpa::Filters::BaseMarksInterface< TInternalTraits > TMarksInterface; + typedef fpa::Filters::Image::SeedsFromLabelsInterface< TInternalTraits > TSeedsInterface; + }; + /** + */ + template< class _TImage, class _TLabels, class _TScalarImage > + class MoriLabelling + : public fpa::Filters::Image::RegionGrow< _TImage, _TLabels, typename _TLabels::PixelType, CTBronchi::MoriLabellingTraits< _TImage, _TLabels > > + { public: - itkNewMacro( Self ); - itkTypeMacro( MoriLabelling, itk::ImageToImageFilter ); + typedef CTBronchi::MoriLabellingTraits< _TImage, _TLabels > TTraits; + fpaTraitsMacro( typename TTraits ); - itkGetConstMacro( UpperThreshold, TPixel ); - itkSetMacro( UpperThreshold, TPixel ); + typedef fpa::Filters::Image::RegionGrow< _TImage, _TLabels, TMark, TTraits > Superclass; + typedef MoriLabelling Self; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - itkGetConstMacro( InsideValue, TLabel ); - itkSetMacro( InsideValue, TLabel ); + typedef fpa::Functors::RegionGrow::BinaryThreshold< TInputValue > TFunctor; - itkGetConstMacro( InsideLabel, TLabel ); - itkSetMacro( InsideLabel, TLabel ); + public: + itkNewMacro( Self ); + itkTypeMacro( MoriLabelling, fpa::Filters::Image::RegionGrow ); - itkGetConstMacro( OutsideLabel, TLabel ); - itkSetMacro( OutsideLabel, TLabel ); + itkGetConstMacro( VesselnessThreshold, double ); + itkSetMacro( VesselnessThreshold, double ); - public: - const TLabelImage* GetInputLabelImage( ) const; - void SetInputLabelImage( TLabelImage* image ); + itkGetConstMacro( UpperThreshold, TInputValue ); + itkSetMacro( UpperThreshold, TInputValue ); - const TInputImage* GetInputRawImage( ) const; - void SetInputRawImage( TInputImage* image ); + ivqITKInputMacro( InputLabels, _TLabels ); + ivqITKInputMacro( InputVesselness, _TScalarImage ); protected: - MoriLabelling( ); - virtual ~MoriLabelling( ); - - virtual void ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) override; + MoriLabelling( ) + : Superclass( ), + m_VesselnessThreshold( 0.05 ), + m_UpperThreshold( -650 ) + { + ivqITKInputConfigureMacro( InputLabels, _TLabels ); + ivqITKInputConfigureMacro( InputVesselness, _TScalarImage ); + this->m_Functor = TFunctor::New( ); + this->SetPredicate( this->m_Functor ); + } + + virtual ~MoriLabelling( ) + { + } + + virtual const itk::DataObject* _GetReferenceInput( ) const override + { + return( this->GetInputLabels( ) ); + } + virtual void _BeforeGenerateData( ) override + { + this->Superclass::_BeforeGenerateData( ); + + this->m_Functor->SetUpperThreshold( this->m_UpperThreshold ); + + typedef itk::MinimumMaximumImageCalculator< _TScalarImage > _TMinMax; + typename _TMinMax::Pointer minMax = _TMinMax::New( ); + minMax->SetImage( this->GetInputVesselness( ) ); + minMax->Compute( ); + this->m_MinVesselness = + ( 1.0 - this->m_VesselnessThreshold ) * + double( minMax->GetMaximum( ) ); + } + + virtual void _PostComputeOutputValue( TNode& n ) override + { + this->Superclass::_PostComputeOutputValue( n ); + if( n.Value == this->GetInsideValue( ) ) + { + const _TLabels* labels = this->GetInputLabels( ); + const _TScalarImage* vesselness = this->GetInputVesselness( ); + if( labels->GetPixel( n.Vertex ) == 0 ) + { + if( this->m_MinVesselness < vesselness->GetPixel( n.Vertex ) ) + n.Value = this->GetInsideValue( ); + else + n.Value = 0; + + } // fi + + } // fi + } private: // Purposely not implemented. @@ -63,18 +120,14 @@ namespace CTBronchi Self& operator=( const Self& other ); protected: - TPixel m_UpperThreshold; - TLabel m_InsideValue; - TLabel m_InsideLabel; - TLabel m_OutsideLabel; + typename TFunctor::Pointer m_Functor; + double m_VesselnessThreshold; + double m_MinVesselness; + TInputValue m_UpperThreshold; }; } // ecapseman -#ifndef ITK_MANUAL_INSTANTIATION -# include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __CTBronchi__MoriLabelling__h__ +#endif // __CTBronchi__Functions__h__ // eof - $RCSfile$