]> Creatis software - FrontAlgorithms.git/blobdiff - appli/CTBronchi/MoriLabelling.h
...
[FrontAlgorithms.git] / appli / CTBronchi / MoriLabelling.h
index f1ac2ea9a4c1072da4004b09e993bac8c326f7de..d4eea090eec3e1a9ad02d6229d885ed439afaf77 100644 (file)
@@ -2,94 +2,72 @@
 // @author Leonardo Florez Valencia
 // @email florez-l@javeriana.edu.co
 // =========================================================================
-
 #ifndef __CTBronchi__MoriLabelling__h__
 #define __CTBronchi__MoriLabelling__h__
 
-#include <itkImageToImageFilter.h>
-#include <itkHessianRecursiveGaussianImageFilter.h>
-#include <itkHessian3DToVesselnessMeasureImageFilter.h>
-
-#include <itkImageFileWriter.h>
-
+#include <fpa/Filters/Image/DefaultTraits.h>
+#include <fpa/Filters/MarksInterface.h>
+#include <fpa/Filters/Image/LabelsSeedFilter.h>
+#include <fpa/Filters/Image/LabelsSeedInterface.h>
+#include <fpa/Filters/Image/RegionGrow.h>
+#include <fpa/Functors/RegionGrow/BinaryThreshold.h>
 
 namespace CTBronchi
 {
   /**
    */
   template< class _TInputImage, class _TLabelImage >
-  class MoriLabelling
-    : public itk::ImageToImageFilter< _TLabelImage, _TLabelImage >
+  class MoriLabellingTraits
+        : public fpa::Filters::Image::DefaultTraits< _TInputImage, _TLabelImage, typename _TLabelImage::PixelType >
   {
   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 fpa::Filters::Image::DefaultTraits< TInputImage, TLabelImage, typename TLabelImage::PixelType > Superclass;
 
+    typedef typename Superclass::TInternalTraits TInternalTraits;
+    typedef typename Superclass::TFilter TFilter;
+    typedef fpa::Filters::MarksInterface< TInternalTraits >  TMarksInterface;
+    typedef fpa::Filters::Image::LabelsSeedInterface< TInternalTraits > TSeedsInterface;
+  };
+
+  /**
+   */
+  template< class _TInputImage, class _TLabelImage >
+  class MoriLabelling
+    : public fpa::Filters::Image::LabelsSeedFilter< fpa::Filters::Image::Algorithm< fpa::Filters::RegionGrow< CTBronchi::MoriLabellingTraits< _TInputImage, _TLabelImage > > >, _TLabelImage >
+  {
   public:
-    itkNewMacro( Self );
-    itkTypeMacro( MoriLabelling, itk::ImageToImageFilter );
+    typedef _TInputImage TInputImage;
+    typedef _TLabelImage TLabelImage;
+    typedef CTBronchi::MoriLabellingTraits< TInputImage, TLabelImage > TTraits;
+    fpaTraitsMacro( typename, TTraits );
 
-    itkGetConstMacro( UpperThreshold, TPixel );
-    itkSetMacro( UpperThreshold, TPixel );
+    typedef fpa::Filters::RegionGrow< TTraits > TBase;
+    typedef fpa::Filters::Image::Algorithm< TBase > TAlgorithm;
+    typedef fpa::Filters::Image::LabelsSeedFilter< TAlgorithm, _TLabelImage > 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 > TLabelFunctor;
 
-    itkGetConstMacro( InsideLabel, TLabel );
-    itkSetMacro( InsideLabel, TLabel );
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro( CTBronchi::MoriLabelling, fpa::Filters::Image::RegionGrow );
 
-    itkGetConstMacro( OutsideLabel, TLabel );
-    itkSetMacro( OutsideLabel, TLabel );
+    itkGetConstMacro( InputInsideValue, TInputValue );
+    itkSetMacro( InputInsideValue, TInputValue );
 
   public:
-    const TLabelImage* GetInputLabelImage( ) const;
-    void SetInputLabelImage( TLabelImage* image );
-
-    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 void _UpdateOutputValue( TNode& n ) override;
 
   private:
     // Purposely not implemented.
@@ -97,10 +75,8 @@ namespace CTBronchi
     Self& operator=( const Self& other );
 
   protected:
-    TPixel m_UpperThreshold;
-    TLabel m_InsideValue;
-    TLabel m_InsideLabel;
-    TLabel m_OutsideLabel;
+    typename TLabelFunctor::Pointer m_LabelFunctor;
+    TInputValue m_InputInsideValue;
   };
 
 } // ecapseman