]> Creatis software - FrontAlgorithms.git/blobdiff - appli/CTBronchi/MoriLabelling.h
...
[FrontAlgorithms.git] / appli / CTBronchi / MoriLabelling.h
index 105c7d024aa53341795c5d6c8a32041098809004..b5993105a70bf691cbae243d109f84b7272896c7 100644 (file)
@@ -2,60 +2,74 @@
 // @author Leonardo Florez Valencia
 // @email florez-l@javeriana.edu.co
 // =========================================================================
-
 #ifndef __CTBronchi__MoriLabelling__h__
 #define __CTBronchi__MoriLabelling__h__
 
-#include <itkImageToImageFilter.h>
+#include <map>
+#include <fpa/Filters/BaseMarksInterface.h>
+#include <fpa/Filters/Image/SeedsFromLabelsInterface.h>
+#include <fpa/Filters/Image/DefaultTraits.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 typename TLabelImage::PixelType TLabel;
+    typedef fpa::Filters::Image::DefaultTraits< TInputImage, TLabelImage, TLabel > Superclass;
+    typedef typename Superclass::TInternalTraits  TInternalTraits;
+    typedef typename Superclass::TMarksImage      TMarksImage;
+    typedef typename Superclass::TFilterInterface TFilterInterface;
+
+    typedef fpa::Filters::BaseMarksInterface< TInternalTraits >  TMarksInterface;
+    typedef fpa::Filters::Image::SeedsFromLabelsInterface< TInternalTraits > TSeedsInterface;
+  };
 
+  /**
+   */
+  template< class _TInputImage, class _TLabelImage >
+  class MoriLabelling
+    : public fpa::Filters::Image::RegionGrow< _TInputImage, _TLabelImage, typename _TLabelImage::PixelType, CTBronchi::MoriLabellingTraits< _TInputImage, _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::Image::RegionGrow< TInputImage, TLabelImage, TMark, TTraits > Superclass;
+    typedef MoriLabelling                   Self;
+    typedef itk::SmartPointer< Self >       Pointer;
+    typedef itk::SmartPointer< const Self > ConstPointer;
+    typedef fpa::Functors::RegionGrow::BinaryThreshold< TInputValue > TFunctor;
 
-    itkGetConstMacro( InsideValue, TLabel );
-    itkSetMacro( InsideValue, TLabel );
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro( CTBronchi::MoriLabelling, fpa::Filters::Image::RegionGrow );
 
-    itkGetConstMacro( InsideLabel, TLabel );
-    itkSetMacro( InsideLabel, TLabel );
+    itkGetConstMacro( LastThreshold, TInputValue );
+    itkSetMacro( LastThreshold, TInputValue );
 
-    itkGetConstMacro( OutsideLabel, TLabel );
-    itkSetMacro( OutsideLabel, TLabel );
+    fpaFilterInputMacro( InputLabels, TLabelImage );
 
   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 ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) override;
+    virtual const itk::DataObject* _GetReferenceInput( ) const override;
+    virtual void _PostComputeOutputValue( TNode& n ) override;
 
   private:
     // Purposely not implemented.
@@ -63,10 +77,8 @@ 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;
+    TInputValue m_LastThreshold;
   };
 
 } // ecapseman