]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/Functors/InvertCostFunction.h
...
[FrontAlgorithms.git] / lib / fpa / Base / Functors / InvertCostFunction.h
index 06315c7cafd4ad64c4aef0c50035dd2399df1f6d..d1e21f4b1cf979ce91b601f6fd1e8411e6f94271 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __FPA__BASE__FUNCTORS__INVERTCOSTFUNCTION__H__
 #define __FPA__BASE__FUNCTORS__INVERTCOSTFUNCTION__H__
 
+#include <cmath>
 #include <itkFunctionBase.h>
 
 namespace fpa
@@ -26,18 +27,27 @@ namespace fpa
         itkNewMacro( Self );
         itkTypeMacro( InvertCostFunction, itkFunctionBase );
 
+        itkGetConstMacro( Alpha, C );
+        itkGetConstMacro( Beta, C );
+
+        itkSetMacro( Alpha, C );
+        itkSetMacro( Beta, C );
+
       public:
         virtual C Evaluate( const C& input ) const
           {
-            if( input < C( 0 ) )
-              return( C( -1 ) / ( C( 1 ) - C( input ) ) );
+            C a = std::pow( input, this->m_Alpha );
+            if( input >= C( 0 ) )
+              return( std::pow( C( 1 ) / ( C( 1 ) + a ), this->m_Beta ) );
             else
-              return( C( 1 ) / ( C( 1 ) + C( input ) ) );
+              return( std::pow( C( -1 ) / ( C( 1 ) - a ), this->m_Beta ) );
           }
 
       protected:
         InvertCostFunction( )
-          : Superclass( )
+          : Superclass( ),
+            m_Alpha( C( 1 ) ),
+            m_Beta( C( 1 ) )
           { }
         virtual ~InvertCostFunction( )
           { }
@@ -46,6 +56,10 @@ namespace fpa
         // Purposely not implemented
         InvertCostFunction( const Self& );
         void operator=( const Self& );
+
+      protected:
+        C m_Alpha;
+        C m_Beta;
       };
 
     } // ecapseman