]> Creatis software - FrontAlgorithms.git/blob - libs/fpa/Base/Functors/InvertValue.h
...
[FrontAlgorithms.git] / libs / fpa / Base / Functors / InvertValue.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__Functors__InvertValue__h__
7 #define __fpa__Base__Functors__InvertValue__h__
8
9 #include <cmath>
10 #include <itkFunctionBase.h>
11
12 namespace fpa
13 {
14   namespace Base
15   {
16     namespace Functors
17     {
18       /**
19        */
20       template< class _TInputValue, class _TOutputValue >
21       class InvertValue
22         : public itk::FunctionBase< _TInputValue, _TOutputValue >
23       {
24       public:
25         typedef InvertValue                                      Self;
26         typedef itk::FunctionBase< _TInputValue, _TOutputValue > Superclass;
27         typedef itk::SmartPointer< Self >                        Pointer;
28         typedef itk::SmartPointer< const Self >                  ConstPointer;
29
30         typedef _TInputValue  TInputValue;
31         typedef _TOutputValue TOutputValue;
32
33       public:
34         itkNewMacro( Self );
35         itkTypeMacro( InvertValue, itk::FunctionBase );
36
37         itkGetConstMacro( Alpha, double );
38         itkGetConstMacro( Beta, double );
39         itkSetMacro( Alpha, double );
40         itkSetMacro( Beta, double );
41
42       public:
43         virtual TOutputValue Evaluate( const TInputValue& a ) const override
44           {
45             double d = this->m_Alpha;
46             d += std::pow( double( a ), this->m_Beta );
47             double x = -1;
48             if( std::fabs( d ) > double( 0 ) )
49               x =
50                 double( 1 ) /
51                 ( this->m_Alpha + std::pow( double( a ), this->m_Beta ) );
52             return( TOutputValue( x ) );
53           }
54
55       protected:
56         InvertValue( )
57           : Superclass( ),
58             m_Alpha( double( 1 ) ),
59             m_Beta( double( 1 ) )
60           { }
61         virtual ~InvertValue( ) { }
62
63       private:
64         InvertValue( const Self& other );
65         Self& operator=( const Self& other );
66
67       protected:
68         double m_Alpha;
69         double m_Beta;
70       };
71
72     } // ecapseman
73
74   } // ecapseman
75
76 } // ecapseman
77
78 #endif // __fpa__Base__Functors__InvertValue__h__
79
80 // eof - $RCSfile$