$extrastylesheet
Olena
User documentation 2.1
An Image Processing Platform
Milena
Getting started
API Reference Manual
All Classes
Examples
Demos
Publications
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
saturate_full.cc
1
// Copyright (C) 2007, 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
30
#include <mln/value/int_u8.hh>
31
#include <mln/value/int_u16.hh>
32
#include <mln/value/int_s8.hh>
33
#include <mln/value/int_s16.hh>
34
35
36
#include <mln/core/routine/duplicate.hh>
37
#include <mln/data/saturate.hh>
38
#include <mln/debug/iota.hh>
39
40
#include <mln/debug/println.hh>
41
42
43
namespace
mln
44
{
45
46
/*
47
48
template <typename I, typename J>
49
void
50
chck(I& ref, J& out, mln_value(I) min, mln_value(I) max)
51
{
52
mln_value(J) min2 = min;
53
mln_value(J) max2 = max;
54
55
mln_piter(I) p (ref.domain ());
56
57
{
58
data::saturate(ref, min, max, out);
59
60
for_all(p)
61
{
62
if (ref(p) <= min)
63
{
64
mln_assertion(out(p) == min2);
65
continue;
66
}
67
if (ref(p) >= max)
68
{
69
mln_assertion(out(p) == max2);
70
continue;
71
}
72
mln_assertion(ref(p) == (mln_value(I)) out(p));
73
}
74
}
75
76
{
77
data::saturate_inplace(ref, min, max);
78
79
for_all(p)
80
{
81
mln_assertion(ref(p) == (mln_value(I)) out(p));
82
}
83
}
84
}
85
86
template <typename I, typename J>
87
void
88
chk1d(unsigned cols,
89
int min,
90
int max)
91
{
92
image1d<I> ima (cols);
93
image1d<J> out (cols);
94
debug::iota (ima);
95
chck(ima, out, min, max);
96
}
97
98
template <typename I, typename J>
99
void
100
chk2d(unsigned rows,
101
unsigned cols,
102
int min,
103
int max)
104
{
105
image2d<I> ima (rows, cols);
106
image2d<J> out (rows, cols);
107
debug::iota (ima);
108
chck(ima, out, min, max);
109
}
110
111
template <typename I, typename J>
112
void
113
chk3d(unsigned slis,
114
unsigned rows,
115
unsigned cols,
116
int min,
117
int max)
118
{
119
image3d<I> ima (slis, rows, cols);
120
image3d<J> out (slis, rows, cols);
121
debug::iota (ima);
122
chck(ima, out, min, max);
123
}
124
125
*/
126
127
}
128
129
130
int
main()
131
{
132
using namespace
mln;
133
134
/*
135
136
unsigned slis_start = 1;
137
unsigned slis_end = 3;
138
139
unsigned rows_start = 1;
140
unsigned rows_end = 5;
141
142
unsigned cols_start = 2;
143
unsigned cols_end = 6;
144
145
146
std::cerr << "Tests data::saturate" << std::endl;
147
148
(std::cerr << "in 1d ... ").flush ();
149
{
150
for (unsigned i = cols_start; i < cols_end; ++i)
151
for (unsigned j = 1; j < i; ++j)
152
for (unsigned k = j + 1; k <= i; ++k)
153
{
154
chk1d<int, int>(i, j, k);
155
chk1d<unsigned, unsigned>(i, j, k);
156
chk1d<int, unsigned>(i, j, k);
157
chk1d<unsigned, int>(i, j, k);
158
159
chk1d<value::int_u8, value::int_u8>(i, j, k);
160
chk1d<value::int_u16, value::int_u16>(i, j, k);
161
chk1d<value::int_s8, value::int_s8>(i, j, k);
162
chk1d<value::int_s16, value::int_s16>(i, j, k);
163
164
chk1d<unsigned, value::int_u8>(i, j, k);
165
chk1d<unsigned, value::int_u16>(i, j, k);
166
chk1d<int, value::int_s8>(i, j, k);
167
chk1d<int, value::int_s16>(i, j, k);
168
169
chk1d<value::int_u8, unsigned>(i, j, k);
170
chk1d<value::int_u16, unsigned>(i, j, k);
171
chk1d<value::int_s8, int>(i, j, k);
172
chk1d<value::int_s16, int>(i, j, k);
173
}
174
}
175
std::cerr << "OK" << std::endl;
176
177
(std::cerr << "in 2d ... ").flush ();
178
{
179
for (unsigned h = rows_start; h < rows_end; ++h)
180
for (unsigned i = cols_start; i < cols_end; ++i)
181
for (unsigned j = 1; j < i; ++j)
182
for (unsigned k = j + 1; k <= i; ++k)
183
{
184
chk2d<int, int>(h, i, j, k);
185
chk2d<unsigned, unsigned>(h, i, j, k);
186
chk2d<int, unsigned>(h, i, j, k);
187
chk2d<unsigned, int>(h, i, j, k);
188
189
chk2d<value::int_u8, value::int_u8>(h, i, j, k);
190
chk2d<value::int_u16, value::int_u16>(h, i, j, k);
191
chk2d<value::int_s8, value::int_s8>(h, i, j, k);
192
chk2d<value::int_s16, value::int_s16>(h, i, j, k);
193
194
chk2d<unsigned, value::int_u8>(h, i, j, k);
195
chk2d<unsigned, value::int_u16>(h, i, j, k);
196
chk2d<int, value::int_s8>(h, i, j, k);
197
chk2d<int, value::int_s16>(h, i, j, k);
198
199
chk2d<value::int_u8, unsigned>(h, i, j, k);
200
chk2d<value::int_u16, unsigned>(h, i, j, k);
201
chk2d<value::int_s8, int>(h, i, j, k);
202
chk2d<value::int_s16, int>(h, i, j, k);
203
}
204
}
205
std::cerr << "OK" << std::endl;
206
207
208
(std::cerr << "in 3d ... ").flush ();
209
{
210
for (unsigned g = slis_start; g < slis_end; ++g)
211
for (unsigned h = rows_start; h < rows_end; ++h)
212
for (unsigned i = cols_start; i < cols_end; ++i)
213
for (unsigned j = 1; j < i; ++j)
214
for (unsigned k = j + 1; k <= i; ++k)
215
{
216
chk3d<int, int>(g, h, i, j, k);
217
chk3d<unsigned, unsigned>(g, h, i, j, k);
218
chk3d<int, unsigned>(g, h, i, j, k);
219
chk3d<unsigned, int>(g, h, i, j, k);
220
221
chk3d<value::int_u8, value::int_u8>(g, h, i, j, k);
222
chk3d<value::int_u16, value::int_u16>(g, h, i, j, k);
223
chk3d<value::int_s8, value::int_s8>(g, h, i, j, k);
224
chk3d<value::int_s16, value::int_s16>(g, h, i, j, k);
225
226
chk3d<unsigned, value::int_u8>(g, h, i, j, k);
227
chk3d<unsigned, value::int_u16>(g, h, i, j, k);
228
chk3d<int, value::int_s8>(g, h, i, j, k);
229
chk3d<int, value::int_s16>(g, h, i, j, k);
230
231
chk3d<value::int_u8, unsigned>(g, h, i, j, k);
232
chk3d<value::int_u16, unsigned>(g, h, i, j, k);
233
chk3d<value::int_s8, int>(g, h, i, j, k);
234
chk3d<value::int_s16, int>(g, h, i, j, k);
235
}
236
}
237
std::cerr << "OK" << std::endl;
238
239
*/
240
241
}
tests
data
saturate_full.cc
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)