]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/Dijkstra/Gaussian.h
d06d84d3084ed8b0c012bf1f1d2a97b42e59ea18
[FrontAlgorithms.git] / lib / fpa / Image / Functors / Dijkstra / Gaussian.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Image__Functors__Dijkstra__Gaussian__h__
7 #define __fpa__Image__Functors__Dijkstra__Gaussian__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          * w_{i,j}=\left(\exp\left(\left(\frac{w_{i}-w_{j}}{\beta}\right)^{2}\right)-1\right)^{\alpha}
22          */
23         template< class _TInputImage, class _TOutputValue >
24         class Gaussian
25           : public fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue >
26         {
27         public:
28           typedef Gaussian Self;
29           typedef fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue > Superclass;
30           typedef itk::SmartPointer< Self >       Pointer;
31           typedef itk::SmartPointer< const Self > ConstPointer;
32
33           typedef typename Superclass::TVertex TVertex;
34
35         public:
36           itkNewMacro( Self );
37           itkTypeMacro(
38             fpa::Image::Functors::Dijkstra::Gaussian,
39             fpa::Image::Functors::Dijkstra::Function
40             );
41
42           itkGetConstMacro( Alpha, double );
43           itkSetMacro( Alpha, double );
44
45           itkGetConstMacro( Beta, double );
46           itkSetMacro( Beta, double );
47
48         public:
49           virtual _TOutputValue Evaluate(
50             const TVertex& v, const TVertex& p
51             ) const override
52             {
53               double d = double( this->m_Image->GetPixel( v ) );
54               d       -= double( this->m_Image->GetPixel( p ) );
55               d       /= this->m_Beta;
56               d = std::exp( d * d ) - double( 1 );
57               return( _TOutputValue( std::pow( d, this->m_Alpha ) ) );
58             }
59
60         protected:
61           Gaussian( )
62             : Superclass( ),
63               m_Alpha( double( 1 ) ),
64               m_Beta( double( 1 ) )
65             {
66             }
67           virtual ~Gaussian( )
68             {
69             }
70
71         private:
72           // Purposely not implemented
73           Gaussian( const Self& other );
74           Self& operator=( const Self& other );
75
76         protected:
77           double m_Alpha;
78           double m_Beta;
79         };
80
81       } // ecapseman
82
83     } // ecapseman
84
85   } // ecapseman
86
87 } // ecapseman
88
89 #endif // __fpa__Image__Functors__Dijkstra__Gaussian__h__
90
91 // eof - $RCSfile$