Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
March 2011
- 7 participants
- 277 discussions
last-svn-commit-773-gb084bec Improve and cleanup whitespace separator detection.
by Guillaume Lazzara 29 Mar '11
by Guillaume Lazzara 29 Mar '11
29 Mar '11
* scribo/core/tag/anchor.hh: Add new anchors.
* scribo/filter/internal/alignment_angle.hh,
* scribo/primitive/link/internal/compute_anchor.hh: Support new
anchors.
* scribo/primitive/extract/separators_nonvisible.hh: Remove dead
code and comment debug code.
* scribo/toolchain/internal/content_in_doc_functor.hh: Detect
horizontal whitespace.
---
scribo/ChangeLog | 16 +
scribo/scribo/core/tag/anchor.hh | 5 +-
scribo/scribo/filter/internal/alignment_angle.hh | 144 +++--
.../primitive/extract/separators_nonvisible.hh | 673 +++++++++-----------
.../primitive/link/internal/compute_anchor.hh | 26 +-
.../toolchain/internal/content_in_doc_functor.hh | 13 +-
6 files changed, 447 insertions(+), 430 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index f03eb97..001e134 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,21 @@
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Improve and cleanup whitespace separator detection.
+
+ * scribo/core/tag/anchor.hh: Add new anchors.
+
+ * scribo/filter/internal/alignment_angle.hh,
+ * scribo/primitive/link/internal/compute_anchor.hh: Support new
+ anchors.
+
+ * scribo/primitive/extract/separators_nonvisible.hh: Remove dead
+ code and comment debug code.
+
+ * scribo/toolchain/internal/content_in_doc_functor.hh: Detect
+ horizontal whitespace.
+
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add new conversion routines from string to tag.
* scribo/core/tag/component.hh,
diff --git a/scribo/scribo/core/tag/anchor.hh b/scribo/scribo/core/tag/anchor.hh
index 262a32d..bb6780c 100644
--- a/scribo/scribo/core/tag/anchor.hh
+++ b/scribo/scribo/core/tag/anchor.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -43,9 +44,11 @@ namespace scribo
ActualRight,
Right,
TopLeft,
+ TopStrictLeft,
TopRight,
BottomLeft,
BottomRight,
+ BottomStrictRight,
Invalid
};
diff --git a/scribo/scribo/filter/internal/alignment_angle.hh b/scribo/scribo/filter/internal/alignment_angle.hh
index 5b88012..33855a8 100644
--- a/scribo/scribo/filter/internal/alignment_angle.hh
+++ b/scribo/scribo/filter/internal/alignment_angle.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory
+// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
@@ -73,76 +73,98 @@ namespace scribo
unsigned current_object, unsigned nbh_object,
anchor::Type anchor)
{
- trace::entering("scribo::filter::internal::alignment_angle_rad");
+ trace::entering("scribo::filter::internal::alignment_angle");
mln_precondition(comps.is_valid());
- float dr, dc;
+ float dr, dc, result = 0;
if (nbh_object == current_object)
return 0;
- // Center
- if (anchor == anchor::Center)
+ switch(anchor)
{
- dr = math::abs(comps(current_object).bbox().pcenter().row()
- - comps(nbh_object).bbox().pcenter().row());
- dc = math::abs(comps(current_object).bbox().pcenter().col()
- - comps(nbh_object).bbox().pcenter().col());
-
- return std::atan(dr / dc);
- }
-
- // Top
- else if (anchor == anchor::Top)
- {
- dr = math::abs(comps(current_object).bbox().pmin().row()
- - comps(nbh_object).bbox().pmin().row());
- dc = math::abs(comps(current_object).bbox().pcenter().col()
- - comps(nbh_object).bbox().pcenter().col());
-
- return std::atan(dr / dc);
+ // Center
+ case anchor::Center:
+ {
+ dr = math::abs(comps(current_object).bbox().pcenter().row()
+ - comps(nbh_object).bbox().pcenter().row());
+ dc = math::abs(comps(current_object).bbox().pcenter().col()
+ - comps(nbh_object).bbox().pcenter().col());
+
+ result = std::atan(dr / dc);
+ }
+ break;
+
+ // Mass Center
+ case anchor::MassCenter:
+ {
+ dr = math::abs(comps(current_object).mass_center().row()
+ - comps(nbh_object).mass_center().row());
+ dc = math::abs(comps(current_object).mass_center().col()
+ - comps(nbh_object).mass_center().col());
+
+ result = std::atan(dr / dc);
+ }
+ break;
+
+ // Top
+ case anchor::TopStrictLeft:
+ case anchor::Top:
+ {
+ dr = math::abs(comps(current_object).bbox().pmin().row()
+ - comps(nbh_object).bbox().pmin().row());
+ dc = math::abs(comps(current_object).bbox().pcenter().col()
+ - comps(nbh_object).bbox().pcenter().col());
+
+ result = std::atan(dr / dc);
+ }
+ break;
+
+ // Bottom
+ case anchor::BottomStrictRight:
+ case anchor::Bottom:
+ {
+ dr = math::abs(comps(current_object).bbox().pmax().row()
+ - comps(nbh_object).bbox().pmax().row());
+ dc = math::abs(comps(current_object).bbox().pcenter().col()
+ - comps(nbh_object).bbox().pcenter().col());
+
+ result = std::atan(dr / dc);
+ }
+ break;
+
+ // Left
+ case anchor::Left:
+ {
+ dr = math::abs(comps(current_object).bbox().pcenter().row()
+ - comps(nbh_object).bbox().pcenter().row());
+ dc = math::abs(comps(current_object).bbox().pmin().col()
+ - comps(nbh_object).bbox().pmin().col());
+
+ result = std::atan(dc / dr);
+ }
+ break;
+
+ // Right
+ case anchor::Right:
+ {
+ dr = math::abs(comps(current_object).bbox().pcenter().row()
+ - comps(nbh_object).bbox().pcenter().row());
+ dc = math::abs(comps(current_object).bbox().pmax().col()
+ - comps(nbh_object).bbox().pmax().col());
+
+ result = std::atan(dc / dr);
+ }
+ break;
+
+ default:
+ trace::warning("scribo::filter::internal::alignment_angle,"
+ " Invalid anchor value... Aborting computation.");
}
- // Bottom
- else if (anchor == anchor::Bottom)
- {
- dr = math::abs(comps(current_object).bbox().pmax().row()
- - comps(nbh_object).bbox().pmax().row());
- dc = math::abs(comps(current_object).bbox().pcenter().col()
- - comps(nbh_object).bbox().pcenter().col());
-
- return std::atan(dr / dc);
- }
-
- // Left
- else if (anchor == anchor::Left)
- {
- dr = math::abs(comps(current_object).bbox().pcenter().row()
- - comps(nbh_object).bbox().pcenter().row());
- dc = math::abs(comps(current_object).bbox().pmin().col()
- - comps(nbh_object).bbox().pmin().col());
-
- return std::atan(dc / dr);
- }
-
- // Right
- else if (anchor == anchor::Right)
- {
- dr = math::abs(comps(current_object).bbox().pcenter().row()
- - comps(nbh_object).bbox().pcenter().row());
- dc = math::abs(comps(current_object).bbox().pmax().col()
- - comps(nbh_object).bbox().pmax().col());
-
- return std::atan(dc / dr);
- }
-
- else
- trace::warning("Invalid anchor value... Aborting computation.");
-
- trace::exiting("scribo::filter::internal::alignment_angle_rad");
- return 0;
-
+ trace::exiting("scribo::filter::internal::alignment_angle");
+ return result;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/scribo/primitive/extract/separators_nonvisible.hh b/scribo/scribo/primitive/extract/separators_nonvisible.hh
index 81ebd64..4e31650 100644
--- a/scribo/scribo/primitive/extract/separators_nonvisible.hh
+++ b/scribo/scribo/primitive/extract/separators_nonvisible.hh
@@ -86,6 +86,8 @@
#include <scribo/preprocessing/denoise_fg.hh>
#include <scribo/preprocessing/rotate_90.hh>
+#include <scribo/primitive/link/internal/compute_anchor.hh>
+
#include <scribo/primitive/link/internal/dmax_default.hh>
#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
@@ -128,80 +130,6 @@ namespace scribo
namespace internal
{
- template <typename L>
- void filter_bad_groups(object_groups<L>& top_groups,
- object_groups<L>& bot_groups)
- {
- const component_set<L>& comps = top_groups.components();
- const L& lbl = comps.labeled_image();
-
- for_all_groups(c, top_groups)
- {
- box2d b = comps(c).bbox();
- b.enlarge(0, comps(c).bbox().height());
- b.crop_wrt(lbl.domain());
-
- typedef mln_value(L) V;
-
- const V* top_ptr = & lbl(b.pmin());
- const V* bot_ptr = & lbl(point2d(b.pmax().row(), b.pmin().col()));
-
- unsigned ntop = 0, nbot = 0;
- for (unsigned n = 0; n < b.width(); ++n)
- {
- if (*top_ptr)
- ++ntop;
- if (*bot_ptr)
- ++nbot;
- }
-
- if (ntop / b.width() > 0.50f)
- top_groups(c) = c;
-
- if (nbot / b.width() > 0.50f)
- bot_groups(c) = c;
- }
-
- }
-
-
- template <typename L>
- mln_site(L)
- my_anchors(const component_set<L>& comps,
- unsigned current_object,
- anchor::Type anchor)
- {
- mln_site(L) sp;// = comps(current_object).bbox().pcenter();
-
- unsigned h = comps(current_object).bbox().height();
-
- switch (anchor)
- {
- default:
- return sp;
-
-
- // Bounding box top center
- case anchor::Top: // FIXME: rename as TopLeft
- sp.col() = comps(current_object).bbox().pmin().col();
- sp.row() = comps(current_object).bbox().pmin().row()
- + math::min(2u, (h + 1) / 2 - 1);
- break;
-
-
- // Bounding box bottom center
- case anchor::Bottom: // FIXME: rename as BottomLeft
- sp.col() = comps(current_object).bbox().pmax().col();
- sp.row() = comps(current_object).bbox().pmax().row()
- - math::min(2u, (h + 1) / 2 - 1);
- break;
- }
-
- return sp;
- }
-
-
-
using namespace primitive::link::internal;
template <typename L, typename E>
@@ -225,12 +153,17 @@ namespace scribo
anchor::Horizontal,
dmax_default(dmax)),
anchor(anchor_),
- debug_(data::convert(value::rgb8(), input)),
- debug_angle_(data::convert(value::rgb8(), input)),
_debug_(debug)
{
+ (void) input; // FIXME : remove this argument
min_alpha_rad = (min_angle / 180.0f) * math::pi;
max_alpha_rad = (max_angle / 180.0f) * math::pi;
+
+ // if (_debug_)
+ // {
+ // debug_ = data::convert(value::rgb8(), input);
+ // debug_angle_ = data::convert(value::rgb8(), input);
+ // }
}
void compute_next_site_(P& p)
@@ -247,7 +180,8 @@ namespace scribo
mln_site(L)
start_point_(unsigned current_object, anchor::Type anchor)
{
- return my_anchors(this->components_, current_object, anchor);
+ return link::internal::compute_anchor(this->components_,
+ current_object, anchor);
}
@@ -303,27 +237,29 @@ namespace scribo
{
super_::validate_link_(current_object, start_point, p, anchor);
- if (_debug_)
- {
- mln_site(L)
- p1 = my_anchors(this->components_, current_object, anchor),
- p2 = my_anchors(this->components_, this->labeled_image_(p),
- anchor);
- mln::draw::line(debug_, p1, p2, literal::green);
-
-
- float
- angle = filter::internal::alignment_angle(this->components_,
- current_object,
- this->labeled_image_(p),
- anchor);
- angle = (angle * 180.0f) / math::pi;
- angle = angle * 20.0f + 1.0f;
- mln::draw::line(debug_angle_, p1, p2,
- value::rgb8(unsigned(angle),
- unsigned(angle),
- unsigned(angle)));
- }
+ // if (_debug_)
+ // {
+ // mln_site(L)
+ // p1 = link::internal::compute_anchor(this->components_,
+ // current_object, anchor),
+ // p2 = link::internal::compute_anchor(this->components_,
+ // this->labeled_image_(p),
+ // anchor);
+ // mln::draw::line(debug_, p1, p2, literal::green);
+
+
+ // float
+ // angle = filter::internal::alignment_angle(this->components_,
+ // current_object,
+ // this->labeled_image_(p),
+ // anchor);
+ // angle = (angle * 180.0f) / math::pi;
+ // angle = angle * 20.0f + 1.0f;
+ // mln::draw::line(debug_angle_, p1, p2,
+ // value::rgb8(unsigned(angle),
+ // unsigned(angle),
+ // unsigned(angle)));
+ // }
}
void invalidate_link_(unsigned current_object,
@@ -333,33 +269,36 @@ namespace scribo
{
super_::invalidate_link_(current_object, start_point, p, anchor);
- if (_debug_)
- {
- if (this->labeled_image_.domain().has(p) && this->labeled_image_(p) != 0)
- {
- mln_site(L)
- p1 = my_anchors(this->components_, current_object, anchor),
- p2 = my_anchors(this->components_, this->labeled_image_(p),
- anchor);
- if (this->labeled_image_.domain().has(p2) && norm::l1_distance(p1.to_vec(), p2.to_vec()) < 300)
- {
- mln::draw::line(debug_, p1, p2, literal::red);
- }
-
-
- float
- angle = filter::internal::alignment_angle(this->components_,
- current_object,
- this->labeled_image_(p),
- anchor);
- angle = (angle * 180.0f) / math::pi;
- angle = angle * 20.0f + 1.0f;
- mln::draw::line(debug_angle_, p1, p2,
- value::rgb8(unsigned(angle),
- unsigned(angle),
- unsigned(angle)));
- }
- }
+ // if (_debug_)
+ // {
+ // if (this->labeled_image_.domain().has(p) && this->labeled_image_(p) != 0)
+ // {
+ // mln_site(L)
+ // p1 = link::internal::compute_anchor(this->components_,
+ // current_object, anchor),
+ // p2 = link::internal::compute_anchor(this->components_,
+ // this->labeled_image_(p),
+ // anchor);
+ // if (this->labeled_image_.domain().has(p2)
+ // && norm::l1_distance(p1.to_vec(), p2.to_vec()) < 300)
+ // {
+ // mln::draw::line(debug_, p1, p2, literal::red);
+ // }
+
+
+ // float
+ // angle = filter::internal::alignment_angle(this->components_,
+ // current_object,
+ // this->labeled_image_(p),
+ // anchor);
+ // angle = (angle * 180.0f) / math::pi;
+ // angle = angle * 20.0f + 1.0f;
+ // mln::draw::line(debug_angle_, p1, p2,
+ // value::rgb8(unsigned(angle),
+ // unsigned(angle),
+ // unsigned(angle)));
+ // }
+ // }
}
@@ -368,8 +307,8 @@ namespace scribo
anchor::Type anchor;
- mln_ch_value(L, value::rgb8) debug_;
- mln_ch_value(L, value::rgb8) debug_angle_;
+ // mln_ch_value(L, value::rgb8) debug_;
+ // mln_ch_value(L, value::rgb8) debug_angle_;
bool _debug_;
};
@@ -392,7 +331,8 @@ namespace scribo
float max_angle,
anchor::Type anchor,
bool debug)
- : super_(input, components, dmax, min_angle, max_angle, anchor, debug)
+ : super_(input, components, dmax, min_angle,
+ max_angle, anchor, debug)
{
}
@@ -427,7 +367,8 @@ namespace scribo
float max_angle,
anchor::Type anchor,
bool debug)
- : super_(input, components, dmax, min_angle, max_angle, anchor, debug)
+ : super_(input, components, dmax, min_angle,
+ max_angle, anchor, debug)
{
}
@@ -455,6 +396,8 @@ namespace scribo
mln_concrete(I)
separators_nonvisible(const Image<I>& in_)
{
+ trace::entering("scribo::primitive::extract::separators_nonvisible");
+
const I& in = exact(in_);
mln_precondition(in.is_valid());
typedef mln_value(I) Vi;
@@ -469,42 +412,35 @@ namespace scribo
util::timer t;
util::timer gt;
- // Load (OK)
- t.start();
- float t_ = t;
- std::cout << "Image loaded - " << t_ << std::endl;
-
gt.start();
- // Remove horizontal lines.
- t.restart();
+ // // Remove horizontal lines.
+ // t.restart();
- mln_concrete(I) hlines = primitive::extract::lines_h_pattern(in, 50, 3);
- mln_concrete(I) input = primitive::remove::separators(in, hlines);
+ // mln_concrete(I) hlines = primitive::extract::lines_h_pattern(in, 50, 3);
+ // mln_concrete(I) input = primitive::remove::separators(in, hlines);
- t_ = t;
- std::cout << "Horizontal lines removed - " << t_ << std::endl;
+ // t_ = t;
+ // std::cout << "Horizontal lines removed - " << t_ << std::endl;
// Closing structural - Connect characters.
- t.restart();
+ t.start();
win::hline2d vl(17);
- mln_concrete(I) input_clo = morpho::closing::structural(input, vl);
+ mln_concrete(I) input_clo = morpho::closing::structural(in, vl);
-// input_clo = scribo::preprocessing::rotate_90(input_clo, true);
-
- t_ = t;
+ float t_ = t;
std::cout << "closing_structural - " << t_ << std::endl;
- if (_debug_)
- {
- // Restore input orientation.
- input = scribo::preprocessing::rotate_90(input, false);
+ // if (_debug_)
+ // {
+ // // Restore input orientation.
+ // input = scribo::preprocessing::rotate_90(input, false);
- io::pbm::save(input_clo, "input_clo.pbm");
- }
+ // io::pbm::save(input_clo, "input_clo.pbm");
+ // }
// Rotate (OK)
t.restart();
@@ -526,9 +462,9 @@ namespace scribo
t_ = t;
std::cout << "extract::components - " << t_ << std::endl;
- if (_debug_)
- io::pgm::save(data::convert(value::int_u8(), components.labeled_image()),
- "lbl.pgm");
+ // if (_debug_)
+ // io::pgm::save(data::convert(value::int_u8(), components.labeled_image()),
+ // "lbl.pgm");
unsigned dmax = 5;
@@ -543,39 +479,42 @@ namespace scribo
{
// Right
internal::single_right_dmax_ratio_aligned_functor<L>
- functor(input_clo, components, dmax, min_angle, max_angle, anchor::Top, _debug_);
-// top_right = primitive::link::impl::compute_fastest(functor, anchor::Top);
- top_right = primitive::link::compute(functor, anchor::Top);
+ functor(input_clo, components, dmax, min_angle, max_angle,
+ anchor::TopStrictLeft, _debug_);
+// top_right = primitive::link::impl::compute_fastest(functor, anchor::TopStrictLeft);
+ top_right = primitive::link::compute(functor, anchor::TopStrictLeft);
t.stop();
- if (_debug_)
- {
- io::ppm::save(functor.debug_, "right_top.ppm");
- io::ppm::save(functor.debug_angle_, "right_top_angle.ppm");
- }
+ // if (_debug_)
+ // {
+ // io::ppm::save(functor.debug_, "right_top.ppm");
+ // io::ppm::save(functor.debug_angle_, "right_top_angle.ppm");
+ // }
t.resume();
// Left
internal::single_left_dmax_ratio_aligned_functor<L>
- lfunctor(input_clo, components, dmax, min_angle, max_angle, anchor::Top, _debug_);
- top_left = primitive::link::compute(lfunctor, anchor::Top);
+ lfunctor(input_clo, components, dmax, min_angle, max_angle,
+ anchor::TopStrictLeft, _debug_);
+ top_left = primitive::link::compute(lfunctor, anchor::TopStrictLeft);
t.stop();
- if (_debug_)
- {
- io::ppm::save(lfunctor.debug_, "left_top.ppm");
- io::ppm::save(lfunctor.debug_angle_, "left_top_angle.ppm");
+ // if (_debug_)
+ // {
+ // io::ppm::save(lfunctor.debug_, "left_top.ppm");
+ // io::ppm::save(lfunctor.debug_angle_, "left_top_angle.ppm");
- mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_);
- data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black))) | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output);
+ // mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_);
+ // data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black)))
+ // | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output);
- io::ppm::save(output, "left_right_top.ppm");
- }
+ // io::ppm::save(output, "left_right_top.ppm");
+ // }
t.resume();
}
@@ -585,105 +524,53 @@ namespace scribo
{
// Right
internal::single_right_dmax_ratio_aligned_functor<L>
- functor(input_clo, components, dmax, min_angle, max_angle, anchor::Bottom, _debug_);
- bot_right = primitive::link::compute(functor, anchor::Bottom);
+ functor(input_clo, components, dmax, min_angle, max_angle,
+ anchor::BottomStrictRight, _debug_);
+ bot_right = primitive::link::compute(functor, anchor::BottomStrictRight);
t.stop();
- if (_debug_)
- {
- io::ppm::save(functor.debug_, "right_bot.ppm");
- io::ppm::save(functor.debug_angle_, "right_bot_angle.ppm");
- }
+ // if (_debug_)
+ // {
+ // io::ppm::save(functor.debug_, "right_bot.ppm");
+ // io::ppm::save(functor.debug_angle_, "right_bot_angle.ppm");
+ // }
t.resume();
// Left
internal::single_left_dmax_ratio_aligned_functor<L>
- lfunctor(input_clo, components, dmax, min_angle, max_angle, anchor::Bottom, _debug_);
- bot_left = primitive::link::compute(lfunctor, anchor::Bottom);
+ lfunctor(input_clo, components, dmax, min_angle, max_angle,
+ anchor::BottomStrictRight, _debug_);
+ bot_left = primitive::link::compute(lfunctor, anchor::BottomStrictRight);
t.stop();
- if (_debug_)
- {
- io::ppm::save(lfunctor.debug_, "left_bot.ppm");
- io::ppm::save(lfunctor.debug_angle_, "left_bot_angle.ppm");
- }
+ // if (_debug_)
+ // {
+ // io::ppm::save(lfunctor.debug_, "left_bot.ppm");
+ // io::ppm::save(lfunctor.debug_angle_, "left_bot_angle.ppm");
- if (_debug_)
- {
- mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_);
- data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black))) | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output);
+ // mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_);
+ // data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black)))
+ // | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output);
- io::ppm::save(output, "left_right_bot.ppm");
- }
+ // io::ppm::save(output, "left_right_bot.ppm");
+ // }
}
t_ = t;
std::cout << "links - " << t_ << std::endl;
-
+ // Merge links and build CC groups
t.restart();
- std::cout << "group - top" << std::endl;
object_groups<L>
top_groups = primitive::group::from_double_link_any(top_left, top_right);
- std::cout << "group - bot" << std::endl;
object_groups<L>
bot_groups = primitive::group::from_double_link_any(bot_left, bot_right);
t_ = t;
std::cout << "group - " << t_ << std::endl;
- t.restart();
- util::array<accu::shape::bbox<point2d> >
- btop_accu(top_groups.nelements()),
- bbot_accu(bot_groups.nelements());
-
-
- for_all_groups(c, top_groups)
- {
- btop_accu(top_groups(c)).take(components(c).bbox());
- bbot_accu(bot_groups(c)).take(components(c).bbox());
- }
- t_ = t;
- std::cout << "groups to group bboxes - " << t_ << std::endl;
-
-
-
- if (_debug_)
- {
-
- mln_ch_value(I, value::rgb8)
- wo_filtering = data::convert(value::rgb8(), input);
-
- for_all_comp_data(d, btop_accu)
- {
- if (btop_accu(d).is_valid())
- {
- mln::draw::line(wo_filtering,
- btop_accu(d).to_result().pmin(),
- point2d(btop_accu(d).to_result().pmin().row(),
- btop_accu(d).to_result().pmax().col()),
- literal::green);
-
- }
- }
-
- for_all_comp_data(d, bbot_accu)
- {
- if (bbot_accu(d).is_valid())
- {
- mln::draw::line(wo_filtering,
- point2d(bbot_accu(d).to_result().pmax().row(),
- bbot_accu(d).to_result().pmin().col()),
- bbot_accu(d).to_result().pmax(),
- literal::green);
- }
-
- }
- io::ppm::save(wo_filtering, "wo_filtering.ppm");
- }
-
-
+ // Filter CC groups
t.restart();
top_groups = filter::object_groups_small(top_groups, min_card);
bot_groups = filter::object_groups_small(bot_groups, min_card);
@@ -691,7 +578,7 @@ namespace scribo
std::cout << "small groups - " << t_ << std::endl;
-
+ // Compute group bboxes
t.restart();
util::array<accu::shape::bbox<point2d> >
top_accu(top_groups.nelements()),
@@ -708,78 +595,35 @@ namespace scribo
-
-
-
-
-
t.restart();
mln_concrete(I) separators;
initialize(separators, input_clo);
+
+ // FIXME: any way to fill border AND data at the same time?
data::fill(separators, false);
+ extension::fill(separators, false);
+
t_ = t;
std::cout << "Initialize separators image - " << t_ << std::endl;
- mln_ch_value(I, value::rgb8) both;
-
- if (_debug_)
- both = data::convert(value::rgb8(), input);
-
-
-
t.restart();
for_all_comp_data(d, top_accu)
{
- if (top_accu(d).is_valid() || btop_accu(d).is_valid())
+ if (top_accu(d).is_valid())
{
- if (top_accu(d).is_valid())
- {
- if (_debug_)
- mln::draw::line(both,
- top_accu(d).to_result().pmin(),
- point2d(top_accu(d).to_result().pmin().row(),
- top_accu(d).to_result().pmax().col()),
- literal::green);
-
- mln::draw::line(separators,
- top_accu(d).to_result().pmin(),
- point2d(top_accu(d).to_result().pmin().row(),
- top_accu(d).to_result().pmax().col()),
- true);
- }
- else
- if (_debug_ && btop_accu(d).is_valid())
- mln::draw::line(both,
- btop_accu(d).to_result().pmin(),
- point2d(btop_accu(d).to_result().pmin().row(),
- btop_accu(d).to_result().pmax().col()),
- literal::yellow);
-
+ mln::draw::line(separators,
+ top_accu(d).to_result().pmin(),
+ point2d(top_accu(d).to_result().pmin().row(),
+ top_accu(d).to_result().pmax().col()),
+ true);
}
- if (bot_accu(d).is_valid() || bbot_accu(d).is_valid())
+ if (bot_accu(d).is_valid())
{
- if (bot_accu(d).is_valid())
- {
- if (_debug_)
- mln::draw::line(both,
- point2d(bot_accu(d).to_result().pmax().row(),
- bot_accu(d).to_result().pmin().col()),
- bot_accu(d).to_result().pmax(),
- literal::green);
-
- mln::draw::line(separators,
- point2d(bot_accu(d).to_result().pmax().row(),
- bot_accu(d).to_result().pmin().col()),
- bot_accu(d).to_result().pmax(),
- true);
- }
- else
- if (_debug_ && bbot_accu(d).is_valid())
- mln::draw::line(both,
- point2d(bbot_accu(d).to_result().pmax().row(),
- bbot_accu(d).to_result().pmin().col()),
- bbot_accu(d).to_result().pmax(),
- literal::yellow);
+ mln::draw::line(separators,
+ point2d(bot_accu(d).to_result().pmax().row(),
+ bot_accu(d).to_result().pmin().col()),
+ bot_accu(d).to_result().pmax(),
+ true);
}
}
@@ -787,22 +631,112 @@ namespace scribo
std::cout << "Drawing output image - " << t_ << std::endl;
- if (_debug_)
- {
- io::ppm::save(both, "both.ppm");
- io::pbm::save(separators, "separators.pbm");
- }
+ // if (_debug_)
+ // {
+ // // Restore input orientation.
+ // mln_concrete(I) input = scribo::preprocessing::rotate_90(in, false);
+
+
+ // // Debug group bboxes (includes all bboxes before filtering)
+ // util::array<accu::shape::bbox<point2d> >
+ // btop_accu(top_groups.nelements()),
+ // bbot_accu(bot_groups.nelements());
+
+
+ // for_all_groups(c, top_groups)
+ // {
+ // btop_accu(top_groups(c)).take(components(c).bbox());
+ // bbot_accu(bot_groups(c)).take(components(c).bbox());
+ // }
+
+ // mln_ch_value(I, value::rgb8)
+ // wo_filtering = data::convert(value::rgb8(), input);
+
+ // for_all_comp_data(d, btop_accu)
+ // {
+ // if (btop_accu(d).is_valid())
+ // {
+ // mln::draw::line(wo_filtering,
+ // btop_accu(d).to_result().pmin(),
+ // point2d(btop_accu(d).to_result().pmin().row(),
+ // btop_accu(d).to_result().pmax().col()),
+ // literal::green);
+
+ // }
+ // }
+
+ // for_all_comp_data(d, bbot_accu)
+ // {
+ // if (bbot_accu(d).is_valid())
+ // {
+ // mln::draw::line(wo_filtering,
+ // point2d(bbot_accu(d).to_result().pmax().row(),
+ // bbot_accu(d).to_result().pmin().col()),
+ // bbot_accu(d).to_result().pmax(),
+ // literal::green);
+ // }
+
+ // }
+ // io::ppm::save(wo_filtering, "wo_filtering.ppm");
+
+ // mln_ch_value(I, value::rgb8) both = data::convert(value::rgb8(), input);
+
+ // for_all_comp_data(d, top_accu)
+ // {
+ // if (top_accu(d).is_valid() || btop_accu(d).is_valid())
+ // {
+ // if (top_accu(d).is_valid())
+ // {
+ // mln::draw::line(both,
+ // top_accu(d).to_result().pmin(),
+ // point2d(top_accu(d).to_result().pmin().row(),
+ // top_accu(d).to_result().pmax().col()),
+ // literal::green);
+ // }
+ // else
+ // if (btop_accu(d).is_valid())
+ // mln::draw::line(both,
+ // btop_accu(d).to_result().pmin(),
+ // point2d(btop_accu(d).to_result().pmin().row(),
+ // btop_accu(d).to_result().pmax().col()),
+ // literal::yellow);
+
+ // }
+ // if (bot_accu(d).is_valid() || bbot_accu(d).is_valid())
+ // {
+ // if (bot_accu(d).is_valid())
+ // {
+ // mln::draw::line(both,
+ // point2d(bot_accu(d).to_result().pmax().row(),
+ // bot_accu(d).to_result().pmin().col()),
+ // bot_accu(d).to_result().pmax(),
+ // literal::green);
+ // }
+ // else
+ // if (bbot_accu(d).is_valid())
+ // mln::draw::line(both,
+ // point2d(bbot_accu(d).to_result().pmax().row(),
+ // bbot_accu(d).to_result().pmin().col()),
+ // bbot_accu(d).to_result().pmax(),
+ // literal::yellow);
+ // }
+
+ // }
+
+ // io::ppm::save(both, "both.ppm");
+ // io::pbm::save(separators, "separators.pbm");
+ // }
// Hit or miss
{
- if (_debug_)
- {
- mln_concrete(I) input_with_seps = duplicate(input_clo);
- data::paste(separators | pw::value(separators), input_with_seps);
+ // if (_debug_)
+ // {
+ // mln_concrete(I) input_with_seps = duplicate(input_clo);
+ // data::paste(separators | pw::value(separators), input_with_seps);
- io::pbm::save(input_with_seps, "input_with_seps.pbm");
- }
+ // io::pbm::save(input_with_seps, "input_with_seps.pbm");
+ // }
t.restart();
unsigned length = 25;
@@ -819,11 +753,12 @@ namespace scribo
typedef mln_ch_value(I,unsigned) J;
J tmp = accu::transform_line(accu, input_clo, length, 1);
+
t_ = t;
std::cout << "* accu::transform_line - " << t_ << std::endl;
- if (_debug_)
- io::pgm::save(data::convert(value::int_u8(), tmp), "tmp.pgm");
+ // if (_debug_)
+ // io::pgm::save(data::convert(value::int_u8(), tmp), "tmp.pgm");
t.restart();
@@ -841,25 +776,53 @@ namespace scribo
unsigned invalid_ratio = unsigned(length * 0.30f);
- mln_piter(I) p(separators.domain());
- for_all(p)
- if (separators(p))
- {
- unsigned lbl = sep_lbl(p);
+ extension::adjust_fill(tmp, 21, 0);
+
+ value::int_u8 *sep_lbl_ptr = sep_lbl.buffer() + sep_lbl.index_of_point(sep_lbl.domain().pmin());
+ bool *separators_ptr = separators.buffer() + separators.index_of_point(separators.domain().pmin());
+ unsigned *tmp_ptr = tmp.buffer() + tmp.index_of_point(tmp.domain().pmin());;
+ int idx1 = tmp.delta_index(dp1);
+ int idx2 = tmp.delta_index(dp2);
+
+ unsigned nrows = separators.nrows();
+ unsigned ncols = separators.ncols();
- unsigned
- top_count = tmp(p + dp1),
- bot_count = tmp(p + dp2);
+ unsigned row_idx_sep_lbl = sep_lbl.delta_index(dpoint2d(+1, - ncols));
+ unsigned row_idx_separators = separators.delta_index(dpoint2d(+1, - ncols));
+ unsigned row_idx_tmp = tmp.delta_index(dpoint2d(+1, - ncols));
- // This site is wrapped between two lines of text so we don't
- // want it.
- if (top_count >= invalid_ratio + 1
- && bot_count >= invalid_ratio + 1)
+ for (unsigned row = 0; row < nrows; ++row)
+ {
+ for (unsigned col = 0; col < ncols; ++col)
+ {
+ if (*separators_ptr)
{
- relbl(lbl) = false;
+ unsigned lbl = *sep_lbl_ptr;
+
+ unsigned
+ top_count = *(tmp_ptr + idx1),
+ bot_count = *(tmp_ptr + idx2);
+
+ // This site is wrapped between two lines of text so we don't
+ // want it.
+ if (top_count >= invalid_ratio + 1
+ && bot_count >= invalid_ratio + 1)
+ {
+ relbl(lbl) = false;
+ }
}
+
+ ++tmp_ptr;
+ ++sep_lbl_ptr;
+ ++separators_ptr;
}
+ tmp_ptr += row_idx_tmp;
+ sep_lbl_ptr += row_idx_sep_lbl;
+ separators_ptr += row_idx_separators;
+ }
+
+
t_ = t;
std::cout << "* reading data - " << t_ << std::endl;
@@ -870,37 +833,35 @@ namespace scribo
mln_concrete(I) output = data::convert(bool(), sep_lbl);
- if (_debug_)
- {
- io::pbm::save(output, "separators_hom.pbm");
- io::pbm::save(separators, "separators_filtered.pbm");
- }
+ // if (_debug_)
+ // {
+ // io::pbm::save(output, "separators_hom.pbm");
+ // io::pbm::save(separators, "separators_filtered.pbm");
- t.restart();
- value::int_u16 ncomps;
- component_set<L> comps = primitive::extract::components(output, c8(), ncomps);
- mln_ch_value(I, value::rgb8) both;
+ // // value::int_u16 ncomps;
+ // // component_set<L> comps = primitive::extract::components(output, c8(), ncomps);
+ // // mln_ch_value(I, value::rgb8) both;
- both = data::convert(value::rgb8(), input);
+ // // 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());
+ // // // Needed since the rotated image origin is (0,0).
+ // // 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);
+ // // }
+ // }
- 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;
+ std::cout << "Non visible separators: " << t_ << std::endl;
+ trace::exiting("scribo::primitive::extract::separators_nonvisible");
return scribo::preprocessing::rotate_90(output, true);
}
}
diff --git a/scribo/scribo/primitive/link/internal/compute_anchor.hh b/scribo/scribo/primitive/link/internal/compute_anchor.hh
index 1c52b91..c1a9106 100644
--- a/scribo/scribo/primitive/link/internal/compute_anchor.hh
+++ b/scribo/scribo/primitive/link/internal/compute_anchor.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -88,10 +88,8 @@ namespace scribo
{
typedef mln_site(L) P;
- unsigned h = components(current_object).bbox().pmax().row()
- - components(current_object).bbox().pmin().row();
- unsigned w = components(current_object).bbox().pmax().col()
- - components(current_object).bbox().pmin().col();
+ unsigned h = components(current_object).bbox().height();
+ unsigned w = components(current_object).bbox().width();
mln_site(L) sp = components(current_object).bbox().pcenter();
@@ -113,6 +111,22 @@ namespace scribo
break;
+ // Bounding box top left
+ case anchor::TopStrictLeft:
+ sp.col() = components(current_object).bbox().pmin().col();
+ sp.row() = components(current_object).bbox().pmin().row()
+ + math::min(2u, (h + 1) / 2 - 1);
+ break;
+
+
+ // Bounding box bottom right
+ case anchor::BottomStrictRight:
+ sp.col() = components(current_object).bbox().pmax().col();
+ sp.row() = components(current_object).bbox().pmax().row()
+ - math::min(2u, (h + 1) / 2 - 1);
+ break;
+
+
// Bounding box bottom center
case anchor::Bottom:
if (h < 30)
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
index ed691e8..48098ba 100644
--- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -34,11 +34,11 @@
# include <scribo/core/line_set.hh>
# include <scribo/core/paragraph_set.hh>
-# include <scribo/primitive/extract/elements.hh>
+# include <scribo/primitive/extract/non_text.hh>
# include <scribo/primitive/extract/components.hh>
-# include <scribo/primitive/extract/vertical_separators.hh>
+//# include <scribo/primitive/extract/vertical_separators.hh>
+# include <scribo/primitive/extract/separators.hh>
# include <scribo/primitive/extract/separators_nonvisible.hh>
-# include <scribo/primitive/extract/elements.hh>
# include <scribo/primitive/identify.hh>
@@ -168,16 +168,17 @@ namespace scribo
input_cleaned = exact(processed_image);
if (enable_line_seps)
{
- on_new_progress_label("Find vertical separators...");
+ on_new_progress_label("Find vertical and horizontal separators...");
- // Vertical separators
- separators = primitive::extract::vertical_separators(processed_image, 81);
+ // Vertical and horizontal separators
+ separators = primitive::extract::separators(processed_image, 81);
on_progress();
on_new_progress_label("Remove separators...");
input_cleaned = primitive::remove::separators(processed_image, separators);
+ doc.set_line_separators(separators);
on_progress();
}
--
1.5.6.5
1
0
last-svn-commit-772-g526859a Add new conversion routines from string to tag.
by Guillaume Lazzara 29 Mar '11
by Guillaume Lazzara 29 Mar '11
29 Mar '11
* scribo/core/tag/component.hh,
* scribo/core/tag/line.hh: Here.
---
scribo/ChangeLog | 7 +++++++
scribo/scribo/core/tag/component.hh | 35 +++++++++++++++++++++++++++++++++++
scribo/scribo/core/tag/line.hh | 34 +++++++++++++++++++++++++++++++++-
3 files changed, 75 insertions(+), 1 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 2d66a58..f03eb97 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,12 @@
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new conversion routines from string to tag.
+
+ * scribo/core/tag/component.hh,
+ * scribo/core/tag/line.hh: Here.
+
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Various changes in scribo core structures.
* scribo/scribo/core/component_info.hh: Remove useless line_id.
diff --git a/scribo/scribo/core/tag/component.hh b/scribo/scribo/core/tag/component.hh
index f773932..10b86a6 100644
--- a/scribo/scribo/core/tag/component.hh
+++ b/scribo/scribo/core/tag/component.hh
@@ -61,6 +61,14 @@ namespace scribo
Image
};
+
+ std::ostream& operator<<(std::ostream& ostr, const Tag& tag);
+ Tag str2tag(const std::string& str);
+
+ std::ostream& operator<<(std::ostream& ostr, const Type& type);
+ Type str2type(const std::string& str);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -85,6 +93,16 @@ namespace scribo
inline
+ Tag str2tag(const std::string& str)
+ {
+ if (str == "Ignored")
+ return Ignored;
+
+ return None;
+ }
+
+
+ inline
std::ostream&
operator<<(std::ostream& ostr, const Type& type)
{
@@ -116,6 +134,23 @@ namespace scribo
}
+ inline
+ Type str2type(const std::string& str)
+ {
+ if (str == "Character")
+ return Character;
+ else if (str == "Separator")
+ return Separator;
+ else if (str == "Noise")
+ return Noise;
+ else if (str == "Punctuation")
+ return Punctuation;
+ else if (str == "Image")
+ return Image;
+
+ return Undefined;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/scribo/core/tag/line.hh b/scribo/scribo/core/tag/line.hh
index 0444a11..3fb1fdf 100644
--- a/scribo/scribo/core/tag/line.hh
+++ b/scribo/scribo/core/tag/line.hh
@@ -96,7 +96,7 @@ namespace scribo
std::ostream&
operator<<(std::ostream& ostr, const Type& type);
-
+ Type str2type(const std::string& str);
# ifndef MLN_INCLUDE_ONLY
@@ -208,6 +208,38 @@ namespace scribo
return ostr << str;
}
+ inline
+ Type str2type(const std::string& str)
+ {
+ if (str == "caption")
+ return Caption;
+ else if (str == "credit")
+ return Credit;
+ else if (str == "drop-capital")
+ return DropCapital;
+ else if (str == "floating")
+ return Floating;
+ else if (str == "footer")
+ return Footer;
+ else if (str == "header")
+ return Header;
+ else if (str == "heading")
+ return Heading;
+ else if (str == "page-number")
+ return PageNumber;
+ else if (str == "paragraph")
+ return Paragraph;
+
+ // Values unsupported by the XSD
+ else if(str == "punctuation")
+ return Punctuation;
+ else if (str == "text")
+ return Text;
+
+ return Undefined;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
last-svn-commit-771-g1bc261b Various changes in scribo core structures.
by Guillaume Lazzara 29 Mar '11
by Guillaume Lazzara 29 Mar '11
29 Mar '11
* scribo/scribo/core/component_info.hh: Remove useless line_id.
* scribo/scribo/core/line_set.hh,
* scribo/scribo/core/component_set.hh: Add new constructors.
* scribo/scribo/core/document.hh: Store line separators.
* scribo/scribo/core/line_info.hh: Share attributes and add new
constructors.
(is_textline): New method.
* scribo/scribo/core/line_links.hh: Do not allocate useless data.
* scribo/scribo/core/paragraph_info.hh (operator<<): New.
* scribo/scribo/core/paragraph_set.hh: Share attributes and add new
constructors.
---
scribo/ChangeLog | 22 ++
scribo/scribo/core/component_info.hh | 17 +--
scribo/scribo/core/component_set.hh | 65 +++++--
scribo/scribo/core/document.hh | 48 +++++-
scribo/scribo/core/line_info.hh | 367 ++++++++++++++++++----------------
scribo/scribo/core/line_links.hh | 2 +-
scribo/scribo/core/line_set.hh | 29 +++-
scribo/scribo/core/paragraph_info.hh | 10 +
scribo/scribo/core/paragraph_set.hh | 84 +++++++-
9 files changed, 425 insertions(+), 219 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index fa99f5b..2d66a58 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,27 @@
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Various changes in scribo core structures.
+
+ * scribo/scribo/core/component_info.hh: Remove useless line_id.
+
+ * scribo/scribo/core/line_set.hh,
+ * scribo/scribo/core/component_set.hh: Add new constructors.
+
+ * scribo/scribo/core/document.hh: Store line separators.
+
+ * scribo/scribo/core/line_info.hh: Share attributes and add new
+ constructors.
+ (is_textline): New method.
+
+ * scribo/scribo/core/line_links.hh: Do not allocate useless data.
+
+ * scribo/scribo/core/paragraph_info.hh (operator<<): New.
+
+ * scribo/scribo/core/paragraph_set.hh: Share attributes and add new
+ constructors.
+
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Rename files in Scribo.
* scribo/primitive/extract/elements.hh,
diff --git a/scribo/scribo/core/component_info.hh b/scribo/scribo/core/component_info.hh
index 4ed6db7..1b03318 100644
--- a/scribo/scribo/core/component_info.hh
+++ b/scribo/scribo/core/component_info.hh
@@ -47,7 +47,6 @@ namespace scribo
class component_info
{
typedef mln::util::object_id<scribo::ComponentId, unsigned> component_id_t;
- typedef mln::util::object_id<scribo::LineId, unsigned> line_id_t;
public:
component_info();
@@ -69,9 +68,6 @@ namespace scribo
component::Type type() const;
void update_type(component::Type type);
- // The line it is rattached to. 0 means an invalid line.
- line_id_t line_id() const;
-
bool is_valid() const;
private:
@@ -82,8 +78,6 @@ namespace scribo
component::Tag tag_;
component::Type type_;
-
- line_id_t line_id_;
};
@@ -109,7 +103,7 @@ namespace scribo
const mln::point2d& mass_center,
unsigned card)
: id_(id), bbox_(bbox), mass_center_(mass_center), card_(card),
- tag_(component::None), type_(component::Undefined), line_id_(0)
+ tag_(component::None), type_(component::Undefined)
{
}
@@ -179,14 +173,6 @@ namespace scribo
inline
- component_info::line_id_t
- component_info::line_id() const
- {
- return line_id_;
- }
-
-
- inline
bool
component_info::is_valid() const
{
@@ -204,7 +190,6 @@ namespace scribo
<< ", mass_center=" << info.mass_center()
<< ", card=" << info.card()
<< ", tag=" << info.tag()
- << ", line_id=" << info.line_id()
<< ")" << std::endl;
}
diff --git a/scribo/scribo/core/component_set.hh b/scribo/scribo/core/component_set.hh
index 103826f..7ddcf16 100644
--- a/scribo/scribo/core/component_set.hh
+++ b/scribo/scribo/core/component_set.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,6 +55,8 @@
# include <mln/core/routine/duplicate.hh>
+# include <mln/value/next.hh>
+
# include <scribo/core/macros.hh>
# include <scribo/core/component_info.hh>
@@ -95,6 +97,8 @@ namespace scribo
void fill_infos(const mln::util::array<pair_data_t>& attribs);
+ // Useful while constructing incrementaly (XML loading).
+ void soft_init(const mln_value(L) ncomps);
L ima_;
mln_value(L) ncomps_;
@@ -128,6 +132,9 @@ namespace scribo
/// Constructor without argument.
component_set();
+ // Constructor from internal data.
+ component_set(const mln::util::tracked_ptr<data_t>& data);
+
/// Constructor from an image \p ima and the number of labels \p ncomps.
component_set(const L& ima, const mln_value(L)& ncomps);
@@ -348,6 +355,19 @@ namespace scribo
}
+ template <typename L>
+ inline
+ void
+ component_set_data<L>::soft_init(const mln_value(L) ncomps)
+ {
+ mln_precondition(infos_.nelements() == 0);
+
+ ncomps_ = ncomps;
+ infos_.reserve(ncomps_);
+ infos_.append(component_info()); // Component 0, i.e. the background.
+ }
+
+
} // end of namespace mln::internal
@@ -361,6 +381,13 @@ namespace scribo
template <typename L>
inline
+ component_set<L>::component_set(const mln::util::tracked_ptr<data_t>& data)
+ {
+ data_ = data;
+ }
+
+ template <typename L>
+ inline
component_set<L>::component_set(const L& ima, const mln_value(L)& ncomps)
{
data_ = new internal::component_set_data<L>(ima, ncomps);
@@ -400,7 +427,7 @@ namespace scribo
const component_info&
component_set<L>::info(const mln_value(L)& id) const
{
- return this->data_->infos_[id];
+ return data_->infos_[id];
}
template <typename L>
@@ -408,7 +435,7 @@ namespace scribo
component_info&
component_set<L>::info(const mln_value(L)& id)
{
- return this->data_->infos_[id];
+ return data_->infos_[id];
}
// template <typename L>
@@ -416,7 +443,7 @@ namespace scribo
// const component_info&
// component_set<L>::operator()(const mln_value(L)& id) const
// {
-// return this->data_->infos_[id];
+// return data_->infos_[id];
// }
// template <typename L>
@@ -424,7 +451,7 @@ namespace scribo
// component_info&
// component_set<L>::operator()(const mln_value(L)& id)
// {
-// return this->data_->infos_[id];
+// return data_->infos_[id];
// }
template <typename L>
@@ -432,7 +459,7 @@ namespace scribo
const component_info&
component_set<L>::operator()(const component_id_t& id) const
{
- return this->data_->infos_[id];
+ return data_->infos_[id];
}
template <typename L>
@@ -440,7 +467,7 @@ namespace scribo
component_info&
component_set<L>::operator()(const component_id_t& id)
{
- return this->data_->infos_[id];
+ return data_->infos_[id];
}
@@ -476,7 +503,7 @@ namespace scribo
const L&
component_set<L>::labeled_image() const
{
- return this->data_->ima_;
+ return data_->ima_;
}
@@ -485,7 +512,7 @@ namespace scribo
bool
component_set<L>::is_valid() const
{
- return this->data_->ima_.is_valid();
+ return data_ != 0 && data_->ima_.is_valid();
}
@@ -503,7 +530,7 @@ namespace scribo
L&
component_set<L>::labeled_image_()
{
- return this->data_->ima_;
+ return data_->ima_;
}
@@ -512,7 +539,7 @@ namespace scribo
mln_concrete(L)
component_set<L>::valid_comps_image_() const
{
- mln::util::array<bool> f(mln::value::next(this->data_->ncomps_));
+ mln::util::array<bool> f(mln::value::next(data_->ncomps_));
f(0) = true;
for_all_comps(c, (*this))
@@ -520,8 +547,8 @@ namespace scribo
mln_value(L) new_ncomps;
mln_concrete(L)
- output = mln::labeling::relabel(this->data_->ima_,
- this->data_->ncomps_,
+ output = mln::labeling::relabel(data_->ima_,
+ data_->ncomps_,
new_ncomps,
f);
@@ -534,7 +561,7 @@ namespace scribo
bool
component_set<L>::has_separators() const
{
- return this->data_->separators_.is_valid();
+ return data_->separators_.is_valid();
}
@@ -544,9 +571,9 @@ namespace scribo
component_set<L>::add_separators(const mln_ch_value(L, bool)& ima)
{
if (! has_separators())
- this->data_->separators_ = ima;
+ data_->separators_ = ima;
else
- mln::logical::or_inplace(this->data_->separators_, ima);
+ mln::logical::or_inplace(data_->separators_, ima);
}
@@ -555,7 +582,7 @@ namespace scribo
const mln_ch_value(L, bool)&
component_set<L>::separators() const
{
- return this->data_->separators_;
+ return data_->separators_;
}
@@ -564,7 +591,7 @@ namespace scribo
void
component_set<L>::clear_separators()
{
- this->data_->separators_.destroy();
+ data_->separators_.destroy();
}
diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh
index f112410..e5ac825 100644
--- a/scribo/scribo/core/document.hh
+++ b/scribo/scribo/core/document.hh
@@ -91,16 +91,24 @@ namespace scribo
const component_set<L>& whitespace_seps_comps() const;
void set_whitespace_separators(const image2d<bool>& whitespace_seps);
+ bool has_line_seps() const;
+ const mln::image2d<bool>& line_seps() const;
+ const component_set<L>& line_seps_comps() const;
+ void set_line_separators(const image2d<bool>& line_seps);
+
+
private:
const char *filename_;
mln::image2d<mln::value::rgb8> image_;
- line_set<L> lines_;
paragraph_set<L> parset_;
component_set<L> elements_;
mln::image2d<bool> whitespace_seps_;
component_set<L> whitespace_seps_comps_;
+
+ mln::image2d<bool> line_seps_;
+ component_set<L> line_seps_comps_;
};
@@ -201,7 +209,6 @@ namespace scribo
return parset_.lines();
}
-
template <typename L>
const paragraph_set<L>&
document<L>::paragraphs() const
@@ -294,6 +301,43 @@ namespace scribo
}
+ template <typename L>
+ bool
+ document<L>::has_line_seps() const
+ {
+ return line_seps_.is_valid();
+ }
+
+
+ template <typename L>
+ const mln::image2d<bool>&
+ document<L>::line_seps() const
+ {
+ return line_seps_;
+ }
+
+
+ template <typename L>
+ const component_set<L>&
+ document<L>::line_seps_comps() const
+ {
+ return line_seps_comps_;
+ }
+
+
+ template <typename L>
+ void
+ document<L>::set_line_separators(const image2d<bool>& line_seps)
+ {
+ line_seps_ = line_seps;
+
+ mln_value(L) ncomps;
+ line_seps_comps_ = primitive::extract::components(line_seps,
+ mln::c8(), ncomps);
+ }
+
+
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/scribo/core/line_info.hh b/scribo/scribo/core/line_info.hh
index 54a5094..c82160a 100644
--- a/scribo/scribo/core/line_info.hh
+++ b/scribo/scribo/core/line_info.hh
@@ -58,12 +58,76 @@ namespace scribo
// Forward declarations.
template <typename L> class line_set;
+ template <typename L> class line_info;
typedef mln::util::object_id<scribo::LineId, unsigned> line_id_t;
+
+ namespace internal
+ {
+ /// Data structure for \c scribo::line_info<I>.
+ template <typename L>
+ struct line_info_data
+ {
+ line_info_data();
+ line_info_data(const line_set<L>& holder,
+ const mln::util::array<component_id_t>& comps);
+
+
+ bool hidden_;
+ line::Tag tag_;
+ mln::box2d bbox_;
+ mln::box2d ebbox_;
+ mln::util::array<component_id_t> components_;
+
+ // Values relative to the line bbox.
+ int baseline_;
+ int meanline_;
+
+ // Values relative to the baseline.
+ unsigned x_height_;
+ int d_height_;
+ int a_height_;
+
+ // Character related stats.
+ unsigned char_space_;
+ unsigned char_width_;
+
+ // Words related stats.
+ unsigned word_space_;
+
+ // Reading direction
+ line::ReadingDirection reading_direction_;
+
+ // Line type
+ line::Type type_;
+
+ // Is this line in reverse video?
+ bool reverse_video_;
+
+ // Text orientation
+ float orientation_;
+
+ // Text reading orientation
+ float reading_orientation_;
+
+ bool indented_;
+
+ std::string text_;
+
+ // Line set holding this element.
+ line_set<L> holder_;
+
+ };
+
+ } // end of namespace scribo::internal
+
+
+
template <typename L>
class line_info
{
+ typedef internal::line_info_data<L> data_t;
typedef mln::util::object_id<scribo::ComponentId, unsigned> component_id_t;
typedef mln::util::object_id<scribo::LineId, unsigned> line_id_t;
@@ -74,6 +138,8 @@ namespace scribo
line_info();
+ line_info(const line_id_t& id, data_t* data);
+
line_info(const line_set<L>& holder,
const line_id_t& id,
const mln::util::array<component_id_t>& comps);
@@ -134,9 +200,10 @@ namespace scribo
const std::string& text() const;
void update_text(const std::string& str);
-
bool is_valid() const;
+ bool is_textline() const;
+
/// Hidden status.
///
/// When a line is hidden, it should not be used in routines
@@ -180,6 +247,9 @@ namespace scribo
/// Returns the delta used to compute the extended bbox.
int delta_of_line() const;
+ /// Update the extended bbox.
+ void update_ebbox();
+
private: // Members
void copy_data(const line_info<L>& other);
@@ -189,81 +259,59 @@ namespace scribo
/// Update bbox and ebbox_ attributes.
void update_bbox_and_ebox(line_info<L>& other);
- /// Update the extended bbox.
- void update_ebbox();
-
mln::box2d merged_ebbox(const scribo::line_info<L>& info_l,
const scribo::line_info<L>& info);
void update_components_type(component::Type type);
private: // Attributes
- // WARNING: NEVER FORGET TO UPDATE COPY CONSTRUCTOR REDEFINITION!!!!
-
line_id_t id_;
- bool hidden_;
- line::Tag tag_;
- mln::box2d bbox_;
- mln::box2d ebbox_;
- mln::util::array<component_id_t> components_;
-
- // Values relative to the line bbox.
- int baseline_;
- int meanline_;
-
- // Values relative to the baseline.
- unsigned x_height_;
- int d_height_;
- int a_height_;
-
- // WARNING: NEVER FORGET TO UPDATE COPY CONSTRUCTOR REDEFINITION!!!!
-
- // Character related stats.
- unsigned char_space_;
- unsigned char_width_;
-
- // Words related stats.
- unsigned word_space_;
-
- // Reading direction
- line::ReadingDirection reading_direction_;
-
- // Line type
- line::Type type_;
+ mln::util::tracked_ptr<data_t> data_;
+ };
- // Is this line in reverse video?
- bool reverse_video_;
- // Text orientation
- float orientation_;
+ template <typename L>
+ std::ostream&
+ operator<<(std::ostream& ostr, const line_info<L>& info);
- // Text reading orientation
- float reading_orientation_;
- bool indented_;
+# ifndef MLN_INCLUDE_ONLY
- std::string text_;
+ namespace internal
+ {
- // Line set holding this element.
- line_set<L> holder_;
+ template <typename L>
+ line_info_data<L>::line_info_data()
+ {
+ hidden_ = false;
+ }
- // WARNING: NEVER FORGET TO UPDATE COPY CONSTRUCTOR REDEFINITION!!!!
- };
+ template <typename L>
+ line_info_data<L>::line_info_data(const line_set<L>& holder,
+ const mln::util::array<component_id_t>& comps)
+ : hidden_(false), tag_(line::None), components_(comps),
+ type_(line::Undefined), holder_(holder)
+ {
+ // FIXME: set valid information for these attributes in
+ // force_stats_update.
+ word_space_ = 0;
+ reading_direction_ = line::LeftToRight;
+ reverse_video_ = false;
- template <typename L>
- std::ostream&
- operator<<(std::ostream& ostr, const line_info<L>& info);
+ orientation_ = 0.;
+ reading_orientation_ = 0.;
+ indented_ = false;
+ }
-# ifndef MLN_INCLUDE_ONLY
+ } // end of namespace scribo::internal
template <typename L>
line_info<L>::line_info()
- : id_(0), hidden_(false)
+ : id_(0)
{
-
}
template <typename L>
@@ -275,47 +323,24 @@ namespace scribo
if (! is_valid())
id_ = other.id();
- hidden_ = other.hidden_;
-
- tag_ = other.tag();
- bbox_ = other.bbox();
- ebbox_ = other.ebbox();
- components_ = other.components();
-
- baseline_ = other.baseline();
- meanline_ = other.meanline();
-
- x_height_ = other.x_height();
- d_height_ = other.d_height();
- a_height_ = other.a_height();
-
- char_space_ = other.char_space();
- char_width_ = other.char_width();
-
- word_space_ = other.word_space();
-
- reading_direction_ = other.reading_direction();
-
- type_ = other.type();
-
- reverse_video_ = other.reverse_video();
-
- orientation_ = other.orientation();
-
- reading_orientation_ = other.reading_orientation();
-
- indented_ = other.indented();
+ data_ = other.data_;
+ }
- text_ = other.text();
- holder_ = other.holder();
+ template <typename L>
+ inline
+ line_info<L>::line_info(const line_id_t& id, data_t *data)
+ : id_(id), data_(data)
+ {
}
+
template <typename L>
inline
line_info<L>::line_info(const line_info<L>& other)
- : id_(0), hidden_(false)
+ : id_(0)
{
+ //data_->hidden_ = false;
copy_data(other);
}
@@ -357,22 +382,10 @@ namespace scribo
line_info<L>::line_info(const line_set<L>& holder,
const line_id_t& id,
const mln::util::array<component_id_t>& comps)
- : id_(id), hidden_(false), tag_(line::None), components_(comps),
- type_(line::Undefined), holder_(holder)
+ : id_(id)
{
-
+ data_ = new data_t(holder, comps);
force_stats_update();
-
- // FIXME: set valid information for these attributes in
- // force_stats_update.
- word_space_ = 0;
- reading_direction_ = line::LeftToRight;
- reverse_video_ = false;
-
- orientation_ = 0.;
- reading_orientation_ = 0.;
-
- indented_ = false;
}
@@ -397,7 +410,7 @@ namespace scribo
line::Tag
line_info<L>::tag() const
{
- return tag_;
+ return data_->tag_;
}
@@ -405,7 +418,7 @@ namespace scribo
void
line_info<L>::update_tag(line::Tag tag)
{
- tag_ = tag;
+ data_->tag_ = tag;
}
@@ -413,14 +426,14 @@ namespace scribo
const mln::box2d&
line_info<L>::bbox() const
{
- return bbox_;
+ return data_->bbox_;
}
template <typename L>
const mln::box2d&
line_info<L>::ebbox() const
{
- return ebbox_;
+ return data_->ebbox_;
}
@@ -428,14 +441,14 @@ namespace scribo
const mln::util::array<typename line_info<L>::component_id_t>&
line_info<L>::components() const
{
- return components_;
+ return data_->components_;
}
template <typename L>
unsigned
line_info<L>::card() const
{
- return components_.size();
+ return data_->components_.size();
}
@@ -443,7 +456,7 @@ namespace scribo
int
line_info<L>::baseline() const
{
- return baseline_;
+ return data_->baseline_;
}
@@ -451,7 +464,7 @@ namespace scribo
int
line_info<L>::meanline() const
{
- return meanline_;
+ return data_->meanline_;
}
@@ -459,7 +472,7 @@ namespace scribo
int
line_info<L>::ascent() const
{
- return baseline_ - a_height() + 1;
+ return data_->baseline_ - a_height() + 1;
}
@@ -467,7 +480,7 @@ namespace scribo
int
line_info<L>::descent() const
{
- return baseline_ - d_height();
+ return data_->baseline_ - d_height();
}
@@ -475,7 +488,7 @@ namespace scribo
unsigned
line_info<L>::x_height() const
{
- return x_height_;
+ return data_->x_height_;
}
@@ -483,7 +496,7 @@ namespace scribo
int
line_info<L>::d_height() const
{
- return d_height_;
+ return data_->d_height_;
}
@@ -491,7 +504,7 @@ namespace scribo
int
line_info<L>::a_height() const
{
- return a_height_;
+ return data_->a_height_;
}
@@ -499,7 +512,7 @@ namespace scribo
unsigned
line_info<L>::char_space() const
{
- return char_space_;
+ return data_->char_space_;
}
@@ -507,7 +520,7 @@ namespace scribo
unsigned
line_info<L>::char_width() const
{
- return char_width_;
+ return data_->char_width_;
}
@@ -515,7 +528,7 @@ namespace scribo
unsigned
line_info<L>::word_space() const
{
- return word_space_;
+ return data_->word_space_;
}
@@ -523,14 +536,14 @@ namespace scribo
line::ReadingDirection
line_info<L>::reading_direction() const
{
- return reading_direction_;
+ return data_->reading_direction_;
}
template <typename L>
line::Type
line_info<L>::type() const
{
- return type_;
+ return data_->type_;
}
@@ -538,10 +551,10 @@ namespace scribo
void
line_info<L>::update_components_type(component::Type type)
{
- for_all_elements(i, components_)
+ for_all_elements(i, data_->components_)
{
- unsigned c = components_[i];
- holder_.components_()(c).update_type(type);
+ unsigned c = data_->components_[i];
+ data_->holder_.components_()(c).update_type(type);
}
}
@@ -550,7 +563,7 @@ namespace scribo
void
line_info<L>::update_type(line::Type type)
{
- type_ = type;
+ data_->type_ = type;
// Some line types may involve updating components type as well.
if (type == line::Punctuation)
@@ -564,7 +577,7 @@ namespace scribo
bool
line_info<L>::reverse_video() const
{
- return reverse_video_;
+ return data_->reverse_video_;
}
@@ -572,7 +585,7 @@ namespace scribo
float
line_info<L>::orientation() const
{
- return orientation_;
+ return data_->orientation_;
}
@@ -580,7 +593,7 @@ namespace scribo
float
line_info<L>::reading_orientation() const
{
- return reading_orientation_;
+ return data_->reading_orientation_;
}
@@ -588,21 +601,21 @@ namespace scribo
bool
line_info<L>::indented() const
{
- return indented_;
+ return data_->indented_;
}
template <typename L>
bool
line_info<L>::has_text() const
{
- return !text_.empty();
+ return !data_->text_.empty();
}
template <typename L>
const std::string&
line_info<L>::text() const
{
- return text_;
+ return data_->text_;
}
@@ -610,7 +623,7 @@ namespace scribo
void
line_info<L>::update_text(const std::string& str)
{
- text_ = str;
+ data_->text_ = str;
}
@@ -624,9 +637,19 @@ namespace scribo
template <typename L>
bool
+ line_info<L>::is_textline() const
+ {
+ return is_valid()
+ && !is_hidden()
+ && type() == line::Text;
+ }
+
+
+ template <typename L>
+ bool
line_info<L>::is_hidden() const
{
- return hidden_;
+ return data_->hidden_;
}
@@ -634,7 +657,7 @@ namespace scribo
void
line_info<L>::set_hidden(bool b)
{
- hidden_ = b;
+ data_->hidden_ = b;
}
@@ -665,8 +688,8 @@ namespace scribo
void
line_info<L>::update_ebbox()
{
- int A = a_height_ - x_height_;
- int D = - d_height_;
+ int A = data_->a_height_ - data_->x_height_;
+ int D = - data_->d_height_;
if (A <= 2 && D > 2)
A = D;
if (D <= 2 && A > 2)
@@ -674,10 +697,12 @@ namespace scribo
int delta = delta_of_line();
- ebbox_ = mln::make::box2d(meanline_ - A, bbox().pmin().col() - delta,
- baseline_ + D, bbox().pmax().col() + delta);
+ data_->ebbox_ = mln::make::box2d(data_->meanline_ - A,
+ bbox().pmin().col() - delta,
+ data_->baseline_ + D,
+ bbox().pmax().col() + delta);
- ebbox_.crop_wrt(holder_.components().labeled_image().domain());
+ data_->ebbox_.crop_wrt(data_->holder_.components().labeled_image().domain());
}
@@ -729,20 +754,20 @@ namespace scribo
// Adjusting ebboxes with the highest delta and merging ebboxes.
int d_delta = other.delta_of_line() - this->delta_of_line();
if (d_delta < 0) // other.delta_of_line() < this->delta_of_line()
- ebbox_.merge(enlarge(other.ebbox(), - d_delta));
+ data_->ebbox_.merge(enlarge(other.ebbox(), - d_delta));
else
{
- mln::box2d b = ebbox_;
- ebbox_ = other.bbox();
- ebbox_.merge(enlarge(b, d_delta));
+ mln::box2d b = data_->ebbox_;
+ data_->ebbox_ = other.bbox();
+ data_->ebbox_.merge(enlarge(b, d_delta));
}
- ebbox_.crop_wrt(holder_.components().labeled_image().domain());
+ data_->ebbox_.crop_wrt(data_->holder_.components().labeled_image().domain());
}
else // /other/ IS NOT a text line.
{
- ebbox_.merge(other.ebbox());
- ebbox_.merge(merged_ebbox(*this, other));
+ data_->ebbox_.merge(other.ebbox());
+ data_->ebbox_.merge(merged_ebbox(*this, other));
}
}
else // /this/ is NOT a text line
@@ -755,15 +780,15 @@ namespace scribo
}
update_type(line::Text);
- ebbox_.merge(other.ebbox());
- ebbox_.merge(merged_ebbox(other, *this));
+ data_->ebbox_.merge(other.ebbox());
+ data_->ebbox_.merge(merged_ebbox(other, *this));
}
// Merging bboxes.
- bbox_.merge(other.bbox());
+ data_->bbox_.merge(other.bbox());
// Make sure the ebbox is included in the image domain.
- ebbox_.crop_wrt(holder_.components().labeled_image().domain());
+ data_->ebbox_.crop_wrt(data_->holder_.components().labeled_image().domain());
}
@@ -771,14 +796,14 @@ namespace scribo
void
line_info<L>::fast_merge(line_info<L>& other, bool hide)
{
- tag_ = line::Needs_Precise_Stats_Update;
+ data_->tag_ = line::Needs_Precise_Stats_Update;
other.update_tag(line::Merged);
other.set_hidden(hide);
// Update bbox and ebbox
update_bbox_and_ebox(other);
- components_.append(other.components());
+ data_->components_.append(other.components());
}
@@ -795,7 +820,7 @@ namespace scribo
line_info<L>::force_stats_update()
{
typedef mln_site(L) P;
- const component_set<L>& comp_set = holder_.components();
+ const component_set<L>& comp_set = data_->holder_.components();
// Init.
typedef mln::value::int_u<12> median_data_t;
@@ -814,21 +839,21 @@ namespace scribo
// Workaround to avoid overflow with int_u<12> in median accumulators.
//
// FIXME: not optimal...
- for_all_elements(i, components_)
+ for_all_elements(i, data_->components_)
{
- unsigned c = components_(i);
+ unsigned c = data_->components_(i);
// Ignore punctuation for stats computation but not for bbox
// computation.
- if (holder_.components()(c).type() == component::Punctuation)
+ if (data_->holder_.components()(c).type() == component::Punctuation)
continue;
ref_line = mln::math::min(comp_set(c).bbox().pmin().row(), ref_line);
}
- for_all_elements(i, components_)
+ for_all_elements(i, data_->components_)
{
- unsigned c = components_(i);
+ unsigned c = data_->components_(i);
const mln::box2d& bb = comp_set(c).bbox();
@@ -837,7 +862,7 @@ namespace scribo
// Ignore punctuation for stats computation but not for bbox
// computation.
- if (holder_.components()(c).type() == component::Punctuation)
+ if (data_->holder_.components()(c).type() == component::Punctuation)
continue;
@@ -853,11 +878,11 @@ namespace scribo
// (right link) (left link)
// Space between characters.
- if (holder_.links()(c) != c)
+ if (data_->holder_.links()(c) != c)
{
int
space = bb.pmin().col()
- - comp_set(holder_.links()(c)).bbox().pmax().col() - 1;
+ - comp_set(data_->holder_.links()(c)).bbox().pmax().col() - 1;
// -- Ignore overlapped characters.
if (space > 0)
@@ -884,31 +909,31 @@ namespace scribo
// Finalization
{
- tag_ = line::None;
- bbox_ = bbox.to_result();
+ data_->tag_ = line::None;
+ data_->bbox_ = bbox.to_result();
// Char space
if (char_space.card() < 2)
- char_space_ = 0;
+ data_->char_space_ = 0;
else
- char_space_ = char_space.to_result();
+ data_->char_space_ = char_space.to_result();
// Char width
if (card() == 2)
- char_width_ = (comp_set(components_[0]).bbox().width()
- + comp_set(components_[1]).bbox().width()) / 2;
+ data_->char_width_ = (comp_set(data_->components_[0]).bbox().width()
+ + comp_set(data_->components_[1]).bbox().width()) / 2;
else
- char_width_ = char_width.to_result();
+ data_->char_width_ = char_width.to_result();
mln::def::coord
absolute_baseline_r = baseline.to_result() + ref_line,
absolute_meanline_r = meanline.to_result() + ref_line;
- baseline_ = absolute_baseline_r;
- meanline_ = absolute_meanline_r;
- x_height_ = baseline_ - meanline_ + 1;
- d_height_ = baseline_ - bbox.to_result().pmax().row();
- a_height_ = baseline_ - bbox.to_result().pmin().row() + 1;
+ data_->baseline_ = absolute_baseline_r;
+ data_->meanline_ = absolute_meanline_r;
+ data_->x_height_ = data_->baseline_ - data_->meanline_ + 1;
+ data_->d_height_ = data_->baseline_ - bbox.to_result().pmax().row();
+ data_->a_height_ = data_->baseline_ - bbox.to_result().pmin().row() + 1;
//FIXME
//
@@ -929,7 +954,7 @@ namespace scribo
const line_set<L>&
line_info<L>::holder() const
{
- return holder_;
+ return data_->holder_;
}
diff --git a/scribo/scribo/core/line_links.hh b/scribo/scribo/core/line_links.hh
index 85c45e8..de62158 100644
--- a/scribo/scribo/core/line_links.hh
+++ b/scribo/scribo/core/line_links.hh
@@ -139,8 +139,8 @@ namespace scribo
template <typename L>
line_links<L>::line_links()
+ : data_(0)
{
- data_ = new data_t();
}
diff --git a/scribo/scribo/core/line_set.hh b/scribo/scribo/core/line_set.hh
index 29795b2..bfa9240 100644
--- a/scribo/scribo/core/line_set.hh
+++ b/scribo/scribo/core/line_set.hh
@@ -99,6 +99,10 @@ namespace scribo
/// Constructor from object groups.
line_set(const object_groups<L>& groups);
+
+ /// Constructor useful for delayed construction (loading from file).
+ line_set(const object_groups<L>& groups,
+ const mln::util::array<line_info<L> >& line_data);
/// @}
/// Compute line stats and fill the underlying information.
@@ -155,8 +159,14 @@ namespace scribo
/// @}
+ /// Return false if it is not initialized (built with the default
+ /// constructor).
bool is_valid() const;
+
+ void update_line_data_(const mln::util::array<line_info<L> >& line_data);
+
+
private:
/// Duplicate the underlying image and create a new line_set.
void init_(const line_set<L>& model);
@@ -233,6 +243,15 @@ namespace scribo
template <typename L>
+ inline
+ line_set<L>::line_set(const object_groups<L>& groups,
+ const mln::util::array<line_info<L> >& line_data)
+ {
+ data_ = new internal::line_set_data<L>(line_data, groups);
+ }
+
+
+ template <typename L>
void
line_set<L>::compute_lines(const object_groups<L>& groups)
{
@@ -396,7 +415,15 @@ namespace scribo
bool
line_set<L>::is_valid() const
{
- return data_->links_.is_valid() && data_->groups_.is_valid();
+ return data_ && data_->groups_.is_valid();
+ }
+
+ template <typename L>
+ inline
+ void
+ line_set<L>::update_line_data_(const mln::util::array<line_info<L> >& line_data)
+ {
+ data_->infos_ = line_data;
}
template <typename L>
diff --git a/scribo/scribo/core/paragraph_info.hh b/scribo/scribo/core/paragraph_info.hh
index a8c623a..17f847f 100644
--- a/scribo/scribo/core/paragraph_info.hh
+++ b/scribo/scribo/core/paragraph_info.hh
@@ -113,6 +113,16 @@ namespace scribo
}
+ template <typename L>
+ std::ostream&
+ operator<<(std::ostream& ostr, const paragraph_info<L>& info)
+ {
+ return ostr << "paragraph_info("
+ << "line_ids=" << info.line_ids()
+ << ", bbox=" << info.bbox()
+ << ")" << std::endl;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo
diff --git a/scribo/scribo/core/paragraph_set.hh b/scribo/scribo/core/paragraph_set.hh
index 355eaa9..6597189 100644
--- a/scribo/scribo/core/paragraph_set.hh
+++ b/scribo/scribo/core/paragraph_set.hh
@@ -36,6 +36,25 @@
namespace scribo
{
+ namespace internal
+ {
+
+ /// Data structure for \c scribo::paragraph_set<I>.
+ template <typename L>
+ struct paragraph_set_data
+ {
+ paragraph_set_data();
+ paragraph_set_data(const line_links<L>& llines, unsigned npars);
+
+ mln::util::array<paragraph_info<L> > pars_;
+ line_set<L> lines_;
+ line_links<L> links_;
+ };
+
+ } // end of namespace scribo::internal
+
+
+
/*! \brief Paragraph container.
Paragraph ids start from 1.
@@ -46,6 +65,7 @@ namespace scribo
{
public:
paragraph_set();
+ paragraph_set(internal::paragraph_set_data<L>* data);
paragraph_set(const line_links<L>& llinks, unsigned npars);
unsigned nelements() const;
@@ -57,9 +77,10 @@ namespace scribo
const line_set<L>& lines() const;
+ const line_links<L>& links() const;
+
private:
- mln::util::array<paragraph_info<L> > pars_;
- line_set<L> lines_;
+ mln::util::tracked_ptr< internal::paragraph_set_data<L> > data_;
};
@@ -77,37 +98,72 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+ // paragraph_set_data<L> >
+
+ namespace internal
+ {
+
+ // data< paragraph_set<L> >
+
+
+ template <typename L>
+ inline
+ paragraph_set_data<L>::paragraph_set_data()
+ {
+ }
+
+
+ template <typename L>
+ inline
+ paragraph_set_data<L>::paragraph_set_data(const line_links<L>& llinks, unsigned npars)
+ : pars_(npars + 1, paragraph_info<L>(llinks)), links_(llinks)
+ {
+ lines_ = llinks.lines();
+ }
+
+ } // end of namespace mln::internal
+
+
template <typename L>
paragraph_set<L>::paragraph_set()
+ : data_(0)
{
}
template <typename L>
+ paragraph_set<L>::paragraph_set(internal::paragraph_set_data<L>* data)
+ {
+ data_ = data;
+ }
+
+ template <typename L>
paragraph_set<L>::paragraph_set(const line_links<L>& llinks, unsigned npars)
- : pars_(npars + 1, paragraph_info<L>(llinks))
{
- lines_ = llinks.lines();
+ data_ = new internal::paragraph_set_data<L>(llinks, npars);
}
template <typename L>
unsigned
paragraph_set<L>::nelements() const
{
- return pars_.nelements() - 1;
+ mln_precondition(data_ != 0);
+ return data_->pars_.nelements() - 1;
}
template <typename L>
paragraph_info<L>&
paragraph_set<L>::operator()(unsigned i)
{
- return pars_[i];
+ mln_precondition(data_ != 0);
+ return data_->pars_[i];
}
template <typename L>
const paragraph_info<L>&
paragraph_set<L>::operator()(unsigned i) const
{
- return pars_[i];
+ mln_precondition(data_ != 0);
+ return data_->pars_[i];
}
@@ -115,7 +171,7 @@ namespace scribo
bool
paragraph_set<L>::is_valid() const
{
- return !pars_.is_empty();
+ return data_ && !data_->pars_.is_empty();
}
@@ -123,7 +179,17 @@ namespace scribo
const line_set<L>&
paragraph_set<L>::lines() const
{
- return lines_;
+ mln_precondition(data_ != 0);
+ return data_->lines_;
+ }
+
+
+ template <typename L>
+ const line_links<L>&
+ paragraph_set<L>::links() const
+ {
+ mln_precondition(data_ != 0);
+ return data_->links_;
}
--
1.5.6.5
1
0
* scribo/primitive/extract/elements.hh,
* src/primitive/extract/extract_discontinued_hlines.cc,
* src/primitive/extract/extract_discontinued_lines.cc,
* src/primitive/extract/extract_discontinued_vlines.cc,
* src/primitive/extract/extract_thick_hlines.cc,
* src/primitive/extract/extract_thick_vlines.cc: Rename to...
* scribo/primitive/extract/non_text.hh,
* src/primitive/extract/discontinued_hlines.cc,
* src/primitive/extract/discontinued_lines.cc,
* src/primitive/extract/discontinued_vlines.cc,
* src/primitive/extract/thick_hlines.cc,
* src/primitive/extract/thick_vlines.cc: ... this.
* scribo/toolchain/internal/content_in_doc_functor.hh: Rename
function call from extract::elements to extract_non_text.
* src/primitive/extract/Makefile.am: Update target names.
---
scribo/ChangeLog | 23 +++++++
.../primitive/extract/{elements.hh => non_text.hh} | 64 +++++++++++---------
.../toolchain/internal/content_in_doc_functor.hh | 2 +-
scribo/src/primitive/extract/Makefile.am | 26 ++++----
...scontinued_hlines.cc => discontinued_hlines.cc} | 0
...discontinued_lines.cc => discontinued_lines.cc} | 0
...scontinued_vlines.cc => discontinued_vlines.cc} | 0
.../{extract_thick_hlines.cc => thick_hlines.cc} | 0
.../{extract_thick_vlines.cc => thick_vlines.cc} | 0
9 files changed, 73 insertions(+), 42 deletions(-)
rename scribo/scribo/primitive/extract/{elements.hh => non_text.hh} (82%)
rename scribo/src/primitive/extract/{extract_discontinued_hlines.cc => discontinued_hlines.cc} (100%)
rename scribo/src/primitive/extract/{extract_discontinued_lines.cc => discontinued_lines.cc} (100%)
rename scribo/src/primitive/extract/{extract_discontinued_vlines.cc => discontinued_vlines.cc} (100%)
rename scribo/src/primitive/extract/{extract_thick_hlines.cc => thick_hlines.cc} (100%)
rename scribo/src/primitive/extract/{extract_thick_vlines.cc => thick_vlines.cc} (100%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 7b409a2..fa99f5b 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,28 @@
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Rename files in Scribo.
+
+ * scribo/primitive/extract/elements.hh,
+ * src/primitive/extract/extract_discontinued_hlines.cc,
+ * src/primitive/extract/extract_discontinued_lines.cc,
+ * src/primitive/extract/extract_discontinued_vlines.cc,
+ * src/primitive/extract/extract_thick_hlines.cc,
+ * src/primitive/extract/extract_thick_vlines.cc: Rename to...
+
+ * scribo/primitive/extract/non_text.hh,
+ * src/primitive/extract/discontinued_hlines.cc,
+ * src/primitive/extract/discontinued_lines.cc,
+ * src/primitive/extract/discontinued_vlines.cc,
+ * src/primitive/extract/thick_hlines.cc,
+ * src/primitive/extract/thick_vlines.cc: ... this.
+
+ * scribo/toolchain/internal/content_in_doc_functor.hh: Rename
+ function call from extract::elements to extract_non_text.
+
+ * src/primitive/extract/Makefile.am: Update target names.
+
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add Base64 conversion routines.
* scribo/scribo/convert/from_base64.hh,
diff --git a/scribo/scribo/primitive/extract/elements.hh b/scribo/scribo/primitive/extract/non_text.hh
similarity index 82%
rename from scribo/scribo/primitive/extract/elements.hh
rename to scribo/scribo/primitive/extract/non_text.hh
index ddf2c92..a017f1f 100644
--- a/scribo/scribo/primitive/extract/elements.hh
+++ b/scribo/scribo/primitive/extract/non_text.hh
@@ -26,12 +26,12 @@
/// \file
///
-/// \brief Find in a document elements which are not text.
+/// \brief Find in a document non text which are not text.
///
/// \fixme To be optimized!
-#ifndef SCRIBO_PRIMITIVE_EXTRACT_ELEMENTS_HH
-# define SCRIBO_PRIMITIVE_EXTRACT_ELEMENTS_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_NON_TEXT_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_NON_TEXT_HH
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
@@ -58,6 +58,10 @@
# include <mln/clustering/kmean_rgb.hh>
# include <mln/fun/v2v/rgb8_to_rgbn.hh>
+# include <mln/util/timer.hh>
+
+# include <mln/io/pbm/save.hh>
+
namespace scribo
{
@@ -72,7 +76,7 @@ namespace scribo
template <typename L, typename I>
component_set<L>
- elements(const document<L>& doc, const Image<I>& input);
+ non_text(const document<L>& doc, const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
@@ -107,9 +111,9 @@ namespace scribo
template <typename L, typename I>
component_set<L>
- elements(const document<L>& doc, const Image<I>& input_)
+ non_text(const document<L>& doc, const Image<I>& input_)
{
- trace::entering("scribo::primitive::extract::elements");
+ trace::entering("scribo::primitive::extract::non_text");
const I& input = exact(input_);
mln_precondition(doc.is_valid());
@@ -135,9 +139,16 @@ namespace scribo
image2d<t_rgb5>
img_rgb5 = mln::data::transform(doc.image(), t_rgb8_to_rgb5());
+ // DEBUG
+ io::pbm::save(content, "text_area.pbm");
+
+ mln::util::timer t;
+ t.start();
img_lbl8 =
mln::clustering::kmean_rgb<double,5>((img_rgb5 | pw::value(content)), 3, 10, 10).unmorph_();
data::fill((img_lbl8 | !pw::value(content)).rw(), 0u);
+ t.stop();
+ std::cout << t << std::endl;
mln::util::array<unsigned>
card = mln::labeling::compute(accu::math::count<value::label_8>(),
@@ -162,15 +173,25 @@ namespace scribo
std::cout << "Removing small elements" << std::endl;
{
- image2d<bool> elts;
- initialize(elts, img_lbl8);
- data::fill(elts, false);
- data::fill((elts | (pw::value(img_lbl8) != pw::cst(0))).rw(), true);
+ image2d<bool> elts;
+ initialize(elts, img_lbl8);
+ data::fill(elts, false);
+ data::fill((elts | (pw::value(img_lbl8) != pw::cst(0))).rw(), true);
+
+ // DEBUG
+ data::fill((elts | (pw::value(doc.line_seps()) != pw::cst(0))).rw(),
+ false);
+ // END OF DEBUG
+
- scribo::def::lbl_type nlabels;
- elts = filter::components_small(elts, c8(), nlabels, 40);
+ scribo::def::lbl_type nlabels;
+ elts = filter::components_small(elts, c8(), nlabels, 40);
- output = primitive::extract::components(elts, c8(), nlabels);
+ // DEBUG
+ io::pbm::save(elts, "elements.pbm");
+ // END OF DEBUG
+
+ output = primitive::extract::components(elts, c8(), nlabels);
}
@@ -207,20 +228,7 @@ namespace scribo
}
}
-// mln::io::pbm::save(merged_elts, "merged_elts.pbm");
-
-// mln::util::array<image2d<value::rgb8> > elt_ima;
-// unsigned i = 0;
-// for_all_comps(c, elt_comp)
-// if (elt_comp(c).is_valid())
-// {
-// elt_ima.append(preprocessing::crop(doc.image(), elt_comp(c).bbox()));
-// mln::io::ppm::save(elt_ima(i), mln::debug::filename("elt.ppm", i));
-// ++i;
-// }
-
-
- trace::exiting("scribo::primitive::extract::elements");
+ trace::exiting("scribo::primitive::extract::non_text");
return output;
}
@@ -233,4 +241,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_PRIMITIVE_EXTRACT_ELEMENTS_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_NON_TEXT_HH
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
index b8aa56d..ed691e8 100644
--- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -463,7 +463,7 @@ namespace scribo
// Extract other Elements
on_new_progress_label("Extracting Elements");
component_set<L>
- elements = scribo::primitive::extract::elements(doc, original_image);
+ elements = scribo::primitive::extract::non_text(doc, original_image);
on_progress();
diff --git a/scribo/src/primitive/extract/Makefile.am b/scribo/src/primitive/extract/Makefile.am
index 2c8188e..a46cd68 100644
--- a/scribo/src/primitive/extract/Makefile.am
+++ b/scribo/src/primitive/extract/Makefile.am
@@ -1,5 +1,5 @@
-# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-# (LRDE).
+# Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+# Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -18,17 +18,17 @@
include $(top_srcdir)/scribo/scribo.mk
-noinst_PROGRAMS = \
- extract_discontinued_lines \
- extract_discontinued_vlines \
- extract_discontinued_hlines \
- extract_thick_vlines \
- extract_thick_hlines \
+noinst_PROGRAMS = \
+ discontinued_lines \
+ discontinued_vlines \
+ discontinued_hlines \
+ thick_vlines \
+ thick_hlines \
lines_pattern
-extract_discontinued_lines_SOURCES = extract_discontinued_lines.cc
-extract_discontinued_vlines_SOURCES = extract_discontinued_vlines.cc
-extract_discontinued_hlines_SOURCES = extract_discontinued_hlines.cc
-extract_thick_vlines_SOURCES = extract_thick_vlines.cc
-extract_thick_hlines_SOURCES = extract_thick_hlines.cc
+discontinued_lines_SOURCES = discontinued_lines.cc
+discontinued_vlines_SOURCES = discontinued_vlines.cc
+discontinued_hlines_SOURCES = discontinued_hlines.cc
+thick_vlines_SOURCES = thick_vlines.cc
+thick_hlines_SOURCES = thick_hlines.cc
lines_pattern_SOURCES = lines_pattern.cc
diff --git a/scribo/src/primitive/extract/extract_discontinued_hlines.cc b/scribo/src/primitive/extract/discontinued_hlines.cc
similarity index 100%
rename from scribo/src/primitive/extract/extract_discontinued_hlines.cc
rename to scribo/src/primitive/extract/discontinued_hlines.cc
diff --git a/scribo/src/primitive/extract/extract_discontinued_lines.cc b/scribo/src/primitive/extract/discontinued_lines.cc
similarity index 100%
rename from scribo/src/primitive/extract/extract_discontinued_lines.cc
rename to scribo/src/primitive/extract/discontinued_lines.cc
diff --git a/scribo/src/primitive/extract/extract_discontinued_vlines.cc b/scribo/src/primitive/extract/discontinued_vlines.cc
similarity index 100%
rename from scribo/src/primitive/extract/extract_discontinued_vlines.cc
rename to scribo/src/primitive/extract/discontinued_vlines.cc
diff --git a/scribo/src/primitive/extract/extract_thick_hlines.cc b/scribo/src/primitive/extract/thick_hlines.cc
similarity index 100%
rename from scribo/src/primitive/extract/extract_thick_hlines.cc
rename to scribo/src/primitive/extract/thick_hlines.cc
diff --git a/scribo/src/primitive/extract/extract_thick_vlines.cc b/scribo/src/primitive/extract/thick_vlines.cc
similarity index 100%
rename from scribo/src/primitive/extract/extract_thick_vlines.cc
rename to scribo/src/primitive/extract/thick_vlines.cc
--
1.5.6.5
1
0
29 Mar '11
---
milena/ChangeLog | 4 ++++
milena/mln/util/array.hh | 25 +++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e03d35c..c4bed2c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/util/array.hh: Add last() method.
+
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add an optional base index for debug::iota.
* mln/debug/iota.hh,
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index 0fe34e7..c7febfe 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -187,6 +187,11 @@ namespace mln
/// \pre i < nelements()
mutable_result operator[](unsigned i);
+ /// \brief Return the last element.
+ ro_result last() const;
+
+ /// \brief Return the last element.
+ mutable_result last();
/// Empty the array. All elements contained in the array are
/// destroyed. \post is_empty() == true
@@ -553,6 +558,22 @@ namespace mln
template <typename T>
inline
+ typename array<T>::ro_result
+ array<T>::last() const
+ {
+ return v_[nelements() - 1];
+ }
+
+ template <typename T>
+ inline
+ typename array<T>::mutable_result
+ array<T>::last()
+ {
+ return v_[nelements() - 1];
+ }
+
+ template <typename T>
+ inline
bool
array<T>::is_empty() const
{
--
1.5.6.5
1
0
last-svn-commit-768-g5717b0c Add an optional base index for debug::iota.
by Guillaume Lazzara 29 Mar '11
by Guillaume Lazzara 29 Mar '11
29 Mar '11
* mln/debug/iota.hh,
* mln/debug/iota.spe.hh: Here.
---
milena/ChangeLog | 7 +++++++
milena/mln/debug/iota.hh | 22 +++++++++++++++++-----
milena/mln/debug/iota.spe.hh | 9 +++++----
3 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 7a28158..e03d35c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,10 @@
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add an optional base index for debug::iota.
+
+ * mln/debug/iota.hh,
+ * mln/debug/iota.spe.hh: Here.
+
2011-01-27 Guillaume Lazzara <z(a)lrde.epita.fr>
* tests/convert/to_qimage_nocopy.cc: Fix a warning.
diff --git a/milena/mln/debug/iota.hh b/milena/mln/debug/iota.hh
index cfc3ae9..3e569b9 100644
--- a/milena/mln/debug/iota.hh
+++ b/milena/mln/debug/iota.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -49,7 +50,7 @@ namespace mln
* assigned.
*/
template <typename I>
- void iota(Image<I>& input);
+ void iota(Image<I>& input, unsigned base_index);
# ifndef MLN_INCLUDE_ONLY
@@ -60,9 +61,9 @@ namespace mln
template <typename I>
inline
void
- iota(trait::image::speed::any, I& input)
+ iota(trait::image::speed::any, I& input, unsigned base_index)
{
- unsigned i = 0;
+ unsigned i = base_index;
mln_piter(I) p(input.domain());
for_all(p)
input(p) = ++i % mln_max(mln_value(I));
@@ -71,17 +72,28 @@ namespace mln
} // end of namespace mln::debug::impl
+
template <typename I>
inline
void
iota(Image<I>& input)
{
+ iota(input, 0);
+ }
+
+
+ template <typename I>
+ inline
+ void
+ iota(Image<I>& input, unsigned base_index)
+ {
trace::entering("debug::iota");
mln_precondition(exact(input).is_valid());
- impl::iota(mln_trait_image_speed(I)(), exact(input));
+ impl::iota(mln_trait_image_speed(I)(), exact(input), base_index);
trace::exiting("debug::iota");
}
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::debug
diff --git a/milena/mln/debug/iota.spe.hh b/milena/mln/debug/iota.spe.hh
index 9a22bca..37e17d9 100644
--- a/milena/mln/debug/iota.spe.hh
+++ b/milena/mln/debug/iota.spe.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -48,16 +49,16 @@ namespace mln
{
template <typename I>
- void iota(trait::image::speed::fastest, I& input);
+ void iota(trait::image::speed::fastest, I& input, unsigned base_index);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
void
- iota(trait::image::speed::fastest, I& input)
+ iota(trait::image::speed::fastest, I& input, unsigned base_index)
{
- unsigned i = 0;
+ unsigned i = base_index;
mln_pixter(I) p(input);
for_all(p)
p.val() = static_cast<mln_value(I)>(++i % mln_max(mln_value(I)));
--
1.5.6.5
1
0
last-svn-commit-767-g6e51a34 configure.ac: configure scribo/tests/convert.
by Guillaume Lazzara 29 Mar '11
by Guillaume Lazzara 29 Mar '11
29 Mar '11
---
ChangeLog | 4 ++++
configure.ac | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3eb76e4..9fedefa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * configure.ac: configure scribo/tests/convert.
+
2011-03-14 Thierry GERAUD <thierry.geraud(a)lrde.epita.fr>
* milena/mln/labeling/regional_maxima.hh
diff --git a/configure.ac b/configure.ac
index d22f65f..e30f010 100644
--- a/configure.ac
+++ b/configure.ac
@@ -343,6 +343,7 @@ AC_CONFIG_FILES([scribo/tests/data.hh])
AC_CONFIG_FILES([
scribo/tests/Makefile
scribo/tests/binarization/Makefile
+ scribo/tests/convert/Makefile
scribo/tests/core/Makefile
scribo/tests/filter/Makefile
scribo/tests/preprocessing/Makefile
--
1.5.6.5
1
0
29 Mar '11
* scribo/scribo/convert/from_base64.hh,
* scribo/scribo/convert/to_base64.hh: New routines.
* scribo/tests/Makefile.am,
* scribo/tests/convert/Makefile.am,
* scribo/tests/convert/base64.cc: New associated test.
---
scribo/ChangeLog | 11 ++
scribo/scribo/convert/from_base64.hh | 217 ++++++++++++++++++++++++++++
scribo/scribo/convert/to_base64.hh | 185 ++++++++++++++++++++++++
scribo/tests/Makefile.am | 1 +
scribo/tests/{core => convert}/Makefile.am | 8 +-
scribo/tests/convert/base64.cc | 89 ++++++++++++
6 files changed, 507 insertions(+), 4 deletions(-)
create mode 100644 scribo/scribo/convert/from_base64.hh
create mode 100644 scribo/scribo/convert/to_base64.hh
copy scribo/tests/{core => convert}/Makefile.am (84%)
create mode 100644 scribo/tests/convert/base64.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 1bd708a..7b409a2 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,14 @@
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add Base64 conversion routines.
+
+ * scribo/scribo/convert/from_base64.hh,
+ * scribo/scribo/convert/to_base64.hh: New routines.
+
+ * scribo/tests/Makefile.am,
+ * scribo/tests/convert/Makefile.am,
+ * scribo/tests/convert/base64.cc: New associated test.
+
2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr>
Add support for whitespace separators visualization.
diff --git a/scribo/scribo/convert/from_base64.hh b/scribo/scribo/convert/from_base64.hh
new file mode 100644
index 0000000..8c14a0f
--- /dev/null
+++ b/scribo/scribo/convert/from_base64.hh
@@ -0,0 +1,217 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+
+
+#ifndef SCRIBO_CONVERT_FROM_BASE64_HH
+# define SCRIBO_CONVERT_FROM_BASE64_HH
+
+/*! \file
+
+ \brief Decode base64 raw data and convert it to an image.
+
+ Based on Bob Trower's code.
+ http://base64.sourceforge.net/b64.c
+
+ LICENCE: Copyright (c) 2001 Bob Trower, Trantor Standard Systems Inc.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated
+ documentation files (the "Software"), to deal in the
+ Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall
+ be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <cstdio>
+#include <cstdlib>
+
+# include <mln/border/resize.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/util/array.hh>
+
+
+
+namespace scribo
+{
+
+ namespace convert
+ {
+
+ using namespace mln;
+
+ template <typename I>
+ void from_base64(const util::array<unsigned char>& data64,
+ Image<I>& output);
+
+
+# if defined HAVE_QT
+
+ template <typename I>
+ void from_base64(const QString& data64, Image<I>& output_);
+
+# endif // ! HAVE_QT
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace internal
+ {
+
+ /*
+ ** Translation Table to decode
+ */
+ static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
+
+ /*
+ ** decodeblock
+ **
+ ** decode 4 '6-bit' characters into 3 8-bit binary bytes
+ */
+ inline
+ void
+ decodeblock(unsigned char in[4], unsigned char out[3])
+ {
+ out[ 0 ] = (unsigned char) (in[0] << 2 | in[1] >> 4);
+ out[ 1 ] = (unsigned char) (in[1] << 4 | in[2] >> 2);
+ out[ 2 ] = (unsigned char) (((in[2] << 6) & 0xc0) | in[3]);
+ }
+
+
+ template <typename V, typename I>
+ void
+ from_base64_(const V& data64, const unsigned length, Image<I>& output_)
+ {
+ trace::entering("scribo::convert::from_base64_");
+
+ mln_precondition(exact(output_).is_valid());
+ using namespace internal;
+
+ I& output = exact(output_);
+
+ unsigned char in[4], out[3], v;
+ int i, len;
+
+ border::resize(output, 0); // Make sure there is no border!
+
+ unsigned char *ptr = (unsigned char *)output.buffer();
+ unsigned char *end_ptr = (unsigned char *)(output.buffer() + output.nelements());
+
+ for (unsigned idx = 0; idx < length;)
+ {
+ for(len = 0, i = 0; i < 4 && idx < length; i++)
+ {
+ v = 0;
+ while(idx < length && v == 0)
+ {
+ v = (unsigned char) data64[idx++];
+ v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]);
+ if(v)
+ {
+ v = (unsigned char) ((v == '$') ? 0 : v - 61);
+ }
+ }
+ if(idx < length)
+ {
+ len++;
+ if(v)
+ {
+ in[ i ] = (unsigned char) (v - 1);
+ }
+ }
+ else
+ {
+ in[i] = 0;
+ }
+ }
+ if(len)
+ {
+ decodeblock(in, out);
+ for(i = 0; i < len - 1 && ptr != end_ptr; i++)
+ {
+ *ptr++ = out[i];
+ }
+ }
+ }
+
+ trace::exiting("scribo::convert::to_base64_");
+ }
+
+
+ } // end of namespace scribo::convert::internal
+
+
+ template <typename I>
+ void
+ from_base64(const util::array<unsigned char>& data64, Image<I>& output_)
+ {
+ trace::entering("scribo::convert::from_base64");
+
+ internal::from_base64_(data64, data64.nelements(), output_);
+
+ trace::exiting("scribo::convert::to_base64");
+ }
+
+
+# if defined HAVE_QT
+
+ template <typename I>
+ void
+ from_base64(const QString& data64, Image<I>& output_)
+ {
+ trace::entering("scribo::convert::from_base64");
+
+ QByteArray data64_ = data64.toAscii();
+ internal::from_base64_(data64_.constData(), data64_.size(), output_);
+
+ trace::exiting("scribo::convert::to_base64");
+ }
+
+# endif // ! HAVE_QT
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::convert
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_CONVERT_FROM_BASE64_HH
diff --git a/scribo/scribo/convert/to_base64.hh b/scribo/scribo/convert/to_base64.hh
new file mode 100644
index 0000000..8df3ed2
--- /dev/null
+++ b/scribo/scribo/convert/to_base64.hh
@@ -0,0 +1,185 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+
+
+#ifndef SCRIBO_CONVERT_TO_BASE64_HH
+# define SCRIBO_CONVERT_TO_BASE64_HH
+
+/*! \file
+
+ \brief Encode an image into base64 raw data.
+
+ Based on Bob Trower's code.
+ http://base64.sourceforge.net/b64.c
+
+ LICENCE: Copyright (c) 2001 Bob Trower, Trantor Standard Systems Inc.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated
+ documentation files (the "Software"), to deal in the
+ Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall
+ be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+# include <cstdio>
+# include <cstdlib>
+
+# include <mln/border/resize.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/util/array.hh>
+
+
+# define B64_DEF_LINE_SIZE 72
+
+namespace scribo
+{
+
+ namespace convert
+ {
+
+ using namespace mln;
+
+
+ template <typename I>
+ void
+ to_base64(const Image<I>& input, util::array<unsigned char>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace internal
+ {
+
+ /*
+ ** Translation Table as described in RFC1113
+ */
+ static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+ /*
+ ** encodeblock
+ **
+ ** encode 3 8-bit binary bytes as 4 '6-bit' characters
+ */
+ inline
+ void
+ encodeblock(unsigned char in[3], unsigned char out[4], int len)
+ {
+ out[0] = cb64[ in[0] >> 2 ];
+ out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
+ out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '=');
+ out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '=');
+ }
+
+ } // end of namespace scribo::convert::internal
+
+
+
+ template <typename I>
+ void
+ to_base64(const Image<I>& input_, util::array<unsigned char>& output)
+ {
+ trace::entering("scribo::convert::to_base64");
+
+ mln_precondition(exact(input_).is_valid());
+ using namespace internal;
+
+ const I& input = exact(input_);
+
+ unsigned char in[3], out[4];
+ int i, len, blocksout = 0;
+
+ // FIXME: Take border into account while moving pointer and
+ // remove that call.
+ border::resize(input, 0);
+
+ const unsigned char
+ *end_ptr = (unsigned char *) (input.buffer() + input.nelements()),
+ *ptr = (unsigned char *)input.buffer();
+
+ while(ptr != end_ptr)
+ {
+ len = 0;
+ for(i = 0; i < 3; ++i)
+ {
+ if (ptr != end_ptr)
+ {
+ in[i] = (unsigned char) *ptr++;
+ ++len;
+ }
+ else
+ {
+ in[i] = 0;
+ for(++i; i < 3; ++i)
+ in[i] = 0;
+ }
+ }
+ if(len)
+ {
+ encodeblock(in, out, len);
+ for(i = 0; i < 4; ++i)
+ output.append(out[i]);
+ ++blocksout;
+ }
+ if(blocksout >= (B64_DEF_LINE_SIZE/4) || ptr == end_ptr)
+ {
+ if(blocksout)
+ {
+ output.append('\r');
+ output.append('\n');
+ }
+ blocksout = 0;
+ }
+ }
+
+ trace::exiting("scribo::convert::to_base64");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+# undef B64_DEF_LINE_SIZE
+
+ } // end of namespace scribo::convert
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_CONVERT_TO_BASE64_HH
diff --git a/scribo/tests/Makefile.am b/scribo/tests/Makefile.am
index 1cb222b..09768b1 100644
--- a/scribo/tests/Makefile.am
+++ b/scribo/tests/Makefile.am
@@ -29,6 +29,7 @@ EXTRA_DIST = \
SUBDIRS = \
binarization \
+ convert \
core \
filter \
preprocessing \
diff --git a/scribo/tests/core/Makefile.am b/scribo/tests/convert/Makefile.am
similarity index 84%
copy from scribo/tests/core/Makefile.am
copy to scribo/tests/convert/Makefile.am
index 356cc31..c4c912c 100644
--- a/scribo/tests/core/Makefile.am
+++ b/scribo/tests/convert/Makefile.am
@@ -1,5 +1,4 @@
-# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-# (LRDE).
+# Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -20,8 +19,9 @@
include $(top_srcdir)/scribo/tests/tests.mk
-check_PROGRAMS = line_info
+check_PROGRAMS = \
+ base64
-line_info_SOURCES = line_info.cc
+base64_SOURCES = base64.cc
TESTS = $(check_PROGRAMS)
diff --git a/scribo/tests/convert/base64.cc b/scribo/tests/convert/base64.cc
new file mode 100644
index 0000000..18d08d9
--- /dev/null
+++ b/scribo/tests/convert/base64.cc
@@ -0,0 +1,89 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+
+/// \file
+
+#include <cstdio>
+#include <cstdlib>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/data/compare.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
+
+#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/iota.hh>
+
+#include <mln/value/int_u16.hh>
+
+#include <scribo/convert/to_base64.hh>
+#include <scribo/convert/from_base64.hh>
+
+#include "tests/data.hh"
+
+using namespace mln;
+
+int main()
+{
+
+ // PBM
+ {
+ image2d<bool> ima;
+ io::pbm::load(ima, SCRIBO_IMG_DIR "/wildly.pbm");
+
+ util::array<unsigned char> out64;
+ scribo::convert::to_base64(ima, out64);
+
+ image2d<bool> outbin(ima.domain());
+ scribo::convert::from_base64(out64, outbin);
+
+ mln_assertion(outbin == ima);
+ }
+
+ // PGM (8bits)
+ {
+ image2d<value::int_u8> ima;
+ io::pgm::load(ima, SCRIBO_IMG_DIR "/text_to_group.pgm");
+
+ util::array<unsigned char> out64;
+ scribo::convert::to_base64(ima, out64);
+
+ image2d<value::int_u8> outbin(ima.domain());
+ scribo::convert::from_base64(out64, outbin);
+
+ mln_assertion(outbin == ima);
+ }
+
+ // PGM (30bits)
+ {
+ image2d<value::int_u<30> > ima(3, 3);
+ debug::iota(ima, 100000);
+
+ util::array<unsigned char> out64;
+ scribo::convert::to_base64(ima, out64);
+
+ image2d<value::int_u<30> > outbin(ima.domain());
+ scribo::convert::from_base64(out64, outbin);
+
+ mln_assertion(outbin == ima);
+ }
+
+
+ return 0;
+}
--
1.5.6.5
1
0
last-svn-commit-765-g94e4a92 =Add support for whitespace separators visualization.
by Guillaume Lazzara 29 Mar '11
by Guillaume Lazzara 29 Mar '11
29 Mar '11
* demo/viewer/common.hh,
* demo/viewer/key_widget.cc,
* demo/viewer/step_widget.cc,
* demo/viewer/viewer.cc: Handle visualization.
* scribo/toolchain/internal/content_in_doc_functor.hh,
* scribo/core/document.hh: Store separator information.
* scribo/io/xml/save.hh: Save whitespace separator data.
---
scribo/ChangeLog | 14 ++++++
scribo/demo/viewer/common.hh | 22 +++++++++-
scribo/demo/viewer/key_widget.cc | 6 ++-
scribo/demo/viewer/step_widget.cc | 1 +
scribo/demo/viewer/viewer.cc | 20 ++++++++-
scribo/scribo/core/document.hh | 47 ++++++++++++++++++++
scribo/scribo/io/xml/save.hh | 18 ++++++++
.../toolchain/internal/content_in_doc_functor.hh | 5 ++-
8 files changed, 128 insertions(+), 5 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index e516cd5..1bd708a 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,17 @@
+2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add support for whitespace separators visualization.
+
+ * demo/viewer/common.hh,
+ * demo/viewer/key_widget.cc,
+ * demo/viewer/step_widget.cc,
+ * demo/viewer/viewer.cc: Handle visualization.
+
+ * scribo/toolchain/internal/content_in_doc_functor.hh,
+ * scribo/core/document.hh: Store separator information.
+
+ * scribo/io/xml/save.hh: Save whitespace separator data.
+
2011-03-29 Guillaume Lazzara <z(a)lrde.epita.fr>
* scribo/toolchain/nepomuk/text_extraction.hh: Remove useless
diff --git a/scribo/demo/viewer/common.hh b/scribo/demo/viewer/common.hh
index 46f20c1..3b11ba5 100644
--- a/scribo/demo/viewer/common.hh
+++ b/scribo/demo/viewer/common.hh
@@ -24,14 +24,30 @@ namespace region
enum RegionId
{
+ // Text regions
+ // -------------
+
Text = 0,
+
+ // Extension
Line,
EndOfTextRegion,
+ // Separators
+ // ----------
+
+ Separator,
+
+ // Extension
+ WhitespaceSeparator,
+
+ EndOfSepsRegion,
+
+ // Misc regions.
+ // -------------
Image,
Noise,
- Separator,
Table,
LineDrawing,
Graphic,
@@ -40,6 +56,10 @@ namespace region
EndOfMiscRegion,
+ // Typographical lines
+ // -------------------
+
+ // Extension
Baseline,
Meanline,
diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
index cc10308..3b07617 100644
--- a/scribo/demo/viewer/key_widget.cc
+++ b/scribo/demo/viewer/key_widget.cc
@@ -22,8 +22,9 @@ KeyWidget::KeyWidget(const region::KeyMap& key_map)
: items_(new QTreeWidget())
{
item_list_.append(new QTreeWidgetItem(QStringList("Text")));
- item_list_.append(new QTreeWidgetItem(QStringList("Regions")));
- item_list_.append(new QTreeWidgetItem(QStringList("Typographical Lines")));
+ item_list_.append(new QTreeWidgetItem(QStringList("Separators")));
+ item_list_.append(new QTreeWidgetItem(QStringList("Misc. Regions")));
+ item_list_.append(new QTreeWidgetItem(QStringList("Typographical lines")));
QLabel* title = new QLabel(tr("Key"));
title->setAlignment(Qt::AlignHCenter);
@@ -38,6 +39,7 @@ KeyWidget::KeyWidget(const region::KeyMap& key_map)
base_id_.append(0);
base_id_.append(region::EndOfTextRegion + 1);
+ base_id_.append(region::EndOfSepsRegion + 1);
base_id_.append(region::EndOfMiscRegion + 1);
base_id_.append(region::EndOfTypoRegion + 1);
diff --git a/scribo/demo/viewer/step_widget.cc b/scribo/demo/viewer/step_widget.cc
index 77e9bd3..19b5d0f 100644
--- a/scribo/demo/viewer/step_widget.cc
+++ b/scribo/demo/viewer/step_widget.cc
@@ -59,6 +59,7 @@ void StepWidget::activate(QListWidgetItem* item)
key = iter.key();
value = iter.value();
+ qDebug() << "Loading " << value;
emit load_xml(value);
}
else
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index 1d48b1a..f34b3e7 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -51,8 +51,11 @@ Viewer::Viewer(int &argc, char** argv)
pdialog_(win_)
{
// Key map
+ // --------
key_map_[region::Text] = qMakePair(tr("Text Region"), QColor(0, 200, 0));
+
+ // Extension
key_map_[region::Line] = qMakePair(tr("Text line"), QColor(255, 0, 0));
key_map_[region::Image] = qMakePair(tr("Image"), QColor(255, 120, 0));
@@ -65,13 +68,23 @@ Viewer::Viewer(int &argc, char** argv)
key_map_[region::Chart] = qMakePair(tr("Chart"), QColor(0, 204, 255));
key_map_[region::Maths] = qMakePair(tr("Maths"), QColor(170, 0, 255));
+ // Extension
+ key_map_[region::WhitespaceSeparator] = qMakePair(tr("Whitespace Separator"), QColor(0, 0, 128));
+
+ // Extension
key_map_[region::Baseline] = qMakePair(tr("Baseline"), QColor(128, 0, 255));
key_map_[region::Meanline] = qMakePair(tr("Meanline"), QColor(128, 0, 255));
+
+
// Region ids
+ // ----------
region_ids_["text_region"] = region::Text;
+
+ // Extension
region_ids_["line"] = region::Line;
+
region_ids_["image_region"] = region::Image;
region_ids_["noise_region"] = region::Noise;
region_ids_["separator_region"] = region::Separator;
@@ -81,6 +94,11 @@ Viewer::Viewer(int &argc, char** argv)
region_ids_["chart_region"] = region::Chart;
region_ids_["maths_region"] = region::Maths;
+ // Extension
+ region_ids_["whitespace_separator_region"] = region::WhitespaceSeparator;
+
+
+
win_->resize(1152, 864);
win_->statusBar();
@@ -572,7 +590,7 @@ Viewer::load_xml(QString filename)
while (!region.isNull())
{
- if (region.toElement().tagName().contains(QRegExp("(image|graphic|chart|separator|table|text)_region")))
+ if (region.toElement().tagName().contains(QRegExp("(whitespace_separator|image|graphic|chart|separator|table|text)_region")))
{
QString attr_id = region.toElement().attribute("id", "none");
add_region(region, attr_id);
diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh
index b547da4..f112410 100644
--- a/scribo/scribo/core/document.hh
+++ b/scribo/scribo/core/document.hh
@@ -32,6 +32,7 @@
/// \brief Describes document content.
# include <mln/core/image/image2d.hh>
+# include <mln/core/alias/neighb2d.hh>
# include <mln/value/rgb8.hh>
# include <mln/io/magick/load.hh>
@@ -39,6 +40,8 @@
# include <scribo/core/line_set.hh>
# include <scribo/core/paragraph_set.hh>
+# include <scribo/primitive/extract/components.hh>
+
namespace scribo
{
@@ -83,6 +86,11 @@ namespace scribo
const mln::image2d<value::rgb8>& image() const;
void set_image(const mln::image2d<value::rgb8>& image);
+ bool has_whitespace_seps() const;
+ const mln::image2d<bool>& whitespace_seps() const;
+ const component_set<L>& whitespace_seps_comps() const;
+ void set_whitespace_separators(const image2d<bool>& whitespace_seps);
+
private:
const char *filename_;
mln::image2d<mln::value::rgb8> image_;
@@ -90,6 +98,9 @@ namespace scribo
line_set<L> lines_;
paragraph_set<L> parset_;
component_set<L> elements_;
+
+ mln::image2d<bool> whitespace_seps_;
+ component_set<L> whitespace_seps_comps_;
};
@@ -247,6 +258,42 @@ namespace scribo
}
+ template <typename L>
+ bool
+ document<L>::has_whitespace_seps() const
+ {
+ return whitespace_seps_.is_valid();
+ }
+
+
+ template <typename L>
+ const mln::image2d<bool>&
+ document<L>::whitespace_seps() const
+ {
+ return whitespace_seps_;
+ }
+
+
+ template <typename L>
+ const component_set<L>&
+ document<L>::whitespace_seps_comps() const
+ {
+ return whitespace_seps_comps_;
+ }
+
+
+ template <typename L>
+ void
+ document<L>::set_whitespace_separators(const image2d<bool>& whitespace_seps)
+ {
+ whitespace_seps_ = whitespace_seps;
+
+ mln_value(L) ncomps;
+ whitespace_seps_comps_ = primitive::extract::components(whitespace_seps,
+ mln::c8(), ncomps);
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh
index 41d4fef..7011e87 100644
--- a/scribo/scribo/io/xml/save.hh
+++ b/scribo/scribo/io/xml/save.hh
@@ -364,6 +364,24 @@ namespace scribo
}
+ // Whitespace seraparators
+ if (doc.has_whitespace_seps())
+ {
+ const component_set<L>&
+ whitespace_seps_comps = doc.whitespace_seps_comps();
+
+ for_all_comps(c, whitespace_seps_comps)
+ {
+ file << " <whitespace_separator_region id=\"wss"
+ << whitespace_seps_comps(c).id()
+ << "\">" << std::endl;
+
+ internal::print_box_coords(file, whitespace_seps_comps(c).bbox(), " ");
+
+ file << " </whitespace_separator_region>" << std::endl;
+ }
+ }
+
file << " </page>" << std::endl;
file << "</pcGts>" << std::endl;
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
index fb7cd7c..b8aa56d 100644
--- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -237,7 +237,10 @@ namespace scribo
if (enable_line_seps)
components.add_separators(separators);
if (enable_whitespace_seps)
+ {
components.add_separators(whitespaces);
+ doc.set_whitespace_separators(whitespaces);
+ }
if (enable_debug)
mln::io::pbm::save(components.separators(),
@@ -251,7 +254,7 @@ namespace scribo
on_progress();
- /// Linking potential objects
+ /// Linking objects
on_new_progress_label("Linking objects...");
object_links<L> left_link
--
1.5.6.5
1
0
29 Mar '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch unstable/scribo has been updated
discards 65ec591cc15b84468c066dd6708e041b1d3949d1 (commit)
discards b1edf757ef7afe1323adbac78593d907da3bbb3f (commit)
discards 59c675bf89f6f708eee6988113338f7b5899807c (commit)
discards 848f99d169cba718ea39658a3a08527e272144a3 (commit)
discards 9b60b90c5214d017209f9082558ed25388988863 (commit)
discards 638a3075e02ea776e2d6e74a2a3d9b8a05d76fde (commit)
discards 4ad3ae8d2a86ab4192be7392871242e2c9535ce4 (commit)
discards 31809b6103dcbba82474e951274676b00f315d2f (commit)
discards 30e9e38e5935bd2305b67bf2c306dafb5fecb047 (commit)
discards 546e98d51ff890f14e1cb3c367541e9c03725350 (commit)
discards 485bbf87ecdf4c53bf672cd47e722c7d75703d75 (commit)
discards 20b750a8628dd43cde273109c57023335c47536d (commit)
discards 3de602aa446941f8a3ad5d03b5bb2cc031a3bdec (commit)
discards 91a93e84e31d7571340188f2f1dacdcdb0d6c210 (commit)
discards abbc1e66aded6326799ed132230fa60bf60b23dd (commit)
discards 1027aef615d0b8cb373aecc25ca8bab812a3ab03 (commit)
discards 794a820803ee4bc55872cb49e38a385b6b38b783 (commit)
discards 5c363a16c9ce736c50e6dcd0e3e7feebd79be7a1 (commit)
discards b01bf1512d4986dbcc51bfb43f54d7a8b562d38e (commit)
discards ed1425b584398be6b36be551e7b4258dfd1758a6 (commit)
discards d31fffd6aad495e8b44b86d3ea667b6d4efa7469 (commit)
discards 1e9c3e590c82f271e8b0cc8c8b85863d36e91474 (commit)
discards 65d90390602dde5d14dd25f5ee088b4ac47f47c5 (commit)
discards ea8ad625701a38fe7980cabc7fd6e8764307b7f4 (commit)
discards ecf417bbb05bb040a637a71b6d5c5d82164d2ca6 (commit)
discards 282de701ea7eefc86919581fe6c004ab7cc36584 (commit)
discards 1d1a977dda81f80570255a3aefa1a8919b9198f1 (commit)
discards 5db5a7215cc5b5adf1cc2e10b287f854a04a32e2 (commit)
discards fe898e73cba128d138abb5ae4c8c4aa411c48e77 (commit)
discards 5b25a55343dd45bc65225697e49fc7af9b35d077 (commit)
discards 0135714d0d79984802f2f19aa2e93321efeb8802 (commit)
discards 20da74d6ce217ba0c7300f024c3b174487cb0cd3 (commit)
discards 881caef92eaa1ad16aa9ae80b26b07fc5a04f191 (commit)
discards 5c06e0488ea613362d8781d163f87207e83ec58f (commit)
discards 6de9b0968f12e6bd0c786ad3aeca239f9895efaa (commit)
discards f92f9d4f33997593565b9bfab782f268786676d4 (commit)
discards 05a6c098580a1fe9e6ab073a75c48230695473d0 (commit)
discards 2de39a7ec2fe9a11b20a7771336c70b1556658fd (commit)
discards 9d82627b1064251d231f796bcd217fa7cdc49c31 (commit)
discards 95bf4497be229dd5ced2b8e05c04c0372e436509 (commit)
discards b4f0eefeec21412d670a4c478f5876388e448f9b (commit)
discards 7c9d3b1c92cc6ba0e952d65f32ed518bb34341cd (commit)
discards 6b548c5cb710f06612c533b57b39c658a038eb12 (commit)
discards d12d660ab6cc7611ddd9d3ee29915d5947f7e7e9 (commit)
discards ca041c01ea50c8fd14779fa5b77586be1ad779be (commit)
discards ba41452a338d6c4fc8b0963626dfd0a5799b8b76 (commit)
discards 6fdc4cc496628083dc48e46a6733f35f5a99649a (commit)
discards 7f4a36790a46eaf04c7b7421b492a6ffe9f9f48e (commit)
discards e2702750f92e4fe0716aa030b90fd96aa63df100 (commit)
discards 134e242fedada16527bd7af8cf5bc9e5f66032f1 (commit)
discards 6985484e9a1b721e6da5bb78ee2222d936d1767a (commit)
discards 8c287df29ff3049d749db0c0867a4b85f63a5dfb (commit)
discards fd62480ce9e6a16bb1dc3585ba100d6a9ea6deb1 (commit)
discards cc8c9ed06e4070b7c0aca23b6d8530fe1f5a9ea0 (commit)
discards c65020df4f9a43ae7aa49e5d6f7467217be9046d (commit)
discards 4756e175a1c2614f91be3cf36e129341e375ac43 (commit)
discards f67cec4c13aa85adffb59cddbf7e0e45925cb5ae (commit)
discards 2a17f6d9312831e4c9094f40622b90dca8a230ed (commit)
discards 77429c34a1a3aa4901710880d612e7ad3949228b (commit)
discards 8f266e9124f39e2d5592ca4dfc914d784ea3f579 (commit)
discards 5dbed1ab586fba85cff78903469e6a4015bbb509 (commit)
discards 959710dac03a9bcd569d14a2d53a6ca149214196 (commit)
discards d3a06bf8f609f7c90871f6bc09b6a37d97ebd972 (commit)
discards 004d118aeb91bd85b36a2379bb7546e37a785189 (commit)
discards 12c45b02b83d3d06505b7f5f8f56c1f2c5b32d41 (commit)
via 57a4952e7ad3d3abda896726c512f4e95bc504cd (commit)
via 686c544acb13148dd2128ae83b18cddc8029e1c2 (commit)
via 87d708bb2ccdf3659a5fc191f3ca76416a79cc51 (commit)
via 923a8af7a76833477e355cc03059cfbbdce25b1d (commit)
via 662b1bec632d060cdf9cf957032e82af73aa9896 (commit)
via f8f7d6ed1b71ff8aabe035767b1fcf6e84588d75 (commit)
via dc4ed30d5f22c4c4a4b94096ac93a1614800cc47 (commit)
via aa0ecbc9822cb8706ac72530a0841a63d2a244ff (commit)
via b54ebe3c542da3c79d58fd247387da8b00238e19 (commit)
via aac2de9ee35fe1566695737451c379b9afa755bb (commit)
via 42ed2b15e27767cdf50b10528973e99a6d634afb (commit)
via 1464e556245e945fe2b94eb3ce8a5b31954f740c (commit)
via e69979da4af750f6283ed7c43655677c62c8ff5f (commit)
via bed2715783538af7278782febe9433ef0c835f94 (commit)
via 843b5b38458c7539426ffb9ba9b6698f0c1e99d3 (commit)
via c737a609e854e5ce70d56e4f6ad9840921defa3c (commit)
via 3e86cf3a3a4a09fca0f563163dec6657ba3ce2e8 (commit)
via cc936794965a111861cfbdcff613b93b973c7d64 (commit)
via 1dcbbab56569a0230493132e3d140d0dc79b3740 (commit)
via 21ca1871949fbb894236c2e2dec5559bf2a24e1e (commit)
via 7d037d1f425c13cc4c826a5cf894f663ea27f4a1 (commit)
via 4c0ed4e9c36662effae97ba593ddbe1efc05c34c (commit)
via 0d770d153cbf6a3add60980fefd1918458c42fe1 (commit)
via 5d88dbd83c9affb5686e37efe37afcf9a5d53eca (commit)
via a3308a173da2fe3baa45965abf6f4518e9d506d2 (commit)
via cb7a3bf6a219c331b2a31c0b565bef45e25a86d6 (commit)
via 742d0124ac3693a0be34054b7479bda100e42f58 (commit)
via e441edb8da2950ba9d709c3d2c2f679d157ba00f (commit)
via 303e38d447b9318912b9b7b047710daafda6131f (commit)
via 257be9e6675086f24fa726b338b6808963030d42 (commit)
via bafdc50acc21db7856510fe73b54bd00d5d5f3d8 (commit)
via fffcde773234dd7adba8489b29a64d4b8fcc101a (commit)
via dd1061b049328e5e45cb02150ec01aa9c9d3dd66 (commit)
via 81e79695003a4c3177a21f3bd19104855abf0226 (commit)
via a5262f2074d0ec366cc7d469670c970cbd937913 (commit)
via e93e375e5ef1e8a7896dced93cad18cb0d97d4b6 (commit)
via 446d79258c5aa740fa15cab5c3f20c0b4b6731e3 (commit)
via 79532c9a9e9ccebba1d5e0b5d40101db765243cd (commit)
via 3c3cd9306aa61e8ade407c361766ab26abfab450 (commit)
via 84614385dac9860d66dc8f21fd7d3066ece4080d (commit)
via e334996fb271c8c67a2e86b37ea63c0a6787d950 (commit)
via 8ef4bff98657b686c57daad227124523ab21ba5f (commit)
via b4cc9d5a84107942def763040a25dc2500fd4d1a (commit)
via 4d0483da3cadcb21a72363e60ab1e03341fefc6f (commit)
via a5f7281229d6d1f7863e8d6e1599191ab58ef347 (commit)
via b3c289fec523879f769e595502414ed47f2110e1 (commit)
via 7d8b1163936a6ff8ddd35d2d8121505f2762d70b (commit)
via 58cdb6cb83494f43896033fd0e89d281ba5cd557 (commit)
via 011b365fbb91a4c09831c41a543996639662a496 (commit)
via 2162f392271790ff1b5b7dd0385b3abcd653940e (commit)
via 3d3a249e468ea6c232e68333d81f7f5711667b3f (commit)
via 09da3ef94bebb0a97f7b5eecbed3ce0cd0a450df (commit)
via 4a86f5dc71cad72e58c0d3d82346fb2c79ad39e6 (commit)
via 23fe97d907eae9b7cc76e8f596246615362d98af (commit)
via 27899113452407db2a9084106ca4c2d3ee1ee632 (commit)
via b084bec81823fe77854f9e300152db84d4fff839 (commit)
via 526859a96a4add6f34a7ea11e7d249f95a1ff80b (commit)
via 1bc261b54d38213850ba8fd321564b8ea498d10a (commit)
via e8700cc4e010e5f1cd4d9e42601dabebb0482115 (commit)
via 9a494f3889b06d2c6f09737ec84cd249e69e3fe5 (commit)
via 5717b0cf67f49a4a293966bb81b24f69b013f12c (commit)
via 6e51a343288b5a4c93f1db10c014f6085440bb9f (commit)
via b14b7ee939b8ad6f796c370582ef286d3c95be7b (commit)
via 94e4a923281b16679280655fa32a219d4b9d72a6 (commit)
via aa9b7390a4bf924d585e1214872df0a284b5e72f (commit)
via 65c603353ecbc8ceb8aea862614261497cebcfe1 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (65ec591cc15b84468c066dd6708e041b1d3949d1)
\
N -- N -- N (57a4952e7ad3d3abda896726c512f4e95bc504cd)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
57a4952 demo/viewer/xml_widget.cc: Fix a warning.
686c544 demo/viewer/runner.cc: Improve progress notification.
87d708b Fix compilation issues on MAC.
923a8af scribo/primitive/link/internal/dmax_functor_base.hh: Make the dmax ratio safer.
662b1be scribo/text/merging: Add a precondition. Fix merging policy.
f8f7d6e scribo/primitive/link/internal/link_functor_base.hh: Stop neighbor lookup when a separator is found.
dc4ed30 Regen generated files.
aa0ecbc Fix namespace ambiguities.
b54ebe3 src/Makefile.am: define HAVE_QT for content_in_doc.
aac2de9 Add missing anchor argument.
42ed2b1 Regen generated files.
1464e55 mln/labeling/colorize.hh: Add a missing inline.
e69979d Add more from_to overloards.
bed2715 build-aux/build_unit_test.sh: Define HAVE_* for unit-tests.
843b5b3 Regen generated files.
c737a60 tests/toolchain/nepomuk/Makefile.am: Add MAGICKXX flags.
3e86cf3 scribo/core/def/lbl_type.hh: Use int_u<n> as label type.
cc93679 Set unit tests dependencies.
1dcbbab New debug tools.
21ca187 New non-text components extraction routine.
7d037d1 Introduce result image output.
4c0ed4e Save image edge coordinates in XML output.
0d770d1 scribo/filter/object_links_aligned.hh: New.
5d88dbd scribo/primitive/extract/separators_nonvisible.hh: Cleanup and improve debug support.
a3308a1 Various small fixes.
cb7a3bf Introduce a new component linking method.
742d012 Spread anchor value to more methods in link functors.
e441edb Introduce a logger class.
303e38d Introduce a logger class.
257be9e Introduce new anchors.
bafdc50 Rename document serializer base class.
fffcde7 Store more information in scribo::document.
dd1061b Rename line_info::components() to line_info::component_ids.
81e7969 Some changes in debug routines.
a5262f2 Add HAVE_QT guards.
e93e375 Small fixes in viewer.
446d792 scribo/io/xml/internal/extended_page_xml_visitor.hh: Save separators data.
79532c9 scribo/io/xml/internal/full_xml_visitor.hh: Do not copy image data.
3c3cd93 Make OCR step optional in viewer.
8461438 scribo/toolchain/internal/content_in_doc_functor.hh: Make OCR step optional.
e334996 Compress image data in XML output.
8ef4bff Small fixes in Scribo.
b4cc9d5 Regen mk files.
4d0483d scribo/primitive/extract/non_text.hh: Remove debug.
a5f7281 Add new debug tools.
b3c289f scribo/text/extract_lines.hh: Update code.
7d8b116 Make use of mln::fun::v2v::rgb_to_luma.
58cdb6c mln/labeling/fill_holes.hh: Improve speed.
011b365 mln/fun/v2v/rgb_to_luma.hh: New function for grayscale conversion.
2162f39 scribo/io/xml/load.hh: New XML loader.
3d3a249 Make XML output more flexible.
09da3ef Set component type during component extraction.
4a86f5d configure.ac: scribo/src/primitive/remove.
23fe97d Add new tools in Scribo.
2789911 Small fixes in Scribo.
b084bec Improve and cleanup whitespace separator detection.
526859a Add new conversion routines from string to tag.
1bc261b Various changes in scribo core structures.
e8700cc Rename files in Scribo.
9a494f3 mln/util/array.hh: Add last() method.
5717b0c Add an optional base index for debug::iota.
6e51a34 configure.ac: configure scribo/tests/convert.
b14b7ee Add Base64 conversion routines.
94e4a92 =Add support for whitespace separators visualization.
aa9b739 Deactivate erroneous assertion in regional_maxima.hh.
-----------------------------------------------------------------------
Summary of changes:
scribo/ChangeLog | 5 +++++
scribo/scribo/toolchain/nepomuk/text_extraction.hh | 3 ++-
2 files changed, 7 insertions(+), 1 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0