]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Functors/Dijkstra/Image/Gaussian.h
...
[FrontAlgorithms.git] / lib / fpa / Functors / Dijkstra / Image / Gaussian.h
diff --git a/lib/fpa/Functors/Dijkstra/Image/Gaussian.h b/lib/fpa/Functors/Dijkstra/Image/Gaussian.h
new file mode 100644 (file)
index 0000000..6cf78c5
--- /dev/null
@@ -0,0 +1,96 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Functors__Dijkstra__Image__Gaussian__h__
+#define __fpa__Functors__Dijkstra__Image__Gaussian__h__
+
+#include <cmath>
+#include <fpa/Functors/BaseVertexFunction.h>
+
+namespace fpa
+{
+  namespace Functors
+  {
+    namespace Dijkstra
+    {
+      namespace Image
+      {
+        /**
+         */
+        template< class _TImage, class _TValue >
+        class Gaussian
+          : public fpa::Functors::BaseVertexFunction< typename _TImage::IndexType, _TValue >
+        {
+        public:
+          typedef _TImage TImage;
+          typedef _TValue TValue;
+          typedef typename TImage::IndexType TVertex;
+          typedef fpa::Functors::BaseVertexFunction< TVertex, TValue >  Superclass;
+          typedef Gaussian                        Self;
+          typedef itk::SmartPointer< Self >       Pointer;
+          typedef itk::SmartPointer< const Self > ConstPointer;
+
+        public:
+          itkNewMacro( Self );
+          itkTypeMacro(
+            fpa::Functors::Dijkstra::Image::Gaussian,
+            fpa::Functors::BaseVertexFunction
+            );
+
+        itkGetConstMacro( Alpha, double );
+        itkSetMacro( Alpha, double );
+
+        itkGetConstMacro( Beta, double );
+        itkSetMacro( Beta, double );
+
+        public:
+          virtual TValue Evaluate( const TVertex& v, const TVertex& p ) const override
+            {
+              const TImage* image =
+                dynamic_cast< const TImage* >(
+                  this->m_DataObject.GetPointer( )
+                  );
+              if( image != NULL )
+              {
+                double d = double( image->GetPixel( v ) );
+                d       -= double( image->GetPixel( p ) );
+                d       /= this->m_Beta;
+                d = std::exp( d * d ) - double( 1 );
+                return( TValue( std::pow( d, this->m_Alpha ) ) );
+              }
+              else
+                return( TValue( -1 ) );
+            }
+
+        protected:
+          Gaussian( )
+            : Superclass( ),
+              m_Alpha( double( 1 ) ),
+              m_Beta( double( 1 ) )
+            {
+            }
+          virtual ~Gaussian( )
+            {
+            }
+
+        private:
+          // Purposely not implemented.
+          Gaussian( const Self& other );
+          Self& operator=( const Self& other );
+
+        protected:
+          double m_Alpha;
+          double m_Beta;
+        };
+
+      } // ecapseman
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Functors__Dijkstra__Gaussian__h__
+// eof - $RCSfile$