
From: Maxime van Noppen <yabo@lrde.epita.fr> To: olena-patches@lrde.epita.fr Subject: r2754: Allow to chain filters URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox ChangeLog: 2008-11-01 Maxime van Noppen <yabo@lrde.epita.fr> Allow to chain filters. * max_tree.hh: Here. * v2.cc: Chain filters. --- max_tree.hh | 24 +++++++++++++++++++----- v2.cc | 5 +++++ 2 files changed, 24 insertions(+), 5 deletions(-) Index: branches/cleanup-2008/milena/sandbox/classif/max_tree.hh =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2753) +++ branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2754) @@ -50,6 +50,7 @@ is_active(f.domain()), mean_color(f.domain()) { run(); + level::fill(is_active, true); } void run() @@ -165,8 +166,6 @@ // Cut components with less represents than lambda void volume_fusion(int lambda) { - level::fill(is_active, true); - mln_fwd_piter(S) p(s); for_all(p) { @@ -177,8 +176,6 @@ void nb_represent_fusion(int lambda) { - level::fill(is_active, true); - mln_fwd_piter(S) p(s); for_all(p) { @@ -187,6 +184,18 @@ } } + void color_fusion(int lambda) + { + mln_fwd_piter(S) p(s); + for_all(p) + { + if (parent(p)[0] - p[0] < lambda && + parent(p)[1] - p[1] < lambda && + parent(p)[2] - p[2] < lambda) + is_active(p) = false; + } + } + template < typename J > void to_ppm(const J& ima, const std::string& file, unsigned f) { @@ -237,11 +246,16 @@ mln_fwd_piter(S) p(s); + //std::cout.width(5); + std::cout.precision(2); + + std::cout << "Color\t\tId\t\tdensity\t\tvolume\t\tnb_represent" << std::endl; + for_all(p) { if (is_active(p)) { - std::cout << "Class " << nb_class << " : " << p << std::endl; + std::cout << mean_color(p) << "\t\t" << nb_class << "\t\t" << density(p) << "\t\t" << vol(p) << "\t\t" << nb_represent(p) << std::endl; ++nb_class; } } Index: branches/cleanup-2008/milena/sandbox/classif/v2.cc =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2753) +++ branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2754) @@ -62,8 +62,13 @@ //run.number_of_nodes(); run.volume(); + run.nb_represent_fusion(lambda); + run.volume_fusion(lambda); + run.color_fusion(5); + run.compute_mean_color(); + run.print_class_info(); run.to_ppm(ima, "out.ppm", f); //std::cout << " Number of nodes : " << run.number_of_nodes() << std::endl;