]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Algorithm.h
Segmentation guided by a gaussian estimator added -- Not yet finished
[FrontAlgorithms.git] / lib / fpa / Image / Algorithm.h
index 289eb6c0e7da7dad12899fcf8c929b3b0e58d5f1..e23a1084c3a585826adb7f9e54ac44bf233f6767 100644 (file)
@@ -8,13 +8,85 @@ namespace fpa
 {
   namespace Image
   {
+    namespace Functors
+    {
+      /**
+       */
+      template< class VV, class C >
+      class CastVertexValueToCost
+        : public itk::FunctionBase< VV, C >
+      {
+      public:
+        // Type-related and pointers
+        typedef CastVertexValueToCost           Self;
+        typedef itk::FunctionBase< VV, C >      Superclass;
+        typedef itk::SmartPointer< Self >       Pointer;
+        typedef itk::SmartPointer< const Self > ConstPointer;
+
+      public:
+        itkNewMacro( Self );
+        itkTypeMacro( CastVertexValueToCost, itkFunctionBase );
+
+      public:
+        virtual C Evaluate( const VV& v ) const
+          { return( C( v ) ); }
+
+      protected:
+        CastVertexValueToCost( )
+          : Superclass( )
+          { }
+        virtual ~CastVertexValueToCost( )
+          { }
+
+      private:
+        // Purposely not implemented
+        CastVertexValueToCost( const Self& );
+        void operator=( const Self& );
+      };
+
+      /**
+       */
+      template< class VV, class C >
+      class CastVertexValueToConstantCost
+        : public itk::FunctionBase< VV, C >
+      {
+      public:
+        // Type-related and pointers
+        typedef CastVertexValueToConstantCost   Self;
+        typedef itk::FunctionBase< VV, C >      Superclass;
+        typedef itk::SmartPointer< Self >       Pointer;
+        typedef itk::SmartPointer< const Self > ConstPointer;
+
+      public:
+        itkNewMacro( Self );
+        itkTypeMacro( CastVertexValueToConstantCost, itkFunctionBase );
+
+      public:
+        virtual C Evaluate( const VV& v ) const
+          { return( C( 1 ) ); }
+
+      protected:
+        CastVertexValueToConstantCost( )
+          : Superclass( )
+          { }
+        virtual ~CastVertexValueToConstantCost( )
+          { }
+
+      private:
+        // Purposely not implemented
+        CastVertexValueToConstantCost( const Self& );
+        void operator=( const Self& );
+      };
+
+    } // ecapseman
+
     /**
      * A generic front propagation algorithm were vertices are image pixels.
      *
      * @param I    Input image type
      * @param A    Base algorithm (RegionGrow, Dijkstra or FastMarching)
      */
-    template< class I, class A >
+    template< class I, class A, class CC >
     class Algorithm
       : public A
     {
@@ -26,8 +98,9 @@ namespace fpa
       typedef itk::SmartPointer< const Self > ConstPointer;
 
       /// Template input values
-      typedef I TInputImage;
-      typedef A TBaseAlgorithm;
+      typedef I  TInputImage;
+      typedef A  TBaseAlgorithm;
+      typedef CC TCostConversionFunction;
 
       typedef typename A::TTraits            TTraits;
       typedef typename TTraits::TCost        TCost;
@@ -36,7 +109,6 @@ namespace fpa
       typedef typename TTraits::TVertexValue TVertexValue;
 
       typedef itk::Image< TResult, I::ImageDimension > TOutputImage;
-      typedef itk::FunctionBase< TCost, TCost > TCostConversionFunction;
 
     protected:
       typedef typename TTraits::TFrontId _TFrontId;