Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GenerateGauss.hh
1 /* This file is part of the BIAS library (Basic ImageAlgorithmS).
2 
3  Copyright (C) 2003-2009 (see file CONTACT for details)
4  Multimediale Systeme der Informationsverarbeitung
5  Institut fuer Informatik
6  Christian-Albrechts-Universitaet Kiel
7 
8 
9  BIAS is free software; you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation; either version 2.1 of the License, or
12  (at your option) any later version.
13 
14  BIAS is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with BIAS; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
22 #ifndef __GenerateGauss_hh__
23 #define __GenerateGauss_hh__
24 
25 #include <cmath>
26 
27 namespace BIAS {
28 
29  // forwrad declaration
30  template <class T> class Vector;
31  template <class T> class Matrix;
32 
33  /** @class GenerateGauss
34  @brief compute one and two dimensional gauss normal distribution
35  @author woelk 01/2008 (c) www.vision-n.de */
37  {
38  public:
39  template <class T>
40  static void Gauss1DSigma(const double &sigma, const double &ratio,
41  BIAS::Vector<T> &result,const bool normalize=true);
42 
43  template <class T>
44  static void Gauss1DSize(const unsigned size, const double &ratio,
45  BIAS::Vector<T> &result, double & sigma,
46  const bool normalize=true);
47 
48  template <class T>
49  static void Gauss1D(const unsigned size, const double &sigma,
50  BIAS::Vector<T> &result, const bool normalize = true);
51 
52  template <class T>
53  static void Gauss2DSigma(const double &sigma, const double &ratio,
54  BIAS::Matrix<T> &result,const bool normalize=true);
55 
56  template <class T>
57  static void Gauss2DSize(const unsigned size, const double &ratio,
58  BIAS::Matrix<T> &result, double &sigma,
59  const bool normalize=true);
60 
61  template <class T>
62  static void Gauss2D(const unsigned size, const double &sigma,
63  BIAS::Matrix<T> &result, const bool normalize = true);
64 
65  protected:
66  /// Given a sigma and fixed ratio between biggest and smallest entry
67  /// of the discrete gauss distribution, compute the required size of the
68  /// vector
69  inline static void Sigma2Size_(const double &sigma, const double &ratio,
70  unsigned &size)
71  { size = (unsigned)ceil(2.0*sqrt(-2.0*sigma*sigma*log(ratio))+1.0); }
72 
73  /// Given a size and fixed ratio between biggest and smallest entry
74  /// of the discrete gauss distribution, compute the required sigma of the
75  /// distribution
76  inline static void Size2Sigma_(const unsigned size, const double &ratio,
77  double &sigma)
78  { const double dx=(double)(size-1)*0.5; sigma=sqrt(-dx*dx*0.5/log(ratio)); }
79  }; //
80 
81 
82 
83 } // namespace
84 
85 
86 #endif // __GenerateGauss_hh__
class for column vectors with arbitrary size
static void Gauss1DSigma(const double &sigma, const double &ratio, BIAS::Vector< T > &result, const bool normalize=true)
compute one and two dimensional gauss normal distribution
static void Size2Sigma_(const unsigned size, const double &ratio, double &sigma)
Given a size and fixed ratio between biggest and smallest entry of the discrete gauss distribution...
static void Gauss2DSigma(const double &sigma, const double &ratio, BIAS::Matrix< T > &result, const bool normalize=true)
static void Gauss1D(const unsigned size, const double &sigma, BIAS::Vector< T > &result, const bool normalize=true)
static void Gauss2DSize(const unsigned size, const double &ratio, BIAS::Matrix< T > &result, double &sigma, const bool normalize=true)
static void Gauss2D(const unsigned size, const double &sigma, BIAS::Matrix< T > &result, const bool normalize=true)
matrix class with arbitrary size, indexing is row major.
static void Sigma2Size_(const double &sigma, const double &ratio, unsigned &size)
Given a sigma and fixed ratio between biggest and smallest entry of the discrete gauss distribution...
static void Gauss1DSize(const unsigned size, const double &ratio, BIAS::Vector< T > &result, double &sigma, const bool normalize=true)