From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: olena-patches(a)lrde.epita.fr
Subject: r2753: Add some debug infos and some filters on max trees
URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-11-01 Maxime van Noppen <yabo(a)lrde.epita.fr>
Add some debug infos and some filters on max trees.
* max_tree.hh,
* v2.cc: Here.
---
max_tree.hh | 40 ++++++++++++++++++++++++++++++++++------
v2.cc | 2 +-
2 files changed, 35 insertions(+), 7 deletions(-)
Index: branches/cleanup-2008/milena/sandbox/classif/max_tree.hh
===================================================================
--- branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2752)
+++ branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2753)
@@ -156,9 +156,14 @@
for_all(p)
mean_color(parent(p)) = (mean_color(parent(p)) + mean_color(p)) / 2.;
+
+ for_all(p)
+ if (mean_color(p)[0] < 10 && mean_color(p)[1] < 10 &&
mean_color(p)[2] < 10)
+ std::cerr << "Warning " << p << " == " <<
mean_color(p) << std::endl;
}
- void simple_filter_1(int lambda)
+ // Cut components with less represents than lambda
+ void volume_fusion(int lambda)
{
level::fill(is_active, true);
@@ -170,6 +175,18 @@
}
}
+ void nb_represent_fusion(int lambda)
+ {
+ level::fill(is_active, true);
+
+ mln_fwd_piter(S) p(s);
+ for_all(p)
+ {
+ if (nb_represent(p) < lambda)
+ is_active(p) = false;
+ }
+ }
+
template < typename J >
void to_ppm(const J& ima, const std::string& file, unsigned f)
{
@@ -183,12 +200,7 @@
point3d node = p3;
if (not is_node(p3))
- {
- if (is_active(parent(p3)))
- goto write;
-
node = parent(p3);
- }
while (not is_active(node))
node = parent(node);
@@ -219,6 +231,22 @@
return s.nsites();
}
+ void print_class_info()
+ {
+ int nb_class = 0;
+
+ mln_fwd_piter(S) p(s);
+
+ for_all(p)
+ {
+ if (is_active(p))
+ {
+ std::cout << "Class " << nb_class << " : "
<< p << std::endl;
+ ++nb_class;
+ }
+ }
+ }
+
bool is_root(const point& p) const
{
return parent(p) == p;
Index: branches/cleanup-2008/milena/sandbox/classif/v2.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2752)
+++ branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2753)
@@ -62,7 +62,7 @@
//run.number_of_nodes();
run.volume();
- run.simple_filter_1(lambda);
+ run.nb_represent_fusion(lambda);
run.compute_mean_color();
run.to_ppm(ima, "out.ppm", f);