51 #include <mln/util/ord.hh>
53 #include <mln/core/image/image2d.hh>
54 #include <mln/core/alias/point2d.hh>
55 #include <mln/core/alias/window2d.hh>
56 #include <mln/core/alias/neighb2d.hh>
58 #include <mln/convert/to_window.hh>
60 #include <mln/util/graph.hh>
61 #include <mln/fun/i2v/array.hh>
62 #include <mln/util/site_pair.hh>
63 #include <mln/core/image/edge_image.hh>
65 #include <mln/morpho/gradient.hh>
66 #include <mln/morpho/closing/area.hh>
67 #include <mln/morpho/watershed/flooding.hh>
69 #include <mln/value/int_u8.hh>
70 #include <mln/value/rgb8.hh>
71 #include <mln/literal/black.hh>
72 #include <mln/literal/colors.hh>
74 #include <mln/io/pgm/load.hh>
75 #include <mln/io/ppm/save.hh>
77 #include <mln/math/max.hh>
79 #include "tests/data.hh"
92 typedef int_u8 input_val_t;
120 equiv_vertex(
p) = g.add_vertex();
124 next_c4_win.insert(0, 1).insert(1, 0);
125 typedef fun::i2v::array<
int> edge_values_t;
126 typedef fun::i2v::array< util::site_pair<
point2d> > edge_sites_t;
127 edge_values_t edge_values;
128 edge_sites_t edge_sites;
129 mln_fwd_qiter_(
window2d) q(next_c4_win,
p);
132 if (work.domain().has(q))
134 g.add_edge(equiv_vertex(p), equiv_vertex(q));
135 edge_values.append(
math::max(work(p), work(q)));
141 lg_ima_t lg_ima(g, edge_sites, edge_values);
148 typedef lg_ima_t::nbh_t nbh_t;
155 mln_assertion(nbasins == 5u);
166 typedef rgb8 output_val_t;
168 point2d output_pmin = input.domain().pmin();
169 point2d output_pmax(input.domain().pmax()[0] * 2,
170 input.domain().pmax()[1] * 2);
171 output_t output(
box2d(output_pmin, output_pmax));
178 input_val_t v = input(p);
181 output(q) = output_val_t(v, v, v);
184 mln_piter_(output_t) p_out(output.domain());
188 if (p_out[0] % 2 == 0 && p_out[1] % 2 == 1)
189 output(p_out) = (output(p_out +
left) + output(p_out +
right)) / 2;
191 if (p_out[0] % 2 == 1 && p_out[1] % 2 == 0)
192 output(p_out) = (output(p_out +
up) + output(p_out +
down)) / 2;
194 if (p_out[0] % 2 == 1 && p_out[1] % 2 == 1)
199 output(p_out +
dpoint2d(+1, +1))) / 4;
205 mln_piter_(wshed_t) pw(wshed.domain());
210 mln_psite_(lg_ima_t) pp(pw);
212 int row1 = pp.first()[0] * 2;
213 int col1 = pp.first()[1] * 2;
214 int row2 = pp.second()[0] * 2;
215 int col2 = pp.second()[1] * 2;
216 point2d q((row1 + row2) / 2, (col1 + col2) / 2);
218 output(q) = literal::red;
232 if (p_out[0] % 2 == 1 && p_out[1] % 2 == 1)