
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Add a topological wst following Laurent's ISMM09 scheme. * theo/esiee/laurent/ismm09/main.cc: Copy to... * theo/esiee/laurent/ismm09/topo_wst.cc: ...this new file. Update. * theo/esiee/laurent/ismm09/main.cc (T, E): Remove useless typedefs. main.cc | 4 --- topo_wst.cc | 76 ++++++++++++++++++++++++------------------------------------ 2 files changed, 31 insertions(+), 49 deletions(-) Index: theo/esiee/laurent/ismm09/topo_wst.cc --- theo/esiee/laurent/ismm09/topo_wst.cc (revision 3286) +++ theo/esiee/laurent/ismm09/topo_wst.cc (working copy) @@ -7,9 +7,7 @@ #include <mln/io/pgm/save.hh> #include <mln/debug/println.hh> -#include <mln/morpho/meyer_wst.hh> -#include <mln/labeling/compute.hh> -#include <mln/accu/count.hh> +#include <mln/debug/iota.hh> #include "pseudo_tree.hh" #include "cplx2d.hh" @@ -20,7 +18,7 @@ void usage(char* argv[]) { std::cerr << "usage: " << argv[0] << " input.pgm" << std::endl; - std::cerr << "Laurent ISMM 2009 scheme." << std::endl; + std::cerr << "Laurent topological watershed transform thru ISMM 2009 scheme." << std::endl; abort(); } @@ -40,6 +38,7 @@ image2d<int_u8> f; io::pgm::load(f, argv[1]); + debug::println("f:", f); // g: weights on edges. @@ -47,67 +46,54 @@ mln_VAR(g, cplx2d::f_to_g(f) ); debug::println("g:", g); - typedef mln_value_(g_t) T; // <--- Type of edge values. - typedef mln_psite_(g_t) E; // <--- Type of edges. + // r: one pixel is one region. - // w: watershed labeling on edges. + typedef label_16 L; + L l_max = f.nsites(); - typedef label_16 L; // <--- Type of labels. - L l_max; - mln_VAR( w, morpho::meyer_wst(g, cplx2d::e2e(), l_max) ); - debug::println("w:", w); - - - mln_VAR( is_w_line, pw::value(w) == pw::cst(0) ); - mln_VAR( g_line, g | is_w_line ); - debug::println("g | line:", g_line); - - mln_VAR(w_ext, cplx2d::extend_w_edges_to_all_faces(w)); + image2d<L> w_ext(2 * f.nrows() - 1, 2 * f.ncols() - 1); + data::fill(w_ext, 0); // Useless but for display! + mln_VAR( w_pixel, w_ext | cplx2d::is_pixel ); + { + mln_fwd_piter_(w_pixel_t) p(w_pixel.domain()); + unsigned l = 0; + for_all(p) + w_pixel(p) = ++l; + } debug::println("w_ext:", w_ext); // e -> (l1, l2) mln_VAR( e_to_l1_l2, function_e_to_l1_l2(w_ext, cplx2d::e2p()) ); -// { -// // Test adjacency "e -> (l1, l2)". -// L l1, l2; -// mln_piter_(g_t) e(g.domain()); -// for_all(e) -// if (w(e) == 0) -// { -// e_to_l1_l2(e, l1, l2); -// std::cout << e << "=" << l1 << '|' << l2 << " "; -// } -// std::cout << std::endl; -// } - // a: array "label -> attribute". - typedef unsigned A; // <--- Type of attributes. + typedef int_u8 A; // <--- Type of attributes. - util::array<A> a = labeling::compute(accu::meta::count(), - g, // image of values - w, // image of labels - l_max); + util::array<A> a(l_max.next()); + { + mln_fwd_piter_(box2d) p(f.domain()); + unsigned l = 0; + for_all(p) + a[++l] = f(p); + } util::array<L> ls = sort_by_increasing_attributes(a, l_max); -// { -// std::cout << "ls:" << std::endl; -// for (unsigned i = 1; i <= l_max; ++i) -// std::cout << ls[i] << "(" << a[ls[i]] << ") "; -// std::cout << std::endl -// << std::endl; -// } + { + std::cout << "ls:" << std::endl; + for (unsigned i = 1; i <= l_max; ++i) + std::cout << ls[i] << "(" << a[ls[i]] << ") "; + std::cout << std::endl + << std::endl; + } // -> pseudo-tree - compute_pseudo_tree(w, g, ls, a, e_to_l1_l2); - + compute_pseudo_tree(w_ext, g, ls, a, e_to_l1_l2); } Property changes on: theo/esiee/laurent/ismm09/topo_wst.cc ___________________________________________________________________ Added: svn:mergeinfo Index: theo/esiee/laurent/ismm09/main.cc --- theo/esiee/laurent/ismm09/main.cc (revision 3287) +++ theo/esiee/laurent/ismm09/main.cc (working copy) @@ -47,9 +47,6 @@ mln_VAR(g, cplx2d::f_to_g(f) ); debug::println("g:", g); - typedef mln_value_(g_t) T; // <--- Type of edge values. - typedef mln_psite_(g_t) E; // <--- Type of edges. - // w: watershed labeling on edges. @@ -109,5 +106,4 @@ // -> pseudo-tree compute_pseudo_tree(w, g, ls, a, e_to_l1_l2); - }