69 #include <mln/value/int_u8.hh>
70 #include <mln/core/image/image2d.hh>
72 #include <mln/pw/all.hh>
74 #include <mln/fun/vv2v/diff_abs.hh>
75 #include <mln/world/inter_pixel/immerse.hh>
76 #include <mln/world/inter_pixel/compute.hh>
77 #include <mln/world/inter_pixel/neighb2d.hh>
79 #include <mln/morpho/watershed/topological.hh>
81 #include <mln/morpho/tree/compute_attribute_image.hh>
82 #include <mln/accu/stat/min.hh>
83 #include <mln/accu/stat/max.hh>
85 #include <mln/io/pgm/load.hh>
86 #include <mln/debug/println.hh>
88 #include <mln/core/var.hh>
91 int main(
int argc,
char* argv[])
95 std::cerr <<
"Usage: " << argv[0] <<
" input.pgm" << std::endl;
116 point2d p_f(p_ima_.row() / 2, p_ima_.col() / 2);
117 f_(p_ima) = input(p_f);
121 image_if<image2d<int_u8>, world::inter_pixel::is_pixel> f =
122 world::inter_pixel::immerse(f_);
131 typedef morpho::watershed::topo_wst<g_t, world::inter_pixel::dbl_neighb2d> tree_t;
132 tree_t tree(g, world::inter_pixel::e2e());
139 std::set<int_u8> values;
140 mln_piter_(w_t) p2(w.domain());
142 values.insert(w(p2));
145 for (std::set<int_u8>::const_iterator alpha = values.begin();
146 alpha != values.end(); ++alpha)
148 mln_VAR(alpha_cc, w | (pw::value(w) > pw::cst(*alpha)));
149 std::cout << *alpha <<
"-cc:" << std::endl;
154 debug::impl::println(w.unmorph_().domain(), alpha_cc);
169 morpho::tree::data<w_t, sites_t> t(w, sites, world::inter_pixel::e2e());
174 mln_ch_value_(w_t, accu::stat::max<int_u8>) init_max_val;
184 mln_piter_(w_t) e(w.domain());
185 mln_niter_(world::inter_pixel::dbl_neighb2d)
186 v_g(world::inter_pixel::e2v(), e);
192 point2d v_f(v_g_.row() / 2, v_g_.col() / 2);
193 init_min_val(e).take(f_(v_f));
194 init_max_val(e).take(f_(v_f));
198 mln_ch_value_(w_t, int_u8) min_val =
199 morpho::tree::compute_attribute_image_from(min_accu, t, init_min_val);
200 accu::stat::max<int_u8> max_accu;
201 mln_ch_value_(w_t, int_u8) max_val =
202 morpho::tree::compute_attribute_image_from(max_accu, t, init_max_val);
204 mln_ch_value_(w_t, int_u8) height;
207 height(e) = max_val(e) - min_val(e);
208 debug::println(height);
211 for (
unsigned alpha = 0; alpha <= 6; ++alpha)
213 mln_VAR(alpha_alpha_cc,
214 w | (pw::value(w) > pw::cst(alpha)
215 || (pw::value(height) > pw::cst(alpha))));
216 std::cout <<
"(" << alpha <<
", " << alpha <<
")-cc:" << std::endl;
218 debug::impl::println(w.unmorph_().domain(), alpha_alpha_cc);