]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Functors/Dijkstra/Image/Gaussian.h
...
[FrontAlgorithms.git] / lib / fpa / Functors / Dijkstra / Image / Gaussian.h
index e917e95bff25897eacb45e78019ca1b15a6628ae..2effb513f4f707236c3203be83514168b9700420 100644 (file)
@@ -38,14 +38,20 @@ namespace fpa
             fpa::Functors::VertexFunction
             );
 
-        itkGetConstMacro( Alpha, double );
-        itkSetMacro( Alpha, double );
+          itkGetConstMacro( Beta, TValue );
+          itkSetMacro( Beta, TValue );
 
-        itkGetConstMacro( Beta, double );
-        itkSetMacro( Beta, double );
+          itkGetConstMacro( Epsilon, TValue );
+          itkSetMacro( Epsilon, TValue );
+
+          itkBooleanMacro( TreatAsWeight );
+          itkGetConstMacro( TreatAsWeight, bool );
+          itkSetMacro( TreatAsWeight, bool );
 
         public:
-          virtual TValue Evaluate( const TVertex& v, const TVertex& p ) const override
+          virtual TValue Evaluate(
+            const TVertex& v, const TVertex& p
+            ) const override
             {
               const TImage* image =
                 dynamic_cast< const TImage* >(
@@ -53,11 +59,15 @@ namespace fpa
                   );
               if( image != NULL )
               {
-                double d = double( image->GetPixel( v ) );
-                d       -= double( image->GetPixel( p ) );
+                TValue d = TValue( image->GetPixel( v ) );
+                d       -= TValue( image->GetPixel( p ) );
                 d       /= this->m_Beta;
-                d = std::exp( d * d ) - double( 1 );
-                return( TValue( std::pow( d, this->m_Alpha ) ) );
+                d       *= d;
+                if( this->m_TreatAsWeight ) d = std::exp(  d );
+                else                        d = std::exp( -d );
+
+                if( d < this->m_Epsilon ) return( this->m_Epsilon );
+                else                      return( d );
               }
               else
                 return( TValue( -1 ) );
@@ -66,8 +76,9 @@ namespace fpa
         protected:
           Gaussian( )
             : Superclass( ),
-              m_Alpha( double( 1 ) ),
-              m_Beta( double( 1 ) )
+              m_Beta( TValue( 1 ) ),
+              m_Epsilon( TValue( 1e-5 ) ),
+              m_TreatAsWeight( true )
             {
             }
           virtual ~Gaussian( )
@@ -80,8 +91,9 @@ namespace fpa
           Self& operator=( const Self& other );
 
         protected:
-          double m_Alpha;
-          double m_Beta;
+          TValue m_Beta;
+          TValue m_Epsilon;
+          bool   m_TreatAsWeight;
         };
 
       } // ecapseman