]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/RegionGrow.h
...
[FrontAlgorithms.git] / lib / fpa / Image / RegionGrow.h
index d65fa6cbbe815e9a3b3c21a290cc18357cec4421..2deff2f637de9001588b0ddbd8bdf1e261188ee1 100644 (file)
@@ -1,10 +1,14 @@
-#ifndef __FPA__IMAGE__REGIONGROW__H__
-#define __FPA__IMAGE__REGIONGROW__H__
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Image__RegionGrow__h__
+#define __fpa__Image__RegionGrow__h__
 
-#include <itkImageFunction.h>
-#include <itkImageToImageFilter.h>
-#include <itkIndex.h>
 #include <fpa/Base/RegionGrow.h>
+#include <fpa/Base/MarksInterfaceWithCollisions.h>
+#include <fpa/Base/SeedsInterface.h>
 #include <fpa/Image/Algorithm.h>
 
 namespace fpa
@@ -12,72 +16,57 @@ namespace fpa
   namespace Image
   {
     /**
-     * @param I Input image type
      */
-    template< class I >
+    template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
     class RegionGrow
-      : public Algorithm< I, fpa::Base::RegionGrow< typename I::IndexType, typename I::PixelType, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, I > > >
+      : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > > >
     {
     public:
-      // Standard class typdedefs
-      typedef typename I::IndexType TVertex;
-      typedef typename I::PixelType TResult;
-      typedef typename I::PixelType TVertexValue;
-      typedef itk::ImageToImageFilter< I, I > TBaseFilter;
-      typedef fpa::Base::RegionGrow< TVertex, TResult, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm;
+      typedef _TInputImage  TInputImage;
+      typedef _TOutputImage TOutputImage;
+      typedef _TFrontId     TFrontId;
+
+      typedef typename TInputImage::IndexType        TVertex;
+      typedef typename TInputImage::PointType        TPoint;
+      typedef typename TVertex::LexicographicCompare TVertexCompare;
+      typedef typename TInputImage::PixelType        TInputValue;
+      typedef typename TOutputImage::PixelType       TOutputValue;
+
+      typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
+      typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
+      typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
 
-      typedef RegionGrow                      Self;
-      typedef Algorithm< I, TBaseAlgorithm >  Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
+      typedef RegionGrow                          Self;
+      typedef fpa::Base::RegionGrow< TAlgorithm > Superclass;
+      typedef itk::SmartPointer< Self >           Pointer;
+      typedef itk::SmartPointer< const Self >     ConstPointer;
 
-      typedef itk::ImageFunction< I, bool > TMembershipFunction;
+      typedef typename TSeedsInterface::TNode  TNode;
+      typedef typename TSeedsInterface::TNodes TNodes;
 
     public:
       itkNewMacro( Self );
-      itkTypeMacro( RegionGrow, fpaBaseRegionGrow );
-
-      itkGetObjectMacro( MembershipFunction, TMembershipFunction );
-      itkSetObjectMacro( MembershipFunction, TMembershipFunction );
+      itkTypeMacro( fpa::Image::RegionGrow, fpa::Base::RegionGrow );
 
     protected:
       RegionGrow( )
-        : Superclass( ),
-          m_MembershipFunction( NULL )
-        }
+        : Superclass( )
+        {
+        }
       virtual ~RegionGrow( )
-        { }
-
-      virtual bool _CheckMembership(
-        const typename Superclass::_TNode& n
-        ) const
         {
-          if( this->m_MembershipFunction.IsNotNull( ) )
-          {
-            if(
-              this->m_MembershipFunction->GetInputImage( ) !=
-              this->GetInput( )
-              )
-              this->m_MembershipFunction->SetInputImage( this->GetInput( ) );
-            return( this->m_MembershipFunction->EvaluateAtIndex( n.Vertex ) );
-          }
-          else
-            return( false );
         }
 
     private:
-      // Purposely not implemented
-      RegionGrow( const Self& );
-      void operator=( const Self& );
-
-    protected:
-      typename TMembershipFunction::Pointer m_MembershipFunction;
+      // Purposely not implemented.
+      RegionGrow( const Self& other );
+      Self& operator=( const Self& other );
     };
 
   } // ecapseman
 
 } // ecapseman
 
-#endif // __FPA__IMAGE__REGIONGROW__H__
+#endif // __fpa__Image__RegionGrow__h__
 
 // eof - $RCSfile$