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
May 2011
- 9 participants
- 171 discussions
last-svn-commit-859-gd90f512 Explicitly set vertical or horizontal attribute for separators in XML output.
by Guillaume Lazzara 05 May '11
by Guillaume Lazzara 05 May '11
05 May '11
* demo/xml2doc/image_crop.cc,
* demo/xml2doc/templates/pdf/regions.xsl: Handle new XML tags.
* scribo/core/document.hh,
* scribo/core/tag/component.hh,
* scribo/io/img/internal/debug_img_visitor.hh,
* scribo/io/img/internal/full_img_visitor.hh,
* scribo/io/img/internal/non_text_img_visitor.hh,
* scribo/io/xml/internal/extended_page_xml_visitor.hh,
* scribo/io/xml/internal/full_xml_visitor.hh,
* scribo/io/xml/internal/page_xml_visitor.hh: Update enum
declaration and handle new cases.
---
scribo/ChangeLog | 18 ++++++++
scribo/demo/xml2doc/image_crop.cc | 7 ++-
scribo/demo/xml2doc/templates/pdf/regions.xsl | 3 +-
scribo/scribo/core/document.hh | 4 +-
scribo/scribo/core/tag/component.hh | 16 +++++--
scribo/scribo/io/img/internal/debug_img_visitor.hh | 3 +-
scribo/scribo/io/img/internal/full_img_visitor.hh | 3 +-
.../scribo/io/img/internal/non_text_img_visitor.hh | 3 +-
.../io/xml/internal/extended_page_xml_visitor.hh | 24 +++++++++-
scribo/scribo/io/xml/internal/full_xml_visitor.hh | 45 +++++++++++++++++---
scribo/scribo/io/xml/internal/page_xml_visitor.hh | 3 +-
11 files changed, 105 insertions(+), 24 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index efc42cf..e857752 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,23 @@
2011-05-05 Guillaume Lazzara <lazzara(a)fidji.lrde.epita.fr>
+ Explicitly set vertical or horizontal attribute for separators in
+ XML output.
+
+ * demo/xml2doc/image_crop.cc,
+ * demo/xml2doc/templates/pdf/regions.xsl: Handle new XML tags.
+
+ * scribo/core/document.hh,
+ * scribo/core/tag/component.hh,
+ * scribo/io/img/internal/debug_img_visitor.hh,
+ * scribo/io/img/internal/full_img_visitor.hh,
+ * scribo/io/img/internal/non_text_img_visitor.hh,
+ * scribo/io/xml/internal/extended_page_xml_visitor.hh,
+ * scribo/io/xml/internal/full_xml_visitor.hh,
+ * scribo/io/xml/internal/page_xml_visitor.hh: Update enum
+ declaration and handle new cases.
+
+2011-05-05 Guillaume Lazzara <lazzara(a)fidji.lrde.epita.fr>
+
Make use of opacity in PDF output.
* demo/xml2doc/image_crop.cc: Create opacity mask.
diff --git a/scribo/demo/xml2doc/image_crop.cc b/scribo/demo/xml2doc/image_crop.cc
index 7d61f75..72fd2b4 100644
--- a/scribo/demo/xml2doc/image_crop.cc
+++ b/scribo/demo/xml2doc/image_crop.cc
@@ -101,7 +101,7 @@ void ImageCrop::from_base64()
child = child.firstChild();
while (!child.isNull())
{
- if (child.toElement().tagName().contains(QRegExp("(image|graphic|chart|separator|table)_region")))
+ if (child.toElement().tagName().contains(QRegExp("(image|graphic|chart|horizontal_separator|vertical_separator|table)_region")))
{
QDomNode node = child.firstChild();
QString id = child.toElement().attribute("id", "none");
@@ -208,7 +208,7 @@ void ImageCrop::to_base64(const QString& out_file, bool no_crop)
while(!line.contains("</pcGts>"))
{
stream2 << "\n" << line;
- if (line.contains(QRegExp("<(image|graphic|chart|separator|table)_region")))
+ if (line.contains(QRegExp("<(image|graphic|chart|horizontal_separator|vertical_separator|table)_region")))
{
stream2 << "\n" << " <container>\n";
stream2 << " <mime>png</mime>\n";
@@ -268,7 +268,7 @@ bool ImageCrop::crop_regions(bool temp)
while (!region.isNull())
{
- if (region.toElement().tagName().contains(QRegExp("(image|graphic|chart|separator|table)_region")))
+ if (region.toElement().tagName().contains(QRegExp("(image|graphic|chart|vertical_separator|horizontal_separator|table)_region")))
{
found_regions = true;
@@ -338,6 +338,7 @@ bool ImageCrop::crop_regions(bool temp)
else
io::magick::save(crop, opacity_mask, QString(output_dir_ + id + ".png").toStdString());
}
+
region = region.nextSibling();
}
diff --git a/scribo/demo/xml2doc/templates/pdf/regions.xsl b/scribo/demo/xml2doc/templates/pdf/regions.xsl
index add0cba..f236a1f 100644
--- a/scribo/demo/xml2doc/templates/pdf/regions.xsl
+++ b/scribo/demo/xml2doc/templates/pdf/regions.xsl
@@ -8,7 +8,8 @@
pcGts/page/graphic_region|
pcGts/page/chart_region|
pcGts/page/table_region|
- pcGts/page/separator_region">
+ pcGts/page/vertical_separator_region|
+ pcGts/page/horizontal_separator_region">
<!-- ID of the region, used to display id.png -->
<xsl:variable name="data">
diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh
index e287c1d..0fe2be3 100644
--- a/scribo/scribo/core/document.hh
+++ b/scribo/scribo/core/document.hh
@@ -343,7 +343,7 @@ namespace scribo
mln_value(L) ncomps;
hline_seps_comps_ = primitive::extract::components(hline_seps,
mln::c8(), ncomps,
- component::LineSeparator);
+ component::HorizontalLineSeparator);
}
@@ -390,7 +390,7 @@ namespace scribo
mln_value(L) ncomps;
vline_seps_comps_ = primitive::extract::components(vline_seps,
mln::c8(), ncomps,
- component::LineSeparator);
+ component::VerticalLineSeparator);
}
diff --git a/scribo/scribo/core/tag/component.hh b/scribo/scribo/core/tag/component.hh
index 7cd2ede..dc9db90 100644
--- a/scribo/scribo/core/tag/component.hh
+++ b/scribo/scribo/core/tag/component.hh
@@ -55,7 +55,8 @@ namespace scribo
{
Undefined = 0,
Character,
- LineSeparator,
+ VerticalLineSeparator,
+ HorizontalLineSeparator,
WhitespaceSeparator,
Noise,
Punctuation,
@@ -117,8 +118,11 @@ namespace scribo
case Character:
str = "Character";
break;
- case LineSeparator:
- str = "LineSeparator";
+ case HorizontalLineSeparator:
+ str = "HorizontalLineSeparator";
+ break;
+ case VerticalLineSeparator:
+ str = "VerticalLineSeparator";
break;
case WhitespaceSeparator:
str = "WhitespaceSeparator";
@@ -143,8 +147,10 @@ namespace scribo
{
if (str == "Character")
return Character;
- else if (str == "LineSeparator")
- return LineSeparator;
+ else if (str == "HorizontalLineSeparator")
+ return HorizontalLineSeparator;
+ else if (str == "VerticalLineSeparator")
+ return VerticalLineSeparator;
else if (str == "WhitespaceSeparator")
return WhitespaceSeparator;
else if (str == "Noise")
diff --git a/scribo/scribo/io/img/internal/debug_img_visitor.hh b/scribo/scribo/io/img/internal/debug_img_visitor.hh
index f1c689d..62097f5 100644
--- a/scribo/scribo/io/img/internal/debug_img_visitor.hh
+++ b/scribo/scribo/io/img/internal/debug_img_visitor.hh
@@ -179,7 +179,8 @@ namespace scribo
{
switch (info.type())
{
- case component::LineSeparator:
+ case component::HorizontalLineSeparator:
+ case component::VerticalLineSeparator:
{
mln::draw::box(output, compute_bbox(info.bbox()),
literal::cyan);
diff --git a/scribo/scribo/io/img/internal/full_img_visitor.hh b/scribo/scribo/io/img/internal/full_img_visitor.hh
index 30987db..170b6a1 100644
--- a/scribo/scribo/io/img/internal/full_img_visitor.hh
+++ b/scribo/scribo/io/img/internal/full_img_visitor.hh
@@ -135,7 +135,8 @@ namespace scribo
{
switch (info.type())
{
- case component::LineSeparator:
+ case component::HorizontalLineSeparator:
+ case component::VerticalLineSeparator:
{
mln::draw::box(output, info.bbox(), literal::cyan);
}
diff --git a/scribo/scribo/io/img/internal/non_text_img_visitor.hh b/scribo/scribo/io/img/internal/non_text_img_visitor.hh
index 24b027e..cc1acb9 100644
--- a/scribo/scribo/io/img/internal/non_text_img_visitor.hh
+++ b/scribo/scribo/io/img/internal/non_text_img_visitor.hh
@@ -132,7 +132,8 @@ namespace scribo
{
switch (info.type())
{
- case component::LineSeparator:
+ case component::HorizontalLineSeparator:
+ case component::VerticalLineSeparator:
{
mln::draw::box(output, info.bbox(), literal::cyan);
}
diff --git a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
index eaf08ac..83e5b0b 100644
--- a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
+++ b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
@@ -179,9 +179,9 @@ namespace scribo
break;
}
- case component::LineSeparator:
+ case component::VerticalLineSeparator:
{
- output << " <separator_region id=\"sr" << info.id()
+ output << " <vertical_separator_region id=\"vlsr" << info.id()
<< "\" sep_orientation=\"0.000000\" "
<< " sep_colour=\"Black\" "
<< " sep_bgcolour=\"White\""
@@ -193,7 +193,25 @@ namespace scribo
internal::print_box_coords(output, info.bbox(), " ");
- output << " </separator_region>" << std::endl;
+ output << " </vertical_separator_region>" << std::endl;
+ break;
+ }
+
+ case component::HorizontalLineSeparator:
+ {
+ output << " <horizontal_separator_region id=\"hlsr" << info.id()
+ << "\" sep_orientation=\"0.000000\" "
+ << " sep_colour=\"Black\" "
+ << " sep_bgcolour=\"White\""
+ << " x_min=\"" << info.bbox().pmin().col() << "\""
+ << " y_min=\"" << info.bbox().pmin().row() << "\""
+ << " x_max=\"" << info.bbox().pmax().col() << "\""
+ << " y_max=\"" << info.bbox().pmax().row() << "\""
+ << ">" << std::endl;
+
+ internal::print_box_coords(output, info.bbox(), " ");
+
+ output << " </horizontal_separator_region>" << std::endl;
break;
}
diff --git a/scribo/scribo/io/xml/internal/full_xml_visitor.hh b/scribo/scribo/io/xml/internal/full_xml_visitor.hh
index c294bbc..b920ca8 100644
--- a/scribo/scribo/io/xml/internal/full_xml_visitor.hh
+++ b/scribo/scribo/io/xml/internal/full_xml_visitor.hh
@@ -355,7 +355,12 @@ namespace scribo
{
output << " <whitespace_separator_region id=\"wss"
<< info.id()
- << "\">" << std::endl;
+ << "\""
+ << " x_min=\"" << info.bbox().pmin().col() << "\""
+ << " y_min=\"" << info.bbox().pmin().row() << "\""
+ << " x_max=\"" << info.bbox().pmax().col() << "\""
+ << " y_max=\"" << info.bbox().pmax().row() << "\""
+ << ">" << std::endl;
internal::print_box_coords(output, info.bbox(), " ");
@@ -363,16 +368,39 @@ namespace scribo
break;
}
- case component::LineSeparator:
+ case component::VerticalLineSeparator:
{
- output << " <separator_region id=\"sr" << info.id()
+ output << " <vertical_separator_region id=\"vlsr" << info.id()
<< "\" sep_orientation=\"0.000000\" "
<< " sep_colour=\"Black\" "
- << " sep_bgcolour=\"White\">" << std::endl;
+ << " sep_bgcolour=\"White\""
+ << " x_min=\"" << info.bbox().pmin().col() << "\""
+ << " y_min=\"" << info.bbox().pmin().row() << "\""
+ << " x_max=\"" << info.bbox().pmax().col() << "\""
+ << " y_max=\"" << info.bbox().pmax().row() << "\""
+ << ">" << std::endl;
internal::print_box_coords(output, info.bbox(), " ");
- output << " </separator_region>" << std::endl;
+ output << " </vertical_separator_region>" << std::endl;
+ break;
+ }
+
+ case component::HorizontalLineSeparator:
+ {
+ output << " <horizontal_separator_region id=\"hlsr" << info.id()
+ << "\" sep_orientation=\"0.000000\" "
+ << " sep_colour=\"Black\" "
+ << " sep_bgcolour=\"White\""
+ << " x_min=\"" << info.bbox().pmin().col() << "\""
+ << " y_min=\"" << info.bbox().pmin().row() << "\""
+ << " x_max=\"" << info.bbox().pmax().col() << "\""
+ << " y_max=\"" << info.bbox().pmax().row() << "\""
+ << ">" << std::endl;
+
+ internal::print_box_coords(output, info.bbox(), " ");
+
+ output << " </horizontal_separator_region>" << std::endl;
break;
}
@@ -383,7 +411,12 @@ namespace scribo
<< "\" img_colour_type=\"24_Bit_Colour\""
<< " img_orientation=\"0.000000\" "
<< " img_emb_text=\"No\" "
- << " img_bgcolour=\"White\">" << std::endl;
+ << " img_bgcolour=\"White\""
+ << " x_min=\"" << info.bbox().pmin().col() << "\""
+ << " y_min=\"" << info.bbox().pmin().row() << "\""
+ << " x_max=\"" << info.bbox().pmax().col() << "\""
+ << " y_max=\"" << info.bbox().pmax().row() << "\""
+ << ">" << std::endl;
internal::print_box_coords(output, info.bbox(), " ");
diff --git a/scribo/scribo/io/xml/internal/page_xml_visitor.hh b/scribo/scribo/io/xml/internal/page_xml_visitor.hh
index 19665d6..0014caf 100644
--- a/scribo/scribo/io/xml/internal/page_xml_visitor.hh
+++ b/scribo/scribo/io/xml/internal/page_xml_visitor.hh
@@ -146,7 +146,8 @@ namespace scribo
{
switch (info.type())
{
- case component::LineSeparator:
+ case component::VerticalLineSeparator:
+ case component::HorizontalLineSeparator:
{
output << " <separator_region id=\"sr" << info.id()
<< "\" sep_orientation=\"0.000000\" "
--
1.5.6.5
1
0
05 May '11
* demo/xml2doc/image_crop.cc: Create opacity mask.
* scribo/io/xml/internal/extended_page_xml_visitor.hh: Add bbox
information in region tag.
---
scribo/ChangeLog | 9 +++
scribo/demo/xml2doc/image_crop.cc | 60 +++++++++++++-------
.../io/xml/internal/extended_page_xml_visitor.hh | 21 ++++++-
3 files changed, 67 insertions(+), 23 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index a213078..efc42cf 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,12 @@
+2011-05-05 Guillaume Lazzara <lazzara(a)fidji.lrde.epita.fr>
+
+ Make use of opacity in PDF output.
+
+ * demo/xml2doc/image_crop.cc: Create opacity mask.
+
+ * scribo/io/xml/internal/extended_page_xml_visitor.hh: Add bbox
+ information in region tag.
+
2011-05-04 Guillaume Lazzara <lazzara(a)fidji.lrde.epita.fr>
Small fixes in Scribo.
diff --git a/scribo/demo/xml2doc/image_crop.cc b/scribo/demo/xml2doc/image_crop.cc
index ba30d8a..7d61f75 100644
--- a/scribo/demo/xml2doc/image_crop.cc
+++ b/scribo/demo/xml2doc/image_crop.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -16,10 +17,13 @@
#include <limits.h>
+#include <scribo/core/macros.hh>
#include <scribo/preprocessing/crop.hh>
#include <mln/value/rgb8.hh>
#include <mln/core/alias/box2d.hh>
#include <mln/core/image/image2d.hh>
+#include <mln/util/couple.hh>
+#include <mln/draw/line.hh>
#include <mln/io/magick/save.hh>
#include <mln/io/magick/load.hh>
#include <mln/io/ppm/all.hh>
@@ -28,6 +32,7 @@
#include "loader.hh"
#include "common.hh"
+#include <mln/io/pbm/save.hh>
ImageCrop::ImageCrop(const QString& xml, const QString& img,
const QString& output)
@@ -270,7 +275,14 @@ bool ImageCrop::crop_regions(bool temp)
QDomNode coords = region.firstChild();
QString id = region.toElement().attribute("id", "none");
- // qDebug() << region.toElement().tagName();
+ // Retrieve region bbox.
+ using namespace mln;
+ def::coord
+ x_min = region.toElement().attribute("x_min").toInt(),
+ y_min = region.toElement().attribute("y_min").toInt(),
+ x_max = region.toElement().attribute("x_max").toInt(),
+ y_max = region.toElement().attribute("y_max").toInt();
+ box2d box = make::box2d(y_min, x_min, y_max, x_max);
while (!coords.isNull() && !coords.toElement().tagName().contains("coords"))
coords = coords.nextSibling();
@@ -279,44 +291,52 @@ bool ImageCrop::crop_regions(bool temp)
break;
QDomNode point = coords.firstChild();
- int x_max = 0;
- int y_max = 0;
- int x_min = INT_MAX;
- int y_min = INT_MAX;
+ // For each row, store first and last column of the line
+ // to be set as object. The rest will be considered as
+ // transparent.
+ util::array<util::couple<def::coord, def::coord> >
+ p_mask(box.nrows(),
+ util::couple<def::coord, def::coord>(x_max + 1, x_min - 1));
+
+ // Compute opacity mask for image region.
while (!point.isNull())
{
int x = point.toElement().attribute("x", "none").toInt();
int y = point.toElement().attribute("y", "none").toInt();
- if (x < x_min)
- x_min = x;
- if (x > x_max)
- x_max = x;
-
- if (y < y_min)
- y_min = y;
- if (y > y_max)
- y_max = y;
+ if (p_mask(y - y_min).first() > x)
+ p_mask(y - y_min).first() = x;
+ if (p_mask(y - y_min).second() < x)
+ p_mask(y - y_min).second() = x;
point = point.nextSibling();
}
- using namespace mln;
- box2d box = make::box2d(y_min, x_min, y_max, x_max);
-
+ // Crop image in input.
image2d<value::rgb8> crop = scribo::preprocessing::crop(ima_, box);
+ // Build image mask.
+ image2d<bool> opacity_mask(box);
+ {
+ data::fill(opacity_mask, true);
+ for_all_elements(e, p_mask)
+ draw::line(opacity_mask,
+ point2d(e + y_min, p_mask(e).first()),
+ point2d(e + y_min, p_mask(e).second()),
+ false);
+ }
+
if (temp)
{
QTemporaryFile tmp(output_dir_ + id + ".XXXXXX.png");
tmp.open();
region_map_[id] = tmp.fileName();
tmp.setAutoRemove(false);
- io::magick::save(crop, tmp.fileName().toStdString());
+ io::magick::save(crop, opacity_mask, tmp.fileName().toStdString());
}
else
- io::magick::save(crop, QString(output_dir_ + id + ".png").toStdString());
+ io::magick::save(crop, opacity_mask, QString(output_dir_ + id + ".png").toStdString());
}
region = region.nextSibling();
}
diff --git a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
index b463677..eaf08ac 100644
--- a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
+++ b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
@@ -166,7 +166,12 @@ namespace scribo
{
output << " <whitespace_separator_region id=\"wss"
<< info.id()
- << "\">" << std::endl;
+ << "\""
+ << " x_min=\"" << info.bbox().pmin().col() << "\""
+ << " y_min=\"" << info.bbox().pmin().row() << "\""
+ << " x_max=\"" << info.bbox().pmax().col() << "\""
+ << " y_max=\"" << info.bbox().pmax().row() << "\""
+ << ">" << std::endl;
internal::print_box_coords(output, info.bbox(), " ");
@@ -179,7 +184,12 @@ namespace scribo
output << " <separator_region id=\"sr" << info.id()
<< "\" sep_orientation=\"0.000000\" "
<< " sep_colour=\"Black\" "
- << " sep_bgcolour=\"White\">" << std::endl;
+ << " sep_bgcolour=\"White\""
+ << " x_min=\"" << info.bbox().pmin().col() << "\""
+ << " y_min=\"" << info.bbox().pmin().row() << "\""
+ << " x_max=\"" << info.bbox().pmax().col() << "\""
+ << " y_max=\"" << info.bbox().pmax().row() << "\""
+ << ">" << std::endl;
internal::print_box_coords(output, info.bbox(), " ");
@@ -195,7 +205,12 @@ namespace scribo
<< "\" img_colour_type=\"24_Bit_Colour\""
<< " img_orientation=\"0.000000\" "
<< " img_emb_text=\"No\" "
- << " img_bgcolour=\"White\">" << std::endl;
+ << " img_bgcolour=\"White\""
+ << " x_min=\"" << info.bbox().pmin().col() << "\""
+ << " y_min=\"" << info.bbox().pmin().row() << "\""
+ << " x_max=\"" << info.bbox().pmax().col() << "\""
+ << " y_max=\"" << info.bbox().pmax().row() << "\""
+ << ">" << std::endl;
internal::print_image_coords(output,
((elt_edge | info.bbox())
--
1.5.6.5
1
0
last-svn-commit-857-g9b5c9ab mln/io/magick/save.hh: Add support for opacity.
by Guillaume Lazzara 05 May '11
by Guillaume Lazzara 05 May '11
05 May '11
---
milena/ChangeLog | 4 +
milena/mln/io/magick/save.hh | 155 ++++++++++++++++++++++++++++++++++--------
2 files changed, 131 insertions(+), 28 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8008503..d12cc20 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-05 Guillaume Lazzara <lazzara(a)fidji.lrde.epita.fr>
+
+ * mln/io/magick/save.hh: Add support for opacity.
+
2011-04-05 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/accu/stat/median_h.hh: Add missing operator=().
diff --git a/milena/mln/io/magick/save.hh b/milena/mln/io/magick/save.hh
index 2ea2957..f592059 100644
--- a/milena/mln/io/magick/save.hh
+++ b/milena/mln/io/magick/save.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.
//
@@ -59,13 +59,29 @@ namespace mln
{
/** Save a Milena image into a file using Magick++.
+ \overload
- \param[out] ima The image to save.
- \param[in] filename The name of the output file. */
+ \param[in] ima The image to save.
+ \param[in] filename The name of the output file. */
template <typename I>
void
save(const Image<I>& ima, const std::string& filename);
+ /** Save a Milena image into a file using Magick++.
+
+ \param[in] ima The image to save.
+
+ \param[in] opacity_mask Mask used to set pixel opacity_mask in output
+ image. Output format must support this feature to be taken
+ into account.
+
+ \param[in] filename The name of the output file.
+ */
+ template <typename I, typename J>
+ void
+ save(const Image<I>& ima, const Image<J>& opacity_mask,
+ const std::string& filename);
+
// FIXME: Unfinished?
#if 0
@@ -125,10 +141,92 @@ namespace mln
} // end of namespace mln::io::magick::impl
- template <typename I>
- inline
+ namespace internal
+ {
+
+ template <typename I>
+ void
+ paste_data(const Image<I>& ima_, Magick::Image& magick_ima)
+ {
+ const I& ima = exact(ima_);
+
+ def::coord
+ minrow = geom::min_row(ima),
+ mincol = geom::min_col(ima),
+ maxrow = geom::max_row(ima),
+ maxcol = geom::max_col(ima),
+ ncols = geom::ncols(ima),
+ nrows = geom::nrows(ima);
+
+ // Ensure that there is only one reference to underlying image
+ // If this is not done, then image pixels will not be modified.
+ magick_ima.modifyImage();
+
+ Magick::Pixels view(magick_ima);
+ // As above, `ncols' is passed before `nrows'.
+ Magick::PixelPacket* pixels = view.get(0, 0, ncols, nrows);
+ const mln_value(I) *ptr_ima = &ima(ima.domain().pmin());
+
+ unsigned row_offset = ima.delta_index(dpoint2d(+1, - ncols));
+
+ for (def::coord row = minrow; row <= maxrow;
+ ++row, ptr_ima += row_offset)
+ for (def::coord col = mincol; col <= maxcol; ++col)
+ *pixels++ = impl::get_color(*ptr_ima++);
+
+ view.sync();
+ }
+
+ template <typename I, typename J>
+ void
+ paste_data_opacity(const Image<I>& ima_,
+ const Image<J>& opacity_mask_,
+ Magick::Image& magick_ima)
+ {
+ const I& ima = exact(ima_);
+ const J& opacity_mask = exact(opacity_mask_);
+
+ def::coord
+ minrow = geom::min_row(ima),
+ mincol = geom::min_col(ima),
+ maxrow = geom::max_row(ima),
+ maxcol = geom::max_col(ima),
+ ncols = geom::ncols(ima),
+ nrows = geom::nrows(ima);
+
+ // Ensure that there is only one reference to underlying image
+ // If this is not done, then image pixels will not be modified.
+ magick_ima.modifyImage();
+
+ Magick::Pixels view(magick_ima);
+ // As above, `ncols' is passed before `nrows'.
+ Magick::PixelPacket* pixels = view.get(0, 0, ncols, nrows);
+ const mln_value(I) *ptr_ima = &ima(ima.domain().pmin());
+ const mln_value(J) *ptr_opacity_mask = &opacity_mask(opacity_mask.domain().pmin());
+
+ unsigned row_offset = ima.delta_index(dpoint2d(+1, - ncols));
+ unsigned opacity_row_offset = opacity_mask.delta_index(dpoint2d(+1, - ncols));
+
+ for (def::coord row = minrow; row <= maxrow;
+ ++row, ptr_ima += row_offset,
+ ptr_opacity_mask += opacity_row_offset)
+ for (def::coord col = mincol; col <= maxcol; ++col)
+ {
+ *pixels = impl::get_color(*ptr_ima++);
+ (*pixels).opacity = ((*ptr_opacity_mask++) ? 255 : 0);
+ ++pixels;
+ }
+
+ view.sync();
+ }
+
+ } // end of namespace mln::io::magick::internal
+
+
+ template <typename I, typename J>
void
- save(const Image<I>& ima_, const std::string& filename)
+ save(const Image<I>& ima_, const Image<J>& opacity_mask_,
+ const std::string& filename)
{
trace::entering("mln::io::magick::save");
@@ -149,15 +247,13 @@ namespace mln
}
const I& ima = exact(ima_);
+ const J& opacity_mask = exact(opacity_mask_);
def::coord
- minrow = geom::min_row(ima),
- mincol = geom::min_col(ima),
- maxrow = geom::max_row(ima),
- maxcol = geom::max_col(ima),
ncols = geom::ncols(ima),
nrows = geom::nrows(ima);
+
// In the construction of a Geometry object, the width (i.e.
// `ncols') comes first, then the height (i.e. `nrows')
// follows.
@@ -168,28 +264,31 @@ namespace mln
// declared further fails and segfault...
Magick::Image magick_ima(Magick::Geometry(ncols, nrows), "white");
- magick_ima.type(Magick::TrueColorType);
-
- // Ensure that there is only one reference to underlying image
- // If this is not done, then image pixels will not be modified.
- magick_ima.modifyImage();
+ if (opacity_mask.is_valid())
+ {
+ magick_ima.type(Magick::TrueColorMatteType);
+ internal::paste_data_opacity(ima, opacity_mask, magick_ima);
+ }
+ else
+ {
+ magick_ima.type(Magick::TrueColorType);
+ internal::paste_data(ima, magick_ima);
+ }
- Magick::Pixels view(magick_ima);
- // As above, `ncols' is passed before `nrows'.
- Magick::PixelPacket* pixels = view.get(0, 0, ncols, nrows);
- const mln_value(I) *ptr_ima = &ima(ima.domain().pmin());
+ magick_ima.write(filename);
- unsigned row_offset = ima.delta_index(dpoint2d(+1, - ncols));
+ trace::exiting("mln::io::magick::save");
+ }
- for (def::coord row = minrow; row <= maxrow;
- ++row, ptr_ima += row_offset)
- for (def::coord col = mincol; col <= maxcol; ++col)
- *pixels++ = impl::get_color(*ptr_ima++);
- view.sync();
- magick_ima.write(filename);
- trace::exiting("mln::io::magick::save");
+ template <typename I>
+ inline
+ void
+ save(const Image<I>& ima, const std::string& filename)
+ {
+ mln_ch_value(I,bool) opacity_mask;
+ save(ima, opacity_mask, filename);
}
--
1.5.6.5
1
0
* demo/xml2doc/image_crop.cc: Abort xml loading if an error
is found.
* scribo/core/line_info.hh: Fix text cleanup.
* scribo/io/img/save.hh: Add documentation.
* scribo/io/xml/internal/extended_page_xml_visitor.hh: Use
internal_gradient.
* scribo/primitive/extract/alignments.hh: Set component type to
whitespaceSeparator.
* src/binarization/sauvola_ms_fg.cc: Fix argument use.
---
scribo/ChangeLog | 19 +++++++++++++++++++
scribo/demo/xml2doc/image_crop.cc | 2 ++
scribo/scribo/core/line_info.hh | 3 ++-
scribo/scribo/io/img/save.hh | 7 +++++++
.../io/xml/internal/extended_page_xml_visitor.hh | 4 ++--
scribo/scribo/primitive/extract/alignments.hh | 2 +-
scribo/src/binarization/sauvola_ms_fg.cc | 6 ++++--
7 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index fc761c3..a213078 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,24 @@
2011-05-04 Guillaume Lazzara <lazzara(a)fidji.lrde.epita.fr>
+ Small fixes in Scribo.
+
+ * demo/xml2doc/image_crop.cc: Abort xml loading if an error
+ is found.
+
+ * scribo/core/line_info.hh: Fix text cleanup.
+
+ * scribo/io/img/save.hh: Add documentation.
+
+ * scribo/io/xml/internal/extended_page_xml_visitor.hh: Use
+ internal_gradient.
+
+ * scribo/primitive/extract/alignments.hh: Set component type to
+ whitespaceSeparator.
+
+ * src/binarization/sauvola_ms_fg.cc: Fix argument use.
+
+2011-05-04 Guillaume Lazzara <lazzara(a)fidji.lrde.epita.fr>
+
Make paragraph extraction work with this branch.
* scribo/core/line_info.hh: Keep few attributes public and update
diff --git a/scribo/demo/xml2doc/image_crop.cc b/scribo/demo/xml2doc/image_crop.cc
index 29a93d8..ba30d8a 100644
--- a/scribo/demo/xml2doc/image_crop.cc
+++ b/scribo/demo/xml2doc/image_crop.cc
@@ -326,6 +326,8 @@ bool ImageCrop::crop_regions(bool temp)
else
{
f.close();
+ qDebug() << "Error while reading XML file!";
+ abort();
return false;
}
}
diff --git a/scribo/scribo/core/line_info.hh b/scribo/scribo/core/line_info.hh
index 27dda84..e91e1c3 100644
--- a/scribo/scribo/core/line_info.hh
+++ b/scribo/scribo/core/line_info.hh
@@ -351,7 +351,7 @@ namespace scribo
static std::map<char, std::string> map = init_map();
std::string output = input;
- for (unsigned i = 0; i < input.size(); ++i)
+ for (unsigned i = 0; i < output.size(); ++i)
{
std::map<char, std::string>::iterator it = map.find(output.at(i));
if (it != map.end())
@@ -360,6 +360,7 @@ namespace scribo
i += it->second.size() - 1;
}
}
+
return output;
}
diff --git a/scribo/scribo/io/img/save.hh b/scribo/scribo/io/img/save.hh
index 56300d6..04f0a3c 100644
--- a/scribo/scribo/io/img/save.hh
+++ b/scribo/scribo/io/img/save.hh
@@ -66,6 +66,13 @@ namespace scribo
NonText : Display non-text regions.
Full : Text and non-text regions.
+
+ DebugWoImage : Display all regions onto a subsampled copy of
+ the original image. A dark background is used as background.
+
+ DebugWithImage : Display all regions onto a subsampled copy of
+ the original image. The original image is used as background.
+
*/
enum Format
{
diff --git a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
index b906a4a..b463677 100644
--- a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
+++ b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
@@ -32,7 +32,7 @@
# include <fstream>
-# include <mln/morpho/elementary/gradient_external.hh>
+# include <mln/morpho/elementary/gradient_internal.hh>
# include <mln/pw/all.hh>
# include <mln/core/image/dmorph/image_if.hh>
@@ -122,7 +122,7 @@ namespace scribo
if (doc.has_elements())
{
// Prepare element edges
- elt_edge = morpho::elementary::gradient_external(doc.elements().labeled_image(), c4());
+ elt_edge = morpho::elementary::gradient_internal(doc.elements().labeled_image(), c4());
doc.elements().accept(*this);
}
diff --git a/scribo/scribo/primitive/extract/alignments.hh b/scribo/scribo/primitive/extract/alignments.hh
index 8d18d93..1e3d835 100644
--- a/scribo/scribo/primitive/extract/alignments.hh
+++ b/scribo/scribo/primitive/extract/alignments.hh
@@ -1085,7 +1085,7 @@ namespace scribo
V ndelim;
component_set<L>
- delim_comps = primitive::extract::components(delimitors, c8(), ndelim);
+ delim_comps = primitive::extract::components(delimitors, c8(), ndelim, component::WhitespaceSeparator);
mln::util::couple<component_set<L>, mln_ch_value(L,bool)>
output(delim_comps, delimitors);
diff --git a/scribo/src/binarization/sauvola_ms_fg.cc b/scribo/src/binarization/sauvola_ms_fg.cc
index 7ff9321..2c5e7fa 100644
--- a/scribo/src/binarization/sauvola_ms_fg.cc
+++ b/scribo/src/binarization/sauvola_ms_fg.cc
@@ -58,10 +58,10 @@ bool check_args(int argc, char * argv[])
const char *args_desc[][2] =
{
{ "input.*", "An image." },
- { "output.pbm", "A binary image." },
{ "lambda", "Lambda used to split bg/fg." },
{ "w", "Window size at scale 1. (Common value: 101)" },
{ "s", "First subsampling ratio (Common value: 3)." },
+ { "output.pbm", "A binary image." },
{0, 0}
};
@@ -92,6 +92,8 @@ int main(int argc, char *argv[])
std::cout << "Using w_1=" << w_1 << " - s=" << s << std::endl;
+ Magick::InitializeMagick(0);
+
// Load
image2d<value::rgb8> input_1;
io::magick::load(input_1, argv[1]);
@@ -108,7 +110,7 @@ int main(int argc, char *argv[])
image2d<bool>
output = scribo::binarization::sauvola_ms(fg_gl, w_1, s, SCRIBO_DEFAULT_SAUVOLA_K);
- io::pbm::save(output, argv[6]);
+ io::pbm::save(output, argv[5]);
}
--
1.5.6.5
1
0
last-svn-commit-855-gae863e4 Make paragraph extraction work with this branch.
by Guillaume Lazzara 04 May '11
by Guillaume Lazzara 04 May '11
04 May '11
* scribo/core/line_info.hh: Keep few attributes public and update
method names.
* scribo/core/stats.hh: Fix missed elements in computation.
* scribo/text/paragraphs.hh: Use line_set and line_links
structures.
* scribo/toolchain/internal/content_in_doc_functor.hh: Make use of
the new paragraph extraction algorithm.
---
scribo/ChangeLog | 15 +
scribo/scribo/core/line_info.hh | 10 +-
scribo/scribo/core/stats.hh | 13 +-
scribo/scribo/text/paragraphs.hh | 1360 ++++++++++----------
.../toolchain/internal/content_in_doc_functor.hh | 178 ++--
5 files changed, 808 insertions(+), 768 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index a6ef3f8..fc761c3 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,18 @@
+2011-05-04 Guillaume Lazzara <lazzara(a)fidji.lrde.epita.fr>
+
+ Make paragraph extraction work with this branch.
+
+ * scribo/core/line_info.hh: Keep few attributes public and update
+ method names.
+
+ * scribo/core/stats.hh: Fix missed elements in computation.
+
+ * scribo/text/paragraphs.hh: Use line_set and line_links
+ structures.
+
+ * scribo/toolchain/internal/content_in_doc_functor.hh: Make use of
+ the new paragraph extraction algorithm.
+
2011-05-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
* tests/unit_test/unit-tests.mk: Regen.
diff --git a/scribo/scribo/core/line_info.hh b/scribo/scribo/core/line_info.hh
index 949315a..27dda84 100644
--- a/scribo/scribo/core/line_info.hh
+++ b/scribo/scribo/core/line_info.hh
@@ -145,14 +145,12 @@ namespace scribo
// Line set holding this element.
line_set<L> holder_;
- private:
- void init_();
-
// DEBUG
stats< float > meanline_clusters_;
stats< float > baseline_clusters_;
- };
+ private:
+ void init_();
};
} // end of namespace scribo::internal
@@ -980,8 +978,8 @@ namespace scribo
{
const component_set<L>& comp_set = data_->holder_.components();
- const unsigned c1 = data_->components_(0);
- const unsigned c2 = data_->components_(1);
+ const unsigned c1 = data_->component_ids_(0);
+ const unsigned c2 = data_->component_ids_(1);
if (data_->holder_.components()(c1).type() == component::Punctuation
|| data_->holder_.components()(c2).type() == component::Punctuation)
diff --git a/scribo/scribo/core/stats.hh b/scribo/scribo/core/stats.hh
index bc24044..095735c 100644
--- a/scribo/scribo/core/stats.hh
+++ b/scribo/scribo/core/stats.hh
@@ -261,7 +261,7 @@ private:
unsigned i = 0;
const unsigned nelements = data_.nelements();
- clusters[0] = cluster_index;
+ clusters.push_back(cluster_index);
const T std = data_.standard_deviation();
for (i = 1; i < nelements - 1; ++i)
@@ -276,11 +276,12 @@ private:
clusters.push_back(cluster_index);
}
- if (nelements > 1
- && data_[i] - data_[i - 1] > std)
- ++cluster_index;
-
- clusters.push_back(cluster_index);
+ if (nelements > 1)
+ {
+ if (data_[i] - data_[i - 1] > std)
+ ++cluster_index;
+ clusters.push_back(cluster_index);
+ }
clusters_.clear();
clusters_.reserve(cluster_index);
diff --git a/scribo/scribo/text/paragraphs.hh b/scribo/scribo/text/paragraphs.hh
index 5cb253e..94e5751 100644
--- a/scribo/scribo/text/paragraphs.hh
+++ b/scribo/scribo/text/paragraphs.hh
@@ -15,7 +15,9 @@
#include <scribo/core/macros.hh>
#include <scribo/core/line_set.hh>
+#include <scribo/core/line_links.hh>
#include <scribo/core/line_info.hh>
+#include <scribo/core/paragraph_set.hh>
using namespace mln;
@@ -59,15 +61,15 @@ namespace scribo
template <typename L>
inline
- void paragraph_links(const util::array<value::int_u16>& left,
- const util::array<value::int_u16>& right,
- util::array<value::int_u16>& output,
- const util::array< line_info<L> >& lines,
+ void paragraph_links(const line_links<L>& left,
+ const line_links<L>& right,
+ line_links<L>& output,
+ const line_set<L>& lines,
const image2d<bool>& input)
{
- output = left;
+ output = left.duplicate();
- const unsigned nlines = lines.nelements();
+ // const unsigned nlines = lines.nelements();
// image2d<value::rgb8> links = data::convert(value::rgb8(), input);
// for (unsigned l = 0; l < nlines; ++l)
@@ -77,242 +79,259 @@ namespace scribo
// mln::io::ppm::save(links, "out_links.ppm");
// For each line
- for (unsigned l = 0; l < nlines; ++l)
- {
- // Neighbors
-
- const value::int_u16 left_nbh = output(l);
- const value::int_u16 right_nbh = right(l);
- const value::int_u16 lol_nbh = output(left_nbh);
-
- // Line features
- const float x_height = lines(l).x_height();
- const float left_x_height = lines(left_nbh).x_height();
- const float right_x_height = lines(right_nbh).x_height();
-
- const box2d& left_line_bbox = lines(left_nbh).bbox();
- const box2d& current_line_bbox = lines(l).bbox();
- const box2d& right_line_bbox = lines(right_nbh).bbox();
- const box2d& lol_line_bbox = lines(lol_nbh).bbox(); // lol : left neighbor of the left neighbor
-
- const int lline_col_min = left_line_bbox.pmin().col();
- const int cline_col_min = current_line_bbox.pmin().col();
- const int rline_col_min = right_line_bbox.pmin().col();
- const int lolline_col_min = lol_line_bbox.pmin().col();
-
- const int lline_col_max = left_line_bbox.pmax().col();
- const int cline_col_max = current_line_bbox.pmax().col();
- const int rline_col_max = right_line_bbox.pmax().col();
-
- const int lline_cw = lines(left_nbh).char_width();
- const int cline_cw = lines(l).char_width();
- const int rline_cw = lines(right_nbh).char_width();
- // Maximal x variation to consider two lines vertically aligned
- const int delta_alignment = cline_cw;
-
- // Checks the baseline distances of the two neighbors
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
{
- // Current line baseline
- const int c_baseline = lines(l).baseline();
-
- // Baseline distance with the left and right neighbors
- const int lc_baseline = lines(left_nbh).baseline() - c_baseline;
- const int rc_baseline = c_baseline -lines(right_nbh).baseline();
+ // Neighbors
+
+ const line_id_t left_nbh = output(l);
+ const line_id_t right_nbh = right(l);
+ const line_id_t lol_nbh = output(left_nbh);
+
+ // Line features
+ const float x_height = lines(l).x_height();
+ const float left_x_height = lines(left_nbh).x_height();
+ const float right_x_height = lines(right_nbh).x_height();
+
+ const box2d& left_line_bbox = lines(left_nbh).bbox();
+ const box2d& current_line_bbox = lines(l).bbox();
+ const box2d& right_line_bbox = lines(right_nbh).bbox();
+ const box2d& lol_line_bbox = lines(lol_nbh).bbox(); // lol : left neighbor of the left neighbor
+
+ const int lline_col_min = left_line_bbox.pmin().col();
+ const int cline_col_min = current_line_bbox.pmin().col();
+ const int rline_col_min = right_line_bbox.pmin().col();
+ const int lolline_col_min = lol_line_bbox.pmin().col();
+
+ const int lline_col_max = left_line_bbox.pmax().col();
+ const int cline_col_max = current_line_bbox.pmax().col();
+ const int rline_col_max = right_line_bbox.pmax().col();
+
+ const int lline_cw = lines(left_nbh).char_width();
+ const int cline_cw = lines(l).char_width();
+ const int rline_cw = lines(right_nbh).char_width();
+ // Maximal x variation to consider two lines vertically aligned
+ const int delta_alignment = cline_cw;
+
+ // Checks the baseline distances of the two neighbors
+ {
+ // Current line baseline
+ const int c_baseline = lines(l).baseline();
- // Max baseline distance between the two neighbors
- // const float delta_baseline_max = std::max(lc_baseline, rc_baseline);
- // const float delta_baseline_min = std::min(lc_baseline,
- // rc_baseline);
+ // Baseline distance with the left and right neighbors
+ const int lc_baseline = lines(left_nbh).baseline() - c_baseline;
+ const int rc_baseline = c_baseline -lines(right_nbh).baseline();
- // Only two lines, meaning the current line has only one neighbor
- bool two_lines = false;
+ // Max baseline distance between the two neighbors
+ // const float delta_baseline_max = std::max(lc_baseline, rc_baseline);
+ // const float delta_baseline_min = std::min(lc_baseline,
+ // rc_baseline);
- // If the current line has no left neighbor
- if (lc_baseline == 0)
- {
- // ror : right neighbor of the right neighbor
- const value::int_u16 ror_nbh = right(right_nbh);
- // const box2d& ror_line_bbox = lines(ror_nbh).bbox();
+ // Only two lines, meaning the current line has only one neighbor
+ bool two_lines = false;
- // If the current line has a ror
- if (ror_nbh != right_nbh
- && output(ror_nbh) == right_nbh)
+ // If the current line has no left neighbor
+ if (lc_baseline == 0)
{
- // Distance between the current line and the right neighbor
- const float right_distance = lines(l).meanline() - lines(right_nbh).baseline();
- // Distance between the right neighbor and the ror
- const float ror_distance = lines(right_nbh).meanline() - lines(ror_nbh).baseline();
- // ror x_height
- const float ror_x_height = lines(ror_nbh).x_height();
-
- // Conditions to cut the link between the current line
- // and its right neighbor
- if (right_distance > 1.4f * ror_distance
- && std::max(ror_x_height, right_x_height) <
- 1.2f * std::min(ror_x_height, right_x_height)
- && output(right_nbh) == l)
+ // ror : right neighbor of the right neighbor
+ const line_id_t ror_nbh = right(right_nbh);
+ //const box2d& ror_line_bbox = lines(ror_nbh).bbox();
+
+ // If the current line has a ror
+ if (ror_nbh != right_nbh
+ && output(ror_nbh) == right_nbh)
{
+ // Distance between the current line and the right neighbor
+ const float right_distance = lines(l).meanline() - lines(right_nbh).baseline();
+ // Distance between the right neighbor and the ror
+ const float ror_distance = lines(right_nbh).meanline() - lines(ror_nbh).baseline();
+ // ror x_height
+ const float ror_x_height = lines(ror_nbh).x_height();
+
+ // Conditions to cut the link between the current line
+ // and its right neighbor
+ if (right_distance > 1.4f * ror_distance
+ && std::max(ror_x_height, right_x_height) <
+ 1.2f * std::min(ror_x_height, right_x_height)
+ && output(right_nbh) == l)
+ {
output(right_nbh) = right_nbh;
continue;
+ }
}
- }
- // Otherwise we only have a group of two lines
- else
- {
- // We determine the distance between the two lines
- const float distance = lines(l).meanline() - lines(right_nbh).baseline();
- two_lines = true;
-
- // If the distance between the two lines is greater than
- // the minimum x height of the two lines then we cut the
- // link between them
- if (distance > 2.0f * std::min(x_height, right_x_height)
- && output(right_nbh) == l)
+ // Otherwise we only have a group of two lines
+ else
{
+ // We determine the distance between the two lines
+ const float distance = lines(l).meanline() - lines(right_nbh).baseline();
+ two_lines = true;
+
+ // If the distance between the two lines is greater than
+ // the minimum x height of the two lines then we cut the
+ // link between them
+ if (distance > 2.0f * std::min(x_height, right_x_height)
+ && output(right_nbh) == l)
+ {
output(right_nbh) = right_nbh;
continue;
+ }
}
- }
- // Lines features
- const float min_x_height = std::min(x_height, right_x_height);
- const float max_x_height = std::max(x_height, right_x_height);
- const float min_char_width = std::min(rline_cw, cline_cw);
- const float max_char_width = std::max(rline_cw, cline_cw);
+ // Lines features
+ const float min_x_height = std::min(x_height, right_x_height);
+ const float max_x_height = std::max(x_height, right_x_height);
+ const float min_char_width = std::min(rline_cw, cline_cw);
+ const float max_char_width = std::max(rline_cw, cline_cw);
- // Condition to cut the link between the current line and
- // its right neighbor
- if ((max_x_height > min_x_height * 1.2f) &&
- !(max_char_width <= 1.2f * min_char_width))
- {
- if (output(right_nbh) == l)
+ // Condition to cut the link between the current line and
+ // its right neighbor
+ if ((max_x_height > min_x_height * 1.2f) &&
+ !(max_char_width <= 1.2f * min_char_width))
{
- output(right_nbh) = right_nbh;
- continue;
+ if (output(right_nbh) == l)
+ {
+ output(right_nbh) = right_nbh;
+ continue;
+ }
}
- }
-
- // If we only have two lines we stop the study
- if (two_lines)
- continue;
- }
- // If the current line has no right neighbor
- else if (rc_baseline == 0)
- {
- // lol : left neighbor of the left neighbor
- // If the left neighbor of the current line has a left neighbor
- if (lol_nbh != left_nbh)
+ // If we only have two lines we stop the study
+ if (two_lines)
+ continue;
+ }
+ // If the current line has no right neighbor
+ else if (rc_baseline == 0)
{
- // Distance between the current line and its left neighbor
- const float left_distance = lines(left_nbh).meanline() -
- lines(l).baseline();
- // Distance between the left neighbor and the left
- // neighbor of its left neighbor
- const float lol_distance = lines(lol_nbh).meanline() -
- lines(left_nbh).baseline();
- // lol x height
- const float lol_x_height = lines(lol_nbh).x_height();
-
- // Conditions to cut the link between the current line
- // and its left neighbor
- if (left_distance > 1.4f * lol_distance
- && std::max(lol_x_height, left_x_height) <
- 1.2f * std::min(lol_x_height, left_x_height))
+ // lol : left neighbor of the left neighbor
+
+ // If the left neighbor of the current line has a left neighbor
+ if (lol_nbh != left_nbh)
{
+ // Distance between the current line and its left neighbor
+ const float left_distance = lines(left_nbh).meanline() -
+ lines(l).baseline();
+ // Distance between the left neighbor and the left
+ // neighbor of its left neighbor
+ const float lol_distance = lines(lol_nbh).meanline() -
+ lines(left_nbh).baseline();
+ // lol x height
+ const float lol_x_height = lines(lol_nbh).x_height();
+
+ // Conditions to cut the link between the current line
+ // and its left neighbor
+ if (left_distance > 1.4f * lol_distance
+ && std::max(lol_x_height, left_x_height) <
+ 1.2f * std::min(lol_x_height, left_x_height))
+ {
output(l) = l;
continue;
+ }
}
- }
- // Otherwise we only have a group of two lines
- else
- {
- // Distance between the current line and it left neighbor
- const float distance = lines(left_nbh).meanline() -
- lines(l).baseline();
+ // Otherwise we only have a group of two lines
+ else
+ {
+ // Distance between the current line and it left neighbor
+ const float distance = lines(left_nbh).meanline() -
+ lines(l).baseline();
- two_lines = true;
+ two_lines = true;
- // If the distance is greater than the min x height
- // between the two lines
- if (distance > 2.0f * std::min(x_height, left_x_height))
- {
+ // If the distance is greater than the min x height
+ // between the two lines
+ if (distance > 2.0f * std::min(x_height, left_x_height))
+ {
output(l) = l;
continue;
+ }
}
- }
-
- // Lines features
- const float min_x_height = std::min(x_height, left_x_height);
- const float max_x_height = std::max(x_height, left_x_height);
- const float min_char_width = std::min(lline_cw, cline_cw);
- const float max_char_width = std::max(lline_cw, cline_cw);
-
- // Condition to cut the link between the current line and
- // its left neighbor
- if ((max_x_height > min_x_height * 1.2f) &&
- !(max_char_width <= 1.2f * min_char_width))
- {
- output(l) = l;
- continue;
- }
- // If we only have two lines we stop the study
- if (two_lines)
- continue;
- }
- // The current line has at least one left and one right neighbor
- else // if (delta_baseline_max >= delta_baseline_min)
- {
- // Distance between the left and the current line
- const float left_distance =
- lines(left_nbh).meanline() - lines(l).baseline();
- // Distance between the right and the current line
- const float right_distance =
- lines(l).meanline() - lines(right_nbh).baseline();
-
- // If the left line is too far compared to the right one
- // we cut the link with it
- if (left_distance > 1.2f * right_distance
- && std::max(x_height, left_x_height) > 1.2f * std::min(x_height, left_x_height))
- {
- output(l) = l;
- continue;
- }
- // If the right line is too far compared to the left one
- // we cut the link with it
- else if (right_distance > 1.2f * left_distance
- && std::max(x_height, right_x_height) > 1.2f * std::min(x_height, right_x_height)
- && output(right_nbh) == l)
- {
- output(right_nbh) = right_nbh;
- continue;
- }
-
- // If the distance between the baseline of the left
- // neighbor and the baseline of the current line is
- // greater than the one between the current line baseline
- // and the right line baseline we have to study the texte
- // features of the right and left lines
- if (lc_baseline > rc_baseline)
- {
- const float cw_max = std::max(lline_cw, cline_cw);
- const float cw_min = std::min(lline_cw, cline_cw);
+ // Lines features
const float min_x_height = std::min(x_height, left_x_height);
const float max_x_height = std::max(x_height, left_x_height);
+ const float min_char_width = std::min(lline_cw, cline_cw);
+ const float max_char_width = std::max(lline_cw, cline_cw);
+ // Condition to cut the link between the current line and
+ // its left neighbor
if ((max_x_height > min_x_height * 1.2f) &&
- !(cw_max <= 1.2f * cw_min))
+ !(max_char_width <= 1.2f * min_char_width))
{
output(l) = l;
continue;
}
+ // If we only have two lines we stop the study
+ if (two_lines)
+ continue;
+ }
+ // The current line has at least one left and one right neighbor
+ else // if (delta_baseline_max >= delta_baseline_min)
+ {
+ // Distance between the left and the current line
+ const float left_distance =
+ lines(left_nbh).meanline() - lines(l).baseline();
+ // Distance between the right and the current line
+ const float right_distance =
+ lines(l).meanline() - lines(right_nbh).baseline();
+
+ // If the left line is too far compared to the right one
+ // we cut the link with it
+ if (left_distance > 1.2f * right_distance
+ && std::max(x_height, left_x_height) > 1.2f * std::min(x_height, left_x_height))
+ {
+ output(l) = l;
+ continue;
+ }
+ // If the right line is too far compared to the left one
+ // we cut the link with it
+ else if (right_distance > 1.2f * left_distance
+ && std::max(x_height, right_x_height) > 1.2f * std::min(x_height, right_x_height)
+ && output(right_nbh) == l)
+ {
+ output(right_nbh) = right_nbh;
+ continue;
+ }
+
+ // If the distance between the baseline of the left
+ // neighbor and the baseline of the current line is
+ // greater than the one between the current line baseline
+ // and the right line baseline we have to study the texte
+ // features of the right and left lines
+ if (lc_baseline > rc_baseline)
+ {
+ const float cw_max = std::max(lline_cw, cline_cw);
+ const float cw_min = std::min(lline_cw, cline_cw);
+ const float min_x_height = std::min(x_height, left_x_height);
+ const float max_x_height = std::max(x_height, left_x_height);
+
+ if ((max_x_height > min_x_height * 1.2f) &&
+ !(cw_max <= 1.2f * cw_min))
+ {
+ output(l) = l;
+ continue;
+ }
+
+ {
+ const float min_x_height = std::min(x_height, right_x_height);
+ const float max_x_height = std::max(x_height, right_x_height);
+ const float cw_max = std::max(rline_cw, cline_cw);
+ const float cw_min = std::min(rline_cw, cline_cw);
+
+ if ((max_x_height > min_x_height * 1.2f)
+ && !(cw_max <= 1.2f * cw_min)
+ && output(right_nbh) == l)
+ {
+ output(right_nbh) = right_nbh;
+ continue;
+ }
+ }
+ }
+ else
{
- const float min_x_height = std::min(x_height, right_x_height);
- const float max_x_height = std::max(x_height, right_x_height);
const float cw_max = std::max(rline_cw, cline_cw);
const float cw_min = std::min(rline_cw, cline_cw);
+ const float min_x_height = std::min(x_height, right_x_height);
+ const float max_x_height = std::max(x_height, right_x_height);
if ((max_x_height > min_x_height * 1.2f)
&& !(cw_max <= 1.2f * cw_min)
@@ -321,44 +340,28 @@ namespace scribo
output(right_nbh) = right_nbh;
continue;
}
- }
- }
- else
- {
- const float cw_max = std::max(rline_cw, cline_cw);
- const float cw_min = std::min(rline_cw, cline_cw);
- const float min_x_height = std::min(x_height, right_x_height);
- const float max_x_height = std::max(x_height, right_x_height);
- if ((max_x_height > min_x_height * 1.2f)
- && !(cw_max <= 1.2f * cw_min)
- && output(right_nbh) == l)
- {
- output(right_nbh) = right_nbh;
- continue;
- }
-
- {
- const float min_x_height = std::min(x_height, left_x_height);
- const float max_x_height = std::max(x_height, left_x_height);
- const float cw_max = std::max(lline_cw, cline_cw);
- const float cw_min = std::min(lline_cw, cline_cw);
-
- if ((max_x_height > min_x_height * 1.2f)
- && !(cw_max <= 1.2f * cw_min))
{
- output(l) = l;
- continue;
+ const float min_x_height = std::min(x_height, left_x_height);
+ const float max_x_height = std::max(x_height, left_x_height);
+ const float cw_max = std::max(lline_cw, cline_cw);
+ const float cw_min = std::min(lline_cw, cline_cw);
+
+ if ((max_x_height > min_x_height * 1.2f)
+ && !(cw_max <= 1.2f * cw_min))
+ {
+ output(l) = l;
+ continue;
+ }
}
}
}
}
- }
- // If we arrive here, it means than the lines in the
- // neighborhood of the current line are quite similar. We can
- // then begin to study the indentations in order to determine
- // the beginning of new paragraphs
+ // If we arrive here, it means than the lines in the
+ // neighborhood of the current line are quite similar. We can
+ // then begin to study the indentations in order to determine
+ // the beginning of new paragraphs
//-----------------------------------------------------------------------------
// ___________________________
@@ -375,35 +378,35 @@ namespace scribo
//
//-----------------------------------------------------------------------------
- {
- // Check if the current line neighbors are aligned
- bool left_right_aligned = false;
- bool left_lol_aligned = false;
- const int dx_lr = std::abs(lline_col_min - rline_col_min);
- const int dx_llol = std::abs(lline_col_min - lolline_col_min);
+ {
+ // Check if the current line neighbors are aligned
+ bool left_right_aligned = false;
+ bool left_lol_aligned = false;
+ const int dx_lr = std::abs(lline_col_min - rline_col_min);
+ const int dx_llol = std::abs(lline_col_min - lolline_col_min);
- if (dx_lr < delta_alignment)
- left_right_aligned = true;
+ if (dx_lr < delta_alignment)
+ left_right_aligned = true;
- if (dx_llol < delta_alignment)
- left_lol_aligned = true;
+ if (dx_llol < delta_alignment)
+ left_lol_aligned = true;
- if (left_right_aligned && left_lol_aligned)
- {
- const int left_right_col_min = std::min(lline_col_min, rline_col_min);
- const int dx_lrc = std::abs(left_right_col_min - cline_col_min);
- const float l_char_width = 1.5f * lines(l).char_width();
-
- if (dx_lrc > l_char_width &&
- dx_lrc < 3.0f * l_char_width &&
- cline_col_min > rline_col_min &&
- cline_col_min > lline_col_min)
+ if (left_right_aligned && left_lol_aligned)
{
- output(right_nbh) = right_nbh;
- continue;
+ const int left_right_col_min = std::min(lline_col_min, rline_col_min);
+ const int dx_lrc = std::abs(left_right_col_min - cline_col_min);
+ const float l_char_width = 1.5f * lines(l).char_width();
+
+ if (dx_lrc > l_char_width &&
+ dx_lrc < 3.0f * l_char_width &&
+ cline_col_min > rline_col_min &&
+ cline_col_min > lline_col_min)
+ {
+ output(right_nbh) = right_nbh;
+ continue;
+ }
}
}
- }
//-----------------------------------------------------------------------------
// ___________________________
@@ -419,41 +422,41 @@ namespace scribo
//
//-----------------------------------------------------------------------------
- {
- // Check if the current line neighbors are aligned
- bool left_right_max_aligned = false;
- bool left_current_min_aligned = false;
- bool lol_current_min_aligned = false;
- const bool lol_is_left = output(left_nbh) == left_nbh;
- const int dx_lr_max = std::abs(lline_col_max - rline_col_max);
- const int dx_lc_min = std::abs(lline_col_min - cline_col_min);
- const int dx_lolc_min = std::abs(lolline_col_min - cline_col_min);
-
- if (dx_lr_max < delta_alignment)
- left_right_max_aligned = true;
-
- if (dx_lc_min < delta_alignment)
- left_current_min_aligned = true;
-
- if (dx_lolc_min < delta_alignment)
- lol_current_min_aligned = true;
-
- if (!left_current_min_aligned && left_right_max_aligned &&
- (lol_current_min_aligned || lol_is_left))
{
- const int dx_lrc = std::abs(lline_col_max - cline_col_max);
- const int l_char_width = lines(l).char_width();
-
- if (dx_lrc > l_char_width &&
- cline_col_max < lline_col_max &&
- cline_col_min < lline_col_min &&
- (lline_col_min > lolline_col_min || lol_is_left))
+ // Check if the current line neighbors are aligned
+ bool left_right_max_aligned = false;
+ bool left_current_min_aligned = false;
+ bool lol_current_min_aligned = false;
+ const bool lol_is_left = output(left_nbh) == left_nbh;
+ const int dx_lr_max = std::abs(lline_col_max - rline_col_max);
+ const int dx_lc_min = std::abs(lline_col_min - cline_col_min);
+ const int dx_lolc_min = std::abs(lolline_col_min - cline_col_min);
+
+ if (dx_lr_max < delta_alignment)
+ left_right_max_aligned = true;
+
+ if (dx_lc_min < delta_alignment)
+ left_current_min_aligned = true;
+
+ if (dx_lolc_min < delta_alignment)
+ lol_current_min_aligned = true;
+
+ if (!left_current_min_aligned && left_right_max_aligned &&
+ (lol_current_min_aligned || lol_is_left))
{
- output(l) = l;
- continue;
+ const int dx_lrc = std::abs(lline_col_max - cline_col_max);
+ const int l_char_width = lines(l).char_width();
+
+ if (dx_lrc > l_char_width &&
+ cline_col_max < lline_col_max &&
+ cline_col_min < lline_col_min &&
+ (lline_col_min > lolline_col_min || lol_is_left))
+ {
+ output(l) = l;
+ continue;
+ }
}
}
- }
//-----------------------------------------------------------------------------
@@ -469,68 +472,69 @@ namespace scribo
//
//-----------------------------------------------------------------------------
- if (left_nbh == l)
- {
- const value::int_u16 ror_nbh = right(right_nbh);
- const box2d& ror_line_bbox = lines(ror_nbh).bbox();
- const int rorline_col_min = ror_line_bbox.pmin().col();
+ if (left_nbh == l)
+ {
+ const line_id_t ror_nbh = right(right_nbh);
+ const box2d& ror_line_bbox = lines(ror_nbh).bbox();
+ const int rorline_col_min = ror_line_bbox.pmin().col();
- bool right_ror_min_aligned = false;
- const int dx_rror_min = std::abs(rline_col_min - rorline_col_min);
+ bool right_ror_min_aligned = false;
+ const int dx_rror_min = std::abs(rline_col_min - rorline_col_min);
- if (dx_rror_min < delta_alignment)
- right_ror_min_aligned = true;
+ if (dx_rror_min < delta_alignment)
+ right_ror_min_aligned = true;
- if (right_ror_min_aligned)
- {
- const int right_ror_col_min = std::min(rline_col_min, rorline_col_min);
- const int dx_rrorc = std::abs(right_ror_col_min - cline_col_min);
- const float l_char_width = 1.5f * lines(l).char_width();
-
- if (dx_rrorc > l_char_width &&
- dx_rrorc < 3.0f * l_char_width &&
- cline_col_min > rline_col_min &&
- cline_col_max >= rline_col_max)
+ if (right_ror_min_aligned)
{
- output(right_nbh) = right_nbh;
- continue;
+ const int right_ror_col_min = std::min(rline_col_min, rorline_col_min);
+ const int dx_rrorc = std::abs(right_ror_col_min - cline_col_min);
+ const float l_char_width = 1.5f * lines(l).char_width();
+
+ if (dx_rrorc > l_char_width &&
+ dx_rrorc < 3.0f * l_char_width &&
+ cline_col_min > rline_col_min &&
+ cline_col_max >= rline_col_max)
+ {
+ output(right_nbh) = right_nbh;
+ continue;
+ }
}
}
}
- }
// Only debug
- {
- image2d<value::rgb8> debug = data::convert(value::rgb8(), input);
-
- for (unsigned i = 0; i < output.nelements(); ++i)
- output(i) = internal::find_root(output, i);
-
- mln::util::array<accu::shape::bbox<point2d> > nbbox(output.nelements());
- for (unsigned i = 0; i < nlines; ++i)
- {
- // if (lines(i).is_textline())
- // {
- // mln::draw::box(debug, lines(i).bbox(), literal::red);
- nbbox(output(i)).take(lines(i).bbox());
- // }
- }
-
- for (unsigned i = 0; i < nbbox.nelements(); ++i)
- if (nbbox(i).is_valid())
- {
- box2d b = nbbox(i).to_result();
- mln::draw::box(debug, b, literal::orange);
- b.enlarge(1);
- mln::draw::box(debug, b, literal::orange);
- b.enlarge(1);
- mln::draw::box(debug, b, literal::orange);
- }
-
- mln::io::ppm::save(debug, "out_paragraph.ppm");
- }
+ // {
+ // image2d<value::rgb8> debug = data::convert(value::rgb8(), input);
+
+ // for (unsigned i = 0; i < output.nelements(); ++i)
+ // output(i) = scribo::make::internal::find_root(output, i);
+
+ // mln::util::array<accu::shape::bbox<point2d> > nbbox(output.nelements());
+ // for_all_lines(l, lines)
+ // if (lines(l).is_textline())
+ // {
+ // // if (lines(i).is_textline())
+ // // {
+ // // mln::draw::box(debug, lines(i).bbox(), literal::red);
+ // nbbox(output(l)).take(lines(l).bbox());
+ // // }
+ // }
+
+ // for (unsigned i = 0; i < nbbox.nelements(); ++i)
+ // if (nbbox(i).is_valid())
+ // {
+ // box2d b = nbbox(i).to_result();
+ // mln::draw::box(debug, b, literal::orange);
+ // b.enlarge(1);
+ // mln::draw::box(debug, b, literal::orange);
+ // b.enlarge(1);
+ // mln::draw::box(debug, b, literal::orange);
+ // }
+
+ // mln::io::ppm::save(debug, "out_paragraph.ppm");
+ // }
}
}
@@ -547,262 +551,269 @@ namespace scribo
template <typename L>
inline
void prepare_lines(const box2d& domain,
- const util::array< line_info<L> >& lines,
- image2d<value::int_u16>& blocks,
+ const line_set<L>& lines,
+ L& blocks,
util::array<box2d>& rbbox)
{
std::map< int, std::vector< const box2d* > > drawn_lines;
- const unsigned nlines = lines.nelements();
+ // const unsigned nlines = lines.nelements();
// For each line
- for (unsigned l = 0; l < nlines; ++l)
- {
- // Rotation of the bounding box
- box2d b = geom::rotate(lines(l).bbox(), -90, domain.pcenter());
- rbbox.append(b);
-
- const unsigned index = l + 1;
- const unsigned even_index = 2 * index;
- const unsigned odd_index = even_index + 1;
-
- // Top of the line
+ //for (unsigned l = 0; l < nlines; ++l)
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
{
- bool not_finished = true;
- int col_offset = 0;
+ // Rotation of the bounding box
+ box2d b = geom::rotate(lines(l).bbox(), -90, domain.pcenter());
+// rbbox.append(b);
+ rbbox(l) = b;
- while (not_finished)
- {
- // Looking for a column in the image to draw the top of the
- // line
+ const unsigned index = l + 1;
+ const unsigned even_index = 2 * index;
+ const unsigned odd_index = even_index + 1;
- const int col = b.pmax().col() + col_offset;
- std::map< int, std::vector< const box2d* > >::iterator it
- = drawn_lines.find(col);
+ // Top of the line
+ {
+ bool not_finished = true;
+ int col_offset = 0;
- if (it != drawn_lines.end())
+ while (not_finished)
{
- const std::vector< const box2d* >& lines = (*it).second;
- const unsigned nb_lines = lines.size();
- unsigned i = 0;
+ // Looking for a column in the image to draw the top of the
+ // line
+
+ const int col = b.pmax().col() + col_offset;
+ std::map< int, std::vector< const box2d* > >::iterator it
+ = drawn_lines.find(col);
- for (i = 0; i < nb_lines; ++i)
+ if (it != drawn_lines.end())
{
- const box2d* box = lines[i];
- const int min_row = std::max(b.pmin().row(), box->pmin().row());
- const int max_row = std::min(b.pmax().row(), box->pmax().row());
+ const std::vector< const box2d* >& lines = (*it).second;
+ const unsigned nb_lines = lines.size();
+ unsigned i = 0;
- if (min_row - max_row <= 0)
- break;
- }
+ for (i = 0; i < nb_lines; ++i)
+ {
+ const box2d* box = lines[i];
+ const int min_row = std::max(b.pmin().row(), box->pmin().row());
+ const int max_row = std::min(b.pmax().row(), box->pmax().row());
- if (i == nb_lines)
+ if (min_row - max_row <= 0)
+ break;
+ }
+
+ if (i == nb_lines)
+ {
+ mln::draw::line(blocks, point2d(b.pmin().row(), col),
+ point2d(b.pmax().row(), col), even_index);
+ not_finished = false;
+ drawn_lines[col].push_back(&(rbbox[l]));
+ }
+ else
+ ++col_offset;
+ }
+ else
{
mln::draw::line(blocks, point2d(b.pmin().row(), col),
point2d(b.pmax().row(), col), even_index);
not_finished = false;
drawn_lines[col].push_back(&(rbbox[l]));
}
- else
- ++col_offset;
- }
- else
- {
- mln::draw::line(blocks, point2d(b.pmin().row(), col),
- point2d(b.pmax().row(), col), even_index);
- not_finished = false;
- drawn_lines[col].push_back(&(rbbox[l]));
}
}
- }
- // Bottom of the line
- {
- bool not_finished = true;
- int col_offset = 0;
-
- while (not_finished)
+ // Bottom of the line
{
- // Looking for a column in the image to draw the bottom of
- // the line
+ bool not_finished = true;
+ int col_offset = 0;
- const int col = b.pmin().col() - col_offset;
- std::map< int, std::vector< const box2d* > >::iterator it
- = drawn_lines.find(col);
-
- if (it != drawn_lines.end())
+ while (not_finished)
{
- const std::vector< const box2d* >& lines = (*it).second;
- const unsigned nb_lines = lines.size();
- unsigned i = 0;
+ // Looking for a column in the image to draw the bottom of
+ // the line
+
+ const int col = b.pmin().col() - col_offset;
+ std::map< int, std::vector< const box2d* > >::iterator it
+ = drawn_lines.find(col);
- for (i = 0; i < nb_lines; ++i)
+ if (it != drawn_lines.end())
{
- const box2d* box = lines[i];
- const int min_row = std::max(b.pmin().row(), box->pmin().row());
- const int max_row = std::min(b.pmax().row(), box->pmax().row());
+ const std::vector< const box2d* >& lines = (*it).second;
+ const unsigned nb_lines = lines.size();
+ unsigned i = 0;
- if (min_row - max_row <= 0)
- break;
- }
+ for (i = 0; i < nb_lines; ++i)
+ {
+ const box2d* box = lines[i];
+ const int min_row = std::max(b.pmin().row(), box->pmin().row());
+ const int max_row = std::min(b.pmax().row(), box->pmax().row());
- if (i == nb_lines)
+ if (min_row - max_row <= 0)
+ break;
+ }
+
+ if (i == nb_lines)
+ {
+ mln::draw::line(blocks, point2d(b.pmin().row(), col),
+ point2d(b.pmax().row(), col), odd_index);
+ not_finished = false;
+ drawn_lines[col].push_back(&(rbbox[l]));
+ }
+ else
+ ++col_offset;
+ }
+ else
{
mln::draw::line(blocks, point2d(b.pmin().row(), col),
point2d(b.pmax().row(), col), odd_index);
not_finished = false;
drawn_lines[col].push_back(&(rbbox[l]));
}
- else
- ++col_offset;
- }
- else
- {
- mln::draw::line(blocks, point2d(b.pmin().row(), col),
- point2d(b.pmax().row(), col), odd_index);
- not_finished = false;
- drawn_lines[col].push_back(&(rbbox[l]));
}
}
}
- }
}
template <typename L>
inline
void
- process_left_link(image2d<value::int_u16>& blocks,
+ process_left_link(L& blocks,
const util::array<box2d>& rbbox,
- const util::array< line_info<L> >& lines,
- util::array<value::int_u16>& left)
+ const line_set<L>& lines,
+ line_links<L>& left)
{
- typedef value::int_u16 V;
+ typedef scribo::def::lbl_type V;
// At the beginning each line is its own neighbor
- for (unsigned i = 0; i < left.nelements(); ++i)
- left(i) = i;
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
+ left(l) = l;
+ else
+ left(l) = 0;
- const unsigned nlines = lines.nelements();
+ // const unsigned nlines = lines.nelements();
// For each line
- for (unsigned i = 0; i < nlines; ++i)
- {
- // Max distance for the line search
- int dmax = 1.5f * lines(i).x_height();
-
- // Starting points in the current line box
- point2d c = rbbox(i).pcenter();
- point2d q(rbbox(i).pmin().row() + ((c.row() - rbbox(i).pmin().row()) / 4), c.col());
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
+ {
+ // Max distance for the line search
+ int dmax = 1.5f * lines(l).x_height();
- int
- midcol = (rbbox(i).pmax().col()
- - rbbox(i).pmin().col()) / 2;
+ // Starting points in the current line box
+ point2d c = rbbox(l).pcenter();
+ point2d q(rbbox(l).pmin().row() + ((c.row() - rbbox(l).pmin().row()) / 4), c.col());
- // Left
- {
- // marge gauche
int
- nleftima = c.col() - blocks.domain().pmin().col(),
- // Distance gauche
- nleft = std::min(nleftima, midcol + dmax);
-
- V
- // Starting points in the box
- *p = &blocks(c),
- *p2 = &blocks(q),
- // End of search
- *pstop = p - nleft - 1,
- // Line neighbor
- *nbh_p = 0;
-
- // While we haven't found a neighbor or reached the limit
- for (; p != pstop; --p, --p2)
+ midcol = (rbbox(l).pmax().col()
+ - rbbox(l).pmin().col()) / 2;
+
+ // Left
{
- if (*p2 != literal::zero // Not the background
- && ((*p2 % 2) == 0) // Looking for the bottom of a line
- && left((*p2 >> 1) - 1) != i) // No loops
+ // marge gauche
+ int
+ nleftima = c.col() - blocks.domain().pmin().col(),
+ // Distance gauche
+ nleft = std::min(nleftima, midcol + dmax);
+
+ V
+ // Starting points in the box
+ *p = &blocks(c),
+ *p2 = &blocks(q),
+ // End of search
+ *pstop = p - nleft - 1,
+ // Line neighbor
+ *nbh_p = 0;
+
+ // While we haven't found a neighbor or reached the limit
+ for (; p != pstop; --p, --p2)
{
- // Neightbor found, we stop the research
- nbh_p = p2;
- break;
- }
+ if (*p2 != literal::zero // Not the background
+ && ((*p2 % 2) == 0) // Looking for the bottom of a line
+ && left((*p2 >> 1) - 1) != l) // No loops
+ {
+ // Neightbor found, we stop the research
+ nbh_p = p2;
+ break;
+ }
- if (*p != literal::zero // Not the background
- && ((*p % 2) == 0) // Looking for the bottom of a line
- && left((*p >> 1) - 1) != i) // No loops
- {
- // Neightbor found, we stop the research
- nbh_p = p;
- break;
+ if (*p != literal::zero // Not the background
+ && ((*p % 2) == 0) // Looking for the bottom of a line
+ && left((*p >> 1) - 1) != l) // No loops
+ {
+ // Neightbor found, we stop the research
+ nbh_p = p;
+ break;
+ }
}
- }
-
- // If a neighbor was found, then we have found the top of the
- // line. We are then looking for the bottom of the encountered
- // line. If during the search process we find a complete line
- // included in the touched line, this line is considered as
- // the neighbor under certain conditions (see below)
-
- //---------------------------------------------------------------
- // _________________________ |
- // |_________________________| => Current line | Search direction
- // v
- // => First encountered top line
- // __________________________________________________ 2Q
- // | Q |
- // | _________________________ |2P
- // | |_____________P___________| => Second top |2P + 1
- // | line |
- // |__________________________________________________|2Q + 1
- //
- //
- //---------------------------------------------------------------
-
- if (nbh_p)
- {
- std::vector<V> lines_nbh;
- const V end_p = *nbh_p + 1;
- const V* nbh_p_copy = nbh_p;
- for (; *nbh_p != end_p; --nbh_p)
+ // If a neighbor was found, then we have found the top of the
+ // line. We are then looking for the bottom of the encountered
+ // line. If during the search process we find a complete line
+ // included in the touched line, this line is considered as
+ // the neighbor under certain conditions (see below)
+
+ //---------------------------------------------------------------
+ // _________________________ |
+ // |_________________________| => Current line | Search direction
+ // v
+ // => First encountered top line
+ // __________________________________________________ 2Q
+ // | Q |
+ // | _________________________ |2P
+ // | |_____________P___________| => Second top |2P + 1
+ // | line |
+ // |__________________________________________________|2Q + 1
+ //
+ //
+ //---------------------------------------------------------------
+
+ if (nbh_p)
{
- if ((*nbh_p) != literal::zero) // Not the background
+ std::vector<V> lines_nbh;
+ const V end_p = *nbh_p + 1;
+ const V* nbh_p_copy = nbh_p;
+
+ for (; *nbh_p != end_p; --nbh_p)
{
- if ((*nbh_p) % 2 == 0)// We have found the top of
- // another line
- lines_nbh.push_back(*nbh_p);
- else
+ if ((*nbh_p) != literal::zero) // Not the background
{
- // We have found the bottom of a line. We are looking if
- // we have already encountered the top of this
- // line. If so, we link the current line with this one
- // under certain conditions:
-
- if (std::find(lines_nbh.begin(), lines_nbh.end(),
- (*nbh_p) - 1) != lines_nbh.end())
+ if ((*nbh_p) % 2 == 0)// We have found the top of
+ // another line
+ lines_nbh.push_back(*nbh_p);
+ else
{
- // If we can link the complete line with the current line
- if (// It must be in the search range
- nbh_p > pstop
- // Avoid loops
- && left(((*nbh_p - 1) >> 1) - 1) != i)
- left(i) = ((*nbh_p - 1) >> 1) - 1;
-
- // We have found a complete line so we stop the search
- break;
+ // We have found the bottom of a line. We are looking if
+ // we have already encountered the top of this
+ // line. If so, we link the current line with this one
+ // under certain conditions:
+
+ if (std::find(lines_nbh.begin(), lines_nbh.end(),
+ (*nbh_p) - 1) != lines_nbh.end())
+ {
+ // If we can link the complete line with the current line
+ if (// It must be in the search range
+ nbh_p > pstop
+ // Avoid loops
+ && left(((*nbh_p - 1) >> 1) - 1) != l)
+ left(l) = ((*nbh_p - 1) >> 1) - 1;
+
+ // We have found a complete line so we stop the search
+ break;
+ }
}
}
}
- }
- // If we haven't found any included line in the first
- // neighbor, then the line is considered as the neighbor of
- // the current line
- if (*nbh_p == end_p)
- left(i) = (*nbh_p_copy >> 1) - 1;
+ // If we haven't found any included line in the first
+ // neighbor, then the line is considered as the neighbor of
+ // the current line
+ if (*nbh_p == end_p)
+ left(l) = (*nbh_p_copy >> 1) - 1;
+ }
}
}
- }
}
@@ -810,137 +821,141 @@ namespace scribo
template <typename L>
inline
void
- process_right_link(image2d<value::int_u16>& blocks,
+ process_right_link(L& blocks,
const util::array<box2d>& rbbox,
- const util::array< line_info<L> >& lines,
- util::array<value::int_u16>& right)
+ const line_set<L>& lines,
+ line_links<L>& right)
{
- typedef value::int_u16 V;
+ typedef scribo::def::lbl_type V;
// At the beginning each line is its own neighbor
- for (unsigned i = 0; i < right.nelements(); ++i)
- right(i) = i;
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
+ right(l) = l;
+ else
+ right(l) = 0;
- const unsigned nlines = lines.nelements();
+ // const unsigned nlines = lines.nelements();
// For each line
- for (unsigned i = 0; i < nlines; ++i)
- {
- // Max distance for the line search
- int dmax = 1.5f * lines(i).x_height();
-
- // Starting points in the current line box
- point2d c = rbbox(i).pcenter();
- point2d q(rbbox(i).pmax().row() - ((rbbox(i).pmax().row() - c.row()) / 4), c.col());
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
+ {
+ // Max distance for the line search
+ int dmax = 1.5f * lines(l).x_height();
- int
- midcol = (rbbox(i).pmax().col()
- - rbbox(i).pmin().col()) / 2;
+ // Starting points in the current line box
+ point2d c = rbbox(l).pcenter();
+ point2d q(rbbox(l).pmax().row() - ((rbbox(l).pmax().row() - c.row()) / 4), c.col());
- // Right
- {
int
- nrightima = geom::ncols(blocks) - c.col() + blocks.domain().pmin().col(),
- nright = std::min(nrightima, midcol + dmax);
-
- V
- // Starting points in the box
- *p = &blocks(c),
- *p2 = &blocks(q),
- // End of search
- *pstop = p + nright - 1,
- // Line neighbor
- *nbh_p = 0;
-
- // While we haven't found a neighbor or reached the limit
- for (; p != pstop; ++p, ++p2)
+ midcol = (rbbox(l).pmax().col()
+ - rbbox(l).pmin().col()) / 2;
+
+ // Right
{
- if (*p2 != literal::zero // Not the background
- && ((*p2 % 2) == 1) // Looking for the bottom of a line
- && right(((*p2 - 1) >> 1) - 1) != i) // No loops
+ int
+ nrightima = geom::ncols(blocks) - c.col() + blocks.domain().pmin().col(),
+ nright = std::min(nrightima, midcol + dmax);
+
+ V
+ // Starting points in the box
+ *p = &blocks(c),
+ *p2 = &blocks(q),
+ // End of search
+ *pstop = p + nright - 1,
+ // Line neighbor
+ *nbh_p = 0;
+
+ // While we haven't found a neighbor or reached the limit
+ for (; p != pstop; ++p, ++p2)
{
- // Neightbor found, we stop the research
- nbh_p = p2;
- break;
- }
+ if (*p2 != literal::zero // Not the background
+ && ((*p2 % 2) == 1) // Looking for the bottom of a line
+ && right(((*p2 - 1) >> 1) - 1) != l) // No loops
+ {
+ // Neightbor found, we stop the research
+ nbh_p = p2;
+ break;
+ }
- if (*p != literal::zero // Not the background
- && ((*p % 2) == 1) // Looking for the bottom of a line
- && right(((*p - 1) >> 1) - 1) != i) // No loops
- {
- // Neightbor found, we stop the research
- nbh_p = p;
- break;
+ if (*p != literal::zero // Not the background
+ && ((*p % 2) == 1) // Looking for the bottom of a line
+ && right(((*p - 1) >> 1) - 1) != l) // No loops
+ {
+ // Neightbor found, we stop the research
+ nbh_p = p;
+ break;
+ }
}
- }
-
- // If a neighbor was found, then we have found the bottom of the
- // line. We are then looking for the top of the encountered
- // line. If during the search process we find a complete line
- // included in the touched line, this line is considered as
- // the neighbor under certain conditions (see below)
-
- //---------------------------------------------------------------
- //
- //
- // __________________________________________________ 2Q
- // | Q |
- // | _________________________ |2P
- // | |_____________P___________| => Second bottom |2P + 1
- // | line |
- // |__________________________________________________|2Q + 1
- // => First encountered bottom line
- // _________________________ ^
- // |_________________________| => Current line | Search direction
- // |
- //---------------------------------------------------------------
-
- if (nbh_p)
- {
- std::vector<V> lines_nbh;
- const V end_p = *nbh_p - 1;
- const V* nbh_p_copy = nbh_p;
- for (; *nbh_p != end_p; ++nbh_p)
+ // If a neighbor was found, then we have found the bottom of the
+ // line. We are then looking for the top of the encountered
+ // line. If during the search process we find a complete line
+ // included in the touched line, this line is considered as
+ // the neighbor under certain conditions (see below)
+
+ //---------------------------------------------------------------
+ //
+ //
+ // __________________________________________________ 2Q
+ // | Q |
+ // | _________________________ |2P
+ // | |_____________P___________| => Second bottom |2P + 1
+ // | line |
+ // |__________________________________________________|2Q + 1
+ // => First encountered bottom line
+ // _________________________ ^
+ // |_________________________| => Current line | Search direction
+ // |
+ //---------------------------------------------------------------
+
+ if (nbh_p)
{
- if (*nbh_p != literal::zero) // Not the background
+ std::vector<V> lines_nbh;
+ const V end_p = *nbh_p - 1;
+ const V* nbh_p_copy = nbh_p;
+
+ for (; *nbh_p != end_p; ++nbh_p)
{
- if (*nbh_p % 2 == 1) // We have found the bottom of
- // another line
- lines_nbh.push_back(*nbh_p);
- else
+ if (*nbh_p != literal::zero) // Not the background
{
- // We have found the top of a line. We are looking if
- //we have already encountered the bottom of this
- // line. If so, we link the current line with this one
- // under certain conditions:
-
- if (std::find(lines_nbh.begin(), lines_nbh.end(),
- *nbh_p + 1) != lines_nbh.end())
+ if (*nbh_p % 2 == 1) // We have found the bottom of
+ // another line
+ lines_nbh.push_back(*nbh_p);
+ else
{
- // If we can link the complete line with the current line
- if (// It must be in the search range
- nbh_p < pstop
- // Avoid loops
- && right((*nbh_p >> 1) - 1) != i)
- right(i) = (*nbh_p >> 1) - 1;
-
- // We have found a complete line, so we stop the search
- break;
+ // We have found the top of a line. We are looking if
+ //we have already encountered the bottom of this
+ // line. If so, we link the current line with this one
+ // under certain conditions:
+
+ if (std::find(lines_nbh.begin(), lines_nbh.end(),
+ *nbh_p + 1) != lines_nbh.end())
+ {
+ // If we can link the complete line with the current line
+ if (// It must be in the search range
+ nbh_p < pstop
+ // Avoid loops
+ && right((*nbh_p >> 1) - 1) != l)
+ right(l) = (*nbh_p >> 1) - 1;
+
+ // We have found a complete line, so we stop the search
+ break;
+ }
}
}
}
- }
- // If we haven't found any included line in the first
- // neighbor, then the line is considered as the neighbor of
- // the current line
+ // If we haven't found any included line in the first
+ // neighbor, then the line is considered as the neighbor of
+ // the current line
- if (*nbh_p == end_p)
- right(i) = ((*nbh_p_copy - 1) >> 1) - 1;
+ if (*nbh_p == end_p)
+ right(l) = ((*nbh_p_copy - 1) >> 1) - 1;
+ }
}
}
- }
}
//-----------------------------------------------------------------------
@@ -950,76 +965,83 @@ namespace scribo
template< typename L >
inline
- void finalize_links(util::array<value::int_u16>& left,
- util::array<value::int_u16>& right,
- const util::array< line_info<L> >& lines)
+ void finalize_links(line_links<L>& left,
+ line_links<L>& right,
+ const line_set<L>& lines)
{
- const unsigned nlines = lines.nelements();
-
- for (unsigned i = 0; i < nlines; ++i)
- {
- const unsigned left_value = left(i);
- const unsigned right_value = right(i);
+ // const unsigned nlines = lines.nelements();
- // If the right neighbor of my left neighbor is itself then its
- // right neighbor is me
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
{
- value::int_u16& v = right(left_value);
+ const unsigned left_value = left(l);
+ const unsigned right_value = right(l);
- if (v == left_value)
- v = i;
- }
+ // If the right neighbor of my left neighbor is itself then its
+ // right neighbor is me
+ {
+ line_id_t& v = right(left_value);
- // If the left neighbor of my right neighbor is itself then its
- // left neighbor is me
- {
- value::int_u16& v = left(right_value);
+ if (v == left_value)
+ v = l;
+ }
+
+ // If the left neighbor of my right neighbor is itself then its
+ // left neighbor is me
+ {
+ line_id_t& v = left(right_value);
- if (v == right_value)
- v = i;
+ if (v == right_value)
+ v = l;
+ }
}
- }
}
template <typename L>
inline
- void extract_paragraphs(line_set<L>& lines,
- const image2d<bool>& input)
+ paragraph_set<L>
+ extract_paragraphs(line_set<L>& lines,
+ const image2d<bool>& input)
{
- typedef value::int_u16 V;
+ typedef scribo::def::lbl_type V;
image2d<V> blocks(geom::rotate(input.domain(), -90, input.domain().pcenter()));
data::fill(blocks, 0);
- util::array< line_info<L> > lines_info;
+ // util::array< line_info<L> > lines_info;
- for_all_lines(l, lines)
- {
- if (lines(l).is_textline())
- lines_info.append(lines(l));
- }
+ // for_all_lines(l, lines)
+ // {
+ // if (lines(l).is_textline())
+ // lines_info.append(lines(l));
+ // }
- const unsigned nlines = lines_info.nelements();
+/// const unsigned nlines = lines_info.nelemnts();
util::array<box2d> rbbox;
- util::array<V> left(nlines);
- util::array<V> right(nlines);
- util::array<V> output;
+ line_links<L> left(lines);
+ left(0) = 0;
+ line_links<L> right(lines);
+ right(0) = 0;
+ line_links<L> output(lines);
+ output(0) = 0;
- rbbox.reserve(nlines);
- output.reserve(nlines);
+ rbbox.resize(lines.nelements() + 1);
std::cout << "Preparing lines" << std::endl;
- prepare_lines(input.domain(), lines_info, blocks, rbbox);
+ prepare_lines(input.domain(), lines , blocks, rbbox);
// io::pgm::save(blocks, "blocks.pgm");
std::cout << "Linking left" << std::endl;
- process_left_link(blocks, rbbox, lines_info, left);
+ process_left_link(blocks, rbbox, lines , left);
std::cout << "Linking right" << std::endl;
- process_right_link(blocks, rbbox, lines_info, right);
+ process_right_link(blocks, rbbox, lines , right);
std::cout << "Finalizing links" << std::endl;
- finalize_links(left, right, lines_info);
+ finalize_links(left, right, lines );
// std::cout << "Finalizing merging" << std::endl;
// finalize_line_merging(left, right, lines);
std::cout << "Extracting paragraphs" << std::endl;
- filter::paragraph_links(left, right, output, lines_info, input);
+ filter::paragraph_links(left, right, output, lines, input);
+
+ paragraph_set<L> par_set = make::paragraph(output);
+ return par_set;
}
}
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
index 25b328b..d60f3cc 100644
--- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -60,6 +60,7 @@
# include <scribo/text/recognition.hh>
# include <scribo/text/merging.hh>
# include <scribo/text/link_lines.hh>
+# include <scribo/text/paragraphs.hh>
# include <scribo/make/debug_filename.hh>
@@ -444,93 +445,96 @@ namespace scribo
on_progress();
}
- // Link text lines
- on_new_progress_label("Linking text lines");
- line_links<L> llinks = scribo::text::link_lines(lines);
-
-
- //===== DEBUG =====
-# ifndef SCRIBO_NDEBUG
- if (debug::logger().is_enabled())
- {
- image2d<value::rgb8>
- debug = data::convert(value::rgb8(), original_image);
- for_all_lines(l, lines)
- {
- if (! lines(l).is_textline())
- continue;
-
- mln::draw::box(debug, lines(l).bbox(), literal::blue);
- mln::draw::line(debug, lines(l).bbox().pcenter(),
- lines(llinks(l)).bbox().pcenter(), literal::green);
- }
-
- debug::logger().log_image(debug::AuxiliaryResults,
- debug, "links_raw");
- }
-# endif // ! SCRIBO_NDEBUG
- //===== END OF DEBUG =====
-
- on_progress();
-
-
- // Filter line links.
- on_new_progress_label("Filter line links");
- llinks = scribo::filter::line_links_x_height(llinks);
-
- //===== DEBUG =====
-# ifndef SCRIBO_NDEBUG
- if (debug::logger().is_enabled())
- {
- image2d<value::rgb8>
- debug = data::convert(value::rgb8(), original_image);
- for_all_links(i, llinks)
- if (llinks(i) && llinks(i) != i)
- mln::draw::line(debug, lines(i).bbox().pcenter(),
- lines(llinks(i)).bbox().pcenter(), literal::red);
-
- debug::logger().log_image(debug::AuxiliaryResults,
- debug, "links");
-
- for (unsigned i = 1; i < llinks.nelements(); ++i)
- llinks(i) = scribo::make::internal::find_root(llinks, i);
-
- debug = data::convert(value::rgb8(), original_image);
- mln::util::array<accu::shape::bbox<point2d> >
- nbbox(llinks.nelements());
-
- for_all_lines(i, lines)
- {
- if (! lines(i).is_textline())
- continue;
-
- mln::draw::box(debug, lines(i).bbox(), literal::red);
- nbbox(llinks(i)).take(lines(i).bbox());
- }
-
- for (unsigned i = 1; i < nbbox.nelements(); ++i)
- if (nbbox(i).is_valid())
- {
- box2d b = nbbox(i).to_result();
- mln::draw::box(debug, b, literal::green);
- b.enlarge(1);
- mln::draw::box(debug, b, literal::green);
- b.enlarge(1);
- mln::draw::box(debug, b, literal::green);
- }
-
- debug::logger().log_image(debug::AuxiliaryResults,
- debug, "par");
- }
-# endif // ! SCRIBO_NDEBUG
- //===== END OF DEBUG =====
-
- on_progress();
-
-
- // Construct paragraphs
- on_new_progress_label("Constructing paragraphs");
- scribo::paragraph_set<L> parset = scribo::make::paragraph(llinks);
+// // Link text lines
+// on_new_progress_label("Linking text lines");
+// line_links<L> llinks = scribo::text::link_lines(lines);
+
+
+// //===== DEBUG =====
+// # ifndef SCRIBO_NDEBUG
+// if (debug::logger().is_enabled())
+// {
+// image2d<value::rgb8>
+// debug = data::convert(value::rgb8(), original_image);
+// for_all_lines(l, lines)
+// {
+// if (! lines(l).is_textline())
+// continue;
+
+// mln::draw::box(debug, lines(l).bbox(), literal::blue);
+// mln::draw::line(debug, lines(l).bbox().pcenter(),
+// lines(llinks(l)).bbox().pcenter(), literal::green);
+// }
+
+// debug::logger().log_image(debug::AuxiliaryResults,
+// debug, "links_raw");
+// }
+// # endif // ! SCRIBO_NDEBUG
+// //===== END OF DEBUG =====
+
+// on_progress();
+
+
+// // Filter line links.
+// on_new_progress_label("Filter line links");
+// llinks = scribo::filter::line_links_x_height(llinks);
+
+// //===== DEBUG =====
+// # ifndef SCRIBO_NDEBUG
+// if (debug::logger().is_enabled())
+// {
+// image2d<value::rgb8>
+// debug = data::convert(value::rgb8(), original_image);
+// for_all_links(i, llinks)
+// if (llinks(i) && llinks(i) != i)
+// mln::draw::line(debug, lines(i).bbox().pcenter(),
+// lines(llinks(i)).bbox().pcenter(), literal::red);
+
+// debug::logger().log_image(debug::AuxiliaryResults,
+// debug, "links");
+
+// for (unsigned i = 1; i < llinks.nelements(); ++i)
+// llinks(i) = scribo::make::internal::find_root(llinks, i);
+
+// debug = data::convert(value::rgb8(), original_image);
+// mln::util::array<accu::shape::bbox<point2d> >
+// nbbox(llinks.nelements());
+
+// for_all_lines(i, lines)
+// {
+// if (! lines(i).is_textline())
+// continue;
+
+// mln::draw::box(debug, lines(i).bbox(), literal::red);
+// nbbox(llinks(i)).take(lines(i).bbox());
+// }
+
+// for (unsigned i = 1; i < nbbox.nelements(); ++i)
+// if (nbbox(i).is_valid())
+// {
+// box2d b = nbbox(i).to_result();
+// mln::draw::box(debug, b, literal::green);
+// b.enlarge(1);
+// mln::draw::box(debug, b, literal::green);
+// b.enlarge(1);
+// mln::draw::box(debug, b, literal::green);
+// }
+
+// debug::logger().log_image(debug::AuxiliaryResults,
+// debug, "par");
+// }
+// # endif // ! SCRIBO_NDEBUG
+// //===== END OF DEBUG =====
+
+// on_progress();
+
+
+// // Construct paragraphs
+// on_new_progress_label("Constructing paragraphs");
+// scribo::paragraph_set<L> parset = scribo::make::paragraph(llinks);
+
+ scribo::paragraph_set<L>
+ parset = extract_paragraphs(lines, doc.binary_image());
doc.set_paragraphs(parset);
on_progress();
--
1.5.6.5
1
0
---
scribo/scribo/core/stats.hh | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/scribo/scribo/core/stats.hh b/scribo/scribo/core/stats.hh
index bc24044..88ecd68 100644
--- a/scribo/scribo/core/stats.hh
+++ b/scribo/scribo/core/stats.hh
@@ -261,7 +261,7 @@ private:
unsigned i = 0;
const unsigned nelements = data_.nelements();
- clusters[0] = cluster_index;
+ clusters.push_back(cluster_index);
const T std = data_.standard_deviation();
for (i = 1; i < nelements - 1; ++i)
@@ -276,11 +276,13 @@ private:
clusters.push_back(cluster_index);
}
- if (nelements > 1
- && data_[i] - data_[i - 1] > std)
- ++cluster_index;
+ if (nelements > 1)
+ {
+ if (data_[i] - data_[i - 1] > std)
+ ++cluster_index;
- clusters.push_back(cluster_index);
+ clusters.push_back(cluster_index);
+ }
clusters_.clear();
clusters_.reserve(cluster_index);
--
1.5.6.5
1
0
03 May '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 julien_temp_paragraphs has been updated
via 6de9f46259689a7e2e125e79da07c3bd7335d8be (commit)
from 8bae0713f5a4e26137e59a5cc6a3f2e947592f7d (commit)
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 -----------------------------------------------------------------
6de9f46 Correction on line spacing
-----------------------------------------------------------------------
Summary of changes:
scribo/scribo/core/line_info.hh | 24 ++++++++++++------------
scribo/scribo/core/stats.hh | 4 ++--
scribo/scribo/text/merging.hh | 3 ++-
scribo/scribo/text/paragraphs.hh | 20 +++++++++-----------
4 files changed, 25 insertions(+), 26 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
---
scribo/scribo/core/line_info.hh | 31 ++++++++++++++++---------------
scribo/scribo/core/stats.hh | 4 ++--
scribo/scribo/text/merging.hh | 3 ++-
scribo/scribo/text/paragraphs.hh | 20 +++++++++-----------
4 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/scribo/scribo/core/line_info.hh b/scribo/scribo/core/line_info.hh
index c683be4..949315a 100644
--- a/scribo/scribo/core/line_info.hh
+++ b/scribo/scribo/core/line_info.hh
@@ -1188,22 +1188,23 @@ namespace scribo
// incremented.
++used_comps;
+
// COMPUTE FEATURES DATA
- // if (comp_set(c).has_features())
- // {
- // // Compute boldness
- // boldness.take(comp_set(c).features().boldness);
- // sum2_boldness += mln::math::sqr<float>(comp_set(c).features().boldness);
-
- // // Compute color
- // color_red.take(comp_set(c).features().color.red());
- // color_green.take(comp_set(c).features().color.green());
- // color_blue.take(comp_set(c).features().color.blue());
-
- // sum2_red += mln::math::sqr<unsigned>(comp_set(c).features().color.red());
- // sum2_green += mln::math::sqr<unsigned>(comp_set(c).features().color.green());
- // sum2_blue += mln::math::sqr<unsigned>(comp_set(c).features().color.blue());
- // }
+ if (comp_set(c).has_features())
+ {
+ // Compute boldness
+ boldness.take(comp_set(c).features().boldness);
+ sum2_boldness += mln::math::sqr<float>(comp_set(c).features().boldness);
+
+ // Compute color
+ color_red.take(comp_set(c).features().color.red());
+ color_green.take(comp_set(c).features().color.green());
+ color_blue.take(comp_set(c).features().color.blue());
+
+ sum2_red += mln::math::sqr<unsigned>(comp_set(c).features().color.red());
+ sum2_green += mln::math::sqr<unsigned>(comp_set(c).features().color.green());
+ sum2_blue += mln::math::sqr<unsigned>(comp_set(c).features().color.blue());
+ }
// FIXME: we must guaranty here that the relationship is from
// right to left, otherwise, the space size computed between
diff --git a/scribo/scribo/core/stats.hh b/scribo/scribo/core/stats.hh
index 570325c..bc24044 100644
--- a/scribo/scribo/core/stats.hh
+++ b/scribo/scribo/core/stats.hh
@@ -273,14 +273,14 @@ private:
&& left_distance <= std))
++cluster_index;
- clusters[i] = cluster_index;
+ clusters.push_back(cluster_index);
}
if (nelements > 1
&& data_[i] - data_[i - 1] > std)
++cluster_index;
- clusters[i] = cluster_index;
+ clusters.push_back(cluster_index);
clusters_.clear();
clusters_.reserve(cluster_index);
diff --git a/scribo/scribo/text/merging.hh b/scribo/scribo/text/merging.hh
index 8ee349b..453c6c3 100644
--- a/scribo/scribo/text/merging.hh
+++ b/scribo/scribo/text/merging.hh
@@ -460,7 +460,8 @@ namespace scribo
if (l_cur_height < l_ted_x_height
&& l_cur_height > 0.05f * l_ted_x_height
&& float(l_cur_width) / float(l_cur.card()) < l_ted.char_width()
- && dx < l_ted_cw)
+ && dx < l_ted_cw
+ && l_cur_pmin.row() < l_ted_pmax.row())
{
l_cur.update_type(line::Punctuation);
return true;
diff --git a/scribo/scribo/text/paragraphs.hh b/scribo/scribo/text/paragraphs.hh
index a3ff802..5cb253e 100644
--- a/scribo/scribo/text/paragraphs.hh
+++ b/scribo/scribo/text/paragraphs.hh
@@ -132,18 +132,16 @@ namespace scribo
{
// ror : right neighbor of the right neighbor
const value::int_u16 ror_nbh = right(right_nbh);
- const box2d& ror_line_bbox = lines(ror_nbh).bbox();
+ // const box2d& ror_line_bbox = lines(ror_nbh).bbox();
// If the current line has a ror
if (ror_nbh != right_nbh
&& output(ror_nbh) == right_nbh)
{
// Distance between the current line and the right neighbor
- const float right_distance =
- current_line_bbox.pcenter().row() - right_line_bbox.pcenter().row();
+ const float right_distance = lines(l).meanline() - lines(right_nbh).baseline();
// Distance between the right neighbor and the ror
- const float ror_distance =
- right_line_bbox.pcenter().row() - ror_line_bbox.pcenter().row();
+ const float ror_distance = lines(right_nbh).meanline() - lines(ror_nbh).baseline();
// ror x_height
const float ror_x_height = lines(ror_nbh).x_height();
@@ -168,7 +166,7 @@ namespace scribo
// If the distance between the two lines is greater than
// the minimum x height of the two lines then we cut the
// link between them
- if (distance > std::min(x_height, right_x_height)
+ if (distance > 2.0f * std::min(x_height, right_x_height)
&& output(right_nbh) == l)
{
output(right_nbh) = right_nbh;
@@ -207,12 +205,12 @@ namespace scribo
if (lol_nbh != left_nbh)
{
// Distance between the current line and its left neighbor
- const float left_distance =
- left_line_bbox.pcenter().row() - current_line_bbox.pcenter().row();
+ const float left_distance = lines(left_nbh).meanline() -
+ lines(l).baseline();
// Distance between the left neighbor and the left
// neighbor of its left neighbor
- const float lol_distance =
- lol_line_bbox.pcenter().row() - left_line_bbox.pcenter().row();
+ const float lol_distance = lines(lol_nbh).meanline() -
+ lines(left_nbh).baseline();
// lol x height
const float lol_x_height = lines(lol_nbh).x_height();
@@ -237,7 +235,7 @@ namespace scribo
// If the distance is greater than the min x height
// between the two lines
- if (distance > std::min(x_height, left_x_height))
+ if (distance > 2.0f * std::min(x_height, left_x_height))
{
output(l) = l;
continue;
--
1.5.6.5
1
0
---
scribo/scribo/core/line_info.hh | 24 ++++++++++++------------
scribo/scribo/core/stats.hh | 4 ++--
scribo/scribo/text/merging.hh | 3 ++-
scribo/scribo/text/paragraphs.hh | 20 +++++++++-----------
4 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/scribo/scribo/core/line_info.hh b/scribo/scribo/core/line_info.hh
index b44b379..a798e9b 100644
--- a/scribo/scribo/core/line_info.hh
+++ b/scribo/scribo/core/line_info.hh
@@ -1193,18 +1193,18 @@ namespace scribo
// incremented.
++used_comps;
- // // Compute boldness
- // boldness.take(comp_set(c).features().boldness);
- // sum2_boldness += mln::math::sqr<float>(comp_set(c).features().boldness);
-
- // // Compute color
- // color_red.take(comp_set(c).features().color.red());
- // color_green.take(comp_set(c).features().color.green());
- // color_blue.take(comp_set(c).features().color.blue());
-
- // sum2_red += mln::math::sqr<unsigned>(comp_set(c).features().color.red());
- // sum2_green += mln::math::sqr<unsigned>(comp_set(c).features().color.green());
- // sum2_blue += mln::math::sqr<unsigned>(comp_set(c).features().color.blue());
+ // Compute boldness
+ boldness.take(comp_set(c).features().boldness);
+ sum2_boldness += mln::math::sqr<float>(comp_set(c).features().boldness);
+
+ // Compute color
+ color_red.take(comp_set(c).features().color.red());
+ color_green.take(comp_set(c).features().color.green());
+ color_blue.take(comp_set(c).features().color.blue());
+
+ sum2_red += mln::math::sqr<unsigned>(comp_set(c).features().color.red());
+ sum2_green += mln::math::sqr<unsigned>(comp_set(c).features().color.green());
+ sum2_blue += mln::math::sqr<unsigned>(comp_set(c).features().color.blue());
// FIXME: we must guaranty here that the relationship is from
diff --git a/scribo/scribo/core/stats.hh b/scribo/scribo/core/stats.hh
index 570325c..bc24044 100644
--- a/scribo/scribo/core/stats.hh
+++ b/scribo/scribo/core/stats.hh
@@ -273,14 +273,14 @@ private:
&& left_distance <= std))
++cluster_index;
- clusters[i] = cluster_index;
+ clusters.push_back(cluster_index);
}
if (nelements > 1
&& data_[i] - data_[i - 1] > std)
++cluster_index;
- clusters[i] = cluster_index;
+ clusters.push_back(cluster_index);
clusters_.clear();
clusters_.reserve(cluster_index);
diff --git a/scribo/scribo/text/merging.hh b/scribo/scribo/text/merging.hh
index 8ee349b..453c6c3 100644
--- a/scribo/scribo/text/merging.hh
+++ b/scribo/scribo/text/merging.hh
@@ -460,7 +460,8 @@ namespace scribo
if (l_cur_height < l_ted_x_height
&& l_cur_height > 0.05f * l_ted_x_height
&& float(l_cur_width) / float(l_cur.card()) < l_ted.char_width()
- && dx < l_ted_cw)
+ && dx < l_ted_cw
+ && l_cur_pmin.row() < l_ted_pmax.row())
{
l_cur.update_type(line::Punctuation);
return true;
diff --git a/scribo/scribo/text/paragraphs.hh b/scribo/scribo/text/paragraphs.hh
index a3ff802..5cb253e 100644
--- a/scribo/scribo/text/paragraphs.hh
+++ b/scribo/scribo/text/paragraphs.hh
@@ -132,18 +132,16 @@ namespace scribo
{
// ror : right neighbor of the right neighbor
const value::int_u16 ror_nbh = right(right_nbh);
- const box2d& ror_line_bbox = lines(ror_nbh).bbox();
+ // const box2d& ror_line_bbox = lines(ror_nbh).bbox();
// If the current line has a ror
if (ror_nbh != right_nbh
&& output(ror_nbh) == right_nbh)
{
// Distance between the current line and the right neighbor
- const float right_distance =
- current_line_bbox.pcenter().row() - right_line_bbox.pcenter().row();
+ const float right_distance = lines(l).meanline() - lines(right_nbh).baseline();
// Distance between the right neighbor and the ror
- const float ror_distance =
- right_line_bbox.pcenter().row() - ror_line_bbox.pcenter().row();
+ const float ror_distance = lines(right_nbh).meanline() - lines(ror_nbh).baseline();
// ror x_height
const float ror_x_height = lines(ror_nbh).x_height();
@@ -168,7 +166,7 @@ namespace scribo
// If the distance between the two lines is greater than
// the minimum x height of the two lines then we cut the
// link between them
- if (distance > std::min(x_height, right_x_height)
+ if (distance > 2.0f * std::min(x_height, right_x_height)
&& output(right_nbh) == l)
{
output(right_nbh) = right_nbh;
@@ -207,12 +205,12 @@ namespace scribo
if (lol_nbh != left_nbh)
{
// Distance between the current line and its left neighbor
- const float left_distance =
- left_line_bbox.pcenter().row() - current_line_bbox.pcenter().row();
+ const float left_distance = lines(left_nbh).meanline() -
+ lines(l).baseline();
// Distance between the left neighbor and the left
// neighbor of its left neighbor
- const float lol_distance =
- lol_line_bbox.pcenter().row() - left_line_bbox.pcenter().row();
+ const float lol_distance = lines(lol_nbh).meanline() -
+ lines(left_nbh).baseline();
// lol x height
const float lol_x_height = lines(lol_nbh).x_height();
@@ -237,7 +235,7 @@ namespace scribo
// If the distance is greater than the min x height
// between the two lines
- if (distance > std::min(x_height, left_x_height))
+ if (distance > 2.0f * std::min(x_height, left_x_height))
{
output(l) = l;
continue;
--
1.5.6.5
1
0
03 May '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
via 397d9adad2d9d3854bb9f6b43fd3b0530af973e3 (commit)
via 25b4393efeaebd453f6c6f55616763076f145472 (commit)
via ff536c853e0777eec9610e8031c26ccfbf5dd791 (commit)
via 6404315b5301e09986e725b6cf33c5a15b62b887 (commit)
via 2fbfae871ca040fa80ac1470913c478fd59e6ad0 (commit)
via 41e20558341e32084c0c45a3590bcb75e91b6c6f (commit)
via 3f50eb758a0ec55dc4a498d10142906db32e4fe9 (commit)
via 7e736d6b5cd3431452a7814d9fb8d1d60f05584e (commit)
via 3ac6dd8d266f0303fd64775d59d37bd6fbf0cdc7 (commit)
via 1bcc1751c88f6a6e1e9850a5cbc0ef0650beff9c (commit)
via 78b802085aa8549923238090b701aa1654425ba9 (commit)
via d82fdf6b2d0142333ee5b365f6fba6cc47923f2e (commit)
via 52a1107eac0fb8d75c28dc12cb5ed9ee798d2ad0 (commit)
via 5b660b4e73e89805ebf3452c7257990922ce3a06 (commit)
via 52f8110a5258a88e6fb0d88ca4e97e24054a0270 (commit)
from f5a185dfd59d5ed9f804d92262899f0cada75631 (commit)
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 -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
scribo/ChangeLog | 190 +++++++++
scribo/scribo/core/component_features_data.hh | 24 +
scribo/scribo/core/component_info.hh | 17 +
scribo/scribo/core/component_set.hh | 36 +-
scribo/scribo/core/document.hh | 68 +++-
scribo/scribo/core/group_info.hh | 184 ++++++++
scribo/scribo/core/internal/sort_comp_ids.hh | 77 ++++
scribo/scribo/core/line_info.hh | 168 +++++---
scribo/scribo/core/line_links.hh | 12 +
scribo/scribo/core/line_set.hh | 66 ++--
scribo/scribo/core/object_groups.hh | 228 ++++++++---
scribo/scribo/core/object_links.hh | 81 +++-
scribo/scribo/core/paragraph_info.hh | 46 ++
scribo/scribo/core/paragraph_set.hh | 21 +
scribo/scribo/debug/bboxes_image.hh | 18 +-
scribo/scribo/debug/decision_image.hh | 8 +-
scribo/scribo/draw/bounding_box_links.hh | 16 +-
scribo/scribo/estim/object_groups_mean_width.hh | 99 +++++
scribo/scribo/estim/object_groups_v_thickness.hh | 106 -----
scribo/scribo/filter/object_groups_mean_width.hh | 99 +++++
scribo/scribo/filter/object_groups_size_ratio.hh | 24 +-
scribo/scribo/filter/object_groups_small.hh | 36 +--
scribo/scribo/filter/object_groups_v_thickness.hh | 99 -----
scribo/scribo/filter/object_groups_with_holes.hh | 2 +-
scribo/scribo/filter/object_links_bbox_overlap.hh | 6 +-
scribo/scribo/filter/object_links_bbox_ratio.hh | 10 +-
scribo/scribo/filter/object_links_left_aligned.hh | 19 +-
.../filter/object_links_non_aligned_simple.hh | 6 +-
scribo/scribo/filter/object_links_right_aligned.hh | 19 +-
scribo/scribo/io/xml/internal/full_xml_visitor.hh | 118 ++++--
scribo/scribo/io/xml/internal/save_image_to_xml.hh | 106 +++++
scribo/scribo/io/xml/load.hh | 164 +++++++-
scribo/scribo/make/text_components_image.hh | 8 +-
scribo/scribo/preprocessing/rotate_90.hh | 8 +-
scribo/scribo/primitive/extract/alignments.hh | 445 ++++++++++----------
.../primitive/extract/separators_nonvisible.hh | 229 +++--------
.../scribo/primitive/group/from_double_link_any.hh | 57 ++-
scribo/scribo/primitive/group/from_single_link.hh | 13 -
scribo/scribo/primitive/internal/is_link_valid.hh | 12 +-
.../primitive/link/internal/link_functor_base.hh | 2 +-
.../link/internal/link_several_dmax_base.hh | 10 +-
scribo/scribo/primitive/link/merge_double_link.hh | 17 +-
.../link/merge_double_link_closest_aligned.hh | 6 +-
.../toolchain/internal/content_in_doc_functor.hh | 54 ++--
scribo/scribo/toolchain/text_in_picture.hh | 10 +-
scribo/src/debug/show_paragraph_blocks.cc | 2 +
scribo/src/preprocessing/split_bg_fg.cc | 6 +-
scribo/tests/Makefile.am | 5 +
scribo/tests/binarization/Makefile.am | 13 +-
scribo/tests/binarization/sauvola.cc | 52 +++
scribo/tests/binarization/sauvola.ref.pbm | Bin 0 -> 32884 bytes
scribo/tests/binarization/sauvola_ms.cc | 53 +++
scribo/tests/binarization/sauvola_ms.ref.pbm | Bin 0 -> 32884 bytes
scribo/tests/core/Makefile.am | 8 +-
scribo/tests/core/object_groups.cc | 103 +++++
scribo/tests/data.hh.in | 3 +
scribo/tests/filter/Makefile.am | 28 ++-
scribo/tests/filter/object_groups_mean_width.cc | 73 ++++
scribo/tests/filter/object_groups_size_ratio.cc | 73 ++++
scribo/tests/filter/object_groups_small.cc | 79 ++++
scribo/tests/filter/object_groups_with_holes.cc | 73 ++++
scribo/tests/filter/object_links_bbox_h_ratio.cc | 69 +++
scribo/tests/filter/object_links_bbox_overlap.cc | 69 +++
scribo/tests/filter/object_links_bbox_w_ratio.cc | 69 +++
scribo/tests/filter/object_links_bottom_aligned.cc | 69 +++
scribo/tests/filter/object_links_center_aligned.cc | 70 +++
scribo/tests/filter/object_links_left_aligned.cc | 69 +++
scribo/tests/filter/object_links_right_aligned.cc | 69 +++
scribo/tests/filter/object_links_top_aligned.cc | 69 +++
scribo/tests/img/alignment_1.pbm | Bin 0 -> 12167 bytes
scribo/tests/img/alignment_1.png | Bin 3145 -> 0 bytes
scribo/tests/img/alignment_2.pbm | Bin 0 -> 12167 bytes
scribo/tests/img/alignment_2.png | Bin 3147 -> 0 bytes
scribo/tests/img/alignment_3.pbm | Bin 0 -> 12167 bytes
scribo/tests/img/alignment_3.png | Bin 3145 -> 0 bytes
scribo/tests/img/alignment_4.pbm | Bin 0 -> 12167 bytes
scribo/tests/img/alignment_4.png | Bin 3155 -> 0 bytes
scribo/tests/img/the_valleys.pbm | Bin 0 -> 1724 bytes
scribo/tests/primitive/extract/Makefile.am | 6 +
scribo/tests/primitive/extract/alignments.cc | 3 +-
scribo/tests/unit_test/cond_tests_qt | 1 +
scribo/tests/unit_test/unit-tests.mk | 16 +-
82 files changed, 3151 insertions(+), 1043 deletions(-)
create mode 100644 scribo/scribo/core/group_info.hh
create mode 100644 scribo/scribo/core/internal/sort_comp_ids.hh
create mode 100644 scribo/scribo/estim/object_groups_mean_width.hh
delete mode 100644 scribo/scribo/estim/object_groups_v_thickness.hh
create mode 100644 scribo/scribo/filter/object_groups_mean_width.hh
delete mode 100644 scribo/scribo/filter/object_groups_v_thickness.hh
create mode 100644 scribo/scribo/io/xml/internal/save_image_to_xml.hh
create mode 100644 scribo/tests/binarization/sauvola.cc
create mode 100644 scribo/tests/binarization/sauvola.ref.pbm
create mode 100644 scribo/tests/binarization/sauvola_ms.cc
create mode 100644 scribo/tests/binarization/sauvola_ms.ref.pbm
create mode 100644 scribo/tests/core/object_groups.cc
create mode 100644 scribo/tests/filter/object_groups_mean_width.cc
create mode 100644 scribo/tests/filter/object_groups_size_ratio.cc
create mode 100644 scribo/tests/filter/object_groups_small.cc
create mode 100644 scribo/tests/filter/object_groups_with_holes.cc
create mode 100644 scribo/tests/filter/object_links_bbox_h_ratio.cc
create mode 100644 scribo/tests/filter/object_links_bbox_overlap.cc
create mode 100644 scribo/tests/filter/object_links_bbox_w_ratio.cc
create mode 100644 scribo/tests/filter/object_links_bottom_aligned.cc
create mode 100644 scribo/tests/filter/object_links_center_aligned.cc
create mode 100644 scribo/tests/filter/object_links_left_aligned.cc
create mode 100644 scribo/tests/filter/object_links_right_aligned.cc
create mode 100644 scribo/tests/filter/object_links_top_aligned.cc
create mode 100644 scribo/tests/img/alignment_1.pbm
delete mode 100644 scribo/tests/img/alignment_1.png
create mode 100644 scribo/tests/img/alignment_2.pbm
delete mode 100644 scribo/tests/img/alignment_2.png
create mode 100644 scribo/tests/img/alignment_3.pbm
delete mode 100644 scribo/tests/img/alignment_3.png
create mode 100644 scribo/tests/img/alignment_4.pbm
delete mode 100644 scribo/tests/img/alignment_4.png
create mode 100644 scribo/tests/img/the_valleys.pbm
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0