]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/Dijkstra/Gaussian.h
5187312b0287008c67a3bae24e2383ea68d25463
[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          */
22         template< class _TInputImage, class _TOutputValue >
23         class Gaussian
24           : public fpa::Image::Functors::Dijkstra::Function< _TInputImage, _TOutputValue >
25         {
26         public:
27           typedef Gaussian 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::Gaussian,
38             fpa::Image::Functors::Dijkstra::Function
39             );
40
41         public:
42           double GetAlpha( ) const
43             {
44               return( double( 1 ) - this->m_Alpha );
45             }
46           double GetBeta( ) const
47             {
48               return( std::sqrt( this->m_Beta ) );
49             }
50           void SetAlpha( const double& v )
51             {
52               this->m_Alpha = double( 1 ) - v;
53               this->Modified( );
54             }
55           void SetBeta( const double& v )
56             {
57               this->m_Beta = v * v;
58               this->Modified( );
59             }
60
61           virtual _TOutputValue Evaluate(
62             const TVertex& v, const TVertex& p
63             ) const override
64             {
65               double d = double( this->m_Image->GetPixel( v ) );
66               d       -= double( this->m_Image->GetPixel( p ) );
67               d = ( d * d ) / this->m_Beta;
68               return(
69                 _TOutputValue( double( 1 ) - ( this->m_Alpha * std::exp( -d ) ) )
70                 );
71             }
72
73         protected:
74           Gaussian( )
75             : Superclass( ),
76               m_Alpha( double( 1 ) ),
77               m_Beta( double( 1 ) )
78             {
79             }
80           virtual ~Gaussian( )
81             {
82             }
83
84         private:
85           // Purposely not implemented
86           Gaussian( const Self& other );
87           Self& operator=( const Self& other );
88
89         protected:
90           double m_Alpha;
91           double m_Beta;
92         };
93
94       } // ecapseman
95
96     } // ecapseman
97
98   } // ecapseman
99
100 } // ecapseman
101
102 #endif // __fpa__Image__Functors__Dijkstra__Gaussian__h__
103
104 // eof - $RCSfile$