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 icdar/hdlac2011 has been updated
discards 118f203ff8c90a367f78502c3b5ecc1883180f86 (commit)
discards 12da563c7ea1fba00e47b8cdb9adf526421218d2 (commit)
discards ebfb6d5d15d50abe54ce41cb88b243c7b03b1935 (commit)
via 58b6a662ab8baecf54514930cebe761fbd9e0e32 (commit)
via 46636f57bf3f360ae661412a50f2b2a808e14f90 (commit)
via 3a15c0260477b4d491a594cc852f8994dd1eef1d (commit)
via 532805f671d39082c9c62414be4c3266e03609bf (commit)
via 9f7843c9c01df078d600f898bf0ea5d2398aebd1 (commit)
via 0a594b3dad7545235b2997ea4ba4547363f4c1ab (commit)
via eb7b2bd077b0fc4256545e37e19af37ed9c4d25e (commit)
via e32f2ebf7a08cee79f727ac55ea902dbd58cd515 (commit)
via 1d411c7c9dd03993cf3e45f9e2835bba1d1b6e5d (commit)
via e06be54cf5ffe080b2268704caf56e2962ff4d2c (commit)
via f28dd55983ff67c868ef37ddecfc7a29da91c61f (commit)
via 02ab025088bb3639de1f2d934900311915267254 (commit)
via efa07ad7381d92b81cc58e2b0acb780f3922be6e (commit)
via 0d80a703e96d8c16a09f592f4dfa2846eadd696e (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (118f203ff8c90a367f78502c3b5ecc1883180f86)
\
N -- N -- N (58b6a662ab8baecf54514930cebe761fbd9e0e32)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
58b6a66 Improve XML output.
46636f5 Improve and cleanup Results in hdoc toolchain.
3a15c02 scribo/primitive/extract/lines_h_thick_and_thin.hh: Improve result quality.
532805f Add new hooks in toolchain functors.
9f7843c scribo/util/component_precise_outline.hh: New. Precise component outline extraction.
0a594b3 Add new element filters.
eb7b2bd Add util::box_intersection.
e32f2eb mln/draw/site_set.hh: new.
1d411c7 Various small fixes in Scribo.
e06be54 Introduce paragraph_id_t type.
f28dd55 Share document structure data.
02ab025 Deep modifications and clean correction of the previous bug.
efa07ad Further correction of the component outlining bug.
0d80a70 Correct a bug in the compononent outlining algorithm.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 4 +
milena/mln/draw/site_set.hh | 88 ++++++
scribo/ChangeLog | 104 +++++++
scribo/scribo/core/document.hh | 171 +++++++----
scribo/scribo/core/paragraph_info.hh | 15 +-
scribo/scribo/core/paragraph_set.hh | 49 +++-
scribo/scribo/core/tag/line.hh | 2 +-
scribo/scribo/core/tag/paragraph.hh | 43 +++
scribo/scribo/debug/line_info_image.hh | 5 +-
scribo/scribo/filter/images_in_paragraph.hh | 119 ++++++++
scribo/scribo/filter/object_links_bbox_overlap.hh | 25 +--
scribo/scribo/filter/paragraphs_bbox_overlap.hh | 176 +++++++++++
scribo/scribo/filter/paragraphs_in_image.hh | 129 ++++++++
scribo/scribo/filter/separators_in_element.hh | 151 ++++++++++
scribo/scribo/filter/separators_in_paragraph.hh | 151 ++++++++++
scribo/scribo/io/img/internal/debug_img_visitor.hh | 130 +++++----
scribo/scribo/io/img/internal/full_img_visitor.hh | 42 ++--
.../io/xml/internal/extended_page_xml_visitor.hh | 81 +++---
scribo/scribo/io/xml/internal/full_xml_visitor.hh | 79 +++---
scribo/scribo/io/xml/internal/page_xml_visitor.hh | 58 ++--
scribo/scribo/primitive/extract/alignments.hh | 12 +-
.../primitive/extract/lines_h_thick_and_thin.hh | 16 +-
scribo/scribo/primitive/extract/lines_pattern.hh | 2 +-
scribo/scribo/primitive/extract/non_text_hdoc.hh | 34 ++-
.../primitive/extract/separators_nonvisible.hh | 6 +-
.../scribo/primitive/group/from_double_link_any.hh | 7 +-
scribo/scribo/text/link_lines.hh | 2 +-
scribo/scribo/text/merging.hh | 37 ++-
scribo/scribo/text/paragraphs.hh | 18 +-
.../toolchain/internal/content_in_doc_functor.hh | 4 +
.../toolchain/internal/content_in_hdoc_functor.hh | 201 +++++++-------
.../toolchain/internal/text_in_doc_functor.hh | 4 +
.../internal/text_in_doc_preprocess_functor.hh | 53 ++++-
.../scribo/toolchain/internal/toolchain_functor.hh | 28 ++-
scribo/scribo/util/box_intersection.hh | 85 ++++++
scribo/scribo/util/component_precise_outline.hh | 309 ++++++++++++++++++++
.../primitive/extract/lines_h_thick_and_thin.cc | 1 +
scribo/tests/primitive/extract/Makefile.am | 2 +-
38 files changed, 2007 insertions(+), 436 deletions(-)
create mode 100644 milena/mln/draw/site_set.hh
create mode 100644 scribo/scribo/core/tag/paragraph.hh
create mode 100644 scribo/scribo/filter/images_in_paragraph.hh
create mode 100644 scribo/scribo/filter/paragraphs_bbox_overlap.hh
create mode 100644 scribo/scribo/filter/paragraphs_in_image.hh
create mode 100644 scribo/scribo/filter/separators_in_element.hh
create mode 100644 scribo/scribo/filter/separators_in_paragraph.hh
create mode 100644 scribo/scribo/util/box_intersection.hh
create mode 100644 scribo/scribo/util/component_precise_outline.hh
hooks/post-receive
--
Olena, a generic and efficient image processing platform
* scribo/filter/images_in_paragraph.hh,
* scribo/filter/paragraphs_bbox_overlap.hh,
* scribo/filter/paragraphs_in_image.hh,
* scribo/filter/separators_in_element.hh,
* scribo/filter/separators_in_paragraph.hh: New.
---
scribo/ChangeLog | 10 ++
scribo/scribo/filter/images_in_paragraph.hh | 119 +++++++++++++++
scribo/scribo/filter/paragraphs_bbox_overlap.hh | 176 +++++++++++++++++++++++
scribo/scribo/filter/paragraphs_in_image.hh | 129 +++++++++++++++++
scribo/scribo/filter/separators_in_element.hh | 151 +++++++++++++++++++
scribo/scribo/filter/separators_in_paragraph.hh | 151 +++++++++++++++++++
6 files changed, 736 insertions(+), 0 deletions(-)
create mode 100644 scribo/scribo/filter/images_in_paragraph.hh
create mode 100644 scribo/scribo/filter/paragraphs_bbox_overlap.hh
create mode 100644 scribo/scribo/filter/paragraphs_in_image.hh
create mode 100644 scribo/scribo/filter/separators_in_element.hh
create mode 100644 scribo/scribo/filter/separators_in_paragraph.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 959746f..16762ae 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,15 @@
2011-05-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new element filters.
+
+ * scribo/filter/images_in_paragraph.hh,
+ * scribo/filter/paragraphs_bbox_overlap.hh,
+ * scribo/filter/paragraphs_in_image.hh,
+ * scribo/filter/separators_in_element.hh,
+ * scribo/filter/separators_in_paragraph.hh: New.
+
+2011-05-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add util::box_intersection.
* scribo/util/box_intersection.hh: New.
diff --git a/scribo/scribo/filter/images_in_paragraph.hh b/scribo/scribo/filter/images_in_paragraph.hh
new file mode 100644
index 0000000..e05b202
--- /dev/null
+++ b/scribo/scribo/filter/images_in_paragraph.hh
@@ -0,0 +1,119 @@
+// 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_FILTER_IMAGES_IN_PARAGRAPH_HH
+# define SCRIBO_FILTER_IMAGES_IN_PARAGRAPH_HH
+
+/// \file
+///
+/// Invalidate false positive separators.
+/// \fixme Share same test canvas as text::merging.
+
+
+# include <mln/core/concept/image.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/core/document.hh>
+
+
+namespace scribo
+{
+
+ namespace filter
+ {
+
+ using namespace mln;
+
+
+ /// Invalidate false positive separators.
+ ///
+ /// \param[in] separators A paragraph set.
+ ///
+ /// \return A doc with invalidated separators.
+ ///
+ /// Warning: it does not remove separators from separator
+ /// image. It only invalidate separator components in their
+ /// respective component_set.
+ ///
+ template <typename L>
+ void
+ images_in_paragraph(document<L>& doc);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L>
+ void
+ images_in_paragraph(document<L>& doc)
+ {
+ trace::entering("scribo::filter::images_in_paragraph");
+
+ mln_precondition(doc.is_valid());
+
+ if (! doc.has_elements())
+ return;
+
+ mln_ch_value(L,bool) billboard;
+ initialize(billboard, doc.image());
+ data::fill(billboard, false);
+
+ for_all_comps(p, doc.paragraphs())
+ if (doc.paragraphs()(p).is_valid())
+ mln::draw::box_plain(billboard, doc.paragraphs()(p).bbox(), true);
+
+
+ component_set<L> elts = doc.elements();
+ for_all_comps(c, elts)
+ if (elts(c).is_valid() && elts(c).type() == component::Image)
+ {
+ const mln_box(L)& b_ = elts(c).bbox();
+
+ const bool tl = billboard(b_.pmin());
+ const bool tr = billboard.at_(b_.pmin().row(), b_.pmax().col());
+ const bool ml = billboard.at_(b_.pcenter().row(), b_.pmin().col());
+ const bool mc = billboard.at_(b_.pcenter().row(), b_.pcenter().col());
+ const bool mr = billboard.at_(b_.pcenter().row(), b_.pmax().col());
+ const bool bl = billboard.at_(b_.pmax().row(), b_.pmin().col());
+ const bool br = billboard(b_.pmax());
+
+ // This separator is included in an element (picture, drawing...)
+ // => Ignore it.
+ if (tl && tr && ml && mc && mr && bl && br)
+ elts(c).update_tag(component::Ignored);
+
+ // FIXME: warning this call may produce inconsistent data
+ // Ignored components are still in the separator image...
+ doc.set_elements(elts);
+ }
+
+ trace::exiting("scribo::filter::images_in_paragraph");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::filter
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_FILTER_IMAGES_IN_PARAGRAPH_HH
diff --git a/scribo/scribo/filter/paragraphs_bbox_overlap.hh b/scribo/scribo/filter/paragraphs_bbox_overlap.hh
new file mode 100644
index 0000000..aa1c8ac
--- /dev/null
+++ b/scribo/scribo/filter/paragraphs_bbox_overlap.hh
@@ -0,0 +1,176 @@
+// 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_FILTER_PARAGRAPHS_BBOX_OVERLAP_HH
+# define SCRIBO_FILTER_PARAGRAPHS_BBOX_OVERLAP_HH
+
+/// \file
+///
+/// Remove invalid paragraphs.
+/// \fixme Share same test canvas as text::merging.
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/dmorph/image_if.hh>
+# include <mln/data/transform.hh>
+# include <mln/util/array.hh>
+
+# include <scribo/core/paragraph_set.hh>
+
+
+namespace scribo
+{
+
+ namespace filter
+ {
+
+ using namespace mln;
+
+
+ /// Remove invalid paragraphs.
+ ///
+ /// \param[in] paragraphs A paragraph set.
+ ///
+ /// \return A paragraph set with invalid paragraphs tag set to
+ /// Paragraph::Ignored.
+ template <typename L>
+ paragraph_set<L>
+ paragraphs_bbox_overlap(const paragraph_set<L>& paragraphs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename L>
+ struct order_paragraphs_id
+ {
+ order_paragraphs_id(const scribo::paragraph_set<L>& paragraphs)
+ : paragraphs_(paragraphs)
+ {
+ }
+
+ bool operator()(const scribo::paragraph_id_t& l1,
+ const scribo::paragraph_id_t& l2) const
+ {
+ const unsigned l1_nsites = paragraphs_(l1).bbox().nsites();
+ const unsigned l2_nsites = paragraphs_(l2).bbox().nsites();
+
+ if (l1_nsites == l2_nsites)
+ return l1 > l2;
+ return l1_nsites > l2_nsites;
+ }
+
+ scribo::paragraph_set<L> paragraphs_;
+ };
+
+ } // end of namespace scribo::filter::internal
+
+
+ template <typename L>
+ paragraph_set<L>
+ paragraphs_bbox_overlap(const paragraph_set<L>& paragraphs)
+ {
+ trace::entering("scribo::filter::paragraphs_bbox_overlap");
+
+ mln_precondition(paragraphs.is_valid());
+
+ L billboard;
+ initialize(billboard, paragraphs.lines().components().labeled_image());
+ data::fill(billboard, 0);
+
+ mln::util::array<bool> not_to_ignore(paragraphs.nelements() + 1, true);
+ not_to_ignore(0) = false;
+
+ for_all_paragraphs(cur_id, paragraphs)
+ {
+ const box2d& b_ = paragraphs(cur_id).bbox();
+
+ if (paragraphs(cur_id).nlines() > 1)
+ {
+ mln::draw::box_plain(billboard, b_, cur_id);
+ continue;
+ }
+
+ const unsigned tl = billboard(b_.pmin());
+ const unsigned tr = billboard.at_(b_.pmin().row(), b_.pmax().col());
+ const unsigned ml = billboard.at_(b_.pcenter().row(), b_.pmin().col());
+ const unsigned mc = billboard.at_(b_.pcenter().row(), b_.pcenter().col());
+ const unsigned mr = billboard.at_(b_.pcenter().row(), b_.pmax().col());
+ const unsigned bl = billboard.at_(b_.pmax().row(), b_.pmin().col());
+ const unsigned br = billboard(b_.pmax());
+
+ typedef std::set<unsigned> set_t;
+ set_t labels;
+ labels.insert(tl);
+ labels.insert(tl);
+ labels.insert(tr);
+ labels.insert(ml);
+ labels.insert(mc);
+ labels.insert(mr);
+ labels.insert(bl);
+ labels.insert(br);
+
+ for (set_t::const_iterator it = labels.begin();
+ it != labels.end();
+ ++it)
+ if (not_to_ignore(*it))
+ {
+ box2d b2 = paragraphs(*it).bbox();
+ box2d b_i = scribo::util::box_intersection(b_, b2);
+
+ // si b_ est inclus dans une boite donc le nombre de comp > 1 => invalid juste b_
+ // sinon => invalid b_ et b2
+ if ((b_i.nsites() / (float)b_.nsites() > 0.4
+ || (b_i.nsites() / (float)b2.nsites()) > 0.9))
+ {
+ not_to_ignore(cur_id) = false;
+
+ if (paragraphs(*it).nlines() < 4)
+ not_to_ignore(*it) = false;
+ }
+ }
+
+ mln::draw::box_plain(billboard, b_, cur_id);
+ }
+
+ paragraph_set<L> output = paragraphs.duplicate();
+ output.invalidate(not_to_ignore);
+
+ trace::exiting("scribo::filter::paragraphs_bbox_overlap");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::filter
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_FILTER_PARAGRAPHS_BBOX_OVERLAP_HH
diff --git a/scribo/scribo/filter/paragraphs_in_image.hh b/scribo/scribo/filter/paragraphs_in_image.hh
new file mode 100644
index 0000000..1029430
--- /dev/null
+++ b/scribo/scribo/filter/paragraphs_in_image.hh
@@ -0,0 +1,129 @@
+// 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_FILTER_PARAGRAPHS_IN_IMAGE_HH
+# define SCRIBO_FILTER_PARAGRAPHS_IN_IMAGE_HH
+
+/// \file
+///
+/// Remove invalid paragraphs.
+/// \fixme Share same test canvas as text::merging.
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/dmorph/image_if.hh>
+
+# include <mln/data/transform.hh>
+
+# include <mln/util/array.hh>
+
+# include <mln/pw/all.hh>
+
+# include <scribo/core/paragraph_set.hh>
+# include <scribo/fun/v2b/objects_small_filter.hh>
+# include <scribo/primitive/extract/components.hh>
+
+
+namespace scribo
+{
+
+ namespace filter
+ {
+
+ using namespace mln;
+
+
+ /// Remove invalid paragraphs.
+ ///
+ /// \param[in] paragraphs A paragraph set.
+ ///
+ /// \return A paragraph set with invalid paragraphs tag set to
+ /// Paragraph::Ignored.
+ template <typename L>
+ void
+ paragraphs_in_image(document<L>& doc);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L>
+ void
+ paragraphs_in_image(document<L>& doc)
+ {
+ trace::entering("scribo::filter::paragraphs_in_image");
+
+ mln_precondition(doc.has_elements());
+ mln_precondition(doc.has_text());
+
+ image2d<bool> billboard;
+ initialize(billboard, doc.lines().components().labeled_image());
+ data::fill(billboard, false);
+
+ // Draw Image bboxes.
+ for_all_elements(e, doc.elements())
+ if (doc.elements()(e).is_valid()
+ && doc.elements()(e).type() == component::Image)
+ mln::draw::box_plain(billboard, doc.elements()(e).bbox(), true);
+
+ mln::io::pbm::save(billboard, "billboard_parimage.pbm");
+
+ const paragraph_set<L>& parset = doc.paragraphs();
+ mln::util::array<bool> not_to_ignore(parset.nelements() + 1, true);
+ not_to_ignore(0) = false;
+
+ for_all_paragraphs(cur_id, parset)
+ {
+ const box2d& b_ = parset(cur_id).bbox();
+ const bool
+ tl = billboard(b_.pmin()),
+ tr = billboard.at_(b_.pmin().row(), b_.pmax().col()),
+ ml = billboard.at_(b_.pcenter().row(), b_.pmin().col()),
+ mc = billboard.at_(b_.pcenter().row(), b_.pcenter().col()),
+ mr = billboard.at_(b_.pcenter().row(), b_.pmax().col()),
+ bl = billboard.at_(b_.pmax().row(), b_.pmin().col()),
+ br = billboard(b_.pmax());
+
+ // The paragraph is fully included in an image.
+ if (tl && tr && ml && mc && mr && bl && br)
+ not_to_ignore(cur_id) = false;
+ }
+
+ paragraph_set<L> output = parset.duplicate();
+ output.invalidate(not_to_ignore);
+ doc.set_paragraphs(output);
+
+ trace::exiting("scribo::filter::paragraphs_in_image");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::filter
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_FILTER_PARAGRAPHS_IN_IMAGE_HH
diff --git a/scribo/scribo/filter/separators_in_element.hh b/scribo/scribo/filter/separators_in_element.hh
new file mode 100644
index 0000000..228d82f
--- /dev/null
+++ b/scribo/scribo/filter/separators_in_element.hh
@@ -0,0 +1,151 @@
+// 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_FILTER_SEPARATORS_IN_ELEMENT_HH
+# define SCRIBO_FILTER_SEPARATORS_IN_ELEMENT_HH
+
+/// \file
+///
+/// Invalidate false positive separators.
+/// \fixme Share same test canvas as text::merging.
+
+
+# include <mln/core/concept/image.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/core/document.hh>
+
+
+namespace scribo
+{
+
+ namespace filter
+ {
+
+ using namespace mln;
+
+
+ /// Invalidate false positive separators.
+ ///
+ /// \param[in] separators A paragraph set.
+ ///
+ /// \return A doc with invalidated separators.
+ ///
+ /// Warning: it does not remove separators from separator
+ /// image. It only invalidate separator components in their
+ /// respective component_set.
+ ///
+ template <typename L>
+ void
+ separators_in_element(document<L>& doc);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L>
+ void
+ separators_in_element(document<L>& doc)
+ {
+ trace::entering("scribo::filter::separators_in_element");
+
+ mln_precondition(doc.is_valid());
+ mln_precondition(doc.has_elements());
+ mln_precondition(doc.has_hline_seps() || doc.has_vline_seps());
+
+ if ((doc.has_hline_seps() && !doc.hline_seps_comps().nelements())
+ && (doc.has_vline_seps() && !doc.vline_seps_comps().nelements()))
+ return;
+
+ mln_ch_value(L,bool) billboard;
+ initialize(billboard, doc.image());
+ data::fill(billboard, false);
+
+ for_all_comps(e, doc.elements())
+ if (doc.elements()(e).is_valid())
+ mln::draw::box_plain(billboard, doc.elements()(e).bbox(), true);
+
+ // Horizontal separators
+ if (doc.has_hline_seps())
+ {
+ component_set<L> hline = doc.hline_seps_comps().duplicate();
+ for_all_comps(c, hline)
+ {
+ const mln_box(L)& b_ = hline(c).bbox();
+
+ const bool tl = billboard(b_.pmin());
+ const bool tr = billboard.at_(b_.pmin().row(), b_.pmax().col());
+ const bool ml = billboard.at_(b_.pcenter().row(), b_.pmin().col());
+ const bool mc = billboard.at_(b_.pcenter().row(), b_.pcenter().col());
+ const bool mr = billboard.at_(b_.pcenter().row(), b_.pmax().col());
+ const bool bl = billboard.at_(b_.pmax().row(), b_.pmin().col());
+ const bool br = billboard(b_.pmax());
+
+ // This separator is included in an element (picture, drawing...)
+ // => Ignore it.
+ if (tl && tr && ml && mc && mr && bl && br)
+ hline(c).update_tag(component::Ignored);
+
+ // FIXME: warning this call may produce inconsistent data
+ // Ignored components are still in the separator image...
+ doc.set_hline_separators(doc.hline_seps(), hline);
+ }
+ }
+
+ // Vertical separators
+ if (doc.has_vline_seps())
+ {
+ component_set<L> vline = doc.vline_seps_comps().duplicate();
+ for_all_comps(c, vline)
+ {
+ const mln_box(L)& b_ = vline(c).bbox();
+
+ const bool tl = billboard(b_.pmin());
+ const bool tr = billboard.at_(b_.pmin().row(), b_.pmax().col());
+ const bool ml = billboard.at_(b_.pcenter().row(), b_.pmin().col());
+ const bool mc = billboard.at_(b_.pcenter().row(), b_.pcenter().col());
+ const bool mr = billboard.at_(b_.pcenter().row(), b_.pmax().col());
+ const bool bl = billboard.at_(b_.pmax().row(), b_.pmin().col());
+ const bool br = billboard(b_.pmax());
+
+ // This separator is included in an element (picture, drawing...)
+ // => Ignore it.
+ if (tl && tr && ml && mc && mr && bl && br)
+ vline(c).update_tag(component::Ignored);
+
+ // FIXME: warning this call may produce inconsistent data
+ // Ignored components are still in the separator image...
+ doc.set_vline_separators(doc.vline_seps(), vline);
+ }
+
+ trace::exiting("scribo::filter::separators_in_element");
+ }
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::filter
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_FILTER_SEPARATORS_IN_ELEMENT_HH
diff --git a/scribo/scribo/filter/separators_in_paragraph.hh b/scribo/scribo/filter/separators_in_paragraph.hh
new file mode 100644
index 0000000..3e7a150
--- /dev/null
+++ b/scribo/scribo/filter/separators_in_paragraph.hh
@@ -0,0 +1,151 @@
+// 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_FILTER_SEPARATORS_IN_PARAGRAPHS_HH
+# define SCRIBO_FILTER_SEPARATORS_IN_PARAGRAPH_HH
+
+/// \file
+///
+/// Invalidate false positive separators.
+/// \fixme Share same test canvas as text::merging.
+
+
+# include <mln/core/concept/image.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/core/document.hh>
+
+
+namespace scribo
+{
+
+ namespace filter
+ {
+
+ using namespace mln;
+
+
+ /// Invalidate false positive separators.
+ ///
+ /// \param[in] separators A paragraph set.
+ ///
+ /// \return A doc with invalidated separators.
+ ///
+ /// Warning: it does not remove separators from separator
+ /// image. It only invalidate separator components in their
+ /// respective component_set.
+ ///
+ template <typename L>
+ void
+ separators_in_paragraph(document<L>& doc);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L>
+ void
+ separators_in_paragraph(document<L>& doc)
+ {
+ trace::entering("scribo::filter::separators_in_paragraph");
+
+ mln_precondition(doc.is_valid());
+ mln_precondition(doc.has_elements());
+ mln_precondition(doc.has_hline_seps() || doc.has_vline_seps());
+
+ if ((doc.has_hline_seps() && !doc.hline_seps_comps().nelements())
+ && (doc.has_vline_seps() && !doc.vline_seps_comps().nelements()))
+ return;
+
+ mln_ch_value(L,bool) billboard;
+ initialize(billboard, doc.image());
+ data::fill(billboard, false);
+
+ for_all_comps(p, doc.paragraphs())
+ if (doc.paragraphs()(p).is_valid())
+ mln::draw::box_plain(billboard, doc.paragraphs()(p).bbox(), true);
+
+ // Horizontal separators
+ if (doc.has_hline_seps())
+ {
+ component_set<L> hline = doc.hline_seps_comps().duplicate();
+ for_all_comps(c, hline)
+ {
+ const mln_box(L)& b_ = hline(c).bbox();
+
+ const bool tl = billboard(b_.pmin());
+ const bool tr = billboard.at_(b_.pmin().row(), b_.pmax().col());
+ const bool ml = billboard.at_(b_.pcenter().row(), b_.pmin().col());
+ const bool mc = billboard.at_(b_.pcenter().row(), b_.pcenter().col());
+ const bool mr = billboard.at_(b_.pcenter().row(), b_.pmax().col());
+ const bool bl = billboard.at_(b_.pmax().row(), b_.pmin().col());
+ const bool br = billboard(b_.pmax());
+
+ // This separator is included in an element (picture, drawing...)
+ // => Ignore it.
+ if (tl && tr && ml && mc && mr && bl && br)
+ hline(c).update_tag(component::Ignored);
+
+ // FIXME: warning this call may produce inconsistent data
+ // Ignored components are still in the separator image...
+ doc.set_hline_separators(doc.hline_seps(), hline);
+ }
+ }
+
+ // Vertical separators
+ if (doc.has_vline_seps())
+ {
+ component_set<L> vline = doc.vline_seps_comps().duplicate();
+ for_all_comps(c, vline)
+ {
+ const mln_box(L)& b_ = vline(c).bbox();
+
+ const bool tl = billboard(b_.pmin());
+ const bool tr = billboard.at_(b_.pmin().row(), b_.pmax().col());
+ const bool ml = billboard.at_(b_.pcenter().row(), b_.pmin().col());
+ const bool mc = billboard.at_(b_.pcenter().row(), b_.pcenter().col());
+ const bool mr = billboard.at_(b_.pcenter().row(), b_.pmax().col());
+ const bool bl = billboard.at_(b_.pmax().row(), b_.pmin().col());
+ const bool br = billboard(b_.pmax());
+
+ // This separator is included in an element (picture, drawing...)
+ // => Ignore it.
+ if (tl && tr && ml && mc && mr && bl && br)
+ vline(c).update_tag(component::Ignored);
+
+ // FIXME: warning this call may produce inconsistent data
+ // Ignored components are still in the separator image...
+ doc.set_vline_separators(doc.vline_seps(), vline);
+ }
+
+ trace::exiting("scribo::filter::separators_in_paragraph");
+ }
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::filter
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_FILTER_SEPARATORS_IN_PARAGRAPH_HH
--
1.5.6.5
---
milena/ChangeLog | 4 ++
milena/mln/draw/{box_plain.hh => site_set.hh} | 58 +++++++++++-------------
2 files changed, 31 insertions(+), 31 deletions(-)
copy milena/mln/draw/{box_plain.hh => site_set.hh} (61%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e8430cd..8ea11b0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * mln/draw/site_set.hh: new.
+
2011-05-17 Guillaume Lazzara <z(a)lrde.epita.fr>
Add new sample programs.
diff --git a/milena/mln/draw/box_plain.hh b/milena/mln/draw/site_set.hh
similarity index 61%
copy from milena/mln/draw/box_plain.hh
copy to milena/mln/draw/site_set.hh
index ec5b865..1738b16 100644
--- a/milena/mln/draw/box_plain.hh
+++ b/milena/mln/draw/site_set.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,23 +23,17 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_DRAW_BOX_PLAIN_HH
-# define MLN_DRAW_BOX_PLAIN_HH
+#ifndef MLN_DRAW_SITE_SET_HH
+# define MLN_DRAW_SITE_SET_HH
/*! \file
*
- * \brief Draw a plain box in an image.
+ * \brief Draw a site set in an image.
*
- * \fixme Rename as box.hh
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/alias/box2d.hh>
-# include <mln/data/fill.hh>
-# include <mln/draw/line.hh>
-# include <mln/pw/image.hh>
-# include <mln/pw/cst.hh>
-
+# include <mln/core/concept/site_set.hh>
namespace mln
{
@@ -47,39 +41,41 @@ namespace mln
namespace draw
{
- /*! Draw a plain box at value \p v in image \p ima
+ /*! Draw a sites with value \p v in image \p ima
*
* \param[in,out] ima The image to be drawn.
- * \param[in] b the box to draw.
+ * \param[in] b the site set to draw.
* \param[in] v The value to assign to all drawn pixels.
+ * \param[in] output_ratio size ratio between output image and the
+ * image from which the bboxes were calculated.
*
- * \pre \p ima has to be initialized.
- * \pre \p ima has \p beg.
- * \pre \p ima has \p end.
+ * \pre \p s is included in \p ima domain.
*
*/
- template <typename I, typename B>
- void box_plain(Image<I>& ima,
- const Box<B>& b,
- const mln_value(I)& v);
+ template <typename I, typename S>
+ void site_set(Image<I>& ima,
+ const Site_Set<S>& s,
+ const mln_value(I)& v,
+ unsigned output_ratio = 1);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename B>
- inline
- void box_plain(Image<I>& ima,
- const Box<B>& b,
- const mln_value(I)& v)
+ template <typename I, typename S>
+ void site_set(Image<I>& ima_,
+ const Site_Set<S>& s_,
+ const mln_value(I)& v,
+ unsigned output_ratio)
{
mln_precondition(exact(ima).is_valid());
+ mln_precondition(exact(ima).domain() >= exact(s));
- mln_psite(I) pmin = exact(b).pmin();
- mln_psite(I) pmax = exact(b).pmax();
-
- mln_precondition(exact(ima).has(pmin) && exact(ima).has(pmax));
+ I& ima = exact(ima_);
+ const S& s = exact(s_);
- data::fill((ima | b).rw(), v);
+ mln_piter(S) p(s);
+ for_all(p)
+ ima(p / output_ratio) = v;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -89,4 +85,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_DRAW_BOX_PLAIN_HH
+#endif // ! MLN_DRAW_SITE_SET_HH
--
1.5.6.5