Milena (Olena)
User documentation 2.0a Id
Main Page
Related Pages
Modules
Namespaces
Classes
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerator
Groups
Pages
doc/benchmark/morpho/erosion.cc
1
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
2
// (LRDE)
3
//
4
// This file is part of Olena.
5
//
6
// Olena is free software: you can redistribute it and/or modify it under
7
// the terms of the GNU General Public License as published by the Free
8
// Software Foundation, version 2 of the License.
9
//
10
// Olena is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
17
//
18
// As a special exception, you may use this file as part of a free
19
// software project without restriction. Specifically, if other files
20
// instantiate templates or use macros or inline functions from this
21
// file, or you compile this file and link it with other files to produce
22
// an executable, this file does not by itself cause the resulting
23
// executable to be covered by the GNU General Public License. This
24
// exception does not however invalidate any other reasons why the
25
// executable file might be covered by the GNU General Public License.
26
32
#include <mln/core/image/image2d.hh>
33
#include <mln/win/all.hh>
34
35
#include <mln/debug/iota.hh>
36
37
#include <mln/io/pgm/load.hh>
38
#include <mln/io/pgm/save.hh>
39
40
#include <mln/value/int_u8.hh>
41
#include <mln/morpho/erosion.hh>
42
#include <mln/arith/diff_abs.hh>
43
44
#include "tests/data.hh"
45
#include "tests/timer.hh"
46
47
48
int
main()
49
{
50
using namespace
mln;
51
using
value::int_u8
;
52
53
// unsigned
54
// l_oct = 11, L_oct = 6 * l_oct + 1,
55
// l_rec = 29, L_rec = 2 * l_rec + 1;
56
57
// l_
58
// oct rec err
59
// 0 0 3
60
// 0 1 5
61
// 1 2 15
62
// 1 3 9
63
// 2 5 11
64
// 3 8 9
65
// 5 13 15
66
// 8 21 11
67
// 11 29 1
68
// 25 66 15
69
70
border::thickness = 20;
71
image2d<int_u8>
lena;
72
io::pgm::load
(lena, MLN_IMG_DIR
"/lena.pgm"
);
73
74
win::rectangle2d
rec(21, 21);
75
win::hline2d
hline(31);
76
win::vline2d
vline(31);
77
win::diag2d
diag2d(31);
78
win::backdiag2d
backdiag2d(31);
79
win::octagon2d
oct(6 * 3 + 1);
80
win::disk2d
disk(6 * 3 + 1);
81
image2d<int_u8>
out;
82
image2d<int_u8>
ref;
83
// trace::quiet = false;
84
timer t;
85
86
/*
87
// Rectangle
88
std::cout << "-------------------------- Rectangle: " << std::endl;
89
90
{
91
t.start();
92
ref = morpho::impl::generic::erosion_on_function(lena, rec);
93
std::cout << "generic on rectangle2d: " << t << std::endl;
94
}
95
96
{
97
t.start();
98
out = morpho::erosion(lena, rec);
99
std::cout << "dispach on rectangle2d: " << t << std::endl;
100
bool test = out == ref;
101
mln_assertion(test);
102
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
103
}
104
105
{
106
t.start();
107
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, rec);
108
std::cout << "erosion_arbitrary_2d_fastest on rectangle2d: " << t << std::endl;
109
bool test = out == ref;
110
mln_assertion(test);
111
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
112
}
113
114
{
115
t.start();
116
out = morpho::impl::erosion_arbitrary_2d(lena, rec);
117
std::cout << "erosion_arbitrary_2d on rectangle2d: " << t << std::endl;
118
bool test = out == ref;
119
mln_assertion(test);
120
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
121
}
122
123
//Hline
124
125
std::cout << "-------------------------- Hline2d: " << std::endl;
126
127
{
128
t.start();
129
ref = morpho::impl::generic::erosion_on_function(lena, hline);
130
std::cout << "generic on hline2d: " << t << std::endl;
131
}
132
133
{
134
t.start();
135
out = morpho::erosion(lena, hline);
136
std::cout << "dispach on hline2d : " << t << std::endl;
137
bool test = out == ref;
138
mln_assertion(test);
139
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
140
}
141
142
{
143
t.start();
144
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, hline);
145
std::cout << "erosion_arbitrary_2d_fastest on hline2d: " << t << std::endl;
146
bool test = out == ref;
147
mln_assertion(test);
148
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
149
}
150
151
152
{
153
t.start();
154
out = morpho::impl::erosion_arbitrary_2d(lena, hline);
155
std::cout << "erosion_arbitrary_2d on hline2d: " << t << std::endl;
156
bool test = out == ref;
157
mln_assertion(test);
158
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
159
}
160
161
std::cout << "-------------------------- Vline2d: "<< std::endl;
162
163
//Vline
164
{
165
t.start();
166
ref = morpho::impl::generic::erosion_on_function(lena, vline);
167
std::cout << "generic on vline2d: " << t << std::endl;
168
}
169
170
{
171
t.start();
172
out = morpho::erosion(lena, vline);
173
std::cout << "dispach on vline2d : " << t << std::endl;
174
bool test = out == ref;
175
mln_assertion(test);
176
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
177
}
178
179
180
{
181
t.start();
182
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, vline);
183
std::cout << "erosion_arbitrary_2d_fastest on vline2d: " << t << std::endl;
184
bool test = out == ref;
185
mln_assertion(test);
186
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
187
}
188
189
190
{
191
t.start();
192
out = morpho::impl::erosion_arbitrary_2d(lena, vline);
193
std::cout << "erosion_arbitrary_2d on vline2d: " << t << std::endl;
194
bool test = out == ref;
195
mln_assertion(test);
196
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
197
}
198
199
200
//Diag2d
201
std::cout << "-------------------------- Diag2d: "<< std::endl;
202
{
203
t.start();
204
ref = morpho::impl::generic::erosion_on_function(lena, diag2d);
205
std::cout << "generic on diag2d: " << t << std::endl;
206
}
207
208
{
209
t.start();
210
out = morpho::erosion(lena, diag2d);
211
std::cout << "dispach on diag2d : " << t << std::endl;
212
bool test = out == ref;
213
mln_assertion(test);
214
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
215
}
216
217
218
{
219
t.start();
220
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, diag2d);
221
std::cout << "erosion_arbitrary_2d_fastest on diag2d: " << t << std::endl;
222
bool test = out == ref;
223
mln_assertion(test);
224
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
225
}
226
227
228
{
229
t.start();
230
out = morpho::impl::erosion_arbitrary_2d(lena, diag2d);
231
std::cout << "erosion_arbitrary_2d on diag2d: " << t << std::endl;
232
bool test = out == ref;
233
mln_assertion(test);
234
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
235
}
236
237
//Backdiag2d
238
std::cout << "-------------------------- Backdiag2d: "<< std::endl;
239
{
240
t.start();
241
ref = morpho::impl::generic::erosion_on_function(lena, backdiag2d);
242
std::cout << "generic on backdiag2d: " << t << std::endl;
243
}
244
245
{
246
t.start();
247
out = morpho::erosion(lena, backdiag2d);
248
std::cout << "dispach on backdiag2d : " << t << std::endl;
249
bool test = out == ref;
250
mln_assertion(test);
251
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
252
}
253
254
255
{
256
t.start();
257
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, backdiag2d);
258
std::cout << "erosion_arbitrary_2d_fastest on backdiag2d: " << t << std::endl;
259
bool test = out == ref;
260
mln_assertion(test);
261
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
262
}
263
264
265
{
266
t.start();
267
out = morpho::impl::erosion_arbitrary_2d(lena, backdiag2d);
268
std::cout << "erosion_arbitrary_2d on backdiag2d: " << t << std::endl;
269
bool test = out == ref;
270
mln_assertion(test);
271
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
272
}
273
*/
274
std::cout <<
"-------------------------- Octagon: "
<< std::endl;
275
border::thickness = 0;
276
// Octagon
277
{
278
t.start();
279
ref = morpho::impl::generic::erosion_on_function(lena, oct);
280
std::cout <<
"generic on octagon: "
<< t << std::endl;
281
io::pgm::save
(ref,
"out_oct_ref.pgm"
);
282
}
283
284
{
285
t.start();
286
out =
morpho::erosion
(lena, oct);
287
std::cout <<
"dispach on octagon: "
<< t << std::endl;
288
io::pgm::save
(out,
"out_oct.pgm"
);
289
io::pgm::save
(
arith::diff_abs
(out, ref),
"diff.pgm"
);
290
291
bool
test = out == ref;
292
mln_assertion(test);
293
std::cout <<
" "
<< (test ?
"OK"
:
"KO!!!"
) << std::endl;
294
}
295
296
297
std::cout <<
"-------------------------- Disk: "
<< std::endl;
298
299
// Disk
300
{
301
t.start();
302
ref = morpho::impl::generic::erosion_on_function(lena, disk);
303
std::cout <<
"generic on disk: "
<< t << std::endl;
304
io::pgm::save
(ref,
"out_disk_ref.pgm"
);
305
}
306
307
{
308
t.start();
309
out =
morpho::erosion
(lena, disk);
310
std::cout <<
"dispach on disk: "
<< t << std::endl;
311
bool
test = out == ref;
312
mln_assertion(test);
313
std::cout <<
" "
<< (test ?
"OK"
:
"KO!!!"
) << std::endl;
314
}
315
316
}
doc
benchmark
morpho
erosion.cc
Generated on Thu Nov 8 2012 10:58:01 for Milena (Olena) by
1.8.2-20120930