Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleMatrixConvolution.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 ExampleMatrixConvolution.cpp
26  @relates Matrix
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/Matrix.hh>
33 #include <iostream>
34 
35 using namespace BIAS;
36 using namespace std;
37 
38 /**
39  @example ExampleMatrixConvolution.cpp
40  @brief Example for convolution of two matrices
41  @ingroup g_examples
42  @author woelk 01/2008 (c) www. vision-n.de
43 */
44 int main(int argc, char *argv[])
45 {
46  const int sl=3, sr=3;
47  Matrix<int> left(sl,sl), right(sr,sr), res;
48 
49  for (int y=0; y<sl; y++){
50  for (int x=0; x<sl; x++){
51  left[y][x] = 1;
52  }
53  }
54 
55  for (int y=0; y<sr; y++){
56  for (int x=0; x<sr; x++){
57  right[y][x] = 1;
58  }
59  }
60 
61  Conv(left, right, res);
62 
63  cout << "convolution of "<<left<<" and "<<right<<" results in "<<res<<endl;
64 
65  return 0;
66 }
matrix class with arbitrary size, indexing is row major.