// ========================================================================= // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= #ifndef __CTBronchi__MoriLabelling__h__ #define __CTBronchi__MoriLabelling__h__ #include #include #include #include namespace CTBronchi { /** */ template< class _TInputImage, class _TLabelImage > class MoriLabelling : public itk::ImageToImageFilter< _TLabelImage, _TLabelImage > { 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; public: itkNewMacro( Self ); itkTypeMacro( MoriLabelling, itk::ImageToImageFilter ); itkGetConstMacro( UpperThreshold, TPixel ); itkSetMacro( UpperThreshold, TPixel ); itkGetConstMacro( InsideValue, TLabel ); itkSetMacro( InsideValue, TLabel ); itkGetConstMacro( InsideLabel, TLabel ); itkSetMacro( InsideLabel, TLabel ); itkGetConstMacro( OutsideLabel, TLabel ); itkSetMacro( OutsideLabel, TLabel ); public: const TLabelImage* GetInputLabelImage( ) const; void SetInputLabelImage( TLabelImage* image ); const TInputImage* GetInputRawImage( ) const; void SetInputRawImage( TInputImage* image ); 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; private: // Purposely not implemented. MoriLabelling( const Self& other ); Self& operator=( const Self& other ); protected: TPixel m_UpperThreshold; TLabel m_InsideValue; TLabel m_InsideLabel; TLabel m_OutsideLabel; }; } // ecapseman #ifndef ITK_MANUAL_INSTANTIATION # include #endif // ITK_MANUAL_INSTANTIATION #endif // __CTBronchi__MoriLabelling__h__ // eof - $RCSfile$