DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BasicConvolutionWeights.h
1 
17 #pragma once
18 
31 #if defined(BasicConvolutionWeights_RECURSES)
32 #error Recursive header files inclusion detected in BasicConvolutionWeights.h
33 #else // defined(BasicConvolutionWeights_RECURSES)
34 
35 #define BasicConvolutionWeights_RECURSES
36 
37 #if !defined BasicConvolutionWeights_h
38 
39 #define BasicConvolutionWeights_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45  #include "DGtal/kernel/NumberTraits.h"
47 
48 namespace DGtal
49 {
50 
52  // template class ConstantConvolutionWeight
60  template <typename TDistance>
62  {
63  // ----------------------- Standard services ------------------------------
64  public:
65 
67  typedef TDistance Distance;
68 
69 
73  inline
74  double operator()(const Distance &/*aDisplacment*/) const
75  {
76  return 1.0;
77  }
78  };
79 
81  // template class ConstantConvolutionWeight
88  template <typename TDistance>
90  {
91  // ----------------------- Standard services ------------------------------
92  public:
93 
95  typedef TDistance Distance;
96 
102  GaussianConvolutionWeights(const double sigma): mySigma(sigma)
103  {
104  myCoef = 1.0/(mySigma * sqrt(2.0*M_PI));
105  myCoef2 = 1.0/(2.0*M_PI);
106  }
107 
115  inline
116  double operator()(const Distance &aDisplacment) const
117  {
118  return myCoef*exp(-NumberTraits<Distance>::castToDouble(aDisplacment)*
120  }
121 
123  double mySigma;
124 
126  double myCoef;
127  double myCoef2;
128  };
129 
130 
131 
132 
133 } // namespace DGtal
134 
136 
137 #endif // !defined BasicConvolutionWeights_h
138 
139 #undef BasicConvolutionWeights_RECURSES
140 #endif // else defined(BasicConvolutionWeights_RECURSES)