49 #include <mln/core/image/image2d.hh>
50 #include <mln/core/alias/point2d.hh>
51 #include <mln/core/alias/window2d.hh>
52 #include <mln/core/alias/neighb2d.hh>
55 #include <mln/core/image/edge_image.hh>
56 #include <mln/pw/all.hh>
57 #include <mln/fun/i2v/array.hh>
58 #include <mln/util/graph.hh>
60 #include <mln/morpho/line_gradient.hh>
61 #include <mln/morpho/closing/area_on_vertices.hh>
62 #include <mln/morpho/meyer_wst.hh>
63 #include <mln/data/stretch.hh>
65 #include <mln/value/int_u8.hh>
66 #include <mln/value/int_u16.hh>
67 #include <mln/value/rgb8.hh>
68 #include <mln/literal/black.hh>
69 #include <mln/literal/colors.hh>
71 #include <mln/io/pgm/load.hh>
72 #include <mln/io/pgm/save.hh>
73 #include <mln/io/ppm/save.hh>
75 #include <mln/math/max.hh>
76 #include <mln/math/abs.hh>
78 #include <mln/opt/at.hh>
80 #include "tests/data.hh"
96 const unsigned nrows = 100;
97 const unsigned ncols = 100;
98 const unsigned square_length = 3;
99 typedef int_u8 input_val_t;
102 for (
unsigned r = 0; r <
nrows; ++r)
103 for (
unsigned c = 0; c <
ncols; ++c)
105 ((r / square_length) % 2 == (c / square_length) % 2)
106 ? mln_min(input_val_t)
107 : mln_max(input_val_t);
108 mln_assertion((nrows * ncols) == 10000);
109 mln_assertion((2 * nrows * ncols - (nrows + ncols)) == 19800);
123 typedef lg_ima_t::nbh_t nbh_t;
130 mln_assertion(nbasins == 1155);
141 typedef rgb8 output_val_t;
143 point2d output_pmin = input.domain().pmin();
144 point2d output_pmax(input.domain().pmax()[0] * 2,
145 input.domain().pmax()[1] * 2);
146 output_t output(
box2d(output_pmin, output_pmax));
153 input_val_t v = input(p);
156 output(q) = output_val_t(v, v, v);
159 mln_piter_(output_t) p_out(output.domain());
163 if (p_out[0] % 2 == 0 && p_out[1] % 2 == 1)
164 output(p_out) = (output(p_out + left) + output(p_out + right)) / 2;
166 if (p_out[0] % 2 == 1 && p_out[1] % 2 == 0)
167 output(p_out) = (output(p_out +
up) + output(p_out + down)) / 2;
169 if (p_out[0] % 2 == 1 && p_out[1] % 2 == 1)
174 output(p_out +
dpoint2d(+1, +1))) / 4;
180 mln_piter_(wshed_t) pw(wshed.domain());
185 mln_psite_(lg_ima_t) pp(pw);
187 int row1 = pp.first()[0] * 2;
188 int col1 = pp.first()[1] * 2;
189 int row2 = pp.second()[0] * 2;
190 int col2 = pp.second()[1] * 2;
191 point2d q((row1 + row2) / 2, (col1 + col2) / 2);
193 output(q) = literal::red;
207 if (p_out[0] % 2 == 1 && p_out[1] % 2 == 1)
215 (output.has(p_out + down ) && output(p_out + down ) ==
literal::red) +
216 (output.has(p_out + left ) && output(p_out + right) ==
literal::red) +
217 (output.has(p_out + right) && output(p_out + left ) ==
literal::red);
221 io::ppm::save(output,
"artificial_line_graph_image_wst-out.ppm");