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/dmorph/sub_image.hh>
31 #include <mln/core/image/dmorph/image_if.hh>
32 #include <mln/fun/p2b/chess.hh>
33 #include <mln/literal/origin.hh>
35 #include <mln/value/int_u8.hh>
36 #include <mln/value/int_s8.hh>
37 #include <mln/value/int_u16.hh>
38 #include <mln/value/int_s16.hh>
39 #include <mln/debug/iota.hh>
41 #include <mln/arith/plus.hh>
88 template <
typename I,
typename J>
90 chck(
const Image<I>& ref_,
const Image<J>& ima_,
const mln_value(I) v)
92 const I& ref =
exact(ref_);
93 const J& ima =
exact(ima_);
95 mln_piter(I)
p (ima.domain ());
97 mln_assertion ((mln_value(I))ima(
p) == (ref(
p) + v));
100 template <typename V>
115 (std::cerr <<
"in 1d ... ").flush ();
117 typedef image1d<V> I;
119 for (V v = 0; v <
max; ++v)
120 for (
unsigned i = 1; i < col; ++i)
124 chck (ima, ima + v, v);
127 std::cerr <<
"OK" << std::endl;
129 (std::cerr <<
"in 2d ... ").flush ();
131 typedef image2d<V> I;
133 for (V v = 0; v <
max; ++v)
134 for (
unsigned i = 1; i < col; ++i)
135 for (
unsigned j = 1; j < row; ++j)
139 chck (ima, ima + v, v);
142 std::cerr <<
"OK" << std::endl;
144 (std::cerr <<
"in 3d ... ").flush ();
146 typedef image3d<V> I;
148 for (V v = 0; v <
max; ++v)
149 for (
unsigned i = 1; i < col; ++i)
150 for (
unsigned j = 1; j < row; ++j)
151 for (
unsigned k = 1; k < sli; ++k)
155 chck (ima, ima + v, v);
158 std::cerr <<
"OK" << std::endl;
161 (std::cerr <<
"in subimage 1d ... ").flush ();
163 typedef image1d<V> I;
164 typedef sub_image<I, box1d> J;
167 for (V v = 0; v <
max; ++v)
168 for (
unsigned i = 1; i < col; ++i)
173 chck (ima, ima + v, v);
176 std::cerr <<
"OK" << std::endl;
178 (std::cerr <<
"in subimage 2d ... ").flush ();
180 typedef image2d<V> I;
181 typedef sub_image<I, box2d> J;
184 for (V v = 0; v <
max; ++v)
185 for (
unsigned i = 1; i < col; ++i)
186 for (
unsigned j = 1; j < row; ++j)
191 chck (ima, ima + v, v);
194 std::cerr <<
"OK" << std::endl;
196 (std::cerr <<
"in subimage 3d ... ").flush ();
198 typedef image3d<V> I;
199 typedef sub_image<I, box3d> J;
202 for (V v = 0; v <
max; ++v)
203 for (
unsigned i = 1; i < col; ++i)
204 for (
unsigned j = 1; j < row; ++j)
205 for (
unsigned k = 1; k < sli; ++k)
210 chck (ima, ima + v, v);
213 std::cerr <<
"OK" << std::endl;
226 std::cerr <<
"Tests arith::plus:" << std::endl;
227 std::cerr <<
"on int:" << std::endl;
229 std::cerr <<
"on unsigned:" << std::endl;
231 std::cerr <<
"on int_u8:" << std::endl;
232 chk<value::int_u8>(16);
233 std::cerr <<
"on int_u16:" << std::endl;
234 chk<value::int_u16>(1000);
235 std::cerr <<
"on int_s8:" << std::endl;
236 chk<value::int_s8>(16);
237 std::cerr <<
"on int_s16:" << std::endl;
238 chk<value::int_s16>(1000);