last-svn-commit-27-g0686d02 Fix object links filters.

* filter/object_links_bottom_aligned.hh, * filter/object_links_center_aligned.hh, * filter/object_links_non_aligned_simple.hh, * filter/object_links_top_aligned.hh: Pass the proper dimension as routine argument. --- scribo/ChangeLog | 11 +++++++ scribo/filter/object_links_bottom_aligned.hh | 2 +- scribo/filter/object_links_center_aligned.hh | 2 +- scribo/filter/object_links_non_aligned_simple.hh | 32 ++++++++++++--------- scribo/filter/object_links_top_aligned.hh | 2 +- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 8488ae3..dfbf01a 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,16 @@ 2009-12-14 Guillaume Lazzara <z@lrde.epita.fr> + Fix object links filters. + + * filter/object_links_bottom_aligned.hh, + * filter/object_links_center_aligned.hh, + * filter/object_links_non_aligned_simple.hh, + * filter/object_links_top_aligned.hh: Pass the proper dimension as + routine argument. + + +2009-12-14 Guillaume Lazzara <z@lrde.epita.fr> + Cleanup Sauvola's binarization code. * binarization/sauvola_threshold.hh, diff --git a/scribo/filter/object_links_bottom_aligned.hh b/scribo/filter/object_links_bottom_aligned.hh index d950a6e..1afebf7 100644 --- a/scribo/filter/object_links_bottom_aligned.hh +++ b/scribo/filter/object_links_bottom_aligned.hh @@ -102,7 +102,7 @@ namespace scribo object_links<L> output = object_links_non_aligned_simple(objects, links, - 1, max_alpha); + 2, max_alpha); trace::exiting("scribo::filter::object_links_bottom_aligned"); return output; diff --git a/scribo/filter/object_links_center_aligned.hh b/scribo/filter/object_links_center_aligned.hh index e44f3cd..abbac9e 100644 --- a/scribo/filter/object_links_center_aligned.hh +++ b/scribo/filter/object_links_center_aligned.hh @@ -95,7 +95,7 @@ namespace scribo object_links<L> output = object_links_non_aligned_simple(objects, links, - 2, max_alpha); + 0, max_alpha); trace::exiting("scribo::filter::object_links_center_aligned"); return output; diff --git a/scribo/filter/object_links_non_aligned_simple.hh b/scribo/filter/object_links_non_aligned_simple.hh index 032b4d0..706497d 100644 --- a/scribo/filter/object_links_non_aligned_simple.hh +++ b/scribo/filter/object_links_non_aligned_simple.hh @@ -81,9 +81,9 @@ namespace scribo The angle between the two bottoms must be lower than \p alpha. edge values : - 0 = top - 1 = bottom - 2 = center + 0 = center + 1 = top + 2 = bottom */ template <typename L> @@ -117,44 +117,47 @@ namespace scribo float max_alpha_rad = (max_alpha / 180.0f) * math::pi; - // Top + // Center if (edge == 0) { for_all_components(i, objects.bboxes()) + { if (links[i] != i) { - dr = math::abs(bboxes[i].pmin().row() - - bboxes[links[i]].pmin().row()); + dr = math::abs(bboxes[i].center().row() + - bboxes[links[i]].center().row()); dc = math::abs(bboxes[i].center().col() - bboxes[links[i]].center().col()); if (std::atan(dr / dc) > max_alpha_rad) output[i] = i; } + } } - // Bottom + // Top else if (edge == 1) + { for_all_components(i, objects.bboxes()) - { if (links[i] != i) { - dr = math::abs(bboxes[i].pmax().row() - - bboxes[links[i]].pmax().row()); + dr = math::abs(bboxes[i].pmin().row() + - bboxes[links[i]].pmin().row()); dc = math::abs(bboxes[i].center().col() - bboxes[links[i]].center().col()); if (std::atan(dr / dc) > max_alpha_rad) output[i] = i; } - } - // Center + } + // Bottom else if (edge == 2) + { for_all_components(i, objects.bboxes()) { if (links[i] != i) { - dr = math::abs(bboxes[i].center().row() - - bboxes[links[i]].center().row()); + dr = math::abs(bboxes[i].pmax().row() + - bboxes[links[i]].pmax().row()); dc = math::abs(bboxes[i].center().col() - bboxes[links[i]].center().col()); @@ -162,6 +165,7 @@ namespace scribo output[i] = i; } } + } else { trace::warning("Invalid edge value... Aborting computation."); diff --git a/scribo/filter/object_links_top_aligned.hh b/scribo/filter/object_links_top_aligned.hh index 47e26c8..4a92c96 100644 --- a/scribo/filter/object_links_top_aligned.hh +++ b/scribo/filter/object_links_top_aligned.hh @@ -102,7 +102,7 @@ namespace scribo object_links<L> output = object_links_non_aligned_simple(objects, links, - 0, + 1, max_alpha); trace::exiting("scribo::filter::object_links_top_aligned"); -- 1.5.6.5
participants (1)
-
Guillaume Lazzara