
From: Maxime van Noppen <yabo@lrde.epita.fr> To: olena-patches@lrde.epita.fr Subject: r2757: Merge the filter chain URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox ChangeLog: 2008-11-01 Maxime van Noppen <yabo@lrde.epita.fr> Merge the filter chain. * max_tree.hh: Add a new_parent image to avoid computing them all * the time. * v2.cc: Define a filter chain order. --- max_tree.hh | 28 ++++++++++++++++++++-------- v2.cc | 21 ++++++++++++++++----- 2 files changed, 36 insertions(+), 13 deletions(-) Index: branches/cleanup-2008/milena/sandbox/classif/max_tree.hh =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2756) +++ branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2757) @@ -34,6 +34,7 @@ S s; mln_ch_value(I, bool) deja_vu; mln_ch_value(I, point) parent; + mln_ch_value(I, point) new_parent; mln_ch_value(I, point) zpar; // image of volumes @@ -47,7 +48,7 @@ max_tree_(const I& f, const N& nbh) : f(f), nbh(nbh), vol(f.domain()), nb_represent(f.domain()), density(f.domain()), - is_active(f.domain()), mean_color(f.domain()) + is_active(f.domain()), mean_color(f.domain()), new_parent(f.domain()) { run(); level::fill(is_active, true); @@ -231,6 +232,23 @@ } } + point active_parent(const point& p) + { + point node = parent(p); + + while (not is_active(node) && not is_root(node)) + node = parent(node); + + return node; + } + + void update_parents() + { + mln_fwd_piter(S) p(s); + for_all(p) + new_parent(p) = active_parent(p); + } + template < typename J > void to_ppm(const J& ima, const std::string& file, unsigned f) { @@ -241,13 +259,7 @@ for_all(p) { point3d p3 = point3d(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f); - - point3d node = p3; - if (not is_node(p3)) - node = parent(p3); - - while (not is_active(node)) - node = parent(node); + point3d node = new_parent(p3); out(p) = value::rgb8(static_cast<unsigned char>(mean_color(node)[0] * f), static_cast<unsigned char>(mean_color(node)[1] * f), Index: branches/cleanup-2008/milena/sandbox/classif/v2.cc =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2756) +++ branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2757) @@ -45,18 +45,29 @@ { max_tree_<J,N> run(histo, nbh); - //run.number_of_nodes(); run.volume(); - run.volume_fusion(lambda); - run.density_fusion(ratio); + std::cout << "step 1 - nb_represent fusion" << std::endl; + //run.nb_represent_fusion(lambda); + std::cout << "step 2 - volume fusion" << std::endl; + //run.volume_fusion(lambda); + std::cout << "step 3 - color fusion" << std::endl; + //run.color_fusion(lambda); + std::cout << "step 3 - density fusion" << std::endl; + //run.density_fusion(ratio); + + std::cout << "step Update parents" << std::endl; + run.update_parents(); + + std::cout << "step Compute mean color" << std::endl; run.compute_mean_color(); - run.to_ppm(ima, "out.ppm", f); + std::cout << "step Print class info" << std::endl; run.print_class_info(); - //std::cout << " Number of nodes : " << run.number_of_nodes() << std::endl; + std::cout << "step Output image" << std::endl; + run.to_ppm(ima, "out.ppm", f); } bool usage(int argc, char ** argv)
participants (1)
-
Maxime van Noppen