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