3356: Cleanup pseudo-tree computation.

https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Cleanup pseudo-tree computation. * theo/esiee/laurent/ismm09/pseudo_tree.hh (compute_pseudo_tree): Move lca stuff.. (compute_lca): ...this new routine. Update pseudo_tree.hh | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) Index: theo/esiee/laurent/ismm09/pseudo_tree.hh --- theo/esiee/laurent/ismm09/pseudo_tree.hh (revision 3355) +++ theo/esiee/laurent/ismm09/pseudo_tree.hh (working copy) @@ -18,6 +18,8 @@ #include <mln/value/int_u8.hh> #include <mln/io/pgm/save.hh> #include <mln/level/stretch.hh> +#include <mln/level/compute.hh> +#include <mln/accu/max.hh> @@ -177,6 +179,20 @@ } + template <typename I, typename E, typename L> + lca_t<L, mln_ch_value(I, std::vector<mln_psite(I)>), E> + compute_lca(const I& epar, const util::array<E>& edge, L l_max) + { + std::vector<E> roots; + mln_VAR(chl, compute_children(epar, edge, l_max, roots)); + + // Connected domain so: + mln_invariant(roots.size() == 1); + E root = roots[0]; // THE root. + + lca_t<L,chl_t,E> lca(l_max, chl, roots); + return lca; + } // ################################################################### @@ -500,24 +516,9 @@ // Finalization. - A aa_max = mln_min(A); - - { - mln_VAR(aa_ext, aa.unmorph_().unmorph_()); - - - debug::println("aa ext (1):", aa_ext); + mln_VAR(lca, compute_lca(epar, edge, l_max)); - std::vector<E> roots; - mln_VAR(chl, compute_children(epar, edge, l_max, roots)); - - // Connected domain so: - mln_invariant(roots.size() == 1); - E root = roots[0]; // THE root. - - lca_t<L,chl_t,E> lca(l_max, chl, roots); - mln_piter(g_line_t) e(g_line.domain()); for_all(e) { @@ -532,14 +533,9 @@ // The attribute value propagates from the lca to the current edge // of the line: aa(e) = aa(e_); - if (aa(e) > aa_max) - aa_max = aa(e); } - debug::println("aa:", aa); - - debug::println("aa ext (2):", aa_ext); - + mln_VAR(aa_ext, aa.unmorph_().unmorph_()); { mln_VAR( aa_line, aa_ext | (pw::value(w) == 0) ); @@ -547,12 +543,15 @@ aa_line), c4().win()), aa_line); + debug::println("aa ext:", aa_ext); } - debug::println("aa ext (3):", aa_ext); + // Outputing. + { + A aa_max = level::compute(accu::max<A>(), aa); using value::int_u8; if (aa_max < 256) { @@ -585,9 +584,7 @@ // } -// debug::println("aa ext (4):", aa_ext); - - } +// debug::println("aa ext with basins:", aa_ext); }
participants (1)
-
Thierry Geraud