PICCANTE  0.4
The hottest HDR imaging library!
precomputed_diff_of_gaussians.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_UTIL_PRECOMPUTED_DIFF_OF_GAUSSIANS_HPP
19 #define PIC_UTIL_PRECOMPUTED_DIFF_OF_GAUSSIANS_HPP
20 
21 #include "../util/precomputed_gaussian.hpp"
22 
23 namespace pic {
24 
29 {
30 protected:
35  {
37  kernelSize = (halfKernelSize << 1) + 1;
38  coeff = new float[kernelSize];
39 
40  float sigma1_sq = sigma1 * sigma1;
41  float sigma1_sq_2 = sigma1_sq * 2.0f;
42 
43  float sigma2_sq = sigma2 * sigma2;
44  float sigma2_sq_2 = sigma2_sq * 2.0f;
45 
46  float C1 = sigma1 * sqrtf(2.0f * C_PI);
47  float C2 = sigma2 * sqrtf(2.0f * C_PI);
48 
49  for(int i = 0; i < kernelSize; i++) {
50  int i_s = i - halfKernelSize;
51  float i_sq_f = -float(i_s * i_s);
52 
53  float G1 = expf(i_sq_f / sigma1_sq_2) / C1;
54  float G2 = expf(i_sq_f / sigma2_sq_2) / C2;
55 
56  coeff[i] = G1 - G2;
57  }
58  }
59 
60 public:
61  float sigma1, sigma2;
63  float *coeff;
64 
69  {
71  sigma1 = 0.0f;
72  sigma2 = 0.0f;
73  coeff = NULL;
74  }
75 
82  {
83 
85  }
86 
88  {
89  if(coeff != NULL) {
90  delete[] coeff;
91  }
92 
93  coeff = NULL;
94  }
95 
100  void calculateKernel(float sigma1, float sigma2)
101  {
102  this->sigma1 = sigma1;
103  this->sigma2 = sigma2;
104 
105  //compute the sigma for the size of the kernel
107 
108  //precompute Gaussian coefficients
110  }
111 };
112 
113 } // end namespace pic
114 
115 #endif /* PIC_UTIL_PRECOMPUTED_DIFF_OF_GAUSSIANS_HPP */
116 
void calculateKernel(float sigma1, float sigma2)
calculateKernel computes a Gaussian kernel of size sigma
Definition: precomputed_diff_of_gaussians.hpp:100
static int getKernelSize(float sigma)
KernelSize computes the size of a kernel in pixel give its sigma.
Definition: precomputed_gaussian.hpp:121
PrecomputedDiffOfGaussians(float sigma1, float sigma2)
PrecomputedDiffOfGaussians.
Definition: precomputed_diff_of_gaussians.hpp:81
float * coeff
Definition: precomputed_diff_of_gaussians.hpp:63
const float C_PI
Definition: math.hpp:50
void precomputeCoefficients()
precomputeCoefficients precomputes a Gaussian kernel.
Definition: precomputed_diff_of_gaussians.hpp:34
int halfKernelSize
Definition: precomputed_diff_of_gaussians.hpp:62
~PrecomputedDiffOfGaussians()
Definition: precomputed_diff_of_gaussians.hpp:87
int kernelSize
Definition: precomputed_diff_of_gaussians.hpp:62
float sigma1
Definition: precomputed_diff_of_gaussians.hpp:61
float sigma2
Definition: precomputed_diff_of_gaussians.hpp:61
Definition: bilateral_separation.hpp:25
#define MAX(a, b)
Definition: math.hpp:73
The PrecomputedDiffOfGaussians class.
Definition: precomputed_diff_of_gaussians.hpp:28
PrecomputedDiffOfGaussians()
PrecomputedDiffOfGaussians.
Definition: precomputed_diff_of_gaussians.hpp:68