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