---
scribo/sandbox/z/white_spaces/white_spaces.cc | 45 ++++++++++++++++----
.../scribo/primitive/group/from_double_link_any.hh | 20 +++++----
2 files changed, 48 insertions(+), 17 deletions(-)
diff --git a/scribo/sandbox/z/white_spaces/white_spaces.cc
b/scribo/sandbox/z/white_spaces/white_spaces.cc
index 54ef436..d32a631 100644
--- a/scribo/sandbox/z/white_spaces/white_spaces.cc
+++ b/scribo/sandbox/z/white_spaces/white_spaces.cc
@@ -59,8 +59,6 @@
#include <scribo/primitive/group/from_double_link_any.hh>
-#include <scribo/primitive/group/from_single_link.hh>
-
#include <scribo/filter/object_links_top_aligned.hh>
#include <scribo/filter/object_groups_small.hh>
#include <scribo/filter/object_links_bottom_aligned.hh>
@@ -411,6 +409,17 @@ int main(int argc, char *argv[])
gt.start();
+
+ // Remove horizontal lines.
+ t.restart();
+
+ image2d<bool> hlines = primitive::extract::lines_h_pattern(input, 50, 3);
+ input = primitive::remove::separators(input, hlines);
+
+ t_ = t;
+ std::cout << "Horizontal lines removed - " << t_ <<
std::endl;
+
+
// Closing structural - Connect characters.
t.restart();
@@ -832,12 +841,32 @@ int main(int argc, char *argv[])
io::pbm::save(output, "separators_hom.pbm");
io::pbm::save(separators, "separators_filtered.pbm");
}
- }
- t_ = t;
- std::cout << "Separator image - " << t_ << std::endl;
+ t.restart();
+ value::int_u16 ncomps;
+ component_set<L> comps = primitive::extract::components(output, c8(), ncomps);
+ image2d<value::rgb8> both;
+
+ both = data::convert(value::rgb8(), input);
+
+ // Needed since the rotated image origin is (0,0). Rotation does
+ // not preserve rotated coordinates.
+ dpoint2d dp(input.domain().pcenter() - input_clo.domain().pcenter());
+
+ for_all_comps(c, comps)
+ {
+ box2d b = geom::rotate(comps(c).bbox(), -90, input_clo.domain().pcenter());
+ mln::draw::line(both,
+ b.pmin() + dp,
+ b.pmax() + dp,
+ literal::green);
+ }
+ t_ = t;
+ std::cout << "Output image - " << t_ << std::endl;
+ gt.stop();
+ t_ = gt;
+ std::cout << "Total time: " << t_ << std::endl;
- gt.stop();
- t_ = gt;
- std::cout << "Total time: " << t_ << std::endl;
+ io::ppm::save(both, argv[5]);
+ }
}
diff --git a/scribo/scribo/primitive/group/from_double_link_any.hh
b/scribo/scribo/primitive/group/from_double_link_any.hh
index b3bd82a..300ecd6 100644
--- a/scribo/scribo/primitive/group/from_double_link_any.hh
+++ b/scribo/scribo/primitive/group/from_double_link_any.hh
@@ -98,16 +98,18 @@ namespace scribo
else
parent(pi) = pli;
}
-
- pi = internal::find_root(parent, i);
- unsigned pri = internal::find_root(parent, right_link(i));
-
- if (pi != pri)
+ else
{
- if (pri < pi)
- parent(pri) = pi;
- else
- parent(pi) = pri;
+ pi = internal::find_root(parent, i);
+ unsigned pri = internal::find_root(parent, right_link(i));
+
+ if (pi != pri)
+ {
+ if (pri < pi)
+ parent(pri) = pi;
+ else
+ parent(pi) = pri;
+ }
}
}
--
1.5.6.5
Show replies by date