$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
transform_inplace.cc
1 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #include <mln/core/image/image1d.hh>
27 #include <mln/core/image/image2d.hh>
28 #include <mln/core/image/image3d.hh>
29 #include <mln/core/image/flat_image.hh>
30 #include <mln/core/image/dmorph/image_if.hh>
31 #include <mln/core/image/dmorph/sub_image.hh>
32 #include <mln/core/image/dmorph/extension_val.hh>
33 #include <mln/core/routine/duplicate.hh>
34 
35 #include <mln/fun/v2v/inc.hh>
36 #include <mln/fun/v2v/dec.hh>
37 #include <mln/fun/p2b/chess.hh>
38 
39 #include <mln/debug/iota.hh>
40 
41 #include <mln/data/transform_inplace.hh>
42 #include <mln/data/compare.hh>
43 
44 
45 
46 int main()
47 {
48  using namespace mln;
49  const unsigned size = 50;
50 
51 
52  // image 2d tests
53  {
54  typedef int T;
55  image2d<T> ref(size, size);
56  debug::iota(ref);
57 
58  image2d<T> ima = duplicate(ref);
61 
62  mln_assertion(ima == ref);
63  }
64 
66  {
67  typedef unsigned short T;
68  image1d<T> ref(size);
69  debug::iota(ref);
70 
71  image1d<T> ima = duplicate(ref);
74 
75  mln_assertion(ima == ref);
76  }
77 
78 
80  {
81  typedef unsigned short T;
82  image3d<T> ref(size, size, size);
83  debug::iota(ref);
84 
85  image3d<T> ima = duplicate(ref);
88 
89  mln_assertion(ima == ref);
90  }
91 
92  // flat image test
93  {
94  typedef short T;
96  ref(5, make::box2d(size, size)),
97  ima(5, make::box2d(size, size));
98 
101 
102  mln_assertion(ima == ref);
103  }
104 
105  // image if test
106  {
107  typedef unsigned short T;
108  typedef image2d<T> I;
109  typedef image_if<I, fun::p2b::chess> II;
110 
111  I ref(size, size);
112  debug::iota(ref);
113  II ref_if = ref | fun::p2b::chess();
114 
115  I ima = duplicate(ref);
116  II ima_if = ima | fun::p2b::chess();
117 
120 
121  mln_assertion(ima_if == ref_if);
122  }
123 
124  // sub_image test
125  {
126  typedef image2d<int> I;
127  typedef sub_image< image2d<int>, box2d > II;
128  typedef image2d<unsigned short> III;
129 
130  I ref(size, size);
131  debug::iota(ref);
132  II sub_ref(ref, make::box2d(4,4, 10,10));
133 
134  I ima = duplicate(ref);
135  II sub_ima(ima, make::box2d(4,4, 10,10));
136 
139 
140  mln_assertion(sub_ima == sub_ref);
141  }
142 
143  // extended image test
144  {
145  typedef int T;
146  typedef image2d<T> I;
147  typedef extension_val< image2d<T> > II;
148 
149  I ref(size, size);
150 
151  I ima = duplicate(ref);
152  II extend_ima(ima, 5);
153 
156 
157  mln_assertion(extend_ima == ref);
158 
159  }
160 }