]> Creatis software - FrontAlgorithms.git/blobdiff - appli/CTBronchi/MoriLabelling.h
...
[FrontAlgorithms.git] / appli / CTBronchi / MoriLabelling.h
index 105c7d024aa53341795c5d6c8a32041098809004..127ec0fd8c500b7b171930ae38418ee5329fc88b 100644 (file)
@@ -6,43 +6,44 @@
 #ifndef __CTBronchi__MoriLabelling__h__
 #define __CTBronchi__MoriLabelling__h__
 
-#include <itkImageToImageFilter.h>
+#include <fpa/Base/RegionGrow.h>
+#include <fpa/Base/MarksInterface.h>
+#include <fpa/Base/Functors/RegionGrow/BinaryThreshold.h>
+#include <fpa/Image/Algorithm.h>
+#include <fpa/Image/DefaultTraits.h>
+#include <fpa/Image/LabelledSeedsInterface.h>
 
 namespace CTBronchi
 {
   /**
    */
-  template< class _TInputImage, class _TLabelImage >
+  template< class _TInputImage, class _TLabelImage, class _TTraits = fpa::Image::DefaultTraits< _TInputImage, _TLabelImage, typename _TLabelImage::PixelType > >
   class MoriLabelling
-    : public itk::ImageToImageFilter< _TLabelImage, _TLabelImage >
+    : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TTraits, fpa::Base::MarksInterface< _TTraits >, fpa::Image::LabelledSeedsInterface< _TTraits > > >
   {
   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 _TTraits     TTraits;
+    fpa_Base_TraitTypes( typename TTraits );
 
-  public:
-    itkNewMacro( Self );
-    itkTypeMacro( MoriLabelling, itk::ImageToImageFilter );
+    typedef fpa::Base::MarksInterface< TTraits > TMarksInterface;
+    typedef fpa::Image::LabelledSeedsInterface< TTraits > TSeedsInterface;
+    typedef fpa::Image::Algorithm< TTraits, 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 fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TThresholdFunction;
 
-    itkGetConstMacro( InsideLabel, TLabel );
-    itkSetMacro( InsideLabel, TLabel );
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro( MoriLabelling, fpa::Base::RegionGrow );
 
-    itkGetConstMacro( OutsideLabel, TLabel );
-    itkSetMacro( OutsideLabel, TLabel );
+    itkGetConstMacro( InsideLabel, TOutputValue );
+    itkSetMacro( InsideLabel, TOutputValue );
 
   public:
     const TLabelImage* GetInputLabelImage( ) const;
@@ -51,11 +52,18 @@ namespace CTBronchi
     const TInputImage* GetInputRawImage( ) const;
     void SetInputRawImage( TInputImage* image );
 
+    TInputValue GetUpperThreshold( ) const;
+    void SetUpperThreshold( TInputValue t );
+
+    TOutputValue GetOutsideValue( ) const;
+    void SetOutsideLabel( TOutputValue o );
+
   protected:
     MoriLabelling( );
     virtual ~MoriLabelling( );
 
-    virtual void ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) override;
+    virtual TNodes _UnifySeeds( ) override;
+    virtual void _UpdateOutputValue( TNode& n ) override;
 
   private:
     // Purposely not implemented.
@@ -63,10 +71,7 @@ namespace CTBronchi
     Self& operator=( const Self& other );
 
   protected:
-    TPixel m_UpperThreshold;
-    TLabel m_InsideValue;
-    TLabel m_InsideLabel;
-    TLabel m_OutsideLabel;
+    TOutputValue m_InsideLabel;
   };
 
 } // ecapseman