Olena-patches
Threads by month
- ----- 2025 -----
- 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
- 9625 discussions
* scribo/convert/from_base64.hh,
* scribo/io/xml/save.hh: Here.
---
scribo/ChangeLog | 7 +++++++
scribo/scribo/convert/from_base64.hh | 12 ++++++++++++
scribo/scribo/io/xml/save.hh | 13 ++++++++++++-
3 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 935e5d1..714874c 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,12 @@
2011-03-11 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add HAVE_QT guards.
+
+ * scribo/convert/from_base64.hh,
+ * scribo/io/xml/save.hh: Here.
+
+2011-03-11 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Small fixes in viewer.
* demo/viewer/main.cc: Add more includes.
diff --git a/scribo/scribo/convert/from_base64.hh b/scribo/scribo/convert/from_base64.hh
index 5eeeb53..753883d 100644
--- a/scribo/scribo/convert/from_base64.hh
+++ b/scribo/scribo/convert/from_base64.hh
@@ -63,6 +63,10 @@
#include <cstdio>
#include <cstdlib>
+# ifdef HAVE_QT
+# include <QString>
+# endif // ! HAVE_QT
+
# include <mln/border/resize.hh>
# include <mln/core/image/image2d.hh>
# include <mln/util/array.hh>
@@ -82,9 +86,13 @@ namespace scribo
Image<I>& output);
+# ifdef HAVE_QT
+
template <typename I>
void from_base64(const QString& data64, Image<I>& output_);
+# endif // ! HAVE_QT
+
# ifndef MLN_INCLUDE_ONLY
@@ -187,6 +195,8 @@ namespace scribo
}
+# ifdef HAVE_QT
+
template <typename I>
void
from_base64(const QString& data64, Image<I>& output_)
@@ -199,6 +209,8 @@ namespace scribo
trace::exiting("scribo::convert::to_base64");
}
+# endif // ! HAVE_QT
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh
index 7428e5d..54afa79 100644
--- a/scribo/scribo/io/xml/save.hh
+++ b/scribo/scribo/io/xml/save.hh
@@ -39,7 +39,10 @@
# include <scribo/core/document.hh>
-# include <scribo/io/xml/internal/full_xml_visitor.hh>
+# ifdef HAVE_QT
+# include <scribo/io/xml/internal/full_xml_visitor.hh>
+# endif // ! HAVE_QT
+
# include <scribo/io/xml/internal/extended_page_xml_visitor.hh>
# include <scribo/io/xml/internal/page_xml_visitor.hh>
@@ -66,7 +69,11 @@ namespace scribo
{
Page,
PageExtended,
+
+# ifdef HAVE_QT
Full
+# endif // ! HAVE_QT
+
//Hocr
};
@@ -100,12 +107,14 @@ namespace scribo
doc.accept(f);
}
+# ifdef HAVE_QT
template <typename L>
void save_full(const document<L>& doc, std::ofstream& output)
{
scribo::io::xml::internal::full_xml_visitor f(output);
doc.accept(f);
}
+# endif // ! HAVE_QT
} // end of namespace scribo::io::xml::internal
@@ -143,9 +152,11 @@ namespace scribo
internal::save_page_extended(doc, output);
break;
+# ifdef HAVE_QT
case Full:
internal::save_full(doc, output);
break;
+# endif // ! HAVE_QT
default:
trace::warning("scribo::io::xml::save - Invalid XML format! Skip saving...");
--
1.5.6.5
1
0

28 Mar '11
---
scribo/ChangeLog | 4 +
scribo/scribo/io/xml/load.hh | 525 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 529 insertions(+), 0 deletions(-)
create mode 100644 scribo/scribo/io/xml/load.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 6571137..cf51ca8 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * scribo/io/xml/load.hh: New XML loader.
+
+2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Make XML output more flexible.
* scribo/core/component_info.hh,
diff --git a/scribo/scribo/io/xml/load.hh b/scribo/scribo/io/xml/load.hh
new file mode 100644
index 0000000..e0f4548
--- /dev/null
+++ b/scribo/scribo/io/xml/load.hh
@@ -0,0 +1,525 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef SCRIBO_IO_XML_LOAD_HH
+# define SCRIBO_IO_XML_LOAD_HH
+
+/// \file
+///
+/// \brief Load document information from XML.
+
+# include <QtXml>
+
+# include <libgen.h>
+# include <fstream>
+# include <sstream>
+
+# include <map>
+
+# include <mln/core/image/image2d.hh>
+
+# include <mln/data/wrap.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/io/pgm/save.hh>
+# include <mln/io/pbm/save.hh>
+
+# include <scribo/core/document.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/core/line_set.hh>
+# include <scribo/core/line_info.hh>
+
+# include <scribo/convert/from_base64.hh>
+
+namespace scribo
+{
+
+ namespace io
+ {
+
+ namespace xml
+ {
+ using namespace mln;
+
+ /*! \brief Load document information from XML.
+
+ We use a XML Schema part of the PAGE (Page Analysis and Ground
+ truth Elements) image representation framework.
+
+ This schema was used in the Page Segmentation COMPetition
+ (PSCOMP) for ICDAR 2009.
+
+ Its XSD file is located here:
+ http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent…
+
+ */
+ template <typename L>
+ void
+ load(document<L>& doc, const std::string& input_name);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+
+ enum Mode
+ {
+ None,
+ ComponentSet,
+ ComponentInfo,
+ LabeledImage,
+ SeparatorsImage,
+ ObjectLinks,
+ ObjectGroups,
+ Point,
+ Link,
+ Group,
+ Line,
+ LineLinks,
+ LineLink,
+ TextData,
+ TextRegion,
+ CompIdList,
+ CompId,
+ Page
+ };
+
+
+ struct ModeData
+ {
+ const char *name;
+ Mode mode;
+ };
+
+
+ static const ModeData mode_data[] = {
+ { "component_set", ComponentSet },
+ { "component_info", ComponentInfo },
+ { "labeled_image", LabeledImage },
+ { "separators_image", SeparatorsImage },
+ { "object_links", ObjectLinks },
+ { "object_groups", ObjectGroups },
+ { "point", Point },
+ { "link", Link },
+ { "group", Group },
+ { "line", Line },
+ { "line_links", LineLinks },
+ { "line_link", LineLink },
+ { "text_data", TextData },
+ { "text_region", TextRegion },
+ { "compid_list", CompIdList },
+ { "compid", CompId },
+ { "page", Page },
+ { 0, None }
+ };
+
+
+ template <typename L>
+ class xml_handler : public QXmlDefaultHandler
+ {
+
+ typedef mln_ch_value(L,bool) B;
+
+ public:
+ xml_handler() : current_paragraph_id(1) { lines_data.append(line_info<L>()); } // line info id starts from 1.
+
+ virtual
+ bool
+ startElement(const QString& /*namespaceURI*/, const QString& /*localName*/,
+ const QString& qName, const QXmlAttributes& atts )
+ {
+ mode.push(find_mode(qName));
+
+ switch (mode.top())
+ {
+
+ // Component Set
+ case ComponentSet:
+ {
+ comp_set_data = new scribo::internal::component_set_data<L>();
+ // qDebug() << qName << " - atts.value(\"nelements\").toInt() = " << atts.value("nelements").toInt();;
+ comp_set_data->soft_init(atts.value("nelements").toInt());
+ }
+ break;
+
+
+ // Component Info
+ case ComponentInfo:
+ {
+ component_info info(atts.value("id").toInt(),
+ mln::make::box2d(atts.value("pmin_y").toInt(),
+ atts.value("pmin_x").toInt(),
+ atts.value("pmax_y").toInt(),
+ atts.value("pmax_x").toInt()),
+ mln::point2d(atts.value("mass_center_y").toInt(),
+ atts.value("mass_center_x").toInt()),
+ atts.value("card").toInt());
+
+
+ info.update_tag(component::str2tag(atts.value("tag").toUtf8().constData()));
+ info.update_type(component::str2type(atts.value("type").toUtf8().constData()));
+
+ comp_set_data->infos_.append(info);
+ }
+ break;
+
+
+ // Object links
+ case ObjectLinks:
+ {
+ // qDebug() << "object_links created";
+ links = object_links<L>(components);
+ }
+ break;
+
+
+ // Object groups
+ case ObjectGroups:
+ {
+ // qDebug() << "object_groups created";
+ groups = object_groups<L>(links);
+ }
+ break;
+
+
+ // Text data
+ case TextData:
+ {
+ // qDebug() << "TextData";
+
+ // Reserve space for line data.
+ lines_data.resize(atts.value("nlines").toInt() + 1);
+ // qDebug() << "line_set created";
+ lines = line_set<L>(groups, lines_data);
+ llinks = line_links<L>(lines);
+ par_data = new scribo::internal::paragraph_set_data<L>(llinks, atts.value("nparagraphs").toInt());
+ // std::cout << par_data->pars_.nelements() << " - " << llinks.nelements() << " - " << lines.nelements() << std::endl;
+ }
+ break;
+
+
+ // Text Region
+ case TextRegion:
+ {
+ // qDebug() << "TextRegion";
+
+ current_paragraph = paragraph_info<L>(llinks);
+ }
+ break;
+
+
+ // Line link
+ case LineLink:
+ {
+ llinks(atts.value("from").toInt()) = atts.value("to").toInt();
+ }
+ break;
+
+
+ // Line
+ case Line:
+ {
+ current_line_id = atts.value("id").toInt();
+
+ line_data = new scribo::internal::line_info_data<L>(lines, mln::util::array<component_id_t>());
+
+ line_data->holder_ = lines;
+ line_data->text_ = atts.value("text").toUtf8().constData();
+
+ line_data->hidden_ = false;
+ line_data->tag_ = static_cast<line::Tag>(atts.value("tag").toInt());
+
+ line_data->baseline_ = atts.value("baseline").toInt();
+ line_data->meanline_ = atts.value("meanline").toInt();
+ line_data->x_height_ = atts.value("x_height").toInt();
+ line_data->d_height_ = atts.value("d_height").toInt();
+ line_data->a_height_ = atts.value("a_height").toInt();
+ line_data->char_space_ = atts.value("kerning").toInt();
+ line_data->char_width_ = atts.value("char_width").toInt();
+ line_data->word_space_ = 0;
+
+ line_data->reading_direction_ = line::LeftToRight;
+ line_data->type_ = line::str2type(atts.value("txt_text_type").toAscii().constData());
+ line_data->reverse_video_ = (atts.value("txt_reverse_video") == "false" ? false : true);
+ line_data->orientation_ = 0;
+ line_data->reading_orientation_ = atts.value("txt_reading_orientation").toInt();
+ line_data->indented_ = (atts.value("txt_indented") == "false" ? false : true);
+
+ bbox.init();
+ }
+ break;
+
+
+ // CompIdList
+ case CompIdList:
+ {
+
+ }
+ break;
+
+
+ // CompId
+ case CompId:
+ {
+ line_data->components_.append(atts.value("value").toInt());
+ }
+ break;
+
+
+ // Point
+ case Point:
+ {
+ point2d p(atts.value("y").toInt(), atts.value("x").toInt());
+ bbox.take(p);
+ }
+ break;
+
+
+ // Labeled Image
+ case LabeledImage:
+ {
+ width = atts.value("width").toInt();
+ height = atts.value("height").toInt();
+ comp_set_data->ima_ = L(mln::make::box2d(height, width), 0); // No border
+ }
+ break;
+
+
+ // Separator Image
+ case SeparatorsImage:
+ {
+ width = atts.value("width").toInt();
+ height = atts.value("height").toInt();
+ comp_set_data->separators_ = B(mln::make::box2d(height, width), 0); // No border
+ }
+ break;
+
+
+ // Link
+ case Link:
+ {
+ links(atts.value("from").toInt()) = atts.value("to").toInt();
+ }
+ break;
+
+
+ // Group
+ case Group:
+ {
+ groups(atts.value("object_id").toInt()) = atts.value("group_id").toInt();
+ }
+ break;
+
+
+ // DEFAULT
+ default:
+ ;
+ }
+
+ return true;
+ }
+
+
+ virtual
+ bool
+ endElement(const QString& /*namespaceURI*/, const QString& /*localName*/, const QString& /*qName*/)
+ {
+ switch(mode.top())
+ {
+ // Component set
+ case ComponentSet:
+ {
+ // qDebug() << "Component set done";
+ components = component_set<L>(comp_set_data);
+ }
+ break;
+
+ // Line
+ case Line:
+ {
+ // qDebug() << "Line done";
+ line_data->bbox_ = bbox;
+ lines_data(current_line_id) = line_info<L>(current_line_id, line_data);
+ lines_data(current_line_id).update_ebbox();
+
+ // Add this line to the current paragraph.
+ current_paragraph.add_line(lines_data(current_line_id));
+ }
+ break;
+
+ // TextRegion
+ case TextRegion:
+ {
+ // qDebug() << TextRegion;
+ par_data->pars_(current_paragraph_id++) = current_paragraph;
+ }
+ break;
+
+ // Page
+ case Page:
+ {
+ // qDebug() << "Page done";
+ lines.update_line_data_(lines_data);
+ parset = paragraph_set<L>(par_data);
+ }
+ break;
+
+ // DEFAULT
+ default:
+ ;
+
+ }
+
+ mode.pop();
+ return true;
+ }
+
+
+
+ bool characters(const QString & ch)
+ {
+ switch (mode.top())
+ {
+ case LabeledImage:
+ {
+ scribo::convert::from_base64(ch, comp_set_data->ima_);
+ }
+ break;
+
+ case SeparatorsImage:
+ {
+ scribo::convert::from_base64(ch, comp_set_data->separators_);
+ }
+ break;
+
+ default:
+ ;
+ }
+
+ return true;
+ }
+
+
+// private: // Methods
+
+ Mode find_mode(const QString& qName)
+ {
+ for (int i = 0; mode_data[i].name; ++i)
+ if (mode_data[i].name == qName)
+ return mode_data[i].mode;
+ return None;
+ }
+
+
+// private: // Attributes
+
+ QStack<Mode> mode;
+
+ // Shape
+ accu::shape::bbox<point2d> bbox;
+
+ unsigned width;
+ unsigned height;
+
+ // Components
+ mln::util::tracked_ptr<scribo::internal::component_set_data<L> > comp_set_data;
+ component_set<L> components;
+
+ object_links<L> links;
+ object_groups<L> groups;
+
+ // Lines
+ unsigned current_line_id;
+ scribo::internal::line_info_data<L> *line_data;
+
+ line_links<L> llinks;
+
+ unsigned current_paragraph_id;
+ paragraph_info<L> current_paragraph;
+ scribo::internal::paragraph_set_data<L> *par_data;
+ paragraph_set<L> parset;
+
+ mln::util::array<line_info<L> > lines_data;
+ line_set<L> lines;
+ };
+
+
+
+
+
+
+
+
+
+
+ template <typename L>
+ void
+ load_extended(document<L>& doc,
+ const std::string& output_name)
+ {
+ xml_handler<L> handler;
+ QXmlSimpleReader reader;
+ reader.setContentHandler(&handler);
+
+ QFile file(output_name.c_str());
+ if (!file.open(QFile::ReadOnly | QFile::Text))
+ {
+ qDebug() << "Cannot read file";
+ return;
+ }
+
+ QXmlInputSource xmlInputSource(&file);
+ if (reader.parse(xmlInputSource))
+ qDebug() << "Loaded successfuly";
+
+ doc.set_paragraphs(handler.parset);
+ }
+
+ } // end of namespace scribo::io::xml::internal
+
+
+ // FACADE
+
+ template <typename L>
+ void
+ load(document<L>& doc,
+ const std::string& output_name)
+ {
+ internal::load_extended(doc, output_name);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::io::xml
+
+ } // end of namespace scribo::io
+
+} // end of namespace scribo
+
+
+#endif // ! SCRIBO_IO_XML_LOAD_HH
+
--
1.5.6.5
1
0

last-svn-commit-779-ge270275 mln/fun/v2v/rgb_to_luma.hh: New function for grayscale conversion.
by Guillaume Lazzara 28 Mar '11
by Guillaume Lazzara 28 Mar '11
28 Mar '11
---
milena/ChangeLog | 5 +++
.../achromatism.hh => mln/fun/v2v/rgb_to_luma.hh} | 32 ++++++++++++-------
2 files changed, 25 insertions(+), 12 deletions(-)
copy milena/{sandbox/green/mln/fun/v2v/achromatism.hh => mln/fun/v2v/rgb_to_luma.hh} (67%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c4bed2c..edefc8e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * mln/fun/v2v/rgb_to_luma.hh: New function for grayscale
+ conversion.
+
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/util/array.hh: Add last() method.
diff --git a/milena/sandbox/green/mln/fun/v2v/achromatism.hh b/milena/mln/fun/v2v/rgb_to_luma.hh
similarity index 67%
copy from milena/sandbox/green/mln/fun/v2v/achromatism.hh
copy to milena/mln/fun/v2v/rgb_to_luma.hh
index 72b545c..304a798 100644
--- a/milena/sandbox/green/mln/fun/v2v/achromatism.hh
+++ b/milena/mln/fun/v2v/rgb_to_luma.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,10 +23,10 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_FUN_V2V_ACHROMATISM_HH
-# define MLN_FUN_V2V_ACHROMATISM_HH
+#ifndef MLN_FUN_V2V_RGB_TO_LUMA_HH
+# define MLN_FUN_V2V_RGB_TO_LUMA_HH
-# include <mln/value/rgb8.hh>
+# include <mln/value/rgb.hh>
namespace mln
{
@@ -37,22 +37,30 @@ namespace mln
namespace v2v
{
- struct achromatism : public Function_v2v< achromatism >
+ template <typename T_luma>
+ struct rgb_to_luma : public Function_v2v< rgb_to_luma<T_luma> >
{
- typedef float result;
+ typedef T_luma result;
+
+ template <typename T_rgb>
+ T_luma operator()(const T_rgb& rgb) const;
- float operator()(const value::rgb8 rgb) const;
};
+
# ifndef MLN_INCLUDE_ONLY
- float achromatism::operator()(const value::rgb8 rgb) const
+ template <typename T_luma>
+ template <typename T_rgb>
+ inline
+ T_luma
+ rgb_to_luma<T_luma>::operator()(const T_rgb& rgb) const
{
- return (math::abs(rgb.red() - rgb.green())
- + math::abs(rgb.red() - rgb.blue())
- + math::abs(rgb.green() - rgb.blue()))/3.0;
+ float luma = 0.299 * rgb.red() + 0.587 * rgb.green() + 0.114 * rgb.blue();
+ return unsigned(luma + 0.49999);
}
+
# endif // !MLN_INCLUDE_ONLY
} // end of namespace fun::v2v
@@ -61,4 +69,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_V2V_ACHROMATISM_HH
+#endif // ! MLN_FUN_V2V_RGB_TO_LUMA_HH
--
1.5.6.5
1
0

last-svn-commit-780-g7f4a367 mln/labeling/fill_holes.hh: Improve speed.
by Guillaume Lazzara 28 Mar '11
by Guillaume Lazzara 28 Mar '11
28 Mar '11
---
milena/ChangeLog | 4 ++++
milena/mln/labeling/fill_holes.hh | 17 +++++++++--------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index edefc8e..2eed916 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/labeling/fill_holes.hh: Improve speed.
+
+2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/fun/v2v/rgb_to_luma.hh: New function for grayscale
conversion.
diff --git a/milena/mln/labeling/fill_holes.hh b/milena/mln/labeling/fill_holes.hh
index e76c489..5e487d9 100644
--- a/milena/mln/labeling/fill_holes.hh
+++ b/milena/mln/labeling/fill_holes.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -33,6 +34,8 @@
# include <mln/labeling/background.hh>
# include <mln/labeling/compute.hh>
+# include <mln/data/transform.hh>
+
# include <mln/core/image/dmorph/image_if.hh>
# include <mln/accu/math/count.hh>
@@ -57,7 +60,7 @@ namespace mln
/// \see mln::labeling::background
///
template <typename I, typename N, typename L>
- I
+ mln_concrete(I)
fill_holes(const Image<I>& input, const Neighborhood<N>& nbh,
L& nlabels);
@@ -66,7 +69,7 @@ namespace mln
template <typename I, typename N, typename L>
inline
- I
+ mln_concrete(I)
fill_holes(const Image<I>& input, const Neighborhood<N>& nbh,
L& nlabels)
{
@@ -77,10 +80,6 @@ namespace mln
mln_precondition(exact(input).is_valid());
mln_precondition(exact(nbh).is_valid());
- mln_ch_value(I, bool) output;
- initialize(output, input);
- data::fill(output, false);
-
mln_ch_value(I, L) lbls = labeling::background(input, nbh, nlabels);
accu::math::count<mln_value(I)> a_;
@@ -99,7 +98,9 @@ namespace mln
}
}
- data::fill((output | (pw::value(lbls) != bg_lbl)).rw(), true);
+ util::array<bool> bg_relbl(arr.nelements(), true);
+ bg_relbl(bg_lbl) = false;
+ mln_ch_value(I, bool) output = data::transform(lbls, bg_relbl);
trace::exiting("labeling::fill_holes");
return output;
--
1.5.6.5
1
0

last-svn-commit-781-g6fdc4cc Make use of mln::fun::v2v::rgb_to_luma.
by Guillaume Lazzara 28 Mar '11
by Guillaume Lazzara 28 Mar '11
28 Mar '11
* scribo/toolchain/internal/text_in_doc_preprocess_functor.hh,
* src/binarization/ppm_sauvola.cc,
* src/binarization/ppm_sauvola_ms.cc,
* src/binarization/ppm_sauvola_ms_fg.cc,
* src/binarization/ppm_sauvola_ms_split.cc,
* src/binarization/sauvola.cc,
* src/binarization/sauvola_debug.cc,
* src/binarization/sauvola_ms.cc,
* src/binarization/sauvola_ms_debug.cc,
* src/binarization/sauvola_ms_fg.cc,
* src/text_in_picture.cc,
* src/text_in_picture_neg.cc,
* src/text_recognition_in_picture.cc: Here.
---
scribo/ChangeLog | 18 ++++++++++++++++++
.../internal/text_in_doc_preprocess_functor.hh | 7 ++++---
scribo/src/binarization/ppm_sauvola.cc | 9 +++++----
scribo/src/binarization/ppm_sauvola_ms.cc | 9 +++++----
scribo/src/binarization/ppm_sauvola_ms_fg.cc | 8 ++++----
scribo/src/binarization/ppm_sauvola_ms_split.cc | 5 ++---
scribo/src/binarization/sauvola.cc | 4 ++--
scribo/src/binarization/sauvola_debug.cc | 8 ++++----
scribo/src/binarization/sauvola_ms.cc | 9 +++++----
scribo/src/binarization/sauvola_ms_debug.cc | 9 +++++----
scribo/src/binarization/sauvola_ms_fg.cc | 8 ++++----
scribo/src/text_in_picture.cc | 7 ++++---
scribo/src/text_in_picture_neg.cc | 5 ++---
scribo/src/text_recognition_in_picture.cc | 9 +++++----
14 files changed, 69 insertions(+), 46 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index cf51ca8..f740230 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,23 @@
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Make use of mln::fun::v2v::rgb_to_luma.
+
+ * scribo/toolchain/internal/text_in_doc_preprocess_functor.hh,
+ * src/binarization/ppm_sauvola.cc,
+ * src/binarization/ppm_sauvola_ms.cc,
+ * src/binarization/ppm_sauvola_ms_fg.cc,
+ * src/binarization/ppm_sauvola_ms_split.cc,
+ * src/binarization/sauvola.cc,
+ * src/binarization/sauvola_debug.cc,
+ * src/binarization/sauvola_ms.cc,
+ * src/binarization/sauvola_ms_debug.cc,
+ * src/binarization/sauvola_ms_fg.cc,
+ * src/text_in_picture.cc,
+ * src/text_in_picture_neg.cc,
+ * src/text_recognition_in_picture.cc: Here.
+
+2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/io/xml/load.hh: New XML loader.
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh
index 6a9506b..6c0dd5a 100644
--- a/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh
+++ b/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh
@@ -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.
//
@@ -29,7 +30,7 @@
#include <mln/core/concept/image.hh>
#include <mln/data/transform.hh>
#include <mln/data/convert.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <mln/subsampling/antialiased.hh>
#include <scribo/binarization/sauvola.hh>
@@ -208,7 +209,7 @@ namespace scribo
on_new_progress_label("Convert to gray-scale image");
image2d<value::int_u8>
intensity_ima = mln::data::transform(input_rgb,
- mln::fun::v2v::rgb_to_int_u<8>());
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
on_progress();
diff --git a/scribo/src/binarization/ppm_sauvola.cc b/scribo/src/binarization/ppm_sauvola.cc
index f0cd355..4732a02 100644
--- a/scribo/src/binarization/ppm_sauvola.cc
+++ b/scribo/src/binarization/ppm_sauvola.cc
@@ -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.
//
@@ -27,7 +27,7 @@
#include <mln/io/ppm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <scribo/binarization/sauvola.hh>
#include <scribo/debug/usage.hh>
@@ -74,7 +74,8 @@ int main(int argc, char *argv[])
// Convert to Gray level image.
image2d<value::int_u8>
- input_gl = data::transform(input, mln::fun::v2v::rgb_to_int_u<8>());
+ input_gl = data::transform(input,
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
// Binarize
image2d<bool> out = scribo::binarization::sauvola(input_gl, w, k);
diff --git a/scribo/src/binarization/ppm_sauvola_ms.cc b/scribo/src/binarization/ppm_sauvola_ms.cc
index eb694c2..cff28f9 100644
--- a/scribo/src/binarization/ppm_sauvola_ms.cc
+++ b/scribo/src/binarization/ppm_sauvola_ms.cc
@@ -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.
//
@@ -29,7 +29,7 @@
#include <mln/io/ppm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <scribo/binarization/sauvola_ms.hh>
#include <scribo/debug/usage.hh>
@@ -110,7 +110,8 @@ int main(int argc, char *argv[])
// Convert to Gray level image.
image2d<value::int_u8>
- input_1_gl = data::transform(input_1, mln::fun::v2v::rgb_to_int_u<8>());
+ input_1_gl = data::transform(input_1,
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
// Binarize
image2d<bool>
diff --git a/scribo/src/binarization/ppm_sauvola_ms_fg.cc b/scribo/src/binarization/ppm_sauvola_ms_fg.cc
index 20f237f..a17ce9f 100644
--- a/scribo/src/binarization/ppm_sauvola_ms_fg.cc
+++ b/scribo/src/binarization/ppm_sauvola_ms_fg.cc
@@ -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.
//
@@ -31,7 +31,7 @@
#include <mln/io/ppm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <scribo/binarization/sauvola_ms.hh>
#include <scribo/preprocessing/split_bg_fg.hh>
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
// Convert to Gray level image.
image2d<value::int_u8>
- fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>());
+ fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_luma<value::int_u8>());
// Binarize
image2d<bool>
diff --git a/scribo/src/binarization/ppm_sauvola_ms_split.cc b/scribo/src/binarization/ppm_sauvola_ms_split.cc
index bb98b38..92a0817 100644
--- a/scribo/src/binarization/ppm_sauvola_ms_split.cc
+++ b/scribo/src/binarization/ppm_sauvola_ms_split.cc
@@ -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.
//
@@ -29,7 +29,6 @@
#include <mln/io/ppm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
#include <scribo/binarization/sauvola_ms_split.hh>
#include <scribo/debug/usage.hh>
diff --git a/scribo/src/binarization/sauvola.cc b/scribo/src/binarization/sauvola.cc
index 0273071..e8047ab 100644
--- a/scribo/src/binarization/sauvola.cc
+++ b/scribo/src/binarization/sauvola.cc
@@ -29,7 +29,7 @@
#include <mln/io/magick/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <scribo/binarization/sauvola.hh>
#include <scribo/debug/usage.hh>
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
// Convert to Gray level image.
image2d<value::int_u8>
- input_1_gl = data::transform(input, mln::fun::v2v::rgb_to_int_u<8>());
+ input_1_gl = data::transform(input, mln::fun::v2v::rgb_to_luma<value::int_u8>());
image2d<bool> out = scribo::binarization::sauvola(input_1_gl, w, k);
diff --git a/scribo/src/binarization/sauvola_debug.cc b/scribo/src/binarization/sauvola_debug.cc
index f723851..0c335a8 100644
--- a/scribo/src/binarization/sauvola_debug.cc
+++ b/scribo/src/binarization/sauvola_debug.cc
@@ -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.
//
@@ -32,7 +32,7 @@
#include <mln/data/convert.hh>
#include <mln/data/saturate.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <scribo/binarization/local_threshold.hh>
#include <scribo/binarization/sauvola.hh>
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
image2d<value::int_u8>
gima = data::transform(input,
- mln::fun::v2v::rgb_to_int_u<8>());
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
image2d<bool>
diff --git a/scribo/src/binarization/sauvola_ms.cc b/scribo/src/binarization/sauvola_ms.cc
index 541b9e5..6d60ab4 100644
--- a/scribo/src/binarization/sauvola_ms.cc
+++ b/scribo/src/binarization/sauvola_ms.cc
@@ -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.
//
@@ -31,7 +31,7 @@
#include <mln/io/magick/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <scribo/binarization/sauvola_ms.hh>
#include <scribo/debug/usage.hh>
@@ -115,7 +115,8 @@ int main(int argc, char *argv[])
// Convert to Gray level image.
image2d<value::int_u8>
- input_1_gl = data::transform(input_1, mln::fun::v2v::rgb_to_int_u<8>());
+ input_1_gl = data::transform(input_1,
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
// Binarize
image2d<bool>
diff --git a/scribo/src/binarization/sauvola_ms_debug.cc b/scribo/src/binarization/sauvola_ms_debug.cc
index 6bf9837..70c1a9a 100644
--- a/scribo/src/binarization/sauvola_ms_debug.cc
+++ b/scribo/src/binarization/sauvola_ms_debug.cc
@@ -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.
//
@@ -29,7 +29,7 @@
#include <mln/io/magick/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <scribo/binarization/sauvola_ms.hh>
#include <scribo/debug/usage.hh>
@@ -124,7 +124,8 @@ int main(int argc, char *argv[])
// Convert to Gray level image.
image2d<value::int_u8>
- input_1_gl = data::transform(input_1, mln::fun::v2v::rgb_to_int_u<8>());
+ input_1_gl = data::transform(input_1,
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
// Binarize.
diff --git a/scribo/src/binarization/sauvola_ms_fg.cc b/scribo/src/binarization/sauvola_ms_fg.cc
index 4227db4..7ff9321 100644
--- a/scribo/src/binarization/sauvola_ms_fg.cc
+++ b/scribo/src/binarization/sauvola_ms_fg.cc
@@ -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.
//
@@ -31,7 +31,7 @@
#include <mln/io/magick/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/data/transform.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <scribo/binarization/sauvola_ms.hh>
#include <scribo/preprocessing/split_bg_fg.hh>
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
// Convert to Gray level image.
image2d<value::int_u8>
- fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>());
+ fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_luma<value::int_u8>());
// Binarize
image2d<bool>
diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture.cc
index e2f30de..77cf7b6 100644
--- a/scribo/src/text_in_picture.cc
+++ b/scribo/src/text_in_picture.cc
@@ -40,7 +40,7 @@
#include <mln/value/rgb8.hh>
#include <mln/value/label_16.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <mln/subsampling/antialiased.hh>
@@ -236,7 +236,8 @@ int main(int argc, char* argv[])
std::cout << "** Using split_bg_fg" << std::endl;
image2d<value::rgb8>
fg = preprocessing::split_bg_fg(input_rgb, lambda, 32).second();
- intensity_ima = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>());
+ intensity_ima = data::transform(fg,
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
t_ = timer_;
std::cout << "Foreground extracted. " << t_ << std::endl;
@@ -253,7 +254,7 @@ int main(int argc, char* argv[])
timer_.start();
std::cout << "** Using data::transform(intensity)" << std::endl;
intensity_ima = data::transform(input_rgb,
- mln::fun::v2v::rgb_to_int_u<8>());
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
t_ = timer_;
std::cout << "Intensity image " << t_ << std::endl;
}
diff --git a/scribo/src/text_in_picture_neg.cc b/scribo/src/text_in_picture_neg.cc
index c1a4317..8d818e0 100644
--- a/scribo/src/text_in_picture_neg.cc
+++ b/scribo/src/text_in_picture_neg.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.
//
@@ -48,8 +49,6 @@
#include <mln/value/rgb8.hh>
#include <mln/value/label_16.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
-
#include <mln/data/wrap.hh>
#include <mln/draw/box.hh>
diff --git a/scribo/src/text_recognition_in_picture.cc b/scribo/src/text_recognition_in_picture.cc
index a5f93a7..8b76f48 100644
--- a/scribo/src/text_recognition_in_picture.cc
+++ b/scribo/src/text_recognition_in_picture.cc
@@ -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.
//
@@ -51,7 +51,7 @@
#include <mln/value/rgb8.hh>
#include <mln/value/label_16.hh>
-#include <mln/fun/v2v/rgb_to_int_u.hh>
+#include <mln/fun/v2v/rgb_to_luma.hh>
#include <mln/data/wrap.hh>
@@ -253,7 +253,8 @@ int main(int argc, char* argv[])
// Extract foreground
image2d<value::rgb8>
fg = preprocessing::split_bg_fg(input_rgb, lambda, 32).second();
- intensity_ima = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>());
+ intensity_ima = data::transform(fg,
+ mln::fun::v2v::rgb_to_luma<value::int_u8>());
// // Perform an initial rotation if needed.
// // input_rgb = geom::rotate(input_rgb, -45, literal::black);
--
1.5.6.5
1
0

last-svn-commit-782-gba41452 scribo/text/extract_lines.hh: Update code.
by Guillaume Lazzara 28 Mar '11
by Guillaume Lazzara 28 Mar '11
28 Mar '11
---
scribo/ChangeLog | 4 ++
scribo/scribo/text/extract_lines.hh | 68 ++++++++++++++++++++++------------
2 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index f740230..74c7a03 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * scribo/text/extract_lines.hh: Update code.
+
+2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Make use of mln::fun::v2v::rgb_to_luma.
* scribo/toolchain/internal/text_in_doc_preprocess_functor.hh,
diff --git a/scribo/scribo/text/extract_lines.hh b/scribo/scribo/text/extract_lines.hh
index 1a25cc8..b81cb79 100644
--- a/scribo/scribo/text/extract_lines.hh
+++ b/scribo/scribo/text/extract_lines.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.
//
@@ -33,13 +33,14 @@
# include <mln/core/concept/image.hh>
-# include <mln/value/label_16.hh>
+# include <mln/value/int_u16.hh>
# include <scribo/core/line_set.hh>
# include <scribo/primitive/extract/components.hh>
# include <scribo/primitive/link/merge_double_link.hh>
+# include <scribo/primitive/link/internal/dmax_width_and_height.hh>
# include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
# include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
@@ -65,11 +66,18 @@ namespace scribo
/*!
** \param[in] input A binary image.
** \param[in] nbh A neighborhood used for labeling.
+ ** \param[in] seps A binary image with separator information.
**
** \return A set of lines.
*/
template <typename I, typename N>
- line_set<mln_ch_value(I,value::label_16)>
+ line_set<mln_ch_value(I,value::int_u16)>
+ extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ const mln_ch_value(I,bool)& separators);
+
+ /// \overload
+ template <typename I, typename N>
+ line_set<mln_ch_value(I,value::int_u16)>
extract_lines(const Image<I>& input, const Neighborhood<N>& nbh);
@@ -77,8 +85,18 @@ namespace scribo
template <typename I, typename N>
- line_set<mln_ch_value(I,value::label_16)>
- extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_)
+ line_set<mln_ch_value(I,value::int_u16)>
+ extract_lines(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ mln_ch_value(I,bool) seps;
+ return extract_lines(input, nbh, seps);
+ }
+
+
+ template <typename I, typename N>
+ line_set<mln_ch_value(I,value::int_u16)>
+ extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ const mln_ch_value(I,bool)& separators)
{
trace::entering("scribo::text::extract_lines");
@@ -88,44 +106,46 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
- typedef mln_ch_value(I,value::label_16) L;
-
/// Finding comps.
- value::label_16 ncomps;
+ typedef mln_ch_value(I,value::int_u16) L;
+ value::int_u16 ncomps;
component_set<L>
- comps = scribo::primitive::extract::components(input, nbh, ncomps);
+ comps = scribo::primitive::extract::components(input, c8(), ncomps);
/// First filtering.
- component_set<L> filtered_comps
- = scribo::filter::components_small(comps, 6);
+ comps = scribo::filter::components_small(comps, 3);
+
+ /// Use separators.
+ if (exact(separators).is_valid())
+ comps.add_separators(separators);
/// Linking potential comps
object_links<L> left_link
- = primitive::link::with_single_left_link_dmax_ratio(filtered_comps);
+ = primitive::link::with_single_left_link_dmax_ratio(comps,
+ primitive::link::internal::dmax_width_and_height(1),
+ anchor::MassCenter);
object_links<L> right_link
- = primitive::link::with_single_right_link_dmax_ratio(filtered_comps);
-
+ = primitive::link::with_single_right_link_dmax_ratio(comps,
+ primitive::link::internal::dmax_width_and_height(1),
+ anchor::MassCenter);
// Validating left and right links.
object_links<L>
merged_links = primitive::link::merge_double_link(left_link,
- right_link);
+ right_link);
- // Remove links if bboxes have too different sizes.
- object_links<L> hratio_filtered_links
- = filter::object_links_bbox_h_ratio(merged_links, 2.0f);
+ object_links<L> hratio_filtered_links
+ = filter::object_links_bbox_h_ratio(merged_links, 2.5f);
object_groups<L>
groups = primitive::group::from_single_link(hratio_filtered_links);
-
- line_set<L> line = scribo::make::line_set(groups);
- line = text::merging(line);
-
+ line_set<L> lines(groups);
+ lines = text::merging(lines);
trace::exiting("scribo::text::extract_lines");
- return line;
+ return lines;
}
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* scribo/src/debug/Makefile.am: New targets.
* scribo/src/debug/show_separators.cc,
* scribo/src/debug/show_stoppers.cc,
* scribo/src/debug/show_text_lines.cc: New.
---
scribo/ChangeLog | 10 ++
scribo/src/debug/Makefile.am | 12 ++-
.../lines_pattern.cc => debug/show_separators.cc} | 74 +++++++++-----
scribo/src/debug/show_stoppers.cc | 104 ++++++++++++++++++++
.../show_text_lines.cc} | 100 +++++++++++--------
5 files changed, 225 insertions(+), 75 deletions(-)
copy scribo/src/{primitive/extract/lines_pattern.cc => debug/show_separators.cc} (50%)
create mode 100644 scribo/src/debug/show_stoppers.cc
copy scribo/src/{text/pbm_lines_recognition.cc => debug/show_text_lines.cc} (52%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 74c7a03..4a9dcbf 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,15 @@
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new debug tools.
+
+ * scribo/src/debug/Makefile.am: New targets.
+
+ * scribo/src/debug/show_separators.cc,
+ * scribo/src/debug/show_stoppers.cc,
+ * scribo/src/debug/show_text_lines.cc: New.
+
+2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/text/extract_lines.hh: Update code.
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/src/debug/Makefile.am b/scribo/src/debug/Makefile.am
index d203f5c..cdb1f30 100644
--- a/scribo/src/debug/Makefile.am
+++ b/scribo/src/debug/Makefile.am
@@ -1,5 +1,5 @@
-# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-# (LRDE).
+# Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+# Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -20,6 +20,7 @@ include $(top_srcdir)/scribo/scribo.mk
noinst_PROGRAMS = \
show_info_x_height \
show_info_median_inter_characters \
+ show_separators \
show_links_left_right_links_validation \
show_links_bbox_h_ratio \
show_links_bbox_overlap \
@@ -43,11 +44,14 @@ noinst_PROGRAMS = \
show_objects_large_small \
show_objects_small \
show_objects_thick \
- show_objects_thin
+ show_objects_thin \
+ show_stoppers \
+ show_text_lines
show_info_x_height_SOURCES = show_info_x_height.cc
show_info_median_inter_characters_SOURCES = show_info_median_inter_characters.cc
+show_separators_SOURCES = show_separators.cc
show_links_left_right_links_validation_SOURCES = show_links_left_right_links_validation.cc
show_links_bbox_h_ratio_SOURCES = show_links_bbox_h_ratio.cc
show_links_bbox_overlap_SOURCES = show_links_bbox_overlap.cc
@@ -72,6 +76,8 @@ show_objects_large_small_SOURCES = show_objects_large_small.cc
show_objects_small_SOURCES = show_objects_small.cc
show_objects_thick_SOURCES = show_objects_thick.cc
show_objects_thin_SOURCES = show_objects_thin.cc
+show_stoppers_SOURCES = show_stoppers.cc
+show_text_lines_SOURCES = show_text_lines.cc
if HAVE_MAGICKXX
diff --git a/scribo/src/primitive/extract/lines_pattern.cc b/scribo/src/debug/show_separators.cc
similarity index 50%
copy from scribo/src/primitive/extract/lines_pattern.cc
copy to scribo/src/debug/show_separators.cc
index cb56b36..ef80da6 100644
--- a/scribo/src/primitive/extract/lines_pattern.cc
+++ b/scribo/src/debug/show_separators.cc
@@ -1,5 +1,4 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -14,33 +13,25 @@
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/box2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/io/pbm/all.hh>
-#include <mln/pw/all.hh>
-#include <mln/data/fill.hh>
-#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/arith/plus.hh>
+#include <mln/labeling/foreground.hh>
#include <scribo/primitive/extract/lines_h_pattern.hh>
#include <scribo/primitive/extract/lines_v_pattern.hh>
#include <scribo/debug/usage.hh>
+#include <scribo/debug/save_bboxes_image.hh>
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image." },
- { "length", " Minimum line length. (Common value : 51)" },
+ { "length", " Minimum line length. (default: 101)" },
{ "delta", " Distance between the object pixel and the background pixel"
- "(Common value : 4)" },
+ "(default: 4)" },
{0, 0}
};
@@ -49,10 +40,10 @@ int main(int argc, char *argv[])
{
using namespace mln;
- if (argc != 5)
+ if (argc != 7 && argc != 5)
return scribo::debug::usage(argv,
- "Extract horizontal lines patterns",
- "input.pbm length delta output.pbm",
+ "Extract horizontal and vertical lines patterns",
+ "input.pbm output.pbm input_wo_seps.pbm output.ppm length delta",
args_desc);
trace::entering("main");
@@ -60,19 +51,46 @@ int main(int argc, char *argv[])
image2d<bool> input;
io::pbm::load(input, argv[1]);
+ // Set default option value
+ unsigned
+ length = 101,
+ delta = 4;
+ if (argc > 5)
+ {
+ length = atoi(argv[5]);
+ delta = atoi(argv[6]);
+ }
+
+ util::timer t;
+ t.start();
+
image2d<bool>
- h_lines = scribo::primitive::extract::lines_h_pattern(input,
- atoi(argv[2]),
- atoi(argv[3]));
+ h_lines = scribo::primitive::extract::lines_h_pattern(input, length, delta);
image2d<bool>
- v_lines = scribo::primitive::extract::lines_v_pattern(input,
- atoi(argv[2]),
- atoi(argv[3]));
+ v_lines = scribo::primitive::extract::lines_v_pattern(input, length, delta);
+
+ v_lines += h_lines;
+
+ t.stop();
+ std::cout << t << "s" << std::endl;
+
+ // Save binary image.
+ io::pbm::save(v_lines, argv[2]);
- data::fill((v_lines | pw::value(h_lines)).rw(), true);
+ // Save input without separators
+ {
+ image2d<bool> in_wo_seps = duplicate(input);
+ data::fill((in_wo_seps | pw::value(v_lines)).rw(), false);
+ io::pbm::save(in_wo_seps, argv[3]);
+ }
- io::pbm::save(v_lines, argv[4]);
+ // Save bbox image
+ value::int_u8 nlabels;
+ image2d<value::int_u8> lbl = labeling::foreground(v_lines, c4(), nlabels);
+ mln::util::array<box2d>
+ bbox = labeling::compute(accu::shape::bbox<point2d>(), lbl, nlabels);
+ scribo::debug::save_bboxes_image(input, bbox, argv[4], literal::red);
trace::exiting("main");
}
diff --git a/scribo/src/debug/show_stoppers.cc b/scribo/src/debug/show_stoppers.cc
new file mode 100644
index 0000000..a108da1
--- /dev/null
+++ b/scribo/src/debug/show_stoppers.cc
@@ -0,0 +1,104 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/box2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/io/pbm/all.hh>
+#include <mln/arith/plus.hh>
+#include <mln/labeling/foreground.hh>
+
+#include <scribo/primitive/extract/lines_h_pattern.hh>
+#include <scribo/primitive/extract/lines_v_pattern.hh>
+#include <scribo/primitive/extract/separators_nonvisible.hh>
+#include <scribo/debug/usage.hh>
+#include <scribo/debug/save_bboxes_image.hh>
+
+
+const char *args_desc[][2] =
+{
+ { "length", " Minimum line length. (default: 101)" },
+ { "delta", " Distance between the object pixel and the background pixel"
+ "(default: 4)" },
+ {0, 0}
+};
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+
+ if (argc != 7 && argc != 5)
+ return scribo::debug::usage(argv,
+ "Extract horizontal, vertical lines and stoppers",
+ "input.pbm output.pbm input_wo_seps.pbm output.ppm length delta",
+ args_desc);
+
+ trace::entering("main");
+
+ image2d<bool> input;
+ io::pbm::load(input, argv[1]);
+
+ // Set default option value
+ unsigned
+ length = 101,
+ delta = 4;
+ if (argc > 5)
+ {
+ length = atoi(argv[5]);
+ delta = atoi(argv[6]);
+ }
+
+ util::timer t;
+
+ t.start();
+ image2d<bool>
+ h_lines = scribo::primitive::extract::lines_h_pattern(input, length, delta);
+
+ image2d<bool>
+ v_lines = scribo::primitive::extract::lines_v_pattern(input, length, delta);
+
+ v_lines += h_lines;
+
+ t.stop();
+
+ // Save input without separators
+ {
+ image2d<bool> in_wo_seps = duplicate(input);
+ data::fill((in_wo_seps | pw::value(v_lines)).rw(), false);
+ io::pbm::save(in_wo_seps, argv[3]);
+ }
+
+ // Save bbox image
+ value::int_u8 nlabels;
+ image2d<value::int_u8> lbl = labeling::foreground(v_lines, c4(), nlabels);
+ mln::util::array<box2d>
+ bbox = labeling::compute(accu::shape::bbox<point2d>(), lbl, nlabels);
+ scribo::debug::save_bboxes_image(input, bbox, argv[4], literal::red);
+
+ t.resume();
+
+ // Non visible separators
+ v_lines += scribo::primitive::extract::separators_nonvisible(input);
+
+ t.stop();
+ std::cout << t << "s" << std::endl;
+
+ // Save binary image.
+ io::pbm::save(v_lines, argv[2]);
+
+ trace::exiting("main");
+}
diff --git a/scribo/src/text/pbm_lines_recognition.cc b/scribo/src/debug/show_text_lines.cc
similarity index 52%
copy from scribo/src/text/pbm_lines_recognition.cc
copy to scribo/src/debug/show_text_lines.cc
index 3451449..a031072 100644
--- a/scribo/src/text/pbm_lines_recognition.cc
+++ b/scribo/src/debug/show_text_lines.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,15 +23,15 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include <iostream>
#include <mln/core/image/image2d.hh>
#include <mln/io/pbm/load.hh>
#include <mln/value/int_u16.hh>
+#include <mln/draw/box_plain.hh>
+#include <mln/pw/all.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/data/convert.hh>
#include <scribo/text/recognition.hh>
@@ -41,19 +41,15 @@
#include <scribo/core/object_links.hh>
#include <scribo/core/object_groups.hh>
-#include <scribo/text/merging.hh>
-#include <scribo/primitive/extract/components.hh>
-#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
-#include <scribo/primitive/group/from_single_link.hh>
+#include <scribo/text/extract_lines.hh>
#include <scribo/io/text_boxes/save.hh>
+#include <scribo/debug/save_bboxes_image.hh>
+
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'True' for objects, 'False'\
-for the background." },
- { "lang", "Must be set to \"eng\", \"fra\", \"deu\", \"spa\", \"ita\" (Default \"fra\")" },
{0, 0}
};
@@ -64,10 +60,10 @@ int main(int argc, char* argv[])
using namespace scribo;
using namespace mln;
- if (argc != 2 && argc != 3 && argc != 4)
+ if (argc != 6)
return scribo::debug::usage(argv,
- "Text recognition",
- "input.pbm [lang] [file]",
+ "Show text lines",
+ "input.pbm input_seps.pbm out.ppm out.pbm comps.pbm",
args_desc);
trace::entering("main");
@@ -75,37 +71,53 @@ int main(int argc, char* argv[])
image2d<bool> input;
mln::io::pbm::load(input, argv[1]);
- typedef image2d<value::int_u16> L;
- value::int_u16 ncomps;
- component_set<L>
- comps = scribo::primitive::extract::components(input, c8(), ncomps);
- std::cout << "ncomps = " << ncomps << std::endl;
-
- object_links<L>
- links = scribo::primitive::link::with_single_left_link_dmax_ratio(comps, 2);
-
- object_groups<L>
- groups = scribo::primitive::group::from_single_link(links);
+ image2d<bool> input_seps;
+ mln::io::pbm::load(input_seps, argv[2]);
- line_set<L> lines(groups);
- lines = text::merging(lines);
+ util::timer t;
+ t.start();
- std::string str = argv[2];
- const char *lang;
- if (argc < 3 || (str != "eng" && str != "fra"
- && str != "deu" && str != "spa"
- && str != "ita"))
- lang = "fra";
- else
- lang = argv[2];
-
- char *output = 0;
- if (argc >= 4)
- output = argv[3];
-
- scribo::text::recognition(lines, lang);
-
- scribo::io::text_boxes::save(lines, output);
+ typedef image2d<value::int_u16> L;
+ line_set<L> lines = text::extract_lines(input, c8(), input_seps);
+
+ t.stop();
+ std::cout << t << "s" << std::endl;
+
+ // Color image with line bboxes.
+ {
+ image2d<value::rgb8> output = data::convert(value::rgb8(), input);
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
+ mln::draw::box(output, lines(l).bbox(), literal::red);
+ mln::io::ppm::save(output, argv[3]);
+ }
+
+ // Binary image with line bboxes.
+ {
+ image2d<bool> output;
+ initialize(output, input);
+ data::fill(output, false);
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
+ mln::draw::box_plain(output, lines(l).bbox(), true);
+ mln::io::pbm::save(output, argv[4]);
+ }
+
+ {
+ image2d<bool> output;
+ initialize(output, input);
+ data::fill(output, false);
+ for_all_lines(l, lines)
+ if (lines(l).is_textline())
+ {
+ const util::array<component_id_t>& comps = lines(l).components();
+ const L& lbl = lines.components().labeled_image();
+ for_all_elements(c, comps)
+ data::fill((output | lines.components()(comps(c)).bbox()).rw(),
+ ((input | lines.components()(comps(c)).bbox()) | (pw::value(lbl) == comps(c))));
+ }
+ mln::io::pbm::save(output, argv[5]);
+ }
trace::exiting("main");
}
--
1.5.6.5
1
0

last-svn-commit-784-gd12d660 scribo/primitive/extract/non_text.hh: Remove debug.
by Guillaume Lazzara 28 Mar '11
by Guillaume Lazzara 28 Mar '11
28 Mar '11
---
scribo/ChangeLog | 4 ++++
scribo/scribo/primitive/extract/non_text.hh | 21 ---------------------
2 files changed, 4 insertions(+), 21 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 4a9dcbf..bbd0cf2 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * scribo/primitive/extract/non_text.hh: Remove debug.
+
+2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add new debug tools.
* scribo/src/debug/Makefile.am: New targets.
diff --git a/scribo/scribo/primitive/extract/non_text.hh b/scribo/scribo/primitive/extract/non_text.hh
index a017f1f..8528782 100644
--- a/scribo/scribo/primitive/extract/non_text.hh
+++ b/scribo/scribo/primitive/extract/non_text.hh
@@ -58,10 +58,6 @@
# include <mln/clustering/kmean_rgb.hh>
# include <mln/fun/v2v/rgb8_to_rgbn.hh>
-# include <mln/util/timer.hh>
-
-# include <mln/io/pbm/save.hh>
-
namespace scribo
{
@@ -139,16 +135,9 @@ namespace scribo
image2d<t_rgb5>
img_rgb5 = mln::data::transform(doc.image(), t_rgb8_to_rgb5());
- // DEBUG
- io::pbm::save(content, "text_area.pbm");
-
- mln::util::timer t;
- t.start();
img_lbl8 =
mln::clustering::kmean_rgb<double,5>((img_rgb5 | pw::value(content)), 3, 10, 10).unmorph_();
data::fill((img_lbl8 | !pw::value(content)).rw(), 0u);
- t.stop();
- std::cout << t << std::endl;
mln::util::array<unsigned>
card = mln::labeling::compute(accu::math::count<value::label_8>(),
@@ -178,19 +167,9 @@ namespace scribo
data::fill(elts, false);
data::fill((elts | (pw::value(img_lbl8) != pw::cst(0))).rw(), true);
- // DEBUG
- data::fill((elts | (pw::value(doc.line_seps()) != pw::cst(0))).rw(),
- false);
- // END OF DEBUG
-
-
scribo::def::lbl_type nlabels;
elts = filter::components_small(elts, c8(), nlabels, 40);
- // DEBUG
- io::pbm::save(elts, "elements.pbm");
- // END OF DEBUG
-
output = primitive::extract::components(elts, c8(), nlabels);
}
--
1.5.6.5
1
0
* scribo/headers.mk,
* scribo/tests/unit_test/unit-tests.mk: Regen.
* scribo/tests/unit_test/cond_tests_qt: Add scribo/io/xml/load.hh.
---
scribo/ChangeLog | 9 +++++++++
scribo/headers.mk | 13 ++++++++++++-
scribo/tests/unit_test/cond_tests_qt | 1 +
scribo/tests/unit_test/unit-tests.mk | 30 +++++++++++++++++++++++++++---
4 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index bbd0cf2..4eae5f8 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,12 @@
+2011-03-02 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Regen mk files.
+
+ * scribo/headers.mk,
+ * scribo/tests/unit_test/unit-tests.mk: Regen.
+
+ * scribo/tests/unit_test/cond_tests_qt: Add scribo/io/xml/load.hh.
+
2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
* scribo/primitive/extract/non_text.hh: Remove debug.
diff --git a/scribo/headers.mk b/scribo/headers.mk
index 7603f8a..0b21a3f 100644
--- a/scribo/headers.mk
+++ b/scribo/headers.mk
@@ -14,17 +14,22 @@ scribo/binarization/sauvola_ms.hh \
scribo/binarization/sauvola_ms_split.hh \
scribo/binarization/sauvola_threshold_image.hh \
scribo/canvas/integral_browsing.hh \
+scribo/convert/from_base64.hh \
scribo/convert/from_qimage.hh \
+scribo/convert/to_base64.hh \
scribo/core/all.hh \
scribo/core/central_sites.hh \
scribo/core/component_info.hh \
scribo/core/component_set.hh \
scribo/core/concept/dmax_functor.hh \
scribo/core/concept/link_functor.hh \
+scribo/core/concept/serializable.hh \
+scribo/core/concept/serialize_visitor.hh \
scribo/core/def/lbl_type.hh \
scribo/core/document.hh \
scribo/core/erase_objects.hh \
scribo/core/init_integral_image.hh \
+scribo/core/internal/doc_xml_serializer.hh \
scribo/core/line_info.hh \
scribo/core/line_links.hh \
scribo/core/line_set.hh \
@@ -93,6 +98,12 @@ scribo/fun/v2b/label_to_bool.hh \
scribo/fun/v2b/objects_large_filter.hh \
scribo/fun/v2b/objects_small_filter.hh \
scribo/io/text_boxes/save.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 \
+scribo/io/xml/internal/print_box_coords.hh \
+scribo/io/xml/internal/print_page_preambule.hh \
+scribo/io/xml/load.hh \
scribo/io/xml/save.hh \
scribo/make/all.hh \
scribo/make/debug_filename.hh \
@@ -115,7 +126,6 @@ scribo/primitive/extract/all.hh \
scribo/primitive/extract/canvas.hh \
scribo/primitive/extract/cells.hh \
scribo/primitive/extract/components.hh \
-scribo/primitive/extract/elements.hh \
scribo/primitive/extract/horizontal_separators.hh \
scribo/primitive/extract/lines_discontinued.hh \
scribo/primitive/extract/lines_h_discontinued.hh \
@@ -130,6 +140,7 @@ scribo/primitive/extract/lines_v_pattern.hh \
scribo/primitive/extract/lines_v_single.hh \
scribo/primitive/extract/lines_v_thick.hh \
scribo/primitive/extract/lines_v_thick_and_single.hh \
+scribo/primitive/extract/non_text.hh \
scribo/primitive/extract/separators.hh \
scribo/primitive/extract/separators_nonvisible.hh \
scribo/primitive/extract/vertical_separators.hh \
diff --git a/scribo/tests/unit_test/cond_tests_qt b/scribo/tests/unit_test/cond_tests_qt
index 5428215..577f9e6 100644
--- a/scribo/tests/unit_test/cond_tests_qt
+++ b/scribo/tests/unit_test/cond_tests_qt
@@ -1 +1,2 @@
scribo/convert/from_qimage.hh
+scribo/io/xml/load.hh
diff --git a/scribo/tests/unit_test/unit-tests.mk b/scribo/tests/unit_test/unit-tests.mk
index 6a8f29d..71b0b5b 100644
--- a/scribo/tests/unit_test/unit-tests.mk
+++ b/scribo/tests/unit_test/unit-tests.mk
@@ -19,11 +19,15 @@ endif HAVE_MAGICKXX
# Starting a conditional unit test list.
if HAVE_QT
check_PROGRAMS += \
-scribo_convert_from_qimage
+scribo_convert_from_qimage \
+scribo_io_xml_load
scribo_convert_from_qimage_CPPFLAGS= ${QT_CPPFLAGS} ${AM_CPPFLAGS}
scribo_convert_from_qimage_LDFLAGS= ${QT_LDFLAGS} ${AM_LDFLAGS}
scribo_convert_from_qimage_SOURCES = scribo_convert_from_qimage.cc
+scribo_io_xml_load_CPPFLAGS= ${QT_CPPFLAGS} ${AM_CPPFLAGS}
+scribo_io_xml_load_LDFLAGS= ${QT_LDFLAGS} ${AM_LDFLAGS}
+scribo_io_xml_load_SOURCES = scribo_io_xml_load.cc
endif HAVE_QT
# Starting a conditional unit test list.
@@ -79,16 +83,21 @@ scribo_binarization_sauvola_ms \
scribo_binarization_sauvola_ms_split \
scribo_binarization_sauvola_threshold_image \
scribo_canvas_integral_browsing \
+scribo_convert_from_base64 \
+scribo_convert_to_base64 \
scribo_core_all \
scribo_core_central_sites \
scribo_core_component_info \
scribo_core_component_set \
scribo_core_concept_dmax_functor \
scribo_core_concept_link_functor \
+scribo_core_concept_serializable \
+scribo_core_concept_serialize_visitor \
scribo_core_def_lbl_type \
scribo_core_document \
scribo_core_erase_objects \
scribo_core_init_integral_image \
+scribo_core_internal_doc_xml_serializer \
scribo_core_line_info \
scribo_core_line_links \
scribo_core_line_set \
@@ -157,6 +166,11 @@ scribo_fun_v2b_label_to_bool \
scribo_fun_v2b_objects_large_filter \
scribo_fun_v2b_objects_small_filter \
scribo_io_text_boxes_save \
+scribo_io_xml_internal_extended_page_xml_visitor \
+scribo_io_xml_internal_full_xml_visitor \
+scribo_io_xml_internal_page_xml_visitor \
+scribo_io_xml_internal_print_box_coords \
+scribo_io_xml_internal_print_page_preambule \
scribo_io_xml_save \
scribo_make_all \
scribo_make_debug_filename \
@@ -179,7 +193,6 @@ scribo_primitive_extract_all \
scribo_primitive_extract_canvas \
scribo_primitive_extract_cells \
scribo_primitive_extract_components \
-scribo_primitive_extract_elements \
scribo_primitive_extract_horizontal_separators \
scribo_primitive_extract_lines_discontinued \
scribo_primitive_extract_lines_h_discontinued \
@@ -194,6 +207,7 @@ scribo_primitive_extract_lines_v_pattern \
scribo_primitive_extract_lines_v_single \
scribo_primitive_extract_lines_v_thick \
scribo_primitive_extract_lines_v_thick_and_single \
+scribo_primitive_extract_non_text \
scribo_primitive_extract_separators \
scribo_primitive_extract_separators_nonvisible \
scribo_primitive_extract_vertical_separators \
@@ -286,16 +300,21 @@ scribo_binarization_sauvola_ms_SOURCES = scribo_binarization_sauvola_ms.cc
scribo_binarization_sauvola_ms_split_SOURCES = scribo_binarization_sauvola_ms_split.cc
scribo_binarization_sauvola_threshold_image_SOURCES = scribo_binarization_sauvola_threshold_image.cc
scribo_canvas_integral_browsing_SOURCES = scribo_canvas_integral_browsing.cc
+scribo_convert_from_base64_SOURCES = scribo_convert_from_base64.cc
+scribo_convert_to_base64_SOURCES = scribo_convert_to_base64.cc
scribo_core_all_SOURCES = scribo_core_all.cc
scribo_core_central_sites_SOURCES = scribo_core_central_sites.cc
scribo_core_component_info_SOURCES = scribo_core_component_info.cc
scribo_core_component_set_SOURCES = scribo_core_component_set.cc
scribo_core_concept_dmax_functor_SOURCES = scribo_core_concept_dmax_functor.cc
scribo_core_concept_link_functor_SOURCES = scribo_core_concept_link_functor.cc
+scribo_core_concept_serializable_SOURCES = scribo_core_concept_serializable.cc
+scribo_core_concept_serialize_visitor_SOURCES = scribo_core_concept_serialize_visitor.cc
scribo_core_def_lbl_type_SOURCES = scribo_core_def_lbl_type.cc
scribo_core_document_SOURCES = scribo_core_document.cc
scribo_core_erase_objects_SOURCES = scribo_core_erase_objects.cc
scribo_core_init_integral_image_SOURCES = scribo_core_init_integral_image.cc
+scribo_core_internal_doc_xml_serializer_SOURCES = scribo_core_internal_doc_xml_serializer.cc
scribo_core_line_info_SOURCES = scribo_core_line_info.cc
scribo_core_line_links_SOURCES = scribo_core_line_links.cc
scribo_core_line_set_SOURCES = scribo_core_line_set.cc
@@ -364,6 +383,11 @@ scribo_fun_v2b_label_to_bool_SOURCES = scribo_fun_v2b_label_to_bool.cc
scribo_fun_v2b_objects_large_filter_SOURCES = scribo_fun_v2b_objects_large_filter.cc
scribo_fun_v2b_objects_small_filter_SOURCES = scribo_fun_v2b_objects_small_filter.cc
scribo_io_text_boxes_save_SOURCES = scribo_io_text_boxes_save.cc
+scribo_io_xml_internal_extended_page_xml_visitor_SOURCES = scribo_io_xml_internal_extended_page_xml_visitor.cc
+scribo_io_xml_internal_full_xml_visitor_SOURCES = scribo_io_xml_internal_full_xml_visitor.cc
+scribo_io_xml_internal_page_xml_visitor_SOURCES = scribo_io_xml_internal_page_xml_visitor.cc
+scribo_io_xml_internal_print_box_coords_SOURCES = scribo_io_xml_internal_print_box_coords.cc
+scribo_io_xml_internal_print_page_preambule_SOURCES = scribo_io_xml_internal_print_page_preambule.cc
scribo_io_xml_save_SOURCES = scribo_io_xml_save.cc
scribo_make_all_SOURCES = scribo_make_all.cc
scribo_make_debug_filename_SOURCES = scribo_make_debug_filename.cc
@@ -386,7 +410,6 @@ scribo_primitive_extract_all_SOURCES = scribo_primitive_extract_all.cc
scribo_primitive_extract_canvas_SOURCES = scribo_primitive_extract_canvas.cc
scribo_primitive_extract_cells_SOURCES = scribo_primitive_extract_cells.cc
scribo_primitive_extract_components_SOURCES = scribo_primitive_extract_components.cc
-scribo_primitive_extract_elements_SOURCES = scribo_primitive_extract_elements.cc
scribo_primitive_extract_horizontal_separators_SOURCES = scribo_primitive_extract_horizontal_separators.cc
scribo_primitive_extract_lines_discontinued_SOURCES = scribo_primitive_extract_lines_discontinued.cc
scribo_primitive_extract_lines_h_discontinued_SOURCES = scribo_primitive_extract_lines_h_discontinued.cc
@@ -401,6 +424,7 @@ scribo_primitive_extract_lines_v_pattern_SOURCES = scribo_primitive_extract_line
scribo_primitive_extract_lines_v_single_SOURCES = scribo_primitive_extract_lines_v_single.cc
scribo_primitive_extract_lines_v_thick_SOURCES = scribo_primitive_extract_lines_v_thick.cc
scribo_primitive_extract_lines_v_thick_and_single_SOURCES = scribo_primitive_extract_lines_v_thick_and_single.cc
+scribo_primitive_extract_non_text_SOURCES = scribo_primitive_extract_non_text.cc
scribo_primitive_extract_separators_SOURCES = scribo_primitive_extract_separators.cc
scribo_primitive_extract_separators_nonvisible_SOURCES = scribo_primitive_extract_separators_nonvisible.cc
scribo_primitive_extract_vertical_separators_SOURCES = scribo_primitive_extract_vertical_separators.cc
--
1.5.6.5
1
0
* scribo/convert/from_base64.hh: Remove guards HAVE_QT.
* scribo/core/document.hh: Initialize ImageMagick.
* scribo/io/xml/internal/html_markups_replace.hh: Remove. Move code...
* scribo/core/line_info.hh: ... here.
* scribo/core/line_links.hh: Make use of is_textline method.
* scribo/core/paragraph_info.hh: Add nlines method.
* scribo/core/paragraph_set.hh: Add a construction routine using a
line_set.
* scribo/io/xml/internal/extended_page_xml_visitor.hh,
* scribo/io/xml/internal/print_box_coords.hh,
* scribo/io/xml/internal/print_page_preambule.hh,
* src/primitive/extract/separators_nonvisible.cc: Fix includes.
* scribo/io/xml/save.hh: Add a precondition.
* scribo/text/extract_lines.hh,
* src/debug/show_info_median_inter_characters.cc,
* src/debug/show_info_x_height.cc,
* src/debug/show_text_lines.cc: Fix label type.
---
scribo/ChangeLog | 30 ++++++
scribo/scribo/convert/from_base64.hh | 8 --
scribo/scribo/core/document.hh | 1 +
scribo/scribo/core/line_info.hh | 45 ++++++++-
scribo/scribo/core/line_links.hh | 5 +-
scribo/scribo/core/paragraph_info.hh | 9 ++
scribo/scribo/core/paragraph_set.hh | 28 ++++++
.../io/xml/internal/extended_page_xml_visitor.hh | 2 -
.../scribo/io/xml/internal/html_markups_replace.hh | 97 --------------------
scribo/scribo/io/xml/internal/print_box_coords.hh | 3 +
.../scribo/io/xml/internal/print_page_preambule.hh | 5 +
scribo/scribo/io/xml/save.hh | 2 +
scribo/scribo/text/extract_lines.hh | 16 ++--
.../src/debug/show_info_median_inter_characters.cc | 12 +-
scribo/src/debug/show_info_x_height.cc | 12 +-
scribo/src/debug/show_text_lines.cc | 2 +-
.../src/primitive/extract/separators_nonvisible.cc | 2 +-
17 files changed, 143 insertions(+), 136 deletions(-)
delete mode 100644 scribo/scribo/io/xml/internal/html_markups_replace.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 4eae5f8..7c29163 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,33 @@
+2011-03-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Small fixes in Scribo.
+
+ * scribo/convert/from_base64.hh: Remove guards HAVE_QT.
+
+ * scribo/core/document.hh: Initialize ImageMagick.
+
+ * scribo/io/xml/internal/html_markups_replace.hh: Remove. Move code...
+ * scribo/core/line_info.hh: ... here.
+
+ * scribo/core/line_links.hh: Make use of is_textline method.
+
+ * scribo/core/paragraph_info.hh: Add nlines method.
+
+ * scribo/core/paragraph_set.hh: Add a construction routine using a
+ line_set.
+
+ * scribo/io/xml/internal/extended_page_xml_visitor.hh,
+ * scribo/io/xml/internal/print_box_coords.hh,
+ * scribo/io/xml/internal/print_page_preambule.hh,
+ * src/primitive/extract/separators_nonvisible.cc: Fix includes.
+
+ * scribo/io/xml/save.hh: Add a precondition.
+
+ * scribo/text/extract_lines.hh,
+ * src/debug/show_info_median_inter_characters.cc,
+ * src/debug/show_info_x_height.cc,
+ * src/debug/show_text_lines.cc: Fix label type.
+
2011-03-02 Guillaume Lazzara <z(a)lrde.epita.fr>
Regen mk files.
diff --git a/scribo/scribo/convert/from_base64.hh b/scribo/scribo/convert/from_base64.hh
index 8c14a0f..5eeeb53 100644
--- a/scribo/scribo/convert/from_base64.hh
+++ b/scribo/scribo/convert/from_base64.hh
@@ -82,13 +82,9 @@ namespace scribo
Image<I>& output);
-# if defined HAVE_QT
-
template <typename I>
void from_base64(const QString& data64, Image<I>& output_);
-# endif // ! HAVE_QT
-
# ifndef MLN_INCLUDE_ONLY
@@ -191,8 +187,6 @@ namespace scribo
}
-# if defined HAVE_QT
-
template <typename I>
void
from_base64(const QString& data64, Image<I>& output_)
@@ -205,8 +199,6 @@ namespace scribo
trace::exiting("scribo::convert::to_base64");
}
-# endif // ! HAVE_QT
-
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh
index 372f0a4..689d0e3 100644
--- a/scribo/scribo/core/document.hh
+++ b/scribo/scribo/core/document.hh
@@ -160,6 +160,7 @@ namespace scribo
void
document<L>::open()
{
+ Magick::InitializeMagick(0);
mln::io::magick::load(image_, filename_);
}
diff --git a/scribo/scribo/core/line_info.hh b/scribo/scribo/core/line_info.hh
index 33a1529..46ba720 100644
--- a/scribo/scribo/core/line_info.hh
+++ b/scribo/scribo/core/line_info.hh
@@ -35,9 +35,10 @@
/// from the x_height and the baseline.
///
/// \fixme The way the meanline and the baseline are computed is not
-/// optimal and does not work is the components are too high (because
+/// optimal and does not work if the components are too high (because
/// of the median accumulator and int_u12 overflows).
+# include <map>
# include <mln/core/alias/box2d.hh>
# include <mln/core/alias/point2d.hh>
@@ -53,8 +54,6 @@
# include <scribo/core/line_set.hh>
# include <scribo/core/component_set.hh>
-# include <scribo/io/xml/internal/html_markups_replace.hh>
-
# include <scribo/core/concept/serializable.hh>
@@ -287,6 +286,42 @@ namespace scribo
namespace internal
{
+ // INTERNAL TOOLS
+
+ static inline std::map<char, std::string> init_map()
+ {
+ std::map<char, std::string> html_map;
+ html_map['\"'] = """;
+ html_map['<'] = "<";
+ html_map['>'] = ">";
+ html_map['&'] = "&";
+ return html_map;
+ }
+
+
+ inline
+ std::string
+ html_markups_replace(const std::string& input)
+ {
+ static std::map<char, std::string> map = init_map();
+
+ std::string output = input;
+ for (unsigned i = 0; i < input.size(); ++i)
+ {
+ std::map<char, std::string>::iterator it = map.find(output.at(i));
+ if (it != map.end())
+ {
+ output.replace(i, 1, it->second);
+ i += it->second.size() - 1;
+ }
+ }
+ return output;
+ }
+
+
+
+ // LINE INFO DATA
+
template <typename L>
line_info_data<L>::line_info_data()
{
@@ -641,7 +676,7 @@ namespace scribo
line_info<L>::update_text(const std::string& str)
{
data_->text_ = str;
- data_->html_text_ = scribo::io::xml::internal::html_markups_replace(str);
+ data_->html_text_ = scribo::internal::html_markups_replace(str);
}
@@ -869,6 +904,8 @@ namespace scribo
ref_line = mln::math::min(comp_set(c).bbox().pmin().row(), ref_line);
}
+ // FIXME: compute font color!
+
for_all_elements(i, data_->components_)
{
unsigned c = data_->components_(i);
diff --git a/scribo/scribo/core/line_links.hh b/scribo/scribo/core/line_links.hh
index fdd09a5..ab36a73 100644
--- a/scribo/scribo/core/line_links.hh
+++ b/scribo/scribo/core/line_links.hh
@@ -215,9 +215,8 @@ namespace scribo
line_links<L>::init()
{
for (unsigned i = 0; i < nelements(); ++i)
- if (! data_->lines_(i).is_valid()
- || data_->lines_(i).is_hidden()
- || data_->lines_(i).type() != line::Text)
+ if (!data_->lines_(i).is_valid()
+ || !data_->lines_(i).is_textline())
{
data_->line_to_link_(i) = 0;
}
diff --git a/scribo/scribo/core/paragraph_info.hh b/scribo/scribo/core/paragraph_info.hh
index 17f847f..f4b1309 100644
--- a/scribo/scribo/core/paragraph_info.hh
+++ b/scribo/scribo/core/paragraph_info.hh
@@ -52,6 +52,8 @@ namespace scribo
const mln::util::array<line_id_t>& line_ids() const;
+ unsigned nlines() const;
+
bool is_valid() const;
private:
@@ -106,6 +108,13 @@ namespace scribo
}
template <typename L>
+ unsigned
+ paragraph_info<L>::nlines() const
+ {
+ return line_ids_.nelements();
+ }
+
+ template <typename L>
bool
paragraph_info<L>::is_valid() const
{
diff --git a/scribo/scribo/core/paragraph_set.hh b/scribo/scribo/core/paragraph_set.hh
index 5451069..f081472 100644
--- a/scribo/scribo/core/paragraph_set.hh
+++ b/scribo/scribo/core/paragraph_set.hh
@@ -215,6 +215,7 @@ namespace scribo
} // end of namespace scribo::make::internal
+ // FIXME: move that code into paragraph_set constructor?
template <typename L>
scribo::paragraph_set<L>
paragraph(const line_links<L>& llinks)
@@ -241,6 +242,33 @@ namespace scribo
return parset;
}
+
+ // FIXME: move that code into paragraph_set constructor?
+ template <typename L>
+ scribo::paragraph_set<L>
+ paragraph(const scribo::line_set<L>& lines)
+ {
+ line_links<L> links(lines);
+ links.init();
+
+ unsigned npars;
+ mln::fun::i2v::array<unsigned>
+ par_ids = mln::make::relabelfun(links.line_to_link(),
+ links.nelements() - 1, npars);
+ paragraph_set<L> parset(links, npars);
+
+ for_all_links(l, links)
+ if (links(l))
+ {
+ value::int_u16 par_id = par_ids(l);
+ parset(par_id).add_line(lines(l));
+ }
+
+ return parset;
+ }
+
+
+
} // end of namespace scribo::make
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 5d8a672..4da0755 100644
--- a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
+++ b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
@@ -40,8 +40,6 @@
# include <scribo/core/line_links.hh>
# include <scribo/core/line_info.hh>
-# include <scribo/convert/to_base64.hh>
-
# include <scribo/io/xml/internal/print_box_coords.hh>
# include <scribo/io/xml/internal/print_page_preambule.hh>
diff --git a/scribo/scribo/io/xml/internal/html_markups_replace.hh b/scribo/scribo/io/xml/internal/html_markups_replace.hh
deleted file mode 100644
index 76f8107..0000000
--- a/scribo/scribo/io/xml/internal/html_markups_replace.hh
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_IO_XML_INTERNAL_HTML_MARKUPS_REPLACE_HH
-# define SCRIBO_IO_XML_INTERNAL_HTML_MARKUPS_REPLACE_HH
-
-/// \file
-///
-/// \brief Replace HTML markups characters by their corresponding
-/// markups.
-
-
-namespace scribo
-{
-
- namespace io
- {
-
- namespace xml
- {
-
- namespace internal
- {
-
- /*! \brief Replace HTML markups characters by their corresponding
- markups.
- */
- inline
- std::string
- html_markups_replace(std::string& input);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- static inline std::map<char, std::string> init_map()
- {
- std::map<char, std::string> html_map;
- html_map['\"'] = """;
- html_map['<'] = "<";
- html_map['>'] = ">";
- html_map['&'] = "&";
- return html_map;
- }
-
-
- inline
- std::string
- html_markups_replace(const std::string& input)
- {
- static std::map<char, std::string> map = init_map();
-
- std::string output = input;
- for (unsigned i = 0; i < input.size(); ++i)
- {
- std::map<char, std::string>::iterator it = map.find(output.at(i));
- if (it != map.end())
- {
- output.replace(i, 1, it->second);
- i += it->second.size() - 1;
- }
- }
- return output;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::io::xml::internal
-
- } // end of namespace scribo::io::xml
-
- } // end of namespace scribo::io
-
-} // end of namespace scribo
-
-#endif // ! SCRIBO_IO_XML_INTERNAL_HTML_MARKUPS_REPLACE_HH
diff --git a/scribo/scribo/io/xml/internal/print_box_coords.hh b/scribo/scribo/io/xml/internal/print_box_coords.hh
index d3aeedf..ad84709 100644
--- a/scribo/scribo/io/xml/internal/print_box_coords.hh
+++ b/scribo/scribo/io/xml/internal/print_box_coords.hh
@@ -30,6 +30,7 @@
///
/// \brief Prints box2d coordinates to XML data.
+# include <fstream>
# include <mln/core/alias/box2d.hh>
namespace scribo
@@ -44,6 +45,8 @@ namespace scribo
namespace internal
{
+ using namespace mln;
+
/*! \brief Prints box2d coordinates to XML data.
*/
void
diff --git a/scribo/scribo/io/xml/internal/print_page_preambule.hh b/scribo/scribo/io/xml/internal/print_page_preambule.hh
index b5ae891..3ee29be 100644
--- a/scribo/scribo/io/xml/internal/print_page_preambule.hh
+++ b/scribo/scribo/io/xml/internal/print_page_preambule.hh
@@ -30,7 +30,9 @@
///
/// \brief Print PAGE XML format preambule.
+# include <fstream>
# include <mln/core/alias/box2d.hh>
+# include <scribo/core/document.hh>
namespace scribo
{
@@ -44,6 +46,9 @@ namespace scribo
namespace internal
{
+ using namespace mln;
+
+
/// \brief Print PAGE XML format preambule.
template <typename L>
void print_PAGE_preambule(std::ofstream& output,
diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh
index 30579d0..7428e5d 100644
--- a/scribo/scribo/io/xml/save.hh
+++ b/scribo/scribo/io/xml/save.hh
@@ -121,6 +121,8 @@ namespace scribo
{
trace::entering("scribo::io::xml::save");
+ mln_precondition(doc.is_open());
+
// Open file
std::ofstream output(output_name.c_str());
if (! output)
diff --git a/scribo/scribo/text/extract_lines.hh b/scribo/scribo/text/extract_lines.hh
index b81cb79..9949d09 100644
--- a/scribo/scribo/text/extract_lines.hh
+++ b/scribo/scribo/text/extract_lines.hh
@@ -33,8 +33,8 @@
# include <mln/core/concept/image.hh>
-# include <mln/value/int_u16.hh>
+# include <scribo/core/def/lbl_type.hh>
# include <scribo/core/line_set.hh>
# include <scribo/primitive/extract/components.hh>
@@ -71,13 +71,13 @@ namespace scribo
** \return A set of lines.
*/
template <typename I, typename N>
- line_set<mln_ch_value(I,value::int_u16)>
+ line_set<mln_ch_value(I,scribo::def::lbl_type)>
extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_,
const mln_ch_value(I,bool)& separators);
/// \overload
template <typename I, typename N>
- line_set<mln_ch_value(I,value::int_u16)>
+ line_set<mln_ch_value(I,scribo::def::lbl_type)>
extract_lines(const Image<I>& input, const Neighborhood<N>& nbh);
@@ -85,7 +85,7 @@ namespace scribo
template <typename I, typename N>
- line_set<mln_ch_value(I,value::int_u16)>
+ line_set<mln_ch_value(I,scribo::def::lbl_type)>
extract_lines(const Image<I>& input, const Neighborhood<N>& nbh)
{
mln_ch_value(I,bool) seps;
@@ -94,7 +94,7 @@ namespace scribo
template <typename I, typename N>
- line_set<mln_ch_value(I,value::int_u16)>
+ line_set<mln_ch_value(I,scribo::def::lbl_type)>
extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_,
const mln_ch_value(I,bool)& separators)
{
@@ -107,10 +107,10 @@ namespace scribo
mln_precondition(nbh.is_valid());
/// Finding comps.
- typedef mln_ch_value(I,value::int_u16) L;
- value::int_u16 ncomps;
+ typedef mln_ch_value(I,scribo::def::lbl_type) L;
+ scribo::def::lbl_type ncomps;
component_set<L>
- comps = scribo::primitive::extract::components(input, c8(), ncomps);
+ comps = scribo::primitive::extract::components(input, nbh, ncomps);
/// First filtering.
comps = scribo::filter::components_small(comps, 3);
diff --git a/scribo/src/debug/show_info_median_inter_characters.cc b/scribo/src/debug/show_info_median_inter_characters.cc
index b55079d..2ba240e 100644
--- a/scribo/src/debug/show_info_median_inter_characters.cc
+++ b/scribo/src/debug/show_info_median_inter_characters.cc
@@ -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.
//
@@ -35,7 +35,7 @@
#include <mln/io/ppm/save.hh>
#include <mln/value/rgb8.hh>
-#include <mln/value/label_16.hh>
+#include <mln/value/int_u16.hh>
#include <mln/draw/box.hh>
#include <mln/draw/line.hh>
@@ -71,14 +71,14 @@ int main(int argc, char* argv[])
image2d<bool> input;
- io::pbm::load(input, argv[1]);
+ mln::io::pbm::load(input, argv[1]);
- typedef image2d<value::label_16> L;
+ typedef image2d<scribo::def::lbl_type> L;
line_set<L> line = scribo::text::extract_lines(input, c8());
image2d<value::rgb8> output = scribo::debug::char_space_image(input, line);
- io::ppm::save(output, argv[2]);
+ mln::io::ppm::save(output, argv[2]);
trace::exiting("main");
}
diff --git a/scribo/src/debug/show_info_x_height.cc b/scribo/src/debug/show_info_x_height.cc
index e5ff8d2..2997230 100644
--- a/scribo/src/debug/show_info_x_height.cc
+++ b/scribo/src/debug/show_info_x_height.cc
@@ -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.
//
@@ -35,8 +35,8 @@
#include <mln/io/ppm/save.hh>
#include <mln/value/rgb8.hh>
-#include <mln/value/label_16.hh>
+#include <scribo/core/def/lbl_type.hh>
#include <scribo/text/extract_lines.hh>
#include <scribo/debug/line_info_image.hh>
#include <scribo/debug/usage.hh>
@@ -66,14 +66,14 @@ int main(int argc, char* argv[])
image2d<bool> input;
- io::pbm::load(input, argv[1]);
+ mln::io::pbm::load(input, argv[1]);
- typedef image2d<value::label_16> L;
+ typedef image2d<scribo::def::lbl_type> L;
line_set<L> line = scribo::text::extract_lines(input, c8());
image2d<value::rgb8> output = scribo::debug::line_info_image(input, line);
- io::ppm::save(output, argv[2]);
+ mln::io::ppm::save(output, argv[2]);
trace::exiting("main");
}
diff --git a/scribo/src/debug/show_text_lines.cc b/scribo/src/debug/show_text_lines.cc
index a031072..368f375 100644
--- a/scribo/src/debug/show_text_lines.cc
+++ b/scribo/src/debug/show_text_lines.cc
@@ -77,7 +77,7 @@ int main(int argc, char* argv[])
util::timer t;
t.start();
- typedef image2d<value::int_u16> L;
+ typedef image2d<scribo::def::lbl_type> L;
line_set<L> lines = text::extract_lines(input, c8(), input_seps);
t.stop();
diff --git a/scribo/src/primitive/extract/separators_nonvisible.cc b/scribo/src/primitive/extract/separators_nonvisible.cc
index 82d4787..d50cc73 100644
--- a/scribo/src/primitive/extract/separators_nonvisible.cc
+++ b/scribo/src/primitive/extract/separators_nonvisible.cc
@@ -27,7 +27,7 @@
#include <mln/io/pbm/all.hh>
#include <mln/data/convert.hh>
-#include <scribo/primitive/extract/separators_nonvisible2.hh>
+#include <scribo/primitive/extract/separators_nonvisible.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
--
1.5.6.5
1
0