]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Functors/GaussianWeight.h
3b2212a75ce15ab2005a04f50956ae3c44ba2b67
[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         itkGetConstMacro( Beta, double );
42         itkSetMacro( Beta, double );
43
44       public:
45         virtual TOutputValue Evaluate(
46           const TVertex& a, const TVertex& p
47           ) const override
48           {
49             double va = double( this->m_Image->GetPixel( a ) );
50             double vp = double( this->m_Image->GetPixel( p ) );
51             double d = va - vp;
52             return( TOutputValue( std::exp( -d * d * this->m_Beta ) ) );
53           }
54
55       protected:
56         GaussianWeight( )
57           : Superclass( ),
58             m_Beta( double( 1 ) )
59           { }
60         virtual ~GaussianWeight( ) { }
61
62       private:
63         GaussianWeight( const Self& other );
64         Self& operator=( const Self& other );
65
66       protected:
67         double m_Beta;
68       };
69
70     } // ecapseman
71
72   } // ecapseman
73
74 } // ecapseman
75
76 #endif // __fpa__Image__Functors__GaussianWeight__h__
77
78 // eof - $RCSfile$