iRoCS Toolbox  1.1.0
ATBDataSynthesis.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2015 Thorsten Falk
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 #ifndef ATBDATASYNTHESIS_HH
24 #define ATBDATASYNTHESIS_HH
25 
26 #include "Array.hh"
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.hh>
30 #endif
31 
32 #include <cmath>
33 
34 namespace atb
35 {
36 
37  const int DEFAULT = 0x00000000;
38  const int NORMALIZE = 0x00000001;
39  const int NORESIZE = 0x00000002;
40  const int FORCESAMPLING = 0x00000004;
41 
43 
44 /*======================================================================*/
65 /*======================================================================*/
66  double erfbase(const double x, ErrorFunctionType type = Erf);
67 
68 /*======================================================================*/
83 /*======================================================================*/
84  inline double gaussian(double x, double mu, double sigma)
85  {
86  if (sigma == 0.0) return (x == mu) ? 1.0 : 0.0;
87  return std::exp(-0.5 * (x - mu) * (x - mu) / (sigma * sigma)) /
88  (std::sqrt(2.0 * M_PI) * sigma);
89  }
90 
91 /*======================================================================*/
110 /*======================================================================*/
111  inline double normalizedHermitePolynomial(double x, double sigma, int d)
112  {
113  if (d < 0) return 0.0;
114  if (d == 0) return 1.0;
115  if (d == 1) return 1.0 / (sigma * sigma) * x;
116  return (x * normalizedHermitePolynomial(x, sigma, d - 1) -
117  (d - 1) * normalizedHermitePolynomial(x, sigma, d - 2)) /
118  (sigma * sigma);
119  }
120 
121 /*======================================================================*/
140 /*======================================================================*/
141  inline double gaussianDerivative(double x, double mu, double sigma, int d)
142  {
143  return ((d % 2 == 0) ? 1.0 : -1.0) *
144  normalizedHermitePolynomial(x - mu, sigma, d) * gaussian(x, mu, sigma);
145  }
146 
147 /*======================================================================*/
171 /*======================================================================*/
172  template<typename DataT, int Dim>
173  void gaussian(blitz::Array<DataT,Dim>& gauss,
174  blitz::TinyVector<double,Dim> const &sigmaUm,
175  blitz::TinyVector<double,Dim> const &elementSizeUm,
176  int flags = DEFAULT);
177 
178 /*======================================================================*/
199 /*======================================================================*/
200  template<typename DataT, int Dim>
201  void gaussian(Array<DataT,Dim>& gauss,
202  blitz::TinyVector<double,Dim> const &sigmaUm,
203  int flags = DEFAULT);
204 
205 /*======================================================================*/
233 /*======================================================================*/
234  template<typename DataT, int Dim>
235  void gaussianDerivative(blitz::Array<DataT,Dim>& gauss,
236  blitz::TinyVector<double,Dim> const &sigmaUm,
237  blitz::TinyVector<double,Dim> const &elementSizeUm,
238  blitz::TinyVector<int,Dim> const &d,
239  int flags = DEFAULT);
240 
241 /*======================================================================*/
266 /*======================================================================*/
267  template<typename DataT, int Dim>
269  blitz::TinyVector<double,Dim> const &sigmaUm,
270  blitz::TinyVector<int,Dim> const &d,
271  int flags = DEFAULT);
272 
273 }
274 
275 #include "ATBDataSynthesis.icc"
276 
277 #endif
Array class derived from blitz++ Arrays for handling microscopic datasets with associated element siz...
double normalizedHermitePolynomial(double x, double sigma, int d)
Evaluate the normalized Hermite polynomial at position x.
The Array class is an extension to the blitz++ Array class providing additional parameters element si...
Definition: Array.hh:85
const int DEFAULT
double erfbase(const double x, ErrorFunctionType type=Erf)
General evaluation of erf, erfc and erfcx, where erf is the error function given as: ...
const int FORCESAMPLING
double gaussianDerivative(double x, double mu, double sigma, int d)
Evaluate the Gaussian derivative of degree d with mean mu and standard deviation sigma at position x...
double gaussian(double x, double mu, double sigma)
Evaluate the Gaussian distribution with mean mu and standard deviation sigma at position x...
const int NORESIZE
const int NORMALIZE