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