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>
40 #include <mln/debug/iota.hh>
42 #include <mln/arith/minus.hh>
93 template <
typename I,
typename J>
95 chck(
const Image<I>& ref_,
const Image<J>& ima_,
const mln_value(I) v)
97 const I& ref = exact(ref_);
98 const J& ima = exact(ima_);
100 mln_piter(I) p (ima.domain ());
102 mln_assertion ((mln_value(I))ima(p) == (ref(p) - v));
105 template <typename V>
120 (std::cerr <<
"in 1d ... ").flush ();
122 typedef image1d<V> I;
124 for (V v = 0; v < max; ++v)
125 for (
unsigned i = 1; i < col; ++i)
129 chck (ima, ima - v, v);
132 std::cerr <<
"OK" << std::endl;
134 (std::cerr <<
"in 2d ... ").flush ();
136 typedef image2d<V> I;
138 for (V v = 0; v < max; ++v)
139 for (
unsigned i = 1; i < col; ++i)
140 for (
unsigned j = 1; j < row; ++j)
144 chck (ima, ima - v, v);
147 std::cerr <<
"OK" << std::endl;
149 (std::cerr <<
"in 3d ... ").flush ();
151 typedef image3d<V> I;
153 for (V v = 0; v < max; ++v)
154 for (
unsigned i = 1; i < col; ++i)
155 for (
unsigned j = 1; j < row; ++j)
156 for (
unsigned k = 1; k < sli; ++k)
160 chck (ima, ima - v, v);
163 std::cerr <<
"OK" << std::endl;
166 (std::cerr <<
"in subimage 1d ... ").flush ();
168 typedef image1d<V> I;
169 typedef sub_image<I, box1d> J;
172 for (V v = 0; v < max; ++v)
173 for (
unsigned i = 1; i < col; ++i)
178 chck (ima, ima - v, v);
181 std::cerr <<
"OK" << std::endl;
183 (std::cerr <<
"in subimage 2d ... ").flush ();
185 typedef image2d<V> I;
186 typedef sub_image<I, box2d> J;
189 for (V v = 0; v < max; ++v)
190 for (
unsigned i = 1; i < col; ++i)
191 for (
unsigned j = 1; j < row; ++j)
196 chck (ima, ima - v, v);
199 std::cerr <<
"OK" << std::endl;
201 (std::cerr <<
"in subimage 3d ... ").flush ();
203 typedef image3d<V> I;
204 typedef sub_image<I, box3d> J;
207 for (V v = 0; v < max; ++v)
208 for (
unsigned i = 1; i < col; ++i)
209 for (
unsigned j = 1; j < row; ++j)
210 for (
unsigned k = 1; k < sli; ++k)
215 chck (ima, ima - v, v);
218 std::cerr <<
"OK" << std::endl;
231 std::cerr <<
"Tests arith::minus:" << std::endl;
232 std::cerr <<
"on int:" << std::endl;
234 std::cerr <<
"on unsigned:" << std::endl;
236 std::cerr <<
"on int_s8:" << std::endl;
237 chk<value::int_s8>(8);
238 std::cerr <<
"on int_s16:" << std::endl;
239 chk<value::int_s16>(1000);