]> Creatis software - FrontAlgorithms.git/blobdiff - appli/CTBronchi/MoriLabelling.h
...
[FrontAlgorithms.git] / appli / CTBronchi / MoriLabelling.h
index 0a9c58609735f86daea46fd91cb60c9ef4518333..b5993105a70bf691cbae243d109f84b7272896c7 100644 (file)
@@ -2,81 +2,84 @@
 // @author Leonardo Florez Valencia
 // @email florez-l@javeriana.edu.co
 // =========================================================================
-
 #ifndef __CTBronchi__MoriLabelling__h__
 #define __CTBronchi__MoriLabelling__h__
 
-/* TODO
-   #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>
-*/
+#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
 {
   /**
    */
-  /* TODO
-     template< class _TInputImage, class _TLabelImage, class _TTraits = fpa::Image::DefaultTraits< _TInputImage, _TLabelImage, typename _TLabelImage::PixelType > >
-     class MoriLabelling
-     : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TTraits, fpa::Base::MarksInterface< _TTraits >, fpa::Image::LabelledSeedsInterface< _TTraits > > >
-     {
-     public:
-     typedef _TInputImage TInputImage;
-     typedef _TLabelImage TLabelImage;
-     typedef _TTraits     TTraits;
-     fpa_Base_TraitTypes( typename TTraits );
-
-     typedef fpa::Base::MarksInterface< TTraits > TMarksInterface;
-     typedef fpa::Image::LabelledSeedsInterface< TTraits > TSeedsInterface;
-     typedef fpa::Image::Algorithm< TTraits, TMarksInterface, TSeedsInterface > TAlgorithm;
-
-     typedef MoriLabelling                       Self;
-     typedef fpa::Base::RegionGrow< TAlgorithm > Superclass;
-     typedef itk::SmartPointer< Self >           Pointer;
-     typedef itk::SmartPointer< const Self >     ConstPointer;
-
-     typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TThresholdFunction;
-
-     public:
-     itkNewMacro( Self );
-     itkTypeMacro( MoriLabelling, fpa::Base::RegionGrow );
-
-     itkGetConstMacro( InsideLabel, TOutputValue );
-     itkSetMacro( InsideLabel, TOutputValue );
-
-     public:
-     const TLabelImage* GetInputLabelImage( ) const;
-     void SetInputLabelImage( TLabelImage* image );
-
-     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 TNodes _UnifySeeds( ) override;
-     virtual void _UpdateOutputValue( TNode& n ) override;
-
-     private:
-     // Purposely not implemented.
-     MoriLabelling( const Self& other );
-     Self& operator=( const Self& other );
-
-     protected:
-     TOutputValue m_InsideLabel;
-     };
-  */
+  template< class _TInputImage, class _TLabelImage >
+  class MoriLabellingTraits
+    : public fpa::Filters::Image::DefaultTraits< _TInputImage, _TLabelImage, typename _TLabelImage::PixelType >
+  {
+  public:
+    typedef _TInputImage TInputImage;
+    typedef _TLabelImage TLabelImage;
+    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:
+    typedef _TInputImage TInputImage;
+    typedef _TLabelImage TLabelImage;
+    typedef CTBronchi::MoriLabellingTraits< TInputImage, TLabelImage > TTraits;
+    fpaTraitsMacro( typename TTraits );
+
+    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;
+
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro( CTBronchi::MoriLabelling, fpa::Filters::Image::RegionGrow );
+
+    itkGetConstMacro( LastThreshold, TInputValue );
+    itkSetMacro( LastThreshold, TInputValue );
+
+    fpaFilterInputMacro( InputLabels, TLabelImage );
+
+  public:
+    TInputValue GetUpperThreshold( ) const;
+    void SetUpperThreshold( TInputValue t );
+
+  protected:
+    MoriLabelling( );
+    virtual ~MoriLabelling( );
+
+    virtual const itk::DataObject* _GetReferenceInput( ) const override;
+    virtual void _PostComputeOutputValue( TNode& n ) override;
+
+  private:
+    // Purposely not implemented.
+    MoriLabelling( const Self& other );
+    Self& operator=( const Self& other );
+
+  protected:
+    typename TFunctor::Pointer m_Functor;
+    TInputValue m_LastThreshold;
+  };
 
 } // ecapseman