last-svn-commit-884-g12da563 2011-05-24 Coddy Levi <levi@lrde.epita.fr>

Further correction of the component outlining bug. * scribo/util/component_outline.hh: Here. --- scribo/ChangeLog | 8 +++++++- scribo/scribo/util/component_outline.hh | 29 +++++++++++++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 9fd4e5e..034f2c4 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,9 @@ +2011-05-24 Coddy Levi <levi@lrde.epita.fr> + + Further correction of the component outlining bug. + + * scribo/util/component_outline.hh: Here. + 2011-05-19 Guillaume Lazzara <z@lrde.epita.fr> Improve results. @@ -42,7 +48,7 @@ * tests/filter/Makefile.am, * tests/util/Makefile.am: Add new targets. - * tests/filter/objects_on_border.cc, +v * tests/filter/objects_on_border.cc, * tests/util/component_outline.cc: New. * tests/img/comp_on_borders.pbm, diff --git a/scribo/scribo/util/component_outline.hh b/scribo/scribo/util/component_outline.hh index ea2f61f..6870755 100644 --- a/scribo/scribo/util/component_outline.hh +++ b/scribo/scribo/util/component_outline.hh @@ -209,10 +209,11 @@ namespace scribo find_farthest(const I& ima, const mln::point2d& begin, const mln::point2d& end, - float precision) + float precision, + int* nb) { float d = 0.; - float dmax = 0.; + float dmax = -1.; e_dir dir = find_first_dir(ima, begin); float a = end[1] - begin[1]; @@ -229,6 +230,8 @@ namespace scribo while (cur != end) { + if (nb != NULL) + (*nb)++; old = cur; cur = next_pt_in_contour(ima, cur, &dir); @@ -237,7 +240,7 @@ namespace scribo if (d < 0) d = -d; - if (d > dmax) + if (d >= dmax) { dmax = d; max = cur; @@ -245,7 +248,7 @@ namespace scribo } - if (dmax > precision * norm) + if (dmax >= precision * norm) return max; else return begin; @@ -261,16 +264,22 @@ namespace scribo mln::p_array<mln::point2d>& l, float precision) { - mln::point2d node = find_farthest(ima, begin, end, precision); + int nb = 0; + mln::point2d node = find_farthest(ima, begin, end, precision, &nb); + int nb_old = nb; if (node != begin) { - if (find_farthest(ima, begin, node, precision) != end) + nb = 0; + mln::point2d test_left = find_farthest(ima, begin, node, precision, &nb); + if ((test_left != end) && (test_left != begin) && (nb_old > nb)) split_rec(ima, begin, node, l, precision); l.append(node); - if (find_farthest(ima, node, end, precision) != begin) + nb = 0; + mln::point2d test_right = find_farthest(ima, node, end, precision, &nb); + if ((test_right != begin) && (test_right != end) && (nb_old > nb)) split_rec(ima, node, end, l, precision); } @@ -287,7 +296,7 @@ namespace scribo { mln::point2d node; - node = find_farthest(ima, begin, end, precision); + node = find_farthest(ima, begin, end, precision, NULL); l.append(begin); @@ -302,7 +311,7 @@ namespace scribo l.append(end); - node = find_farthest(ima, end, begin, precision); + node = find_farthest(ima, end, begin, precision, NULL); if (node != end) { @@ -362,7 +371,7 @@ namespace scribo std::pair<mln::point2d, mln::point2d> initials = internal::get_initials(ima); - std::cout << " - " << initials.first << " - " << initials.second << std::endl; + std::cout << " - " << initials.first << " - " << initials.first << std::endl; internal::split(ima, initials.first, -- 1.5.6.5

Coddy Levi <levi@lrde.epita.fr> writes: [...]
--- a/scribo/ChangeLog +++ b/scribo/ChangeLog
[...]
@@ -42,7 +48,7 @@ * tests/filter/Makefile.am, * tests/util/Makefile.am: Add new targets.
- * tests/filter/objects_on_border.cc, +v * tests/filter/objects_on_border.cc, * tests/util/component_outline.cc: New.
* tests/img/comp_on_borders.pbm,
Careful. You should reread your patches before pushing them. :)
diff --git a/scribo/scribo/util/component_outline.hh b/scribo/scribo/util/component_outline.hh index ea2f61f..6870755 100644 --- a/scribo/scribo/util/component_outline.hh +++ b/scribo/scribo/util/component_outline.hh @@ -209,10 +209,11 @@ namespace scribo find_farthest(const I& ima, const mln::point2d& begin, const mln::point2d& end, - float precision) + float precision, + int* nb) { float d = 0.; - float dmax = 0.; + float dmax = -1.; e_dir dir = find_first_dir(ima, begin);
float a = end[1] - begin[1]; @@ -229,6 +230,8 @@ namespace scribo
while (cur != end) { + if (nb != NULL) + (*nb)++;
« NULL » is a C term. In C++, you should use « 0 » (and when the next standard is published, « nullptr »). [...]
@@ -287,7 +296,7 @@ namespace scribo { mln::point2d node;
- node = find_farthest(ima, begin, end, precision); + node = find_farthest(ima, begin, end, precision, NULL);
l.append(begin);
@@ -302,7 +311,7 @@ namespace scribo
l.append(end);
- node = find_farthest(ima, end, begin, precision); + node = find_farthest(ima, end, begin, precision, NULL);
if (node != end) {
Likewise.
@@ -362,7 +371,7 @@ namespace scribo std::pair<mln::point2d, mln::point2d> initials = internal::get_initials(ima);
- std::cout << " - " << initials.first << " - " << initials.second << std::endl; + std::cout << " - " << initials.first << " - " << initials.first << std::endl;
Please try to keep lines within 80 columns. Thanks in advance.
participants (2)
-
Coddy Levi
-
Roland Levillain