Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleGenerateGauss.cpp
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 
23 
24 /**
25  @example ExampleGenerateGauss.cpp
26  @relates GenerateGauss
27  @brief Example for convolution of two matrices
28  @ingroup g_examples
29  @author woelk 01/2008 (c) www. vision-n.de
30 */
31 
32 #include <Base/Math/GenerateGauss.hh>
33 #include <Base/Math/Vector.hh>
34 #include <Base/Math/Matrix.hh>
35 
36 #include <iostream>
37 
38 using namespace BIAS;
39 using namespace std;
40 
41 int main(int argc, char *argv[])
42 {
43  int size = 5;
44  double sigma = 2.0;
45  Vector<double> vg;
46  Matrix<double> mg;
47  bool normalize = true;
48 
49  /// generation using sigma and size
50  GenerateGauss::Gauss1D(size, sigma, vg, normalize);
51  if (normalize) cout << "normalized ";
52  cout << "gauss vector of size "<<size<<" with sigma "<<sigma<<" : "<<vg<<endl;
53 
54  GenerateGauss::Gauss2D(size, sigma, mg, normalize);
55  if (normalize) cout << "normalized ";
56  cout << "gauss matrix of size "<<size<<"x"<<size<<" with sigma "<<sigma
57  <<" : "<<mg<<endl;
58 
59  /// generation using size and ratio
60  double ratio = 1e-2;
61  GenerateGauss::Gauss1DSize(size, ratio, vg, sigma, normalize);
62  if (normalize) cout << "normalized ";
63  cout << "gauss vector of size "<<size<<" with ratio "<<ratio
64  <<" results in sigma "<<sigma<<" : "<<vg<<endl;
65 
66  GenerateGauss::Gauss2DSize(size, ratio, mg, sigma, normalize);
67  if (normalize) cout << "normalized ";
68  cout << "gauss matrix of size "<<size<<"x"<<size<<" with ratio "<<ratio
69  <<" results in sigma "<<sigma<<" : "<<mg<<endl;
70 
71  /// generation using sigma and ratio
72  sigma = 1.0;
73  GenerateGauss::Gauss1DSigma(sigma, ratio, vg, normalize);
74  if (normalize) cout << "normalized ";
75  cout << "gauss vector with sigma "<<sigma<<" and ratio "<<ratio
76  <<" results in size "<<vg.size()<<" : "<<vg<<endl;
77 
78  GenerateGauss::Gauss2DSigma(sigma, ratio, mg, normalize);
79  if (normalize) cout << "normalized ";
80  cout << "gauss matrix with sigma "<<sigma<<" and ratio "<<ratio
81  <<" results in size "<<mg.num_rows()<<"x"<<mg.num_cols()<<" : "
82  <<mg<<endl;
83 
84 
85 
86 
87  return 0;
88 }
Subscript num_cols() const
Definition: cmat.h:320
static void Gauss1DSigma(const double &sigma, const double &ratio, BIAS::Vector< T > &result, const bool normalize=true)
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)
static void Gauss1DSize(const unsigned size, const double &ratio, BIAS::Vector< T > &result, double &sigma, const bool normalize=true)
Subscript num_rows() const
Definition: cmat.h:319
Subscript size() const
Definition: vec.h:262