]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/MoriRegionGrow.h
...
[FrontAlgorithms.git] / lib / fpa / Image / MoriRegionGrow.h
index 7a509ec9ac9339fb27f1f44d52aef2cc247a4b52..41c122e32d9caf0c5d5cc89cdcb0e493ff23fb12 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef __fpa__Image__MoriRegionGrow__h__
 #define __fpa__Image__MoriRegionGrow__h__
 
-#include <fpa/Image/RegionGrow.h>
-#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
+#include <itkImageToImageFilter.h>
+#include <itkBinaryThresholdImageFilter.h>
+#include <fpa/Image/MoriRegionGrowHelper.h>
 
 namespace fpa
 {
@@ -10,53 +11,64 @@ namespace fpa
   {
     /**
      */
-    template< class _TInputImage, class _TOutputImage >
+    template< class _TInputImage, class _TOutputImage, class _TAuxPixel = unsigned short >
     class MoriRegionGrow
-      : public fpa::Image::RegionGrow< _TInputImage, _TOutputImage >
+      : public itk::ImageToImageFilter< _TInputImage, _TOutputImage >
     {
     public:
-      typedef MoriRegionGrow                                        Self;
-      typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > Superclass;
-      typedef itk::SmartPointer< Self >                             Pointer;
-      typedef itk::SmartPointer< const Self >                       ConstPointer;
-
-      typedef typename Superclass::TOutput       TOutput;
-      typedef typename Superclass::TVertex       TVertex;
-      typedef typename Superclass::TGrowFunction TGrowFunction;
-      typedef
-      fpa::Image::Functors::RegionGrow::BinaryThreshold< _TInputImage >
-      TBinThresholdFunction;
-      typedef typename _TInputImage::PixelType TPixel;
+      typedef MoriRegionGrow                                         Self;
+      typedef itk::ImageToImageFilter< _TInputImage, _TOutputImage > Superclass;
+      typedef itk::SmartPointer< Self >                              Pointer;
+      typedef itk::SmartPointer< const Self >                        ConstPointer;
 
-    protected:
-      typedef typename Superclass::_TQueueNode _TQueueNode;
-      typedef typename Superclass::_TQueue     _TQueue;
+      typedef itk::Image< _TAuxPixel, _TInputImage::ImageDimension >      TAuxImage;
+      typedef fpa::Image::MoriRegionGrowHelper< _TInputImage, TAuxImage > THelper;
+      typedef itk::BinaryThresholdImageFilter< TAuxImage, _TOutputImage > TThreshold;
+
+      typedef typename _TInputImage::IndexType  TIndex;
+      typedef typename _TInputImage::PixelType  TInputPixel;
+      typedef typename _TOutputImage::PixelType TOutputPixel;
 
     public:
       itkNewMacro( Self );
-      itkTypeMacro( fpa::Image::MoriRegionGrow, fpa::Image::RegionGrow );
+      itkTypeMacro( fpa::Image::MoriRegionGrow, itk::ImageToImageFilter );
 
-      itkGetConstMacro( Lower, TPixel );
-      itkGetConstMacro( Upper, TPixel );
-      itkGetConstMacro( Step, TPixel );
-      itkGetConstMacro( Sensitivity, double );
+      itkGetConstMacro( Seed, TIndex );
+      itkSetMacro( Seed, TIndex );
 
-      itkSetMacro( Lower, TPixel );
-      itkSetMacro( Upper, TPixel );
-      itkSetMacro( Step, TPixel );
-      itkSetMacro( Sensitivity, double );
+    public:
+      TAuxImage* GetAuxiliaryImage( );
+      const TAuxImage* GetAuxiliaryImage( ) const;
+
+      TInputPixel GetLower( ) const;
+      TInputPixel GetUpper( ) const;
+      TInputPixel GetStep( ) const;
+      TOutputPixel GetInsideValue( ) const;
+      TOutputPixel GetOutsideValue( ) const;
+
+      void SetLower( const TInputPixel& v );
+      void SetUpper( const TInputPixel& v );
+      void SetStep( const TInputPixel& v );
+      void SetInsideValue( const TOutputPixel& v );
+      void SetOutsideValue( const TOutputPixel& v );
+
+
+      /* TODO
+         itkGetConstMacro( Lower, TPixel );
+         itkGetConstMacro( Upper, TPixel );
+         itkGetConstMacro( Step, TPixel );
+         itkGetConstMacro( Sensitivity, double );
+         itkSetMacro( Lower, TPixel );
+         itkSetMacro( Upper, TPixel );
+         itkSetMacro( Step, TPixel );
+         itkSetMacro( Sensitivity, double );
+      */
 
     protected:
       MoriRegionGrow( );
       virtual ~MoriRegionGrow( );
 
-      virtual bool _ContinueGenerateData( ) override;
-      virtual void _BeforeGenerateData( ) override;
-      virtual void _AfterGenerateData( ) override;
-      virtual void _BeforeLoop( ) override;
-      virtual void _AfterLoop( ) override;
-      virtual bool _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) override;
-      virtual void _UpdateResult( const _TQueueNode& n ) override;
+      virtual void GenerateData( ) override;
 
     private:
       // Purposely not defined
@@ -64,20 +76,9 @@ namespace fpa
       Self& operator=( const Self& other );
 
     protected:
-      TPixel m_Lower;
-      TPixel m_Upper;
-      TPixel m_Step;
-      double m_Sensitivity;
-
-      _TQueue m_NextQueue;
-      unsigned long m_ActualCount;
-      unsigned long m_PrevCount;
-
-      // Standard deviation
-      double m_N;
-      double m_S1;
-      double m_S2;
-      double m_STD;
+      typename THelper::Pointer m_Helper;
+      typename TThreshold::Pointer m_Threshold;
+      TIndex m_Seed;
     };
 
   } // ecapseman