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>
34 #include <mln/literal/origin.hh>
36 #include <mln/value/int_s8.hh>
37 #include <mln/value/int_s16.hh>
38 #include <mln/value/int_u8.hh>
39 #include <mln/value/int_u16.hh>
40 #include <mln/debug/iota.hh>
42 #include <mln/arith/times.hh>
89 template <
typename I,
typename J>
91 chck(
const Image<I>& ref_,
const Image<J>& ima_,
const mln_value(I) v)
93 const I& ref =
exact(ref_);
94 const J& ima =
exact(ima_);
96 mln_piter(I)
p (ima.domain ());
98 mln_assertion ((mln_value(I))ima(
p) == (ref(
p) * v));
101 template <typename V>
116 (std::cerr <<
"in 1d ... ").flush ();
118 typedef image1d<V> I;
120 for (V v = 0; v <
max; ++v)
121 for (
unsigned i = 1; i < col; ++i)
125 chck (ima, ima * v, v);
128 std::cerr <<
"OK" << std::endl;
130 (std::cerr <<
"in 2d ... ").flush ();
132 typedef image2d<V> I;
134 for (V v = 0; v <
max; ++v)
135 for (
unsigned i = 1; i < col; ++i)
136 for (
unsigned j = 1; j < row; ++j)
140 chck (ima, ima * v, v);
143 std::cerr <<
"OK" << std::endl;
145 (std::cerr <<
"in 3d ... ").flush ();
147 typedef image3d<V> I;
149 for (V v = 0; v <
max; ++v)
150 for (
unsigned i = 1; i < col; ++i)
151 for (
unsigned j = 1; j < row; ++j)
152 for (
unsigned k = 1; k < sli; ++k)
156 chck (ima, ima * v, v);
159 std::cerr <<
"OK" << std::endl;
162 (std::cerr <<
"in subimage 1d ... ").flush ();
164 typedef image1d<V> I;
165 typedef sub_image<I, box1d> J;
168 for (V v = 0; v <
max; ++v)
169 for (
unsigned i = 1; i < col; ++i)
174 chck (ima, ima * v, v);
177 std::cerr <<
"OK" << std::endl;
179 (std::cerr <<
"in subimage 2d ... ").flush ();
181 typedef image2d<V> I;
182 typedef sub_image<I, box2d> J;
185 for (V v = 0; v <
max; ++v)
186 for (
unsigned i = 1; i < col; ++i)
187 for (
unsigned j = 1; j < row; ++j)
192 chck (ima, ima * v, v);
195 std::cerr <<
"OK" << std::endl;
197 (std::cerr <<
"in subimage 3d ... ").flush ();
199 typedef image3d<V> I;
200 typedef sub_image<I, box3d> J;
203 for (V v = 0; v <
max; ++v)
204 for (
unsigned i = 1; i < col; ++i)
205 for (
unsigned j = 1; j < row; ++j)
206 for (
unsigned k = 1; k < sli; ++k)
211 chck (ima, ima * v, v);
214 std::cerr <<
"OK" << std::endl;
227 std::cerr <<
"Tests arith::times:" << std::endl;
228 std::cerr <<
"on int:" << std::endl;
230 std::cerr <<
"on unsigned:" << std::endl;
232 std::cerr <<
"on int_u8:" << std::endl;
233 chk<value::int_u8>(9);
234 std::cerr <<
"on int_u16:" << std::endl;
235 chk<value::int_u16>(1000);
236 std::cerr <<
"on int_s8:" << std::endl;
237 chk<value::int_s8>(5);
238 std::cerr <<
"on int_s16:" << std::endl;
239 chk<value::int_s16>(1000);