Commit 3151875d authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

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.
parent 74ae8cb3
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> 2009-12-14 Guillaume Lazzara <z@lrde.epita.fr>
Cleanup Sauvola's binarization code. Cleanup Sauvola's binarization code.
......
...@@ -102,7 +102,7 @@ namespace scribo ...@@ -102,7 +102,7 @@ namespace scribo
object_links<L> object_links<L>
output = object_links_non_aligned_simple(objects, links, output = object_links_non_aligned_simple(objects, links,
1, max_alpha); 2, max_alpha);
trace::exiting("scribo::filter::object_links_bottom_aligned"); trace::exiting("scribo::filter::object_links_bottom_aligned");
return output; return output;
......
...@@ -95,7 +95,7 @@ namespace scribo ...@@ -95,7 +95,7 @@ namespace scribo
object_links<L> object_links<L>
output = object_links_non_aligned_simple(objects, links, output = object_links_non_aligned_simple(objects, links,
2, max_alpha); 0, max_alpha);
trace::exiting("scribo::filter::object_links_center_aligned"); trace::exiting("scribo::filter::object_links_center_aligned");
return output; return output;
......
...@@ -81,9 +81,9 @@ namespace scribo ...@@ -81,9 +81,9 @@ namespace scribo
The angle between the two bottoms must be lower than \p alpha. The angle between the two bottoms must be lower than \p alpha.
edge values : edge values :
0 = top 0 = center
1 = bottom 1 = top
2 = center 2 = bottom
*/ */
template <typename L> template <typename L>
...@@ -117,44 +117,47 @@ namespace scribo ...@@ -117,44 +117,47 @@ namespace scribo
float max_alpha_rad = (max_alpha / 180.0f) * math::pi; float max_alpha_rad = (max_alpha / 180.0f) * math::pi;
// Top // Center
if (edge == 0) if (edge == 0)
{ {
for_all_components(i, objects.bboxes()) for_all_components(i, objects.bboxes())
{
if (links[i] != i) if (links[i] != i)
{ {
dr = math::abs(bboxes[i].pmin().row() dr = math::abs(bboxes[i].center().row()
- bboxes[links[i]].pmin().row()); - bboxes[links[i]].center().row());
dc = math::abs(bboxes[i].center().col() dc = math::abs(bboxes[i].center().col()
- bboxes[links[i]].center().col()); - bboxes[links[i]].center().col());
if (std::atan(dr / dc) > max_alpha_rad) if (std::atan(dr / dc) > max_alpha_rad)
output[i] = i; output[i] = i;
} }
}
} }
// Bottom // Top
else if (edge == 1) else if (edge == 1)
{
for_all_components(i, objects.bboxes()) for_all_components(i, objects.bboxes())
{
if (links[i] != i) if (links[i] != i)
{ {
dr = math::abs(bboxes[i].pmax().row() dr = math::abs(bboxes[i].pmin().row()
- bboxes[links[i]].pmax().row()); - bboxes[links[i]].pmin().row());
dc = math::abs(bboxes[i].center().col() dc = math::abs(bboxes[i].center().col()
- bboxes[links[i]].center().col()); - bboxes[links[i]].center().col());
if (std::atan(dr / dc) > max_alpha_rad) if (std::atan(dr / dc) > max_alpha_rad)
output[i] = i; output[i] = i;
} }
} }
// Center // Bottom
else if (edge == 2) else if (edge == 2)
{
for_all_components(i, objects.bboxes()) for_all_components(i, objects.bboxes())
{ {
if (links[i] != i) if (links[i] != i)
{ {
dr = math::abs(bboxes[i].center().row() dr = math::abs(bboxes[i].pmax().row()
- bboxes[links[i]].center().row()); - bboxes[links[i]].pmax().row());
dc = math::abs(bboxes[i].center().col() dc = math::abs(bboxes[i].center().col()
- bboxes[links[i]].center().col()); - bboxes[links[i]].center().col());
...@@ -162,6 +165,7 @@ namespace scribo ...@@ -162,6 +165,7 @@ namespace scribo
output[i] = i; output[i] = i;
} }
} }
}
else else
{ {
trace::warning("Invalid edge value... Aborting computation."); trace::warning("Invalid edge value... Aborting computation.");
......
...@@ -102,7 +102,7 @@ namespace scribo ...@@ -102,7 +102,7 @@ namespace scribo
object_links<L> object_links<L>
output = object_links_non_aligned_simple(objects, links, output = object_links_non_aligned_simple(objects, links,
0, 1,
max_alpha); max_alpha);
trace::exiting("scribo::filter::object_links_top_aligned"); trace::exiting("scribo::filter::object_links_top_aligned");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment