X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FCTBronchi%2FMoriLabelling.h;h=b51cfeb1ee363174e2b8927f50189432d9da6690;hb=e69d65c084b579e4014cf35688eae78a9a397834;hp=f1ac2ea9a4c1072da4004b09e993bac8c326f7de;hpb=7a0591e1611721f36428cee7d7cce6161f517612;p=FrontAlgorithms.git diff --git a/appli/CTBronchi/MoriLabelling.h b/appli/CTBronchi/MoriLabelling.h index f1ac2ea..b51cfeb 100644 --- a/appli/CTBronchi/MoriLabelling.h +++ b/appli/CTBronchi/MoriLabelling.h @@ -6,12 +6,11 @@ #ifndef __CTBronchi__MoriLabelling__h__ #define __CTBronchi__MoriLabelling__h__ -#include -#include -#include - -#include - +#include +#include +#include +#include +#include namespace CTBronchi { @@ -19,35 +18,40 @@ namespace CTBronchi */ template< class _TInputImage, class _TLabelImage > class MoriLabelling - : public itk::ImageToImageFilter< _TLabelImage, _TLabelImage > + : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TLabelImage, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Image::LabelledSeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TLabelImage::PixelType, typename _TLabelImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > > { public: - typedef MoriLabelling Self; - typedef itk::ImageToImageFilter< _TLabelImage, _TLabelImage > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - typedef _TInputImage TInputImage; typedef _TLabelImage TLabelImage; - typedef typename TInputImage::PixelType TPixel; - typedef typename TLabelImage::PixelType TLabel; - typedef typename TLabelImage::RegionType TRegion; + typedef typename TInputImage::PixelType TInputValue; + typedef typename TInputImage::PointType TPoint; + typedef typename TInputImage::IndexType TVertex; + typedef typename TLabelImage::PixelType TOutputValue; + typedef typename TVertex::LexicographicCompare TVertexCompare; - public: - itkNewMacro( Self ); - itkTypeMacro( MoriLabelling, itk::ImageToImageFilter ); + typedef fpa::Base::MarksInterface< TVertex > TMarksInterface; + typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TOutputValue, TVertexCompare > TSeedsInterface; + typedef fpa::Image::Algorithm< TInputImage, TLabelImage, TMarksInterface, TSeedsInterface > TAlgorithm; - itkGetConstMacro( UpperThreshold, TPixel ); - itkSetMacro( UpperThreshold, TPixel ); + typedef MoriLabelling Self; + typedef fpa::Base::RegionGrow< TAlgorithm > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - itkGetConstMacro( InsideValue, TLabel ); - itkSetMacro( InsideValue, TLabel ); + typedef typename TSeedsInterface::TNode TNode; + typedef typename TSeedsInterface::TNodes TNodes; - itkGetConstMacro( InsideLabel, TLabel ); - itkSetMacro( InsideLabel, TLabel ); + typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TThresholdFunction; - itkGetConstMacro( OutsideLabel, TLabel ); - itkSetMacro( OutsideLabel, TLabel ); + public: + itkNewMacro( Self ); + itkTypeMacro( MoriLabelling, fpa::Base::RegionGrow ); + + itkGetConstMacro( InsideLabel, TOutputValue ); + itkSetMacro( InsideLabel, TOutputValue ); + + itkGetConstMacro( OutsideLabel, TOutputValue ); + itkSetMacro( OutsideLabel, TOutputValue ); public: const TLabelImage* GetInputLabelImage( ) const; @@ -56,40 +60,15 @@ namespace CTBronchi const TInputImage* GetInputRawImage( ) const; void SetInputRawImage( TInputImage* image ); + TInputValue GetUpperThreshold( ) const; + void SetUpperThreshold( TInputValue t ); + protected: MoriLabelling( ); virtual ~MoriLabelling( ); - virtual void BeforeThreadedGenerateData( ) override - { - this->Superclass::BeforeThreadedGenerateData( ); - - const TInputImage* raw = this->GetInputRawImage( ); - typename TInputImage::SpacingType spac = raw->GetSpacing( ); - double sigma = spac[ 0 ]; - for( unsigned int d = 1; d < TInputImage::ImageDimension; ++d ) - sigma = ( spac[ d ] < sigma )? spac[ d ]: sigma; - sigma *= 1.5; - - typedef itk::HessianRecursiveGaussianImageFilter< TInputImage > _THessian; - typename _THessian::Pointer hessian = _THessian::New( ); - hessian->SetInput( raw ); - hessian->SetSigma( sigma ); - - typedef itk::Hessian3DToVesselnessMeasureImageFilter< double > _TVesselness; - typename _TVesselness::Pointer vesselness = _TVesselness::New( ); - vesselness->SetInput( hessian->GetOutput( ) ); - vesselness->SetAlpha1( 0.5 ); - vesselness->SetAlpha2( 2.0 ); - - typename itk::ImageFileWriter< typename _TVesselness::OutputImageType >::Pointer w = - itk::ImageFileWriter< typename _TVesselness::OutputImageType >::New( ); - w->SetInput( vesselness->GetOutput( ) ); - w->SetFileName( "vessel.mhd" ); - w->Update( ); - } - - virtual void ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) override; + virtual TNodes _UnifySeeds( ) override; + virtual void _UpdateOutputValue( TNode& n ) override; private: // Purposely not implemented. @@ -97,10 +76,8 @@ namespace CTBronchi Self& operator=( const Self& other ); protected: - TPixel m_UpperThreshold; - TLabel m_InsideValue; - TLabel m_InsideLabel; - TLabel m_OutsideLabel; + TOutputValue m_InsideLabel; + TOutputValue m_OutsideLabel; }; } // ecapseman