]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Functors/InvertCostFunction.h
...
[FrontAlgorithms.git] / lib / fpa / Base / Functors / InvertCostFunction.h
1 #ifndef __FPA__BASE__FUNCTORS__INVERTCOSTFUNCTION__H__
2 #define __FPA__BASE__FUNCTORS__INVERTCOSTFUNCTION__H__
3
4 #include <cmath>
5 #include <itkFunctionBase.h>
6
7 namespace fpa
8 {
9   namespace Base
10   {
11     namespace Functors
12     {
13       /**
14        */
15       template< class C >
16       class InvertCostFunction
17         : public itk::FunctionBase< C, C >
18       {
19       public:
20         /// Type-related and pointers
21         typedef InvertCostFunction              Self;
22         typedef itk::FunctionBase< C, C >       Superclass;
23         typedef itk::SmartPointer< Self >       Pointer;
24         typedef itk::SmartPointer< const Self > ConstPointer;
25
26       public:
27         itkNewMacro( Self );
28         itkTypeMacro( InvertCostFunction, itkFunctionBase );
29
30         itkGetConstMacro( Alpha, C );
31         itkGetConstMacro( Beta, C );
32
33         itkSetMacro( Alpha, C );
34         itkSetMacro( Beta, C );
35
36       public:
37         virtual C Evaluate( const C& input ) const
38           {
39             C a = std::pow( input, this->m_Alpha );
40             if( input >= C( 0 ) )
41               return( std::pow( C( 1 ) / ( C( 1 ) + a ), this->m_Beta ) );
42             else
43               return( std::pow( C( -1 ) / ( C( 1 ) - a ), this->m_Beta ) );
44           }
45
46       protected:
47         InvertCostFunction( )
48           : Superclass( ),
49             m_Alpha( C( 1 ) ),
50             m_Beta( C( 1 ) )
51           { }
52         virtual ~InvertCostFunction( )
53           { }
54
55       private:
56         // Purposely not implemented
57         InvertCostFunction( const Self& );
58         void operator=( const Self& );
59
60       protected:
61         C m_Alpha;
62         C m_Beta;
63       };
64
65     } // ecapseman
66
67   } // ecapseman
68
69 } // ecapseman
70
71 #endif // __FPA__BASE__FUNCTORS__INVERTCOSTFUNCTION__H__
72
73 // eof - $RCSfile$