* extract/primitive/canvas.hh,
* extract/primitive/cells.hh,
* extract/primitive/lines_discontinued.hh,
* extract/primitive/lines_h_discontinued.hh,
* extract/primitive/lines_h_pattern.hh,
* extract/primitive/lines_h_single.hh,
* extract/primitive/lines_h_thick.hh,
* extract/primitive/lines_pattern.hh,
* extract/primitive/lines_thick.hh,
* extract/primitive/lines_v_discontinued.hh,
* extract/primitive/lines_v_pattern.hh,
* extract/primitive/lines_v_single.hh,
* extract/primitive/lines_v_thick.hh,
* extract/primitive/objects.hh,
* text/grouping/group_from_double_link.hh,
* text/grouping/group_from_graph.hh,
* text/grouping/group_from_single_link.hh,
* text/grouping/group_with_graph.hh,
* text/grouping/group_with_rag.hh,
* text/grouping/group_with_several_graphes.hh,
* text/grouping/group_with_several_left_links.hh,
* text/grouping/group_with_several_right_links.hh,
* text/grouping/group_with_single_left_link.hh,
* text/grouping/group_with_single_right_link.hh,
* text/grouping/internal/find_graph_link.hh,
* text/grouping/internal/find_root.hh,
* text/grouping/internal/have_link_valid.hh,
* text/grouping/internal/init_link_array.hh,
* text/grouping/internal/init_link_array.hh,
* text/grouping/internal/is_link_valid.hh,
* text/grouping/internal/update_link_array.hh: Move...
* primitive/extract/canvas.hh,
* primitive/extract/cells.hh,
* primitive/extract/lines_discontinued.hh,
* primitive/extract/lines_h_discontinued.hh,
* primitive/extract/lines_h_pattern.hh,
* primitive/extract/lines_h_single.hh,
* primitive/extract/lines_h_thick.hh,
* primitive/extract/lines_pattern.hh,
* primitive/extract/lines_thick.hh,
* primitive/extract/lines_v_discontinued.hh,
* primitive/extract/lines_v_pattern.hh,
* primitive/extract/lines_v_single.hh,
* primitive/extract/lines_v_thick.hh,
* primitive/extract/objects.hh,
* primitive/group/from_double_link.hh,
* primitive/group/from_graph.hh,
* primitive/group/from_single_link.hh,
* primitive/internal/find_graph_link.hh,
* primitive/internal/find_root.hh,
* primitive/internal/have_link_valid.hh,
* primitive/internal/init_link_array.hh,
* primitive/internal/is_link_valid.hh,
* primitive/internal/update_graph_link.hh,
* primitive/link/with_graph.hh,
* primitive/link/with_rag.hh,
* primitive/link/with_several_graphes.hh,
* primitive/link/with_several_left_links.hh,
* primitive/link/with_several_right_links.hh,
* primitive/link/with_single_left_link.hh,
* primitive/link/with_single_right_link.hh: ... here.
* text/all.hh,
* all.hh: Update includes.
* draw/bounding_box_links.hh
* filter/large_objects.hh
* filter/small_object_groups.hh
* filter/thick_objects.hh
* filter/thin_objects.hh
* src/extract/primitive/extract_discontinued_hlines.cc
* src/extract/primitive/extract_discontinued_lines.cc
* src/extract/primitive/extract_discontinued_vlines.cc
* src/extract/primitive/extract_thick_hlines.cc
* src/extract/primitive/extract_thick_vlines.cc
* src/extract/primitive/find_discontinued_lines.cc
* src/extract/primitive/find_single_lines.cc
* src/extract/primitive/find_thick_lines.cc
* src/filter/large_objects.cc
* src/filter/small_objects.cc
* src/filter/thick_objects.cc
* src/filter/thin_objects.cc
* src/recognition.cc
* src/table/erase.cc
* src/table_rebuild_opening.cc
* src/table_rebuild_rank.cc
* src/text/grouping/group_from_double_link.cc
* src/text/grouping/group_from_double_several_links.cc
* src/text/grouping/group_from_graph.cc
* src/text/grouping/group_from_rag.cc
* src/text/grouping/group_from_several_graph.cc
* src/text/grouping/group_from_several_left_links.cc
* src/text/grouping/group_from_single_link.cc
* src/text_in_photo.cc
* table/extract.hh
* table/internal/repair_lines.hh
* tests/filter/small_and_large_bboxes.cc
* tests/table/extract_lines_with_rank.cc
* text/extract_lines.hh: Update function calls and includes.
* filter/small_objects.hh: Update function calls and includes, and
use a functor.
* fun/v2b/small_objects_filter.hh: New filter functor.
* tests/unit_test/unit-tests.mk,
* headers.mk: Regen.
* make/influence_zone_graph.hh: Fix wrong namespace.
* primitive/group/apply.hh: New routine.
* primitive/link/all.hh,
* primitive/group/all.hh: New.
* text/grouping/internal/all.hh,
* text/grouping/internal/find_left_link.hh,
* text/grouping/internal/find_right_link.hh,
* text/grouping/internal/init_link_array.hh,
* text/grouping/internal/update_graph_link.hh: Move...
* primitive/internal/all.hh,
* primitive/internal/find_left_link.hh,
* primitive/internal/find_right_link.hh,
* primitive/internal/init_link_array.hh,
* primitive/internal/update_graph_link.hh: ... here.
* primitive/link/merge_double_link.hh: New routine.
---
scribo/ChangeLog | 135 +++++++++++++++++
scribo/all.hh | 1 +
scribo/draw/bounding_box_links.hh | 16 +-
scribo/filter/large_objects.hh | 4 +-
scribo/filter/small_object_groups.hh | 10 +-
scribo/filter/small_objects.hh | 61 +-------
scribo/filter/thick_objects.hh | 4 +-
scribo/filter/thin_objects.hh | 4 +-
scribo/fun/v2b/small_objects_filter.hh | 129 ++++++++++++++++
scribo/headers.mk | 78 ++++++----
scribo/make/influence_zone_graph.hh | 98 ++++++-------
scribo/{ => primitive}/all.hh | 29 ++--
scribo/{text/grouping => primitive/extract}/all.hh | 47 ++++---
.../primitive => primitive/extract}/canvas.hh | 33 ++--
.../primitive => primitive/extract}/cells.hh | 20 ++--
.../extract}/lines_discontinued.hh | 22 ++--
.../extract}/lines_h_discontinued.hh | 16 +-
.../extract}/lines_h_pattern.hh | 19 ++-
.../extract}/lines_h_single.hh | 14 +-
.../extract}/lines_h_thick.hh | 16 +-
.../extract}/lines_pattern.hh | 16 +-
.../primitive => primitive/extract}/lines_thick.hh | 24 ++--
.../extract}/lines_v_discontinued.hh | 16 +-
.../extract}/lines_v_pattern.hh | 19 ++-
.../extract}/lines_v_single.hh | 14 +-
.../extract}/lines_v_thick.hh | 16 +-
.../primitive => primitive/extract}/objects.hh | 19 ++-
scribo/{text => primitive/group}/all.hh | 30 +++--
scribo/primitive/group/apply.hh | 126 ++++++++++++++++
.../group/from_double_link.hh} | 83 ++++-------
.../group/from_graph.hh} | 69 +++++----
.../group/from_single_link.hh} | 50 ++++---
.../internal/all.hh} | 52 +++-----
.../internal/find_graph_link.hh | 93 ++++++------
scribo/primitive/internal/find_left_link.hh | 104 +++++++++++++
scribo/primitive/internal/find_right_link.hh | 105 +++++++++++++
.../grouping => primitive}/internal/find_root.hh | 15 +--
.../internal/have_link_valid.hh} | 53 +++----
.../internal/init_link_array.hh | 39 ++---
.../internal/is_link_valid.hh} | 61 ++++----
scribo/primitive/internal/update_graph_link.hh | 102 +++++++++++++
.../internal/update_link_array.hh | 86 +++++------
scribo/{text => primitive/link}/all.hh | 33 +++--
scribo/primitive/link/merge_double_link.hh | 123 +++++++++++++++
.../link/with_graph.hh} | 30 ++--
.../link/with_rag.hh} | 24 ++--
.../link/with_several_graphes.hh} | 34 ++--
.../link/with_several_left_links.hh} | 46 +++---
.../link/with_several_right_links.hh} | 46 +++---
.../link/with_single_left_link.hh} | 39 +++---
.../link/with_single_right_link.hh} | 39 +++---
.../primitive/extract_discontinued_hlines.cc | 4 +-
.../primitive/extract_discontinued_lines.cc | 8 +-
.../primitive/extract_discontinued_vlines.cc | 4 +-
.../src/extract/primitive/extract_thick_hlines.cc | 4 +-
.../src/extract/primitive/extract_thick_vlines.cc | 4 +-
.../extract/primitive/find_discontinued_lines.cc | 8 +-
scribo/src/extract/primitive/find_single_lines.cc | 12 +-
scribo/src/extract/primitive/find_thick_lines.cc | 16 +-
scribo/src/filter/large_objects.cc | 2 +-
scribo/src/filter/small_objects.cc | 2 +-
scribo/src/filter/thick_objects.cc | 2 +-
scribo/src/filter/thin_objects.cc | 2 +-
scribo/src/recognition.cc | 31 ++--
scribo/src/table/erase.cc | 8 +-
scribo/src/table_rebuild_opening.cc | 8 +-
scribo/src/table_rebuild_rank.cc | 8 +-
scribo/src/text/grouping/group_from_double_link.cc | 30 +++--
.../grouping/group_from_double_several_links.cc | 50 +++----
scribo/src/text/grouping/group_from_graph.cc | 20 ++-
scribo/src/text/grouping/group_from_rag.cc | 10 +-
.../src/text/grouping/group_from_several_graph.cc | 19 ++-
.../text/grouping/group_from_several_left_links.cc | 22 ++-
scribo/src/text/grouping/group_from_single_link.cc | 34 +++--
scribo/src/text_in_photo.cc | 42 +++---
scribo/table/extract.hh | 14 +-
scribo/table/internal/repair_lines.hh | 4 +-
scribo/tests/filter/small_and_large_bboxes.cc | 22 ++--
scribo/tests/table/extract_lines_with_rank.cc | 15 +-
scribo/tests/unit_test/unit-tests.mk | 156 ++++++++++++--------
scribo/text/all.hh | 1 -
scribo/text/extract_lines.hh | 30 +++--
scribo/text/grouping/internal/all.hh | 65 --------
scribo/text/grouping/internal/find_left_link.hh | 107 -------------
scribo/text/grouping/internal/find_right_link.hh | 110 --------------
scribo/text/grouping/internal/update_graph_link.hh | 107 -------------
86 files changed, 1885 insertions(+), 1458 deletions(-)
create mode 100644 scribo/fun/v2b/small_objects_filter.hh
copy scribo/{ => primitive}/all.hh (76%)
rename scribo/{text/grouping => primitive/extract}/all.hh (52%)
rename scribo/{extract/primitive => primitive/extract}/canvas.hh (81%)
rename scribo/{extract/primitive => primitive/extract}/cells.hh (88%)
rename scribo/{extract/primitive => primitive/extract}/lines_discontinued.hh (87%)
rename scribo/{extract/primitive => primitive/extract}/lines_h_discontinued.hh (90%)
rename scribo/{extract/primitive => primitive/extract}/lines_h_pattern.hh (87%)
rename scribo/{extract/primitive => primitive/extract}/lines_h_single.hh (94%)
rename scribo/{extract/primitive => primitive/extract}/lines_h_thick.hh (90%)
rename scribo/{extract/primitive => primitive/extract}/lines_pattern.hh (90%)
rename scribo/{extract/primitive => primitive/extract}/lines_thick.hh (86%)
rename scribo/{extract/primitive => primitive/extract}/lines_v_discontinued.hh (90%)
rename scribo/{extract/primitive => primitive/extract}/lines_v_pattern.hh (86%)
rename scribo/{extract/primitive => primitive/extract}/lines_v_single.hh (94%)
rename scribo/{extract/primitive => primitive/extract}/lines_v_thick.hh (90%)
rename scribo/{extract/primitive => primitive/extract}/objects.hh (89%)
copy scribo/{text => primitive/group}/all.hh (69%)
create mode 100644 scribo/primitive/group/apply.hh
rename scribo/{text/grouping/group_from_double_link.hh =>
primitive/group/from_double_link.hh} (57%)
rename scribo/{text/grouping/group_from_graph.hh => primitive/group/from_graph.hh}
(70%)
rename scribo/{text/grouping/group_from_single_link.hh =>
primitive/group/from_single_link.hh} (68%)
copy scribo/{text/grouping/internal/init_link_array.hh => primitive/internal/all.hh}
(61%)
rename scribo/{text/grouping => primitive}/internal/find_graph_link.hh (51%)
create mode 100644 scribo/primitive/internal/find_left_link.hh
create mode 100644 scribo/primitive/internal/find_right_link.hh
rename scribo/{text/grouping => primitive}/internal/find_root.hh (84%)
rename scribo/{text/grouping/internal/is_link_valid.hh =>
primitive/internal/have_link_valid.hh} (60%)
rename scribo/{text/grouping => primitive}/internal/init_link_array.hh (69%)
rename scribo/{text/grouping/internal/have_link_valid.hh =>
primitive/internal/is_link_valid.hh} (56%)
create mode 100644 scribo/primitive/internal/update_graph_link.hh
rename scribo/{text/grouping => primitive}/internal/update_link_array.hh (52%)
copy scribo/{text => primitive/link}/all.hh (64%)
create mode 100644 scribo/primitive/link/merge_double_link.hh
rename scribo/{text/grouping/group_with_graph.hh => primitive/link/with_graph.hh}
(79%)
rename scribo/{text/grouping/group_with_rag.hh => primitive/link/with_rag.hh} (80%)
rename scribo/{text/grouping/group_with_several_graphes.hh =>
primitive/link/with_several_graphes.hh} (77%)
rename scribo/{text/grouping/group_with_several_left_links.hh =>
primitive/link/with_several_left_links.hh} (76%)
rename scribo/{text/grouping/group_with_several_right_links.hh =>
primitive/link/with_several_right_links.hh} (76%)
rename scribo/{text/grouping/group_with_single_left_link.hh =>
primitive/link/with_single_left_link.hh} (75%)
rename scribo/{text/grouping/group_with_single_right_link.hh =>
primitive/link/with_single_right_link.hh} (73%)
delete mode 100644 scribo/text/grouping/internal/all.hh
delete mode 100644 scribo/text/grouping/internal/find_left_link.hh
delete mode 100644 scribo/text/grouping/internal/find_right_link.hh
delete mode 100644 scribo/text/grouping/internal/update_graph_link.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 0aae996..03925b6 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,140 @@
2009-08-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Mass renaming/cleanup in Scribo.
+
+ * extract/primitive/canvas.hh,
+ * extract/primitive/cells.hh,
+ * extract/primitive/lines_discontinued.hh,
+ * extract/primitive/lines_h_discontinued.hh,
+ * extract/primitive/lines_h_pattern.hh,
+ * extract/primitive/lines_h_single.hh,
+ * extract/primitive/lines_h_thick.hh,
+ * extract/primitive/lines_pattern.hh,
+ * extract/primitive/lines_thick.hh,
+ * extract/primitive/lines_v_discontinued.hh,
+ * extract/primitive/lines_v_pattern.hh,
+ * extract/primitive/lines_v_single.hh,
+ * extract/primitive/lines_v_thick.hh,
+ * extract/primitive/objects.hh,
+ * text/grouping/group_from_double_link.hh,
+ * text/grouping/group_from_graph.hh,
+ * text/grouping/group_from_single_link.hh,
+ * text/grouping/group_with_graph.hh,
+ * text/grouping/group_with_rag.hh,
+ * text/grouping/group_with_several_graphes.hh,
+ * text/grouping/group_with_several_left_links.hh,
+ * text/grouping/group_with_several_right_links.hh,
+ * text/grouping/group_with_single_left_link.hh,
+ * text/grouping/group_with_single_right_link.hh,
+ * text/grouping/internal/find_graph_link.hh,
+ * text/grouping/internal/find_root.hh,
+ * text/grouping/internal/have_link_valid.hh,
+ * text/grouping/internal/init_link_array.hh,
+ * text/grouping/internal/init_link_array.hh,
+ * text/grouping/internal/is_link_valid.hh,
+ * text/grouping/internal/update_link_array.hh: Move...
+
+ * primitive/extract/canvas.hh,
+ * primitive/extract/cells.hh,
+ * primitive/extract/lines_discontinued.hh,
+ * primitive/extract/lines_h_discontinued.hh,
+ * primitive/extract/lines_h_pattern.hh,
+ * primitive/extract/lines_h_single.hh,
+ * primitive/extract/lines_h_thick.hh,
+ * primitive/extract/lines_pattern.hh,
+ * primitive/extract/lines_thick.hh,
+ * primitive/extract/lines_v_discontinued.hh,
+ * primitive/extract/lines_v_pattern.hh,
+ * primitive/extract/lines_v_single.hh,
+ * primitive/extract/lines_v_thick.hh,
+ * primitive/extract/objects.hh,
+ * primitive/group/from_double_link.hh,
+ * primitive/group/from_graph.hh,
+ * primitive/group/from_single_link.hh,
+ * primitive/internal/find_graph_link.hh,
+ * primitive/internal/find_root.hh,
+ * primitive/internal/have_link_valid.hh,
+ * primitive/internal/init_link_array.hh,
+ * primitive/internal/is_link_valid.hh,
+ * primitive/internal/update_graph_link.hh,
+ * primitive/link/with_graph.hh,
+ * primitive/link/with_rag.hh,
+ * primitive/link/with_several_graphes.hh,
+ * primitive/link/with_several_left_links.hh,
+ * primitive/link/with_several_right_links.hh,
+ * primitive/link/with_single_left_link.hh,
+ * primitive/link/with_single_right_link.hh: ... here.
+
+ * text/all.hh,
+ * all.hh: Update includes.
+
+ * draw/bounding_box_links.hh
+ * filter/large_objects.hh
+ * filter/small_object_groups.hh
+ * filter/thick_objects.hh
+ * filter/thin_objects.hh
+ * src/extract/primitive/extract_discontinued_hlines.cc
+ * src/extract/primitive/extract_discontinued_lines.cc
+ * src/extract/primitive/extract_discontinued_vlines.cc
+ * src/extract/primitive/extract_thick_hlines.cc
+ * src/extract/primitive/extract_thick_vlines.cc
+ * src/extract/primitive/find_discontinued_lines.cc
+ * src/extract/primitive/find_single_lines.cc
+ * src/extract/primitive/find_thick_lines.cc
+ * src/filter/large_objects.cc
+ * src/filter/small_objects.cc
+ * src/filter/thick_objects.cc
+ * src/filter/thin_objects.cc
+ * src/recognition.cc
+ * src/table/erase.cc
+ * src/table_rebuild_opening.cc
+ * src/table_rebuild_rank.cc
+ * src/text/grouping/group_from_double_link.cc
+ * src/text/grouping/group_from_double_several_links.cc
+ * src/text/grouping/group_from_graph.cc
+ * src/text/grouping/group_from_rag.cc
+ * src/text/grouping/group_from_several_graph.cc
+ * src/text/grouping/group_from_several_left_links.cc
+ * src/text/grouping/group_from_single_link.cc
+ * src/text_in_photo.cc
+ * table/extract.hh
+ * table/internal/repair_lines.hh
+ * tests/filter/small_and_large_bboxes.cc
+ * tests/table/extract_lines_with_rank.cc
+ * text/extract_lines.hh: Update function calls and includes.
+
+ * filter/small_objects.hh: Update function calls and includes, and
+ use a functor.
+
+ * fun/v2b/small_objects_filter.hh: New filter functor.
+
+ * tests/unit_test/unit-tests.mk,
+ * headers.mk: Regen.
+
+ * make/influence_zone_graph.hh: Fix wrong namespace.
+
+ * primitive/group/apply.hh: New routine.
+
+ * primitive/link/all.hh,
+ * primitive/group/all.hh: New.
+
+
+ * text/grouping/internal/all.hh,
+ * text/grouping/internal/find_left_link.hh,
+ * text/grouping/internal/find_right_link.hh,
+ * text/grouping/internal/init_link_array.hh,
+ * text/grouping/internal/update_graph_link.hh: Move...
+
+ * primitive/internal/all.hh,
+ * primitive/internal/find_left_link.hh,
+ * primitive/internal/find_right_link.hh,
+ * primitive/internal/init_link_array.hh,
+ * primitive/internal/update_graph_link.hh: ... here.
+
+ * primitive/link/merge_double_link.hh: New routine.
+
+2009-08-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Set specific cxxflags for tests in Scribo.
* scribo.mk: Set optimization flags in AM_CXXFLAGS.
diff --git a/scribo/all.hh b/scribo/all.hh
index 8fadbb2..4debad0 100644
--- a/scribo/all.hh
+++ b/scribo/all.hh
@@ -43,6 +43,7 @@ namespace scribo
# include <scribo/filter/all.hh>
# include <scribo/make/all.hh>
# include <scribo/preprocessing/all.hh>
+# include <scribo/primitive/all.hh>
# include <scribo/table/all.hh>
# include <scribo/text/all.hh>
# include <scribo/util/all.hh>
diff --git a/scribo/draw/bounding_box_links.hh b/scribo/draw/bounding_box_links.hh
index 908da17..15e7260 100644
--- a/scribo/draw/bounding_box_links.hh
+++ b/scribo/draw/bounding_box_links.hh
@@ -36,7 +36,7 @@
# include <mln/canvas/browsing/depth_first_search.hh>
# include <scribo/core/macros.hh>
-# include <scribo/text/grouping/internal/is_link_valid.hh>
+# include <scribo/primitive/internal/is_link_valid.hh>
namespace scribo
{
@@ -228,7 +228,7 @@ namespace scribo
std::vector<bool> deja_vu;
};
- } // end of namespace scribo::text::grouping::internal
+ } // end of namespace scribo::draw::internal
template <typename I>
@@ -322,9 +322,9 @@ namespace scribo
right_link_value);
mln::util::couple<bool, unsigned>
- nbh = text::grouping::internal::is_link_valid(left_link,
- right_link,
- i);
+ nbh = primitive::internal::is_link_valid(left_link,
+ right_link,
+ i);
if (nbh.first())
mln::draw::line(input,
@@ -372,9 +372,9 @@ namespace scribo
right_link_value);
mln::util::couple<bool, unsigned>
- nbh = text::grouping::internal::is_link_valid(left_link,
- right_link,
- i);
+ nbh = primitive::internal::is_link_valid(left_link,
+ right_link,
+ i);
if (nbh.first())
mln::draw::line(input,
diff --git a/scribo/filter/large_objects.hh b/scribo/filter/large_objects.hh
index e7e4f25..4494965 100644
--- a/scribo/filter/large_objects.hh
+++ b/scribo/filter/large_objects.hh
@@ -43,7 +43,7 @@
# include <mln/pw/all.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/objects.hh>
+# include <scribo/primitive/extract/objects.hh>
namespace scribo
{
@@ -154,7 +154,7 @@ namespace scribo
V nlabels;
typedef object_image(mln_ch_value(I,V)) lbl_t;
- lbl_t lbl = extract::primitive::objects(input, nbh, nlabels);
+ lbl_t lbl = primitive::extract::objects(input, nbh, nlabels);
typedef internal::large_objects_filter<lbl_t> func_t;
func_t fv2b(lbl, max_size);
diff --git a/scribo/filter/small_object_groups.hh b/scribo/filter/small_object_groups.hh
index 7f10e1d..5fa5ee3 100644
--- a/scribo/filter/small_object_groups.hh
+++ b/scribo/filter/small_object_groups.hh
@@ -33,6 +33,8 @@
# include <mln/util/array.hh>
+# include <scribo/core/object_groups.hh>
+
namespace scribo
{
@@ -45,24 +47,26 @@ namespace scribo
/*! \brief Remove objects within a group with less than \p n
links.
- \param[in] parent_link Information about object links.
+ \param[in] groups Information about object groups.
\param[in] n_links The minimum number of links per group.
\return A function mapping an object id to a bool. It is set to
true if an object is part of a group with more than \p n_links
links.
*/
+ template <typename L>
mln::util::array<bool>
- small_object_groups(const mln::util::array<unsigned>& parent_link,
+ small_object_groups(const object_groups<L>& groups,
unsigned n_links);
# ifndef MLN_INCLUDE_ONLY
+ template <typename L>
inline
mln::util::array<bool>
- small_object_groups(const mln::util::array<unsigned>& parent_link,
+ small_object_groups(const object_groups<L>& parent_link,
unsigned n_links)
{
// Counting the number of objects per group.
diff --git a/scribo/filter/small_objects.hh b/scribo/filter/small_objects.hh
index 006827a..d6d7113 100644
--- a/scribo/filter/small_objects.hh
+++ b/scribo/filter/small_objects.hh
@@ -48,8 +48,10 @@
# include <mln/set/compute.hh>
+
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/objects.hh>
+# include <scribo/fun/v2b/small_objects_filter.hh>
+# include <scribo/primitive/extract/objects.hh>
namespace scribo
@@ -93,57 +95,6 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
-
- /// Filter Functor.
- /// Return false for all objects which are too small.
- template <typename L>
- struct small_objects_filter
- : Function_v2b< small_objects_filter<L> >
- {
- typedef accu::math::count<mln_psite(L)> card_t;
-
- /// Constructor
- ///
- /// \param[in] objects Component bounding boxes.
- /// \param[in] min_size Minimum component size.
- //
- small_objects_filter(const object_image(L)& objects,
- unsigned min_size)
- {
- card_ = labeling::compute(card_t(), objects, objects.nlabels());
- min_size_ = min_size;
- }
-
-
- /// Check if the component is large enough.
- ///
- /// \param l A label.
- ///
- /// \return false if the component area is strictly inferion to
- /// \p min_size_.
- //
- bool operator()(const mln_value(L)& l) const
- {
- if (l == literal::zero)
- return true;
- return card_[l] >= min_size_;
- }
-
- /// The component bounding boxes.
- mln::util::array<mln_result(card_t)> card_;
-
- /// The minimum area.
- unsigned min_size_;
- };
-
-
- } // end of namespace scribo::filter::internal
-
-
-
template <typename I, typename N, typename V>
inline
mln_concrete(I)
@@ -162,9 +113,9 @@ namespace scribo
V nlabels;
typedef mln_ch_value(I,V) lbl_t;
- object_image(lbl_t) lbl = extract::primitive::objects(input, nbh, nlabels);
+ object_image(lbl_t) lbl = primitive::extract::objects(input, nbh, nlabels);
- typedef internal::small_objects_filter<mln_ch_value(I,V)> func_t;
+ typedef fun::v2b::small_objects_filter<mln_ch_value(I,V)> func_t;
func_t fv2b(lbl, min_size);
lbl.relabel(fv2b);
@@ -187,7 +138,7 @@ namespace scribo
mln_precondition(objects.is_valid());
- internal::small_objects_filter<L> f(objects, min_size);
+ fun::v2b::small_objects_filter<L> f(objects, min_size);
object_image(L) output;
output.init_from_(objects);
diff --git a/scribo/filter/thick_objects.hh b/scribo/filter/thick_objects.hh
index 15b4c78..2cb1f30 100644
--- a/scribo/filter/thick_objects.hh
+++ b/scribo/filter/thick_objects.hh
@@ -36,7 +36,7 @@
# include <mln/util/array.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/objects.hh>
+# include <scribo/primitive/extract/objects.hh>
@@ -146,7 +146,7 @@ namespace scribo
V nlabels;
typedef mln_ch_value(I,V) lbl_t;
object_image(lbl_t) objects
- = extract::primitive::objects(input, nbh, nlabels);
+ = primitive::extract::objects(input, nbh, nlabels);
typedef internal::thick_object_filter<lbl_t> func_t;
func_t fv2b(objects, max_thickness);
diff --git a/scribo/filter/thin_objects.hh b/scribo/filter/thin_objects.hh
index 867be28..2149a38 100644
--- a/scribo/filter/thin_objects.hh
+++ b/scribo/filter/thin_objects.hh
@@ -36,7 +36,7 @@
# include <mln/util/array.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/objects.hh>
+# include <scribo/primitive/extract/objects.hh>
namespace scribo
{
@@ -144,7 +144,7 @@ namespace scribo
V nlabels;
typedef mln_ch_value(I,V) lbl_t;
object_image(lbl_t) objects
- = extract::primitive::objects(input, nbh, nlabels);
+ = primitive::extract::objects(input, nbh, nlabels);
typedef internal::thin_objects_filter<lbl_t> func_t;
func_t fv2b(objects, min_thickness);
diff --git a/scribo/fun/v2b/small_objects_filter.hh
b/scribo/fun/v2b/small_objects_filter.hh
new file mode 100644
index 0000000..477bd47
--- /dev/null
+++ b/scribo/fun/v2b/small_objects_filter.hh
@@ -0,0 +1,129 @@
+// Copyright (C) 2009 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_FUN_V2B_SMALL_OBJECTS_FILTER_HH
+# define SCRIBO_FUN_V2B_SMALL_OBJECTS_FILTER_HH
+
+/// \file
+///
+/// Remove small objects in a binary image.
+
+
+
+# include <mln/core/concept/function.hh>
+
+# include <mln/util/array.hh>
+
+# include <mln/accu/math/count.hh>
+
+# include <mln/labeling/compute.hh>
+
+# include <scribo/core/object_image.hh>
+
+
+namespace scribo
+{
+
+ namespace fun
+ {
+
+ namespace v2b
+ {
+
+ using namespace mln;
+
+
+ /// Filter Functor.
+ /// Return false for all objects which are too small.
+ template <typename L>
+ struct small_objects_filter
+ : Function_v2b< small_objects_filter<L> >
+ {
+ typedef accu::math::count<mln_psite(L)> card_t;
+
+ /// Constructor
+ ///
+ /// \param[in] objects Component bounding boxes.
+ /// \param[in] min_size Minimum component size.
+ //
+ small_objects_filter(const object_image(L)& objects,
+ unsigned min_size);
+
+
+ /// Check if the component is large enough.
+ ///
+ /// \param l A label.
+ ///
+ /// \return false if the component area is strictly inferion to
+ /// \p min_size_.
+ //
+ bool operator()(const mln_value(L)& l) const;
+
+ /// The component bounding boxes.
+ mln::util::array<mln_result(card_t)> card_;
+
+ /// The minimum area.
+ unsigned min_size_;
+ };
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename L>
+ inline
+ small_objects_filter<L>::small_objects_filter(
+ const object_image(L)& objects,
+ unsigned min_size)
+ {
+ card_ = labeling::compute(card_t(), objects, objects.nlabels());
+ min_size_ = min_size;
+ }
+
+
+
+ template <typename L>
+ inline
+ bool
+ small_objects_filter<L>::operator()(const mln_value(L)& l) const
+ {
+ if (l == literal::zero)
+ return true;
+ return card_[l] >= min_size_;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace scribo::fun::v2b
+
+ } // end of namespace scribo::fun
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_FILTER_SMALL_OBJECTS_HH
diff --git a/scribo/headers.mk b/scribo/headers.mk
index 0aa7b35..c266c78 100644
--- a/scribo/headers.mk
+++ b/scribo/headers.mk
@@ -7,7 +7,9 @@ nobase_scribo_HEADERS = \
./core/central_sites.hh \
./core/erase_objects.hh \
./core/macros.hh \
+./core/object_groups.hh \
./core/object_image.hh \
+./core/object_links.hh \
./debug/all.hh \
./debug/save_bboxes_image.hh \
./debug/save_label_image.hh \
@@ -18,18 +20,6 @@ nobase_scribo_HEADERS = \
./draw/all.hh \
./draw/bounding_box_links.hh \
./draw/bounding_boxes.hh \
-./extract/primitive/canvas.hh \
-./extract/primitive/cells.hh \
-./extract/primitive/lines_discontinued.hh \
-./extract/primitive/lines_h_discontinued.hh \
-./extract/primitive/lines_h_pattern.hh \
-./extract/primitive/lines_h_thick.hh \
-./extract/primitive/lines_pattern.hh \
-./extract/primitive/lines_thick.hh \
-./extract/primitive/lines_v_discontinued.hh \
-./extract/primitive/lines_v_pattern.hh \
-./extract/primitive/lines_v_thick.hh \
-./extract/primitive/objects.hh \
./filter/all.hh \
./filter/large_objects.hh \
./filter/small_object_groups.hh \
@@ -43,6 +33,49 @@ nobase_scribo_HEADERS = \
./make/text.hh \
./preprocessing/all.hh \
./preprocessing/unskew.hh \
+./primitive/all.hh \
+./primitive/extract/all.hh \
+./primitive/extract/canvas.hh \
+./primitive/extract/cells.hh \
+./primitive/extract/lines_discontinued.hh \
+./primitive/extract/lines_h_discontinued.hh \
+./primitive/extract/lines_h_pattern.hh \
+./primitive/extract/lines_h_single.hh \
+./primitive/extract/lines_h_thick.hh \
+./primitive/extract/lines_pattern.hh \
+./primitive/extract/lines_thick.hh \
+./primitive/extract/lines_v_discontinued.hh \
+./primitive/extract/lines_v_pattern.hh \
+./primitive/extract/lines_v_single.hh \
+./primitive/extract/lines_v_thick.hh \
+./primitive/extract/objects.hh \
+./primitive/group/all.hh \
+./primitive/group/apply.hh \
+./primitive/group/filter_non_aligned.hh \
+./primitive/group/filter_non_h_aligned.hh \
+./primitive/group/filter_non_v_aligned.hh \
+./primitive/group/from_double_link.hh \
+./primitive/group/from_graph.hh \
+./primitive/group/from_single_link.hh \
+./primitive/internal/all.hh \
+./primitive/internal/find_graph_link.hh \
+./primitive/internal/find_left_link.hh \
+./primitive/internal/find_right_link.hh \
+./primitive/internal/find_root.hh \
+./primitive/internal/have_link_valid.hh \
+./primitive/internal/init_link_array.hh \
+./primitive/internal/is_link_valid.hh \
+./primitive/internal/update_graph_link.hh \
+./primitive/internal/update_link_array.hh \
+./primitive/link/all.hh \
+./primitive/link/merge_double_link.hh \
+./primitive/link/with_graph.hh \
+./primitive/link/with_rag.hh \
+./primitive/link/with_several_graphes.hh \
+./primitive/link/with_several_left_links.hh \
+./primitive/link/with_several_right_links.hh \
+./primitive/link/with_single_left_link.hh \
+./primitive/link/with_single_right_link.hh \
./table/align_lines_horizontaly.hh \
./table/align_lines_verticaly.hh \
./table/all.hh \
@@ -60,27 +93,6 @@ nobase_scribo_HEADERS = \
./text/all.hh \
./text/clean.hh \
./text/extract_lines.hh \
-./text/grouping/all.hh \
-./text/grouping/group_from_double_link.hh \
-./text/grouping/group_from_graph.hh \
-./text/grouping/group_from_single_link.hh \
-./text/grouping/group_with_graph.hh \
-./text/grouping/group_with_rag.hh \
-./text/grouping/group_with_several_graphes.hh \
-./text/grouping/group_with_several_left_links.hh \
-./text/grouping/group_with_several_right_links.hh \
-./text/grouping/group_with_single_left_link.hh \
-./text/grouping/group_with_single_right_link.hh \
-./text/grouping/internal/all.hh \
-./text/grouping/internal/find_graph_link.hh \
-./text/grouping/internal/find_left_link.hh \
-./text/grouping/internal/find_right_link.hh \
-./text/grouping/internal/find_root.hh \
-./text/grouping/internal/have_link_valid.hh \
-./text/grouping/internal/init_link_array.hh \
-./text/grouping/internal/is_link_valid.hh \
-./text/grouping/internal/update_graph_link.hh \
-./text/grouping/internal/update_link_array.hh \
./text/recognition.hh \
./util/all.hh \
./util/text.hh
diff --git a/scribo/make/influence_zone_graph.hh b/scribo/make/influence_zone_graph.hh
index ca0d6fb..c01fba1 100644
--- a/scribo/make/influence_zone_graph.hh
+++ b/scribo/make/influence_zone_graph.hh
@@ -48,72 +48,66 @@
namespace scribo
{
- namespace text
+ namespace make
{
-
- namespace grouping
- {
-
- using namespace mln;
-
-
- /// Compute a labeled image of input, then compute an influence
- /// zone image and make a graph from it.
- ///
- /// \param[in] input_ a binary image.
- /// \param[in] nbh_ a neighbordhood.
- /// \param[in] label_type The type of this argument is used
- /// as label type while labeling the image.
- /// \param[in] iz_dmax Max distance of the influence zone.
- ///
- /// \return a region adjacency graph.
- template <typename I, typename N, typename V>
- util::graph
- influence_zone_graph(const Image<I>& input_,
- const Neighborhood<N>& nbh_,
- const V& label_type,
- unsigned iz_dmax);
+ using namespace mln;
+
+
+ /// Compute a labeled image of input, then compute an influence
+ /// zone image and make a graph from it.
+ ///
+ /// \param[in] input_ a binary image.
+ /// \param[in] nbh_ a neighbordhood.
+ /// \param[in] label_type The type of this argument is used
+ /// as label type while labeling the image.
+ /// \param[in] iz_dmax Max distance of the influence zone.
+ ///
+ /// \return a region adjacency graph.
+ template <typename I, typename N, typename V>
+ util::graph
+ influence_zone_graph(const Image<I>& input_,
+ const Neighborhood<N>& nbh_,
+ const V& label_type,
+ unsigned iz_dmax);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N, typename V>
- util::graph
- influence_zone_graph(const Image<I>& input_,
- const Neighborhood<N>& nbh_,
- const V& label_type,
- unsigned iz_dmax)
- {
- trace::entering("scribo::make::influence_zone_graph");
+ template <typename I, typename N, typename V>
+ util::graph
+ influence_zone_graph(const Image<I>& input_,
+ const Neighborhood<N>& nbh_,
+ const V& label_type,
+ unsigned iz_dmax)
+ {
+ trace::entering("scribo::make::influence_zone_graph");
- (void) label_type;
- I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ (void) label_type;
+ I& input = exact(input_);
+ const N& nbh = exact(nbh_);
- mlc_equal(mln_value(I), bool)::check();
- mln_assertion(input.is_valid());
- mln_assertion(nbh.is_valid());
+ mlc_equal(mln_value(I), bool)::check();
+ mln_assertion(input.is_valid());
+ mln_assertion(nbh.is_valid());
- V nlabels;
- typedef mln_ch_value(I,V) lbl_t;
- lbl_t lbl = labeling::blobs(input, nbh, nlabels);
+ V nlabels;
+ typedef mln_ch_value(I,V) lbl_t;
+ lbl_t lbl = labeling::blobs(input, nbh, nlabels);
- lbl_t iz = transform::influence_zone_geodesic(lbl, nbh, iz_dmax);
+ lbl_t iz = transform::influence_zone_geodesic(lbl, nbh, iz_dmax);
- util::graph g
- = mln::make::influence_zone_adjacency_graph(
- iz | (pw::value(iz) != pw::cst(literal::zero)),
- nbh, nlabels);
+ util::graph g
+ = mln::make::influence_zone_adjacency_graph(
+ iz | (pw::value(iz) != pw::cst(literal::zero)),
+ nbh, nlabels);
- trace::exiting("scribo::make::influence_zone_graph");
- return g;
- }
+ trace::exiting("scribo::make::influence_zone_graph");
+ return g;
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
-
- } // end of namespace scribo::text
+ } // end of namespace scribo::make
} // end of namespace scribo
diff --git a/scribo/all.hh b/scribo/primitive/all.hh
similarity index 76%
copy from scribo/all.hh
copy to scribo/primitive/all.hh
index 8fadbb2..3eb72d7 100644
--- a/scribo/all.hh
+++ b/scribo/primitive/all.hh
@@ -23,28 +23,29 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_ALL_HH
-# define SCRIBO_ALL_HH
+#ifndef SCRIBO_PRIMITIVE_ALL_HH
+# define SCRIBO_PRIMITIVE_ALL_HH
/// \file
///
-/// Include all headers located in scribo/.
+/// Include all headers located in scribo/primitive.
/// Namespace of the whole project.
namespace scribo
{
+ /// Namespace of primitive related routines.
+ namespace primitive
+ {
+ }
+
} // end of namespace scribo
-# include <scribo/core/all.hh>
-# include <scribo/debug/all.hh>
-# include <scribo/draw/all.hh>
-# include <scribo/filter/all.hh>
-# include <scribo/make/all.hh>
-# include <scribo/preprocessing/all.hh>
-# include <scribo/table/all.hh>
-# include <scribo/text/all.hh>
-# include <scribo/util/all.hh>
-
-#endif // ! SCRIBO_ALL_HH
+
+# include <scribo/primitive/extract/all.hh>
+# include <scribo/primitive/group/all.hh>
+# include <scribo/primitive/internal/all.hh>
+# include <scribo/primitive/link/all.hh>
+
+#endif // ! SCRIBO_PRIMITIVE_ALL_HH
diff --git a/scribo/text/grouping/all.hh b/scribo/primitive/extract/all.hh
similarity index 52%
rename from scribo/text/grouping/all.hh
rename to scribo/primitive/extract/all.hh
index a4a664c..de1688e 100644
--- a/scribo/text/grouping/all.hh
+++ b/scribo/primitive/extract/all.hh
@@ -23,40 +23,45 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_ALL_HH
-# define SCRIBO_TEXT_GROUPING_ALL_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_ALL_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_ALL_HH
/// \file
///
-/// Include all headers located in scribo/text/grouping.
+/// Include all headers located in scribo/primitive.
+
+/// Namespace of the whole project.
namespace scribo
{
- namespace text
+ namespace primitive
{
- /// Namespace of routines grouping text components.
- namespace grouping
+ /// Namespace of primitive extraction related routines.
+ namespace extract
{
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
+# include <scribo/primitive/extract/lines_pattern.hh>
+# include <scribo/primitive/extract/canvas.hh>
+# include <scribo/primitive/extract/lines_h_thick.hh>
+# include <scribo/primitive/extract/lines_h_single.hh>
+# include <scribo/primitive/extract/lines_v_single.hh>
+# include <scribo/primitive/extract/lines_discontinued.hh>
+# include <scribo/primitive/extract/all.hh>
+# include <scribo/primitive/extract/lines_v_thick.hh>
+# include <scribo/primitive/extract/lines_v_discontinued.hh>
+# include <scribo/primitive/extract/lines_h_pattern.hh>
+# include <scribo/primitive/extract/objects.hh>
+# include <scribo/primitive/extract/cells.hh>
+# include <scribo/primitive/extract/lines_thick.hh>
+# include <scribo/primitive/extract/lines_h_discontinued.hh>
+# include <scribo/primitive/extract/lines_v_pattern.hh>
-# include <scribo/text/grouping/internal/all.hh>
-# include <scribo/text/grouping/group_with_several_graphes.hh>
-# include <scribo/text/grouping/group_from_double_link.hh>
-# include <scribo/text/grouping/group_with_several_right_links.hh>
-# include <scribo/text/grouping/group_with_graph.hh>
-# include <scribo/text/grouping/group_with_single_left_link.hh>
-# include <scribo/text/grouping/group_with_several_left_links.hh>
-# include <scribo/text/grouping/group_from_graph.hh>
-# include <scribo/text/grouping/group_from_single_link.hh>
-# include <scribo/text/grouping/group_with_single_right_link.hh>
-
-
-#endif // ! SCRIBO_TEXT_GROUPING_ALL_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_ALL_HH
diff --git a/scribo/extract/primitive/canvas.hh b/scribo/primitive/extract/canvas.hh
similarity index 81%
rename from scribo/extract/primitive/canvas.hh
rename to scribo/primitive/extract/canvas.hh
index dbd1de4..a2e9b4a 100644
--- a/scribo/extract/primitive/canvas.hh
+++ b/scribo/primitive/extract/canvas.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_CANVAS_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_CANVAS_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_CANVAS_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_CANVAS_HH
/// \file
///
@@ -51,12 +51,12 @@
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
-
+ using namespace mln;
/// Rebuild a table from its line bounding boxes.
/*!
@@ -72,8 +72,8 @@ namespace scribo
template <typename I, typename V>
mln_ch_value(I,bool)
canvas(const Image<I>& input_,
- const util::array<box<mln_site(I)> >& hlines_,
- const util::array<box<mln_site(I)> >& vlines_,
+ const mln::util::array<box<mln_site(I)> >& hlines_,
+ const mln::util::array<box<mln_site(I)> >& vlines_,
unsigned max_dist_lines);
@@ -83,8 +83,8 @@ namespace scribo
template <typename I, typename V>
mln_ch_value(I,bool)
canvas(const Image<I>& input_,
- const util::array<box<mln_site(I)> >& hlines,
- const util::array<box<mln_site(I)> >& vlines,
+ const mln::util::array<box<mln_site(I)> >& hlines,
+ const mln::util::array<box<mln_site(I)> >& vlines,
unsigned max_dist_lines)
{
trace::entering("scribo::primitive::canvas");
@@ -93,11 +93,12 @@ namespace scribo
mlc_equal(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
- typedef util::array<box<mln_site(I)> > lines_t;
- util::couple<lines_t, lines_t> lines = mln::make::couple(hlines, vlines);
+ typedef mln::util::array<box<mln_site(I)> > lines_t;
+ mln::util::couple<lines_t, lines_t>
+ lines = mln::make::couple(hlines, vlines);
- util::array<int> rows = align_lines_horizontaly(input, hlines, 5);
- util::array<int> cols = align_lines_verticaly(input, vlines, 5);
+ mln::util::array<int> rows = align_lines_horizontaly(input, hlines, 5);
+ mln::util::array<int> cols = align_lines_verticaly(input, vlines, 5);
repair_vertical_lines(input, lines, 30);
repair_horizontal_lines(input, lines, 30);
@@ -121,10 +122,10 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_CANVAS_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_CANVAS_HH
diff --git a/scribo/extract/primitive/cells.hh b/scribo/primitive/extract/cells.hh
similarity index 88%
rename from scribo/extract/primitive/cells.hh
rename to scribo/primitive/extract/cells.hh
index 44690e7..08b3fd6 100644
--- a/scribo/extract/primitive/cells.hh
+++ b/scribo/primitive/extract/cells.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_CELLS_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_CELLS_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_CELLS_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_CELLS_HH
/// \file
///
@@ -44,7 +44,7 @@
# include <scribo/table/rebuild.hh>
# include <scribo/table/erase.hh>
-# include <scribo/extract/primitive/lines_discontinued.hh>
+# include <scribo/primitive/extract/lines_discontinued.hh>
# include <scribo/make/debug_filename.hh>
@@ -52,10 +52,10 @@
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
using namespace mln;
@@ -98,9 +98,9 @@ namespace scribo
win::line<mln_grid(I::site), 0, mln_coord(I::site)> vline(51);
win::line<mln_grid(I::site), 1, mln_coord(I::site)> hline(51);
boxarray_t
- vlines = extract::primitive::lines_discontinued(input, nbh,
+ vlines = primitive::extract::lines_discontinued(input, nbh,
ncells, vline, 6),
- hlines = extract::primitive::lines_discontinued(input, nbh,
+ hlines = primitive::extract::lines_discontinued(input, nbh,
ncells, hline, 6);
typedef mln_ch_value(I,V) cells_ima_t;
@@ -117,10 +117,10 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_CELLS_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_CELLS_HH
diff --git a/scribo/extract/primitive/lines_discontinued.hh
b/scribo/primitive/extract/lines_discontinued.hh
similarity index 87%
rename from scribo/extract/primitive/lines_discontinued.hh
rename to scribo/primitive/extract/lines_discontinued.hh
index 97d08f8..8ced7e3 100644
--- a/scribo/extract/primitive/lines_discontinued.hh
+++ b/scribo/primitive/extract/lines_discontinued.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_DISCONTINUED_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_DISCONTINUED_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_DISCONTINUED_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_DISCONTINUED_HH
/// \file
///
@@ -42,15 +42,15 @@
# include <scribo/core/macros.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/objects.hh>
+# include <scribo/primitive/extract/objects.hh>
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
using namespace mln;
@@ -113,7 +113,7 @@ namespace scribo
const Neighborhood<N>& nbh_, V& nlines,
const Window<W>& win_, unsigned rank_k)
{
- trace::entering("scribo::primitive::lines_discontinued");
+ trace::entering("scribo::primitive::extract::lines_discontinued");
internal::lines_discontinued_tests(input_, nbh_, nlines, win_, rank_k);
@@ -130,9 +130,9 @@ namespace scribo
mln_ch_value(I,bool) filter
= morpho::dilation(morpho::rank_filter(input, win, rank_k), W(dil));
object_image(mln_ch_value(I,V)) output
- = extract::primitive::objects(filter, nbh, nlines);
+ = primitive::extract::objects(filter, nbh, nlines);
- trace::exiting("scribo::primitive::lines_discontinued");
+ trace::exiting("scribo::primitive::extract::lines_discontinued");
return output;
}
@@ -140,10 +140,10 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_DISCONTINUED_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_DISCONTINUED_HH
diff --git a/scribo/extract/primitive/lines_h_discontinued.hh
b/scribo/primitive/extract/lines_h_discontinued.hh
similarity index 90%
rename from scribo/extract/primitive/lines_h_discontinued.hh
rename to scribo/primitive/extract/lines_h_discontinued.hh
index ce62fde..48ba12a 100644
--- a/scribo/extract/primitive/lines_h_discontinued.hh
+++ b/scribo/primitive/extract/lines_h_discontinued.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_H_DISCONTINUED_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_H_DISCONTINUED_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_H_DISCONTINUED_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_H_DISCONTINUED_HH
/// \file
///
@@ -35,17 +35,17 @@
# include <mln/win/hline2d.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/lines_discontinued.hh>
+# include <scribo/primitive/extract/lines_discontinued.hh>
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
using namespace mln;
@@ -124,10 +124,10 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_H_DISCONTINUED_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_H_DISCONTINUED_HH
diff --git a/scribo/extract/primitive/lines_h_pattern.hh
b/scribo/primitive/extract/lines_h_pattern.hh
similarity index 87%
rename from scribo/extract/primitive/lines_h_pattern.hh
rename to scribo/primitive/extract/lines_h_pattern.hh
index 2aa531e..7716ac5 100644
--- a/scribo/extract/primitive/lines_h_pattern.hh
+++ b/scribo/primitive/extract/lines_h_pattern.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_H_PATTERN_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_H_PATTERN_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_H_PATTERN_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_H_PATTERN_HH
/// \file
///
@@ -37,16 +37,17 @@
# include <mln/morpho/dilation.hh>
-# include <scribo/extract/primitive/lines_pattern.hh>
+# include <scribo/primitive/extract/lines_pattern.hh>
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
+
using namespace mln;
/// Extract horizontal lines matching a specific pattern.
@@ -90,12 +91,12 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::impl::generic
+ } // end of namespace scribo::primitive::extract
- } // end of namespace mln::impl
+ } // end of namespace scribo::primitive
-} // end of namespace mln
+} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_H_PATTERN_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_H_PATTERN_HH
diff --git a/scribo/extract/primitive/lines_h_single.hh
b/scribo/primitive/extract/lines_h_single.hh
similarity index 94%
rename from scribo/extract/primitive/lines_h_single.hh
rename to scribo/primitive/extract/lines_h_single.hh
index 9146483..9b6d7c4 100644
--- a/scribo/extract/primitive/lines_h_single.hh
+++ b/scribo/primitive/extract/lines_h_single.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_H_SINGLE_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_H_SINGLE_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_H_SINGLE_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_H_SINGLE_HH
/// \file
///
@@ -40,10 +40,10 @@
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
@@ -194,10 +194,10 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_H_SINGLE_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_H_SINGLE_HH
diff --git a/scribo/extract/primitive/lines_h_thick.hh
b/scribo/primitive/extract/lines_h_thick.hh
similarity index 90%
rename from scribo/extract/primitive/lines_h_thick.hh
rename to scribo/primitive/extract/lines_h_thick.hh
index cfbf1cc..817f47d 100644
--- a/scribo/extract/primitive/lines_h_thick.hh
+++ b/scribo/primitive/extract/lines_h_thick.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_H_THICK_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_H_THICK_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_H_THICK_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_H_THICK_HH
/// \file
///
@@ -35,15 +35,15 @@
# include <mln/win/hline2d.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/lines_thick.hh>
+# include <scribo/primitive/extract/lines_thick.hh>
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
using namespace mln;
@@ -120,10 +120,10 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_H_THICK_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_H_THICK_HH
diff --git a/scribo/extract/primitive/lines_pattern.hh
b/scribo/primitive/extract/lines_pattern.hh
similarity index 90%
rename from scribo/extract/primitive/lines_pattern.hh
rename to scribo/primitive/extract/lines_pattern.hh
index 45bc487..cd2b558 100644
--- a/scribo/extract/primitive/lines_pattern.hh
+++ b/scribo/primitive/extract/lines_pattern.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_PATTERN_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_PATTERN_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_PATTERN_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_PATTERN_HH
/// \file
///
@@ -43,10 +43,10 @@
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
using namespace mln;
@@ -112,11 +112,11 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::impl::generic
+ } // end of namespace scribo::primitive::extract
- } // end of namespace mln::impl
+ } // end of namespace scribo::primitive
-} // end of namespace mln
+} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_PATTERN_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_PATTERN_HH
diff --git a/scribo/extract/primitive/lines_thick.hh
b/scribo/primitive/extract/lines_thick.hh
similarity index 86%
rename from scribo/extract/primitive/lines_thick.hh
rename to scribo/primitive/extract/lines_thick.hh
index 5d88cc5..f54e9b0 100644
--- a/scribo/extract/primitive/lines_thick.hh
+++ b/scribo/primitive/extract/lines_thick.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_THICK_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_THICK_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_THICK_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_THICK_HH
/// \file
///
@@ -39,15 +39,15 @@
# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
-# include <scribo/extract/primitive/objects.hh>
+# include <scribo/primitive/extract/objects.hh>
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
@@ -81,9 +81,9 @@ namespace scribo
template <typename I, typename N, typename V, typename W>
void
- lines_thick_tests(const Image<I>& input_,
- const Neighborhood<N>& nbh_, V& nlines,
- const Window<W>& win_)
+ lines_thick_tests(const Image<I>& input,
+ const Neighborhood<N>& nbh, V& nlines,
+ const Window<W>& win)
{
mlc_equal(mln_value(I),bool)::check();
mlc_bool(mln_site_(I)::dim == 2)::check();
@@ -117,7 +117,7 @@ namespace scribo
mln_ch_value(I,bool) filter = morpho::opening::structural(input, win);
object_image(mln_ch_value(I,V)) output
- = extract::primitive::objects(filter, nbh, nlines);
+ = primitive::extract::objects(filter, nbh, nlines);
trace::exiting("scribo::primitive::lines_thick");
return output;
@@ -126,10 +126,10 @@ namespace scribo
# endif // !MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_VERTICAL_LINES_THICK_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_LINES_THICK_HH
diff --git a/scribo/extract/primitive/lines_v_discontinued.hh
b/scribo/primitive/extract/lines_v_discontinued.hh
similarity index 90%
rename from scribo/extract/primitive/lines_v_discontinued.hh
rename to scribo/primitive/extract/lines_v_discontinued.hh
index 0755d2b..8463111 100644
--- a/scribo/extract/primitive/lines_v_discontinued.hh
+++ b/scribo/primitive/extract/lines_v_discontinued.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_V_DISCONTINUED_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_V_DISCONTINUED_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_V_DISCONTINUED_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_V_DISCONTINUED_HH
/// \file
///
@@ -34,17 +34,17 @@
# include <mln/core/concept/neighborhood.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/lines_discontinued.hh>
+# include <scribo/primitive/extract/lines_discontinued.hh>
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
@@ -118,11 +118,11 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_V_DISCONTINUED_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_V_DISCONTINUED_HH
diff --git a/scribo/extract/primitive/lines_v_pattern.hh
b/scribo/primitive/extract/lines_v_pattern.hh
similarity index 86%
rename from scribo/extract/primitive/lines_v_pattern.hh
rename to scribo/primitive/extract/lines_v_pattern.hh
index be920fc..29f4a54 100644
--- a/scribo/extract/primitive/lines_v_pattern.hh
+++ b/scribo/primitive/extract/lines_v_pattern.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_V_PATTERN_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_V_PATTERN_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
/// \file
///
@@ -37,16 +37,17 @@
# include <mln/morpho/dilation.hh>
-# include <scribo/extract/primitive/lines_pattern.hh>
+# include <scribo/primitive/extract/lines_pattern.hh>
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
+
using namespace mln;
@@ -85,12 +86,12 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::impl::generic
+ } // end of namespace scribo::primitive::extract
- } // end of namespace mln::impl
+ } // end of namespace scribo::primitive
-} // end of namespace mln
+} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_V_PATTERN_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
diff --git a/scribo/extract/primitive/lines_v_single.hh
b/scribo/primitive/extract/lines_v_single.hh
similarity index 94%
rename from scribo/extract/primitive/lines_v_single.hh
rename to scribo/primitive/extract/lines_v_single.hh
index ee49eb8..f700dd0 100644
--- a/scribo/extract/primitive/lines_v_single.hh
+++ b/scribo/primitive/extract/lines_v_single.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_V_SINGLE_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_V_SINGLE_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_V_SINGLE_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_V_SINGLE_HH
/// \file
///
@@ -40,10 +40,10 @@
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
using namespace mln;
@@ -190,10 +190,10 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_V_SINGLE_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_V_SINGLE_HH
diff --git a/scribo/extract/primitive/lines_v_thick.hh
b/scribo/primitive/extract/lines_v_thick.hh
similarity index 90%
rename from scribo/extract/primitive/lines_v_thick.hh
rename to scribo/primitive/extract/lines_v_thick.hh
index 19cec92..e1cecee 100644
--- a/scribo/extract/primitive/lines_v_thick.hh
+++ b/scribo/primitive/extract/lines_v_thick.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_LINES_V_THICK_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_LINES_V_THICK_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_V_THICK_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_LINES_V_THICK_HH
/// \file
///
@@ -35,15 +35,15 @@
# include <mln/win/vline2d.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/extract/primitive/lines_thick.hh>
+# include <scribo/primitive/extract/lines_thick.hh>
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
using namespace mln;
@@ -120,10 +120,10 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_LINES_V_THICK_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_V_THICK_HH
diff --git a/scribo/extract/primitive/objects.hh b/scribo/primitive/extract/objects.hh
similarity index 89%
rename from scribo/extract/primitive/objects.hh
rename to scribo/primitive/extract/objects.hh
index a4110e2..2ca2f5d 100644
--- a/scribo/extract/primitive/objects.hh
+++ b/scribo/primitive/extract/objects.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_EXTRACT_PRIMITIVE_OBJECTS_HH
-# define SCRIBO_EXTRACT_PRIMITIVE_OBJECTS_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_OBJECTS_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_OBJECTS_HH
/// \file
///
@@ -52,17 +52,18 @@
namespace scribo
{
- namespace extract
+ namespace primitive
{
- namespace primitive
+ namespace extract
{
using namespace mln;
/// Extract objects in a binary image.
///
- /// \param[in] input A binary image. Objects are must be set to 'true'
+ /// \param[in] input A binary image. Objects are must be set
+ /// to 'true'
/// and background to 'false'.
/// \param[in] nbh A neighborhood to be used for labeling.
/// \param[in,out] nobjects Will store the numbers of objects found.
@@ -98,7 +99,7 @@ namespace scribo
}
- } // end of namespace scribo::extract::primitive::internal
+ } // end of namespace scribo::primitive::extract::internal
template <typename I, typename N, typename V>
@@ -127,11 +128,11 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::extract::primitive
+ } // end of namespace scribo::primitive::extract
- } // end of namespace scribo::extract
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_EXTRACT_PRIMITIVE_OBJECTS_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_OBJECTS_HH
diff --git a/scribo/text/all.hh b/scribo/primitive/group/all.hh
similarity index 69%
copy from scribo/text/all.hh
copy to scribo/primitive/group/all.hh
index 000d5b9..75f0685 100644
--- a/scribo/text/all.hh
+++ b/scribo/primitive/group/all.hh
@@ -23,27 +23,35 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_ALL_HH
-# define SCRIBO_TEXT_ALL_HH
+#ifndef SCRIBO_PRIMITIVE_GROUP_ALL_HH
+# define SCRIBO_PRIMITIVE_GROUP_ALL_HH
/// \file
///
-/// Include all headers located in scribo/text.
+/// Include all headers located in scribo/primitive/group.
namespace scribo
{
- /// Namespace of routines working on text components.
- namespace text
+ namespace primitive
{
- } // end of namespace scribo::text
+ /// Namespace of primitive grouping related routines.
+ namespace group
+ {
+
+ } // end of namespace scribo::primitive::group
+
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-# include <scribo/text/extract_lines.hh>
-//# include <scribo/text/recognition.hh>
-# include <scribo/text/clean.hh>
-# include <scribo/text/grouping/all.hh>
-#endif // ! SCRIBO_TEXT_ALL_HH
+
+# include <scribo/primitive/group/apply.hh>
+# include <scribo/primitive/group/from_double_link.hh>
+# include <scribo/primitive/group/from_graph.hh>
+# include <scribo/primitive/group/from_single_link.hh>
+
+
+#endif // ! SCRIBO_PRIMITIVE_GROUP_ALL_HH
diff --git a/scribo/primitive/group/apply.hh b/scribo/primitive/group/apply.hh
new file mode 100644
index 0000000..02e75cd
--- /dev/null
+++ b/scribo/primitive/group/apply.hh
@@ -0,0 +1,126 @@
+// Copyright (C) 2009 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_PRIMITIVE_GROUP_APPLY_HH
+# define SCRIBO_PRIMITIVE_GROUP_APPLY_HH
+
+/// \file
+///
+/// Apply grouping in an object image.
+
+# include <scribo/core/object_links.hh>
+# include <scribo/core/object_groups.hh>
+# include <scribo/core/object_image.hh>
+
+# include <scribo/primitive/group/from_single_link.hh>
+
+namespace scribo
+{
+
+ namespace primitive
+ {
+
+ namespace group
+ {
+
+ using namespace mln;
+
+ /*! \brief Apply grouping in an object image.
+
+ \param objects An object image.
+ \param groups An object group structure.
+
+ \return A copy of \p objects with grouped objects.
+ */
+ template <typename L>
+ object_image(L)
+ apply(const object_image(L)& objects,
+ const object_groups<L>& groups);
+
+ /// \overload
+ template <typename L>
+ object_image(L)
+ apply(const object_image(L)& objects,
+ const object_links<L>& links);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename L>
+ object_image(L)
+ apply(const object_image(L)& objects,
+ const object_groups<L>& groups)
+
+ {
+ trace::entering("scribo::primitive::group::apply");
+
+ mln_precondition(objects.is_valid());
+ mln_precondition(groups.nelements() == objects.nlabels().next());
+ mln_precondition(groups.nelements() == objects.bboxes().nelements());
+ mln_precondition(groups.objects_id_() == objects.id_());
+
+ object_image(L) output;
+ output.init_from_(objects);
+ output.relabel(groups);
+
+ trace::exiting("scribo::primitive::group::apply");
+ return output;
+ }
+
+
+ template <typename L>
+ object_image(L)
+ apply(const object_image(L)& objects,
+ const object_links<L>& links)
+
+ {
+ trace::entering("scribo::primitive::group::apply");
+
+ mln_precondition(objects.is_valid());
+ mln_precondition(links.nelements() == objects.nlabels().next());
+ mln_precondition(links.nelements() == objects.bboxes().nelements());
+ mln_precondition(links.objects_id_() == objects.id_());
+
+
+ object_groups<L> group = group::from_single_link(objects, links);
+
+ object_image(L) output = apply(objects, links);
+
+ trace::exiting("scribo::primitive::group::apply");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::primitive::group
+
+ } // end of namespace scribo::primitive
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_PRIMITIVE_GROUP_APPLY_HH
diff --git a/scribo/text/grouping/group_from_double_link.hh
b/scribo/primitive/group/from_double_link.hh
similarity index 57%
rename from scribo/text/grouping/group_from_double_link.hh
rename to scribo/primitive/group/from_double_link.hh
index 5c82cb2..8c15dc3 100644
--- a/scribo/text/grouping/group_from_double_link.hh
+++ b/scribo/primitive/group/from_double_link.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_FROM_DOUBLE_LINK_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_FROM_DOUBLE_LINK_HH
+#ifndef SCRIBO_PRIMITIVE_GROUP_FROM_DOUBLE_LINK_HH
+# define SCRIBO_PRIMITIVE_GROUP_FROM_DOUBLE_LINK_HH
/// \file
@@ -42,23 +42,20 @@
# include <scribo/core/macros.hh>
-# include <scribo/util/text.hh>
-
-# include <scribo/make/text.hh>
-
+# include <scribo/core/object_groups.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/text/grouping/internal/find_root.hh>
-# include <scribo/text/grouping/internal/is_link_valid.hh>
-# include <scribo/text/grouping/internal/init_link_array.hh>
+# include <scribo/primitive/internal/find_root.hh>
+# include <scribo/primitive/internal/is_link_valid.hh>
+# include <scribo/primitive/internal/init_link_array.hh>
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace group
{
/*! Group objects from left and right links information and
@@ -70,22 +67,13 @@ namespace scribo
\param[in] right_link The right neighbor of each line of text.
\param[in] parent_link The function used to group components.
- \return An image of grouped objects.
+ \return Return object groups information.
*/
template <typename L>
- object_image(L)
- group_from_double_link(const object_image(L)& objects,
- const mln::util::array<unsigned>& left_link,
- const mln::util::array<unsigned>& right_link,
- mln::util::array<unsigned>& parent_link);
-
- /// \overload
- template <typename L>
- object_image(L)
- group_from_double_link(const object_image(L)& objects,
- const mln::util::array<unsigned>& left_link,
- const mln::util::array<unsigned>& right_link);
-
+ object_groups<L>
+ from_double_link(const object_image(L)& objects,
+ const object_links<L>& left_link,
+ const object_links<L>& right_link);
@@ -94,17 +82,18 @@ namespace scribo
template <typename L>
inline
- object_image(L)
- group_from_double_link(const object_image(L)& objects,
- const mln::util::array<unsigned>& left_link,
- const mln::util::array<unsigned>& right_link,
- mln::util::array<unsigned>& parent_link)
+ object_groups<L>
+ from_double_link(const object_image(L)& objects,
+ const object_links<L>& left_link,
+ const object_links<L>& right_link)
{
- trace::entering("scribo::text::grouping::group_from_double_link");
+ trace::entering("scribo::primitive::group::from_double_link");
mln_precondition(left_link.nelements() == right_link.nelements());
+ mln_precondition(left_link.objects_id_() == objects.id_());
+ mln_precondition(right_link.objects_id_() == objects.id_());
- mln::util::array<unsigned> parent(left_link.nelements());
+ object_groups<L> parent(objects, left_link.nelements());
internal::init_link_array(parent);
for_all_ncomponents(i, objects.nlabels())
{
@@ -123,38 +112,18 @@ namespace scribo
for (unsigned i = parent.nelements() - 1; i < parent.nelements(); --i)
parent[i] = parent[parent[i]];
- object_image(L) output;
- output.init_from_(objects);
- output.relabel(parent);
-
- parent_link = parent;
- trace::exiting("scribo::text::grouping::group_from_double_link");
- return output;
- }
-
-
- template <typename L>
- inline
- object_image(L)
- group_from_double_link(const object_image(L)& objects,
- const mln::util::array<unsigned>& left_link,
- const mln::util::array<unsigned>& right_link)
- {
- mln::util::array<unsigned> parent_link;
- return group_from_double_link(objects,
- left_link,
- right_link,
- parent_link);
+ trace::exiting("scribo::primitive::group::from_double_link");
+ return parent;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::group
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_FROM_DOUBLE_LINK_HH
+#endif // ! SCRIBO_PRIMITIVE_GROUP_FROM_DOUBLE_LINK_HH
diff --git a/scribo/text/grouping/group_from_graph.hh
b/scribo/primitive/group/from_graph.hh
similarity index 70%
rename from scribo/text/grouping/group_from_graph.hh
rename to scribo/primitive/group/from_graph.hh
index f6e6cf2..55cb56d 100644
--- a/scribo/text/grouping/group_from_graph.hh
+++ b/scribo/primitive/group/from_graph.hh
@@ -23,13 +23,13 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_FROM_GRAPH_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_FROM_GRAPH_HH
+#ifndef SCRIBO_PRIMITIVE_GROUP_FROM_GRAPH_HH
+# define SCRIBO_PRIMITIVE_GROUP_FROM_GRAPH_HH
/// \file
///
-/// Group lines of text according to a graph of links between
-/// the lines of text.
+/// Group objects according to a graph of links
+
# include <mln/core/concept/graph.hh>
# include <mln/core/concept/image.hh>
@@ -46,6 +46,8 @@
# include <mln/util/array.hh>
# include <mln/util/graph_ids.hh>
+# include <scribo/core/object_links.hh>
+# include <scribo/core/object_groups.hh>
# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
@@ -53,26 +55,25 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace group
{
using namespace mln;
- /// Group lines of text according to a graph of links between
- /// the lines of text.
+ /// Group objects according to a graph of links
///
- /// \param[in] text An object image.
- /// \param[in] g_ The graph of links between the lines of text.
+ /// \param[in] objects An object image.
+ /// \param[in] g_ The graph of object links.
///
- /// \return An image with grouped objects.
+ /// \return Object groups information.
//
template <typename L, typename G>
- object_image(L)
- group_from_graph(const object_image(L)& text,
- const Graph<G>& g_);
+ object_groups<L>
+ from_graph(const object_image(L)& objects,
+ const Graph<G>& g_);
# ifndef MLN_INCLUDE_ONLY
@@ -83,15 +84,20 @@ namespace scribo
/// Functor to be passed to depth_first_search.
/// Map each component vertex with its representative vertex id.
- template <typename V>
+ template <typename L>
struct map_vertex_to_representative_id_functor
{
+ map_vertex_to_representative_id_functor(const object_image(L)& objects)
+ : vertextorep(objects)
+ {
+ }
+
/// Initialize the functor.
template <typename G>
void init(const Graph<G>& g)
{
- vertextorep.resize(exact(g).v_nmax(), mln_max(V));
+ vertextorep.resize(exact(g).v_nmax(), mln_max(mln_value(L)));
}
/// All components have been processed.
@@ -123,7 +129,7 @@ namespace scribo
/// Does the vertex with id \p id have been already treated?
bool to_be_treated(const mln::util::vertex_id_t& id)
- { return vertextorep(id) == mln_max(V); }
+ { return vertextorep(id) == mln_max(mln_value(L)); }
/// Does the neighbor vertex \p id have been already treated?
bool to_be_queued(const mln::util::vertex_id_t& id)
@@ -133,43 +139,42 @@ namespace scribo
mln::util::vertex_id_t current_;
/// Map a verted id to its component id.
- fun::i2v::array<V> vertextorep;
+ object_links<L> vertextorep;
};
- } // end of namespace scribo::text::grouping::internal
+ } // end of namespace scribo::primitive::group::internal
template <typename L, typename G>
inline
- object_image(L)
- group_from_graph(const object_image(L)& text,
- const Graph<G>& g_)
+ object_groups<L>
+ from_graph(const object_image(L)& objects,
+ const Graph<G>& g_)
{
- trace::entering("scribo::text::grouping::group_from_graph");
+ trace::entering("scribo::primitive::group::from_graph");
const G& g = exact(g_);
mln_assertion(g.is_valid());
- internal::map_vertex_to_representative_id_functor<mln_value(L)> f;
+ internal::map_vertex_to_representative_id_functor<L> f(objects);
canvas::browsing::depth_first_search(g, f);
- object_image(L) output;
- output.init_from_(text);
- output.relabel(f.vertextorep);
+ object_groups<L> groups(objects);
+ groups.init_(f.vertextorep);
- trace::exiting("scribo::text::grouping::group_from_graph");
- return output;
+ trace::exiting("scribo::primitive::group::from_graph");
+ return groups;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::group
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_FROM_GRAPH_HH
+#endif // ! SCRIBO_PRIMITIVE_GROUP_FROM_GRAPH_HH
diff --git a/scribo/text/grouping/group_from_single_link.hh
b/scribo/primitive/group/from_single_link.hh
similarity index 68%
rename from scribo/text/grouping/group_from_single_link.hh
rename to scribo/primitive/group/from_single_link.hh
index 0f4e7b3..2b53b67 100644
--- a/scribo/text/grouping/group_from_single_link.hh
+++ b/scribo/primitive/group/from_single_link.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_FROM_SINGLE_LINK_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_FROM_SINGLE_LINK_HH
+#ifndef SCRIBO_PRIMITIVE_GROUP_FROM_SINGLE_LINK_HH
+# define SCRIBO_PRIMITIVE_GROUP_FROM_SINGLE_LINK_HH
/// \file
///
@@ -38,8 +38,10 @@
# include <mln/util/array.hh>
-# include <scribo/text/grouping/internal/find_root.hh>
+# include <scribo/primitive/internal/find_root.hh>
+# include <scribo/core/object_groups.hh>
+# include <scribo/core/object_links.hh>
# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
@@ -47,10 +49,10 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace group
{
using namespace mln;
@@ -62,45 +64,45 @@ namespace scribo
\param[in] objects An object image.
\param[in] link_array The neighbor line of each line.
- \return An object image with grouped objects.
+ \return Object groups information.
*/
template <typename L>
- object_image(L)
- group_from_single_link(const object_image(L)& objects,
- const mln::util::array<unsigned>& link_array);
+ object_groups<L>
+ from_single_link(const object_image(L)& objects,
+ const object_links<L>& link_array);
+
# ifndef MLN_INCLUDE_ONLY
template <typename L>
inline
- object_image(L)
- group_from_single_link(const object_image(L)& objects,
- const mln::util::array<unsigned>& link_array)
+ object_groups<L>
+ from_single_link(const object_image(L)& objects,
+ const object_links<L>& link_array)
{
- trace::entering("scribo::text::grouping::group_from_single_link");
+ trace::entering("scribo::primitive::group::from_single_link");
mln_precondition(objects.is_valid());
mln_precondition(link_array.nelements() == objects.nlabels().next());
mln_precondition(link_array.nelements() == objects.bboxes().nelements());
+ mln_precondition(link_array.objects_id_() == objects.id_());
- mln::util::array<unsigned> parent_array = link_array;
- for_all_components(i, parent_array)
- internal::find_root(parent_array, i);
+ object_groups<L> parent_array(objects);
+ parent_array.init_(link_array);
- object_image(L) output;
- output.init_from_(objects);
- output.relabel(parent_array);
+ for_all_components(i, parent_array)
+ primitive::internal::find_root(parent_array, i);
- trace::exiting("scribo::text::grouping::group_from_single_link");
- return output;
+ trace::exiting("scribo::primitive::group::from_single_link");
+ return parent_array;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::group
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_FROM_SINGLE_LINK_HH
+#endif // ! SCRIBO_PRIMITIVE_GROUP_FROM_SINGLE_LINK_HH
diff --git a/scribo/text/grouping/internal/init_link_array.hh
b/scribo/primitive/internal/all.hh
similarity index 61%
copy from scribo/text/grouping/internal/init_link_array.hh
copy to scribo/primitive/internal/all.hh
index 522c221..86aa62a 100644
--- a/scribo/text/grouping/internal/init_link_array.hh
+++ b/scribo/primitive/internal/all.hh
@@ -23,54 +23,38 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_INIT_LINK_ARRAY_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_INIT_LINK_ARRAY_HH
+#ifndef SCRIBO_PRIMITIVE_INTERNAL_ALL_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_ALL_HH
/// \file
///
-/// Initialize a link array.
-
-
-# include <mln/util/array.hh>
-
+/// Include all headers located in scribo/primitive/internal.
namespace scribo
{
- using namespace mln;
-
- namespace text
+ namespace primitive
{
- namespace grouping
+ /// Namespace of internal routines grouping text components.
+ namespace internal
{
- namespace internal
- {
-
- /// Initialize a link array.
- void
- init_link_array(mln::util::array<unsigned>& link_array);
+ } // end of namespace scribo::primitive::internal
-# ifndef MLN_INCLUDE_ONLY
+ } // end of namespace scribo::primitive
- inline
- void
- init_link_array(mln::util::array<unsigned>& link_array)
- {
- for (unsigned i = 0; i < link_array.nelements(); ++i)
- link_array[i] = i;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
+} // end of namespace scribo
- } // end of namespace scribo::text
-} // end of namespace scribo
+# include <scribo/primitive/internal/init_link_array.hh>
+# include <scribo/primitive/internal/is_link_valid.hh>
+# include <scribo/primitive/internal/find_root.hh>
+# include <scribo/primitive/internal/find_graph_link.hh>
+# include <scribo/primitive/internal/find_right_link.hh>
+# include <scribo/primitive/internal/update_graph_link.hh>
+# include <scribo/primitive/internal/update_link_array.hh>
+# include <scribo/primitive/internal/find_left_link.hh>
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_INIT_LINK_ARRAY_HH
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_ALL_HH
diff --git a/scribo/text/grouping/internal/find_graph_link.hh
b/scribo/primitive/internal/find_graph_link.hh
similarity index 51%
rename from scribo/text/grouping/internal/find_graph_link.hh
rename to scribo/primitive/internal/find_graph_link.hh
index 733b646..b2f6549 100644
--- a/scribo/text/grouping/internal/find_graph_link.hh
+++ b/scribo/primitive/internal/find_graph_link.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_FIND_GRAPH_LINK_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_FIND_GRAPH_LINK_HH
+#ifndef SCRIBO_PRIMITIVE_INTERNAL_FIND_GRAPH_LINK_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_FIND_GRAPH_LINK_HH
/// \file
///
@@ -38,7 +38,7 @@
# include <mln/util/array.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/text/grouping/internal/update_graph_link.hh>
+# include <scribo/primitive/internal/update_graph_link.hh>
//FIXME: not generic.
# include <mln/core/alias/dpoint2d.hh>
@@ -47,70 +47,65 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace internal
{
- namespace internal
- {
-
- /// Find a neighbor of a text line in a specific range if it exists.
- ///
- /// \param g_ The link graph.
- /// \param text The lines of text.
- /// \param current_comp The current line being processed.
- /// \param dmax The maximum lookup distance.
- /// \param c Start point of the neighbor lookup.
- //
- template <typename G, typename L>
- void
- find_graph_link(Graph<G>& g_,
- const object_image(L)& text,
- unsigned current_comp,
- int dmax,
- const mln_site(L)& c);
+ /// Find a neighbor of a text line in a specific range if it exists.
+ ///
+ /// \param g_ The link graph.
+ /// \param text The lines of text.
+ /// \param current_comp The current line being processed.
+ /// \param dmax The maximum lookup distance.
+ /// \param c Start point of the neighbor lookup.
+ //
+ template <typename G, typename L>
+ void
+ find_graph_link(Graph<G>& g_,
+ const object_image(L)& text,
+ unsigned current_comp,
+ int dmax,
+ const mln_site(L)& c);
# ifndef MLN_INCLUDE_ONLY
- template <typename G, typename L>
- void
- find_graph_link(Graph<G>& g_,
- const object_image(L)& text,
- unsigned current_comp,
- int dmax,
- const mln_site(L)& c)
- {
- trace::entering("scribo::text::grouping::internal::find_graph_link");
+ template <typename G, typename L>
+ void
+ find_graph_link(Graph<G>& g_,
+ const object_image(L)& text,
+ unsigned current_comp,
+ int dmax,
+ const mln_site(L)& c)
+ {
+ trace::entering("scribo::primitive::internal::find_graph_link");
- G& g = exact(g_);
- mln_precondition(g.is_valid());
- mln_precondition(text.is_valid());
+ G& g = exact(g_);
+ mln_precondition(g.is_valid());
+ mln_precondition(text.is_valid());
- ///FIXME: the following code is not generic...
- /// First site on the right of the central site
- mln_site(L) p = c + right;
+ ///FIXME: the following code is not generic...
+ /// First site on the right of the central site
+ mln_site(L) p = c + right;
- while (text.domain().has(p) && (text(p) == literal::zero
- || text(p) == current_comp)
- && math::abs(p.col() - c.col()) < dmax)
- ++p.col();
+ while (text.domain().has(p) && (text(p) == literal::zero
+ || text(p) == current_comp)
+ && math::abs(p.col() - c.col()) < dmax)
+ ++p.col();
- update_graph_link(text, g, p, c, current_comp, dmax);
+ update_graph_link(text, g, p, c, current_comp, dmax);
- trace::exiting("scribo::text::grouping::internal::find_graph_link");
- }
+ trace::exiting("scribo::primitive::internal::find_graph_link");
+ }
# endif // MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::internal
} // end of namespace scribo::text
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_FIND_GRAPH_LINK_HH
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_FIND_GRAPH_LINK_HH
diff --git a/scribo/primitive/internal/find_left_link.hh
b/scribo/primitive/internal/find_left_link.hh
new file mode 100644
index 0000000..7ef2895
--- /dev/null
+++ b/scribo/primitive/internal/find_left_link.hh
@@ -0,0 +1,104 @@
+// Copyright (C) 2009 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_PRIMITIVE_INTERNAL_FIND_LEFT_LINK_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_FIND_LEFT_LINK_HH
+
+/// \file
+///
+/// Find the left neighbor of a line of text if exists.
+
+# include <mln/core/concept/image.hh>
+
+# include <mln/math/abs.hh>
+
+# include <mln/util/array.hh>
+
+# include <scribo/core/object_image.hh>
+# include <scribo/primitive/internal/update_link_array.hh>
+
+//FIXME: not generic.
+# include <mln/core/alias/dpoint2d.hh>
+
+namespace scribo
+{
+
+ namespace primitive
+ {
+
+ namespace internal
+ {
+
+ /// Find the left neighbor of a line of text if exists.
+ ///
+ /// \param objects An image of objects.
+ /// \param left_link The left neighbors.
+ /// \param current_comp A text line id.
+ /// \param dmax The maximum lookup distance.
+ /// \param c The lookup start point.
+ //
+ template <typename L>
+ void
+ find_left_link(const object_image(L)& objects,
+ mln::util::array<unsigned>& left_link,
+ unsigned current_comp,
+ int dmax,
+ const mln_site(L)& c);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L>
+ void
+ find_left_link(const object_image(L)& objects,
+ mln::util::array<unsigned>& left_link,
+ unsigned current_comp,
+ int dmax,
+ const mln_site(L)& c)
+ {
+ ///FIXME: the following code is not generic...
+ /// First site on the right of the central site
+ mln_site(L) p = c + mln::left;
+
+ while (objects.domain().has(p) // Not outside image domain
+ && (objects(p) == literal::zero // Is the background
+ || objects(p) == current_comp // Is the current component
+ || left_link[objects(p)] == current_comp) // Creates a loop
+ && math::abs(p.col() - c.col()) < dmax) // Not to far
+ --p.col();
+
+ update_link_array(objects, left_link, p, c, current_comp, dmax);
+ }
+
+# endif // MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::primitive::internal
+
+ } // end of namespace scribo::primitive
+
+} // end of namespace scribo
+
+
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_FIND_LEFT_LINK_HH
diff --git a/scribo/primitive/internal/find_right_link.hh
b/scribo/primitive/internal/find_right_link.hh
new file mode 100644
index 0000000..10f9565
--- /dev/null
+++ b/scribo/primitive/internal/find_right_link.hh
@@ -0,0 +1,105 @@
+// Copyright (C) 2009 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_PRIMITIVE_INTERNAL_FIND_RIGHT_LINK_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_FIND_RIGHT_LINK_HH
+
+/// \file
+///
+/// Find the right neighbor of a line of text if exists.
+
+# include <mln/core/concept/image.hh>
+
+# include <mln/math/abs.hh>
+
+# include <mln/util/array.hh>
+
+# include <scribo/core/object_image.hh>
+# include <scribo/primitive/internal/update_link_array.hh>
+
+//FIXME: not generic.
+# include <mln/core/alias/dpoint2d.hh>
+
+namespace scribo
+{
+
+ namespace primitive
+ {
+
+ namespace internal
+ {
+
+ using namespace mln;
+
+ /// Find the right neighbor of a line of text if exists.
+ ///
+ /// \param text The lines of text.
+ /// \param right_link The right neighbors.
+ /// \param current_comp A text line id.
+ /// \param dmax The maximum lookup distance.
+ /// \param c The lookup start point.
+ //
+ template <typename L>
+ void
+ find_right_link(const object_image(L)& text,
+ mln::util::array<unsigned>& right_link,
+ unsigned current_comp,
+ int dmax,
+ const mln_site(L)& c);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L>
+ void
+ find_right_link(const object_image(L)& objects,
+ mln::util::array<unsigned>& right_link,
+ unsigned current_comp,
+ int dmax,
+ const mln_site(L)& c)
+ {
+ ///FIXME: the following code is not generic...
+ /// First site on the right of the central site
+ mln_site(L) p = c + mln::right;
+
+ while (objects.domain().has(p) // Not outside image domain
+ && (objects(p) == literal::zero // Is the background
+ || objects(p) == current_comp // Is the current component
+ || right_link[objects(p)] == current_comp) // Creates a loop
+ && math::abs(p.col() - c.col()) < dmax) // Not too far
+ ++p.col();
+
+ update_link_array(objects, right_link, p, c, current_comp, dmax);
+ }
+
+# endif // MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::primitive::internal
+
+ } // end of namespace scribo::primitive
+
+} // end of namespace scribo
+
+
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_FIND_RIGHT_LINK_HH
diff --git a/scribo/text/grouping/internal/find_root.hh
b/scribo/primitive/internal/find_root.hh
similarity index 84%
rename from scribo/text/grouping/internal/find_root.hh
rename to scribo/primitive/internal/find_root.hh
index c1da04f..70499ec 100644
--- a/scribo/text/grouping/internal/find_root.hh
+++ b/scribo/primitive/internal/find_root.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_FIND_ROOT_LINK_ARRAY_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_FIND_ROOT_LINK_ARRAY_HH
+#ifndef SCRIBO_PRIMITIVE_INTERNAL_FIND_ROOT_LINK_ARRAY_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_FIND_ROOT_LINK_ARRAY_HH
/// \file
///
@@ -37,12 +37,9 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
- {
-
namespace internal
{
@@ -64,13 +61,11 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::internal
} // end of namespace scribo::text
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_FIND_ROOT_LINK_ARRAY_HH
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_FIND_ROOT_LINK_ARRAY_HH
diff --git a/scribo/text/grouping/internal/is_link_valid.hh
b/scribo/primitive/internal/have_link_valid.hh
similarity index 60%
rename from scribo/text/grouping/internal/is_link_valid.hh
rename to scribo/primitive/internal/have_link_valid.hh
index 32d6747..3425745 100644
--- a/scribo/text/grouping/internal/is_link_valid.hh
+++ b/scribo/primitive/internal/have_link_valid.hh
@@ -23,12 +23,12 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_IS_LINK_VALID_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_IS_LINK_VALID_HH
+#ifndef SCRIBO_PRIMITIVE_INTERNAL_HAVE_LINK_VALID_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_HAVE_LINK_VALID_HH
/// \file
///
-/// Validate a link from two different links.
+/// Tells whether a component have at least one valid link
# include <mln/util/array.hh>
@@ -37,47 +37,42 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace internal
{
- namespace internal
- {
-
- /// Validate a link from two different links.
- ///
- /// \param[in] left_link Left link of components.
- /// \param[in] right_link Right link of components.
- /// \param[in] i The component id.
- ///
- /// \return True if the link is between the \p i-th component
- /// and it neighbor is validated.
- mln::util::couple<bool,unsigned>
- is_link_valid(const mln::util::array<unsigned>& left_link,
+ /// Tells whether a component have at least one valid link link.
+ ///
+ /// \param[in] left_link Left link of components.
+ /// \param[in] right_link Right link of components.
+ /// \param[in] i The component id.
+ ///
+ /// \return True if the \p i-th component has at least one
+ /// valid link.
+ bool
+ have_link_valid(const mln::util::array<unsigned>& left_link,
const mln::util::array<unsigned>& right_link,
unsigned i);
# ifndef MLN_INCLUDE_ONLY
- mln::util::couple<bool,unsigned>
- is_link_valid(const mln::util::array<unsigned>& left_link,
+ bool
+ have_link_valid(const mln::util::array<unsigned>& left_link,
const mln::util::array<unsigned>& right_link,
unsigned i)
- {
- bool b = (right_link[left_link[i]] == i && left_link[i] != i);
- return mln::make::couple(b, left_link[i]);
- }
+ {
+ return (right_link[left_link[i]] == i && left_link[i] != i)
+ || (left_link[right_link[i]] == i && right_link[i] != i);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::internal
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_IS_LINK_VALID_HH
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_HAVE_LINK_VALID_HH
diff --git a/scribo/text/grouping/internal/init_link_array.hh
b/scribo/primitive/internal/init_link_array.hh
similarity index 69%
rename from scribo/text/grouping/internal/init_link_array.hh
rename to scribo/primitive/internal/init_link_array.hh
index 522c221..c46dca0 100644
--- a/scribo/text/grouping/internal/init_link_array.hh
+++ b/scribo/primitive/internal/init_link_array.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_INIT_LINK_ARRAY_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_INIT_LINK_ARRAY_HH
+#ifndef SCRIBO_PRIMITIVE_INTERNAL_INIT_LINK_ARRAY_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_INIT_LINK_ARRAY_HH
/// \file
///
@@ -39,38 +39,33 @@ namespace scribo
using namespace mln;
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace internal
{
- namespace internal
- {
-
- /// Initialize a link array.
- void
- init_link_array(mln::util::array<unsigned>& link_array);
+ /// Initialize a link array.
+ void
+ init_link_array(mln::util::array<unsigned>& link_array);
# ifndef MLN_INCLUDE_ONLY
- inline
- void
- init_link_array(mln::util::array<unsigned>& link_array)
- {
- for (unsigned i = 0; i < link_array.nelements(); ++i)
- link_array[i] = i;
- }
+ inline
+ void
+ init_link_array(mln::util::array<unsigned>& link_array)
+ {
+ for (unsigned i = 0; i < link_array.nelements(); ++i)
+ link_array[i] = i;
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::internal
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_INIT_LINK_ARRAY_HH
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_INIT_LINK_ARRAY_HH
diff --git a/scribo/text/grouping/internal/have_link_valid.hh
b/scribo/primitive/internal/is_link_valid.hh
similarity index 56%
rename from scribo/text/grouping/internal/have_link_valid.hh
rename to scribo/primitive/internal/is_link_valid.hh
index bdc6f18..69fe484 100644
--- a/scribo/text/grouping/internal/have_link_valid.hh
+++ b/scribo/primitive/internal/is_link_valid.hh
@@ -23,12 +23,12 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_HAVE_LINK_VALID_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_HAVE_LINK_VALID_HH
+#ifndef SCRIBO_PRIMITIVE_INTERNAL_IS_LINK_VALID_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_IS_LINK_VALID_HH
/// \file
///
-/// Tells whether a component have at least one valid link
+/// Validate a link from two different links.
# include <mln/util/array.hh>
@@ -37,47 +37,42 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace internal
{
- namespace internal
- {
-
- /// Tells whether a component have at least one valid link link.
- ///
- /// \param[in] left_link Left link of components.
- /// \param[in] right_link Right link of components.
- /// \param[in] i The component id.
- ///
- /// \return True if the \p i-th component has at least one
- /// valid link.
- bool
- have_link_valid(const mln::util::array<unsigned>& left_link,
- const mln::util::array<unsigned>& right_link,
- unsigned i);
+ /// Validate a link from two different links.
+ ///
+ /// \param[in] left_link Left link of components.
+ /// \param[in] right_link Right link of components.
+ /// \param[in] i The component id.
+ ///
+ /// \return True if the link is between the \p i-th component
+ /// and it neighbor is validated.
+ mln::util::couple<bool,unsigned>
+ is_link_valid(const mln::util::array<unsigned>& left_link,
+ const mln::util::array<unsigned>& right_link,
+ unsigned i);
# ifndef MLN_INCLUDE_ONLY
- bool
- have_link_valid(const mln::util::array<unsigned>& left_link,
- const mln::util::array<unsigned>& right_link,
- unsigned i)
- {
- return (right_link[left_link[i]] == i && left_link[i] != i)
- || (left_link[right_link[i]] == i && right_link[i] != i);
- }
+ mln::util::couple<bool,unsigned>
+ is_link_valid(const mln::util::array<unsigned>& left_link,
+ const mln::util::array<unsigned>& right_link,
+ unsigned i)
+ {
+ bool b = (right_link[left_link[i]] == i && left_link[i] != i);
+ return mln::make::couple(b, left_link[i]);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::internal
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_HAVE_LINK_VALID_HH
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_IS_LINK_VALID_HH
diff --git a/scribo/primitive/internal/update_graph_link.hh
b/scribo/primitive/internal/update_graph_link.hh
new file mode 100644
index 0000000..54e06de
--- /dev/null
+++ b/scribo/primitive/internal/update_graph_link.hh
@@ -0,0 +1,102 @@
+// Copyright (C) 2009 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_PRIMITIVE_INTERNAL_UPDATE_GRAPH_LINK_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_UPDATE_GRAPH_LINK_HH
+
+/// \file
+///
+/// Update graph edges if a valid neighbor is found.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/graph.hh>
+# include <mln/math/abs.hh>
+
+namespace scribo
+{
+
+ namespace primitive
+ {
+
+ namespace internal
+ {
+
+ using namespace mln;
+
+
+ /// Update graph edges if a valid neighbor is found.
+ ///
+ /// \param[in] lbl_ A label image.
+ /// \param[in] g_ A graph.
+ /// \param[in] p A site of \p lbl_.
+ /// \param[in] c A site of \p lbl_.
+ /// \param[in] i A vertex id.
+ /// \param[in] dmax The maximum distance allowed to look for a
+ /// neighbor.
+ //
+ template <typename I, typename G>
+ void
+ update_graph_link(const Image<I>& lbl_, Graph<G>& g_,
+ const mln_site(I)& p, const mln_site(I)& c,
+ unsigned i, int dmax);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I, typename G>
+ inline
+ void
+ update_graph_link(const Image<I>& lbl_, Graph<G>& g_,
+ const mln_site(I)& p, const mln_site(I)& c,
+ unsigned i, int dmax)
+ {
+ trace::entering("scribo::primitive::internal::update_graph_link");
+
+ const I& lbl = exact(lbl_);
+ G& g = exact(g_);
+
+ mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
+ mln_precondition(exact(lbl).is_valid());
+ mln_precondition(g.is_valid());
+
+ if (lbl.domain().has(p) && lbl(p) != literal::zero && lbl(p) != i
+ && (math::abs(p.col() - c.col())) < dmax)
+ g.add_edge(lbl(p), i);
+
+ trace::exiting("scribo::primitive::internal::update_graph_link");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::primitive::internal
+
+ } // end of namespace scribo::primitive
+
+} // end of namespace scribo
+
+
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_UPDATE_GRAPH_LINK_HH
diff --git a/scribo/text/grouping/internal/update_link_array.hh
b/scribo/primitive/internal/update_link_array.hh
similarity index 52%
rename from scribo/text/grouping/internal/update_link_array.hh
rename to scribo/primitive/internal/update_link_array.hh
index 0a82cc8..c26ec78 100644
--- a/scribo/text/grouping/internal/update_link_array.hh
+++ b/scribo/primitive/internal/update_link_array.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_LINK_ARRAY_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_LINK_ARRAY_HH
+#ifndef SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
+# define SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
/// \file
///
@@ -40,64 +40,60 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace internal
{
- namespace internal
- {
-
- using namespace mln;
+ using namespace mln;
- /// Update the lookup table \p link_array if a neighbor is found
- /// on the right of the current bbox.
- ///
- /// \param[in] lbl A label image.
- /// \param[in] link_array Links of bounding boxes.
- /// \param[in] p A site of \p lbl.
- /// \param[in] c A site of \p lbl.
- //
- template <typename I>
- void
- update_link_array(const Image<I>& lbl,
- mln::util::array<unsigned>& link_array,
- const mln_site(I)& p, const mln_site(I)& c,
- unsigned i, int dmax);
+ /// Update the lookup table \p link_array if a neighbor is found
+ /// on the right of the current bbox.
+ ///
+ /// \param[in] lbl A label image.
+ /// \param[in] link_array Links of bounding boxes.
+ /// \param[in] p A site of \p lbl.
+ /// \param[in] c A site of \p lbl.
+ //
+ template <typename I>
+ void
+ update_link_array(const Image<I>& lbl,
+ mln::util::array<unsigned>& link_array,
+ const mln_site(I)& p, const mln_site(I)& c,
+ unsigned i, int dmax);
# ifndef MLN_INCLUDE_ONLY
- template <typename I>
- inline
- void
- update_link_array(const Image<I>& lbl_, mln::util::array<unsigned>&
link_array,
- const mln_site(I)& p, const mln_site(I)& c,
- unsigned i, int dmax)
- {
- const I& lbl = exact(lbl_);
-
- mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
- mln_assertion(lbl.is_valid());
-
- if (lbl.domain().has(p) // Not outside image domain
- && lbl(p) != literal::zero // Not the background
- && lbl(p) != i // Not the current component
- && (math::abs(p.col() - c.col())) < dmax // Not too far
- && link_array[lbl(p)] != i) // Not creating a loop
- link_array[i] = lbl(p);
- }
+ template <typename I>
+ inline
+ void
+ update_link_array(const Image<I>& lbl_,
+ mln::util::array<unsigned>& link_array,
+ const mln_site(I)& p, const mln_site(I)& c,
+ unsigned i, int dmax)
+ {
+ const I& lbl = exact(lbl_);
+
+ mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
+ mln_assertion(lbl.is_valid());
-# endif // ! MLN_INCLUDE_ONLY
+ if (lbl.domain().has(p) // Not outside image domain
+ && lbl(p) != literal::zero // Not the background
+ && lbl(p) != i // Not the current component
+ && (math::abs(p.col() - c.col())) < dmax // Not too far
+ && link_array[lbl(p)] != i) // Not creating a loop
+ link_array[i] = lbl(p);
+ }
- } // end of namespace scribo::text::grouping::internal
+# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::internal
} // end of namespace scribo::text
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_LINK_ARRAY_HH
+#endif // ! SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
diff --git a/scribo/text/all.hh b/scribo/primitive/link/all.hh
similarity index 64%
copy from scribo/text/all.hh
copy to scribo/primitive/link/all.hh
index 000d5b9..7313adb 100644
--- a/scribo/text/all.hh
+++ b/scribo/primitive/link/all.hh
@@ -23,27 +23,38 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_ALL_HH
-# define SCRIBO_TEXT_ALL_HH
+#ifndef SCRIBO_PRIMITIVE_LINK_ALL_HH
+# define SCRIBO_PRIMITIVE_LINK_ALL_HH
/// \file
///
-/// Include all headers located in scribo/text.
+/// Include all headers located in scribo/primitive/group.
namespace scribo
{
- /// Namespace of routines working on text components.
- namespace text
+ namespace primitive
{
- } // end of namespace scribo::text
+ /// Namespace of primitive linking related routines.
+ namespace link
+ {
+
+ } // end of namespace scribo::primitive::group
+
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-# include <scribo/text/extract_lines.hh>
-//# include <scribo/text/recognition.hh>
-# include <scribo/text/clean.hh>
-# include <scribo/text/grouping/all.hh>
-#endif // ! SCRIBO_TEXT_ALL_HH
+
+
+# include <scribo/primitive/link/with_several_graphes.hh>
+# include <scribo/primitive/link/with_several_right_links.hh>
+# include <scribo/primitive/link/with_graph.hh>
+# include <scribo/primitive/link/with_single_left_link.hh>
+# include <scribo/primitive/link/with_several_left_links.hh>
+# include <scribo/primitive/link/with_single_right_link.hh>
+
+
+#endif // ! SCRIBO_PRIMITIVE_LINK_ALL_HH
diff --git a/scribo/primitive/link/merge_double_link.hh
b/scribo/primitive/link/merge_double_link.hh
new file mode 100644
index 0000000..3181117
--- /dev/null
+++ b/scribo/primitive/link/merge_double_link.hh
@@ -0,0 +1,123 @@
+// Copyright (C) 2009 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_PRIMITIVE_LINK_MERGE_DOUBLE_LINK_HH
+# define SCRIBO_PRIMITIVE_LINK_MERGE_DOUBLE_LINK_HH
+
+
+/// \file
+///
+/// Validate and merge double link information. A link must exist in
+/// both ways to be validated.
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/site_set/box.hh>
+
+# include <mln/accu/shape/bbox.hh>
+
+# include <mln/data/compare.hh>
+
+# include <mln/util/array.hh>
+
+# include <scribo/core/macros.hh>
+
+# include <scribo/core/object_links.hh>
+# include <scribo/core/object_image.hh>
+# include <scribo/primitive/internal/find_root.hh>
+# include <scribo/primitive/internal/is_link_valid.hh>
+# include <scribo/primitive/internal/init_link_array.hh>
+
+
+namespace scribo
+{
+
+ namespace primitive
+ {
+
+ namespace link
+ {
+
+ /*!
+ \brief Validate and merge double link information. A link
+ must exist in both ways to be validated.
+
+ \param[in] objects The Lines of text.
+ \param[in] left_link The left neighbor of each line of text.
+ \param[in] right_link The right neighbor of each line of text.
+
+ \return The merge of left_link and right_link.
+ */
+ template <typename L>
+ object_links<L>
+ merge_double_link(const object_image(L)& objects,
+ const object_links<L>& left_link,
+ const object_links<L>& right_link);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename L>
+ inline
+ object_links<L>
+ merge_double_link(const object_image(L)& objects,
+ const object_links<L>& left_link,
+ const object_links<L>& right_link)
+ {
+ trace::entering("scribo::primitive::link::merge_double_link");
+
+ mln_precondition(objects.is_valid());
+ mln_precondition(left_link.nelements() == right_link.nelements());
+ mln_precondition(left_link.objects_id_() == objects.id_());
+ mln_precondition(right_link.objects_id_() == objects.id_());
+
+
+ object_links<L> merge(left_link);
+
+ for_all_ncomponents(i, objects.nlabels())
+ {
+ mln::util::couple<bool, unsigned>
+ nbh = internal::is_link_valid(left_link, right_link, i);
+ if (!nbh.first())
+ merge[i] = i;
+ }
+
+ trace::exiting("scribo::primitive::link::merge_double_link");
+ return merge;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace scribo::primitive::link
+
+ } // end of namespace scribo::primitive
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_PRIMITIVE_LINK_MERGE_DOUBLE_LINK_HH
diff --git a/scribo/text/grouping/group_with_graph.hh
b/scribo/primitive/link/with_graph.hh
similarity index 79%
rename from scribo/text/grouping/group_with_graph.hh
rename to scribo/primitive/link/with_graph.hh
index e13e2e9..5f16ec8 100644
--- a/scribo/text/grouping/group_with_graph.hh
+++ b/scribo/primitive/link/with_graph.hh
@@ -23,12 +23,12 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_GRAPH_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_GRAPH_HH
+#ifndef SCRIBO_PRIMITIVE_LINK_WITH_GRAPH_HH
+# define SCRIBO_PRIMITIVE_LINK_WITH_GRAPH_HH
/// \file
///
-/// Group character bounding boxes with a graph.
+/// Link character bounding boxes with a graph.
# include <mln/core/concept/image.hh>
@@ -43,18 +43,18 @@
# include <scribo/core/macros.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/find_graph_link.hh>
+# include <scribo/primitive/internal/init_link_array.hh>
+# include <scribo/primitive/internal/find_graph_link.hh>
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace link
{
/*!
@@ -70,7 +70,7 @@ namespace scribo
*/
template <typename L>
mln::util::graph
- group_with_graph(const object_image(L)& objects,
+ with_graph(const object_image(L)& objects,
unsigned neighb_max_distance);
@@ -79,10 +79,10 @@ namespace scribo
template <typename L>
inline
mln::util::graph
- group_with_graph(const object_image(L)& objects,
- unsigned neighb_max_distance)
+ with_graph(const object_image(L)& objects,
+ unsigned neighb_max_distance)
{
- trace::entering("scribo::text::grouping::group_with_graph");
+ trace::entering("scribo::primitive::link::with_graph");
mln_precondition(objects.is_valid());
@@ -107,7 +107,7 @@ namespace scribo
internal::find_graph_link(g, objects, i, dmax, mass_center[i]);
}
- trace::exiting("scribo::text::grouping::group_with_graph");
+ trace::exiting("scribo::primitive::link::with_graph");
return g;
}
@@ -115,11 +115,11 @@ namespace scribo
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::link
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_GRAPH_HH
+#endif // ! SCRIBO_PRIMITIVE_LINK_WITH_GRAPH_HH
diff --git a/scribo/text/grouping/group_with_rag.hh b/scribo/primitive/link/with_rag.hh
similarity index 80%
rename from scribo/text/grouping/group_with_rag.hh
rename to scribo/primitive/link/with_rag.hh
index c995335..3638ec7 100644
--- a/scribo/text/grouping/group_with_rag.hh
+++ b/scribo/primitive/link/with_rag.hh
@@ -23,13 +23,13 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_RAG_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_RAG_HH
+#ifndef SCRIBO_PRIMITIVE_LINK_WITH_RAG_HH
+# define SCRIBO_PRIMITIVE_LINK_WITH_RAG_HH
/// \file
///
-/// Group objects with a region adjacency graph.
+/// Link objects with a region adjacency graph.
# include <mln/core/concept/neighborhood.hh>
@@ -48,10 +48,10 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace link
{
using namespace mln;
@@ -59,7 +59,7 @@ namespace scribo
template <typename L, typename N>
util::couple<mln::util::graph, mln_concrete(L)>
- group_with_rag(const object_image(L)& objects,
+ with_rag(const object_image(L)& objects,
const Neighborhood<N>& nbh);
@@ -68,10 +68,10 @@ namespace scribo
template <typename L, typename N>
util::couple<mln::util::graph, mln_concrete(L)>
- group_with_rag(const object_image(L)& objects,
+ with_rag(const object_image(L)& objects,
const Neighborhood<N>& nbh)
{
- trace::entering("scribo::text::grouping::group_with_rag");
+ trace::entering("scribo::primitive::link::with_rag");
mln_precondition(objects.is_valid());
@@ -83,17 +83,17 @@ namespace scribo
nbh,
objects.nlabels());
- trace::exiting("scribo::text::grouping::group_with_rag");
+ trace::exiting("scribo::primitive::link::with_rag");
return make::couple(g, iz);
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::link
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_RAG_HH
+#endif // ! SCRIBO_PRIMITIVE_LINK_WITH_RAG_HH
diff --git a/scribo/text/grouping/group_with_several_graphes.hh
b/scribo/primitive/link/with_several_graphes.hh
similarity index 77%
rename from scribo/text/grouping/group_with_several_graphes.hh
rename to scribo/primitive/link/with_several_graphes.hh
index 24cea3d..148d3cc 100644
--- a/scribo/text/grouping/group_with_several_graphes.hh
+++ b/scribo/primitive/link/with_several_graphes.hh
@@ -23,12 +23,12 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_GRAPHES_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_GRAPHES_HH
+#ifndef SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_GRAPHES_HH
+# define SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_GRAPHES_HH
/// \file
///
-/// Group character bounding boxes with several graphes.
+/// Link character bounding boxes with several graphes.
# include <mln/core/concept/image.hh>
# include <mln/labeling/compute.hh>
@@ -41,34 +41,34 @@
# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
-# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/find_graph_link.hh>
+# include <scribo/primitive/internal/init_link_array.hh>
+# include <scribo/primitive/internal/find_graph_link.hh>
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace link
{
- /// Group character bounding boxes with several graphes.
+ /// Link character bounding boxes with several graphes.
/// Look up for neighbors on the left of each box.
template <typename L>
mln::util::graph
- group_with_several_graphes(const object_image(L)& objects,
- unsigned neighb_max_distance);
+ with_several_graphes(const object_image(L)& objects,
+ unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
inline
mln::util::graph
- group_with_several_graphes(const object_image(L)& objects,
- unsigned neighb_max_distance)
+ with_several_graphes(const object_image(L)& objects,
+ unsigned neighb_max_distance)
{
- trace::entering("scribo::text::grouping::group_with_several_graphes");
+ trace::entering("scribo::primitive::link::with_several_graphes");
mln::util::graph g(objects.nlabels().next());
@@ -113,16 +113,16 @@ namespace scribo
}
- trace::exiting("scribo::text::grouping::group_with_several_graphes");
+ trace::exiting("scribo::primitive::link::with_several_graphes");
return g;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::link
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_GRAPHES_HH
+#endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_GRAPHES_HH
diff --git a/scribo/text/grouping/group_with_several_left_links.hh
b/scribo/primitive/link/with_several_left_links.hh
similarity index 76%
rename from scribo/text/grouping/group_with_several_left_links.hh
rename to scribo/primitive/link/with_several_left_links.hh
index 8b9e9ff..c2c6c83 100644
--- a/scribo/text/grouping/group_with_several_left_links.hh
+++ b/scribo/primitive/link/with_several_left_links.hh
@@ -23,33 +23,34 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_LEFT_LINKS_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_LEFT_LINKS_HH
+#ifndef SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_LEFT_LINKS_HH
+# define SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_LEFT_LINKS_HH
/// \file
///
/// Link text bounding boxes with their left neighbor.
///
-/// Merge code with text::grouping::group_with_single_right_link.hh
+/// Merge code with primitive::link::with_single_right_link.hh
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/util/array.hh>
+# include <scribo/core/object_links.hh>
# include <scribo/core/macros.hh>
-# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/find_left_link.hh>
+# include <scribo/primitive/internal/init_link_array.hh>
+# include <scribo/primitive/internal/find_left_link.hh>
# include <scribo/util/text.hh>
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace link
{
/// Map each character bounding box to its left bounding box neighbor
@@ -59,25 +60,28 @@ namespace scribo
/// \return an mln::util::array. Map a bounding box to its left neighbor.
template <typename L>
inline
- mln::util::array<unsigned>
- group_with_several_left_links(const object_image(L)& objects,
- unsigned neighb_max_distance);
+ object_links<L>
+ with_several_left_links(const object_image(L)& objects,
+ unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
inline
- mln::util::array<unsigned>
- group_with_several_left_links(const object_image(L)& objects,
- unsigned neighb_max_distance)
+ object_links<L>
+ with_several_left_links(const object_image(L)& objects,
+ unsigned neighb_max_distance)
{
- trace::entering("scribo::text::grouping::group_with_several_left_links");
+ trace::entering("scribo::primitive::link::with_several_left_links");
mln_precondition(objects.is_valid());
- mln::util::array<unsigned>
- link_1(objects.nlabels().next()), link_2(objects.nlabels().next()),
- link_3(objects.nlabels().next()), final_link(objects.nlabels().next());
+ object_links<L>
+ link_1(objects, objects.nlabels().next()),
+ link_2(objects, objects.nlabels().next()),
+ link_3(objects, objects.nlabels().next()),
+ final_link(objects, objects.nlabels().next());
+
internal::init_link_array(link_1);
internal::init_link_array(link_2);
internal::init_link_array(link_3);
@@ -131,16 +135,16 @@ namespace scribo
final_link[i] = i;
}
- trace::exiting("scribo::text::grouping::group_with_several_left_links");
+ trace::exiting("scribo::primitive::link::with_several_left_links");
return final_link;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::link
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_LEFT_LINKS_HH
+#endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_LEFT_LINKS_HH
diff --git a/scribo/text/grouping/group_with_several_right_links.hh
b/scribo/primitive/link/with_several_right_links.hh
similarity index 76%
rename from scribo/text/grouping/group_with_several_right_links.hh
rename to scribo/primitive/link/with_several_right_links.hh
index d0a5400..17e00cc 100644
--- a/scribo/text/grouping/group_with_several_right_links.hh
+++ b/scribo/primitive/link/with_several_right_links.hh
@@ -23,34 +23,35 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_RIGHT_LINKS_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_RIGHT_LINKS_HH
+#ifndef SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_RIGHT_LINKS_HH
+# define SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_RIGHT_LINKS_HH
/// \file
///
/// Link text bounding boxes with their right neighbor.
///
-/// Merge code with text::grouping::group_with_single_right_link.hh
+/// Merge code with primitive::link::with_single_right_link.hh
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/util/array.hh>
+# include <scribo/core/object_links.hh>
# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
-# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/find_right_link.hh>
+# include <scribo/primitive/internal/init_link_array.hh>
+# include <scribo/primitive/internal/find_right_link.hh>
# include <scribo/util/text.hh>
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace link
{
using namespace mln;
@@ -62,25 +63,28 @@ namespace scribo
/// \return an mln::util::array. Map a bounding box to its right neighbor.
template <typename L>
inline
- mln::util::array<unsigned>
- group_with_several_right_links(const object_image(L)& objects,
- unsigned neighb_max_distance);
+ object_links<L>
+ with_several_right_links(const object_image(L)& objects,
+ unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
inline
- mln::util::array<unsigned>
- group_with_several_right_links(const object_image(L)& objects,
- unsigned neighb_max_distance)
+ object_links<L>
+ with_several_right_links(const object_image(L)& objects,
+ unsigned neighb_max_distance)
{
- trace::entering("scribo::text::grouping::group_with_several_right_links");
+ trace::entering("scribo::primitive::link::with_several_right_links");
mln_precondition(objects.is_valid());
- mln::util::array<unsigned>
- link_1(objects.nlabels().next()), link_2(objects.nlabels().next()),
- link_3(objects.nlabels().next()), final_link(objects.nlabels().next());
+ object_links<L>
+ link_1(objects, objects.nlabels().next()),
+ link_2(objects, objects.nlabels().next()),
+ link_3(objects, objects.nlabels().next()),
+ final_link(objects, objects.nlabels().next());
+
internal::init_link_array(link_1);
internal::init_link_array(link_2);
internal::init_link_array(link_3);
@@ -135,16 +139,16 @@ namespace scribo
final_link[i] = i;
}
- trace::exiting("scribo::text::grouping::group_with_several_right_links");
+ trace::exiting("scribo::primitive::link::with_several_right_links");
return final_link;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::link
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_RIGHT_LINKS_HH
+#endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_RIGHT_LINKS_HH
diff --git a/scribo/text/grouping/group_with_single_left_link.hh
b/scribo/primitive/link/with_single_left_link.hh
similarity index 75%
rename from scribo/text/grouping/group_with_single_left_link.hh
rename to scribo/primitive/link/with_single_left_link.hh
index 19593c6..03cb870 100644
--- a/scribo/text/grouping/group_with_single_left_link.hh
+++ b/scribo/primitive/link/with_single_left_link.hh
@@ -23,14 +23,14 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_SINGLE_LEFT_LINK_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_SINGLE_LEFT_LINK_HH
+#ifndef SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_LEFT_LINK_HH
+# define SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_LEFT_LINK_HH
/// \file
///
/// Link text objects with their left neighbor.
///
-/// Merge code with text::grouping::group_with_single_right_link.hh
+/// Merge code with primitive::link::with_single_right_link.hh
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -43,10 +43,11 @@
# include <mln/util/array.hh>
+# include <scribo/core/object_links.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/find_left_link.hh>
+# include <scribo/primitive/internal/init_link_array.hh>
+# include <scribo/primitive/internal/find_left_link.hh>
//FIXME: not generic.
# include <mln/core/alias/dpoint2d.hh>
@@ -54,10 +55,10 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace link
{
/// Map each text object to its left bounding box neighbor
@@ -71,23 +72,23 @@ namespace scribo
//
template <typename L>
inline
- mln::util::array<unsigned>
- group_with_single_left_link(const object_image(L)& objects,
- unsigned neighb_max_distance);
+ object_links<L>
+ with_single_left_link(const object_image(L)& objects,
+ unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
inline
- mln::util::array<unsigned>
- group_with_single_left_link(const object_image(L)& objects,
- unsigned neighb_max_distance)
+ object_links<L>
+ with_single_left_link(const object_image(L)& objects,
+ unsigned neighb_max_distance)
{
- trace::entering("scribo::text::grouping::group_with_single_left_link");
+ trace::entering("scribo::primitive::link::with_single_left_link");
mln_precondition(objects.is_valid());
- mln::util::array<unsigned> left_link(objects.nlabels().next());
+ object_links<L> left_link(objects, objects.nlabels().next());
internal::init_link_array(left_link);
mln::util::array<mln_result(accu::center<mln_psite(L)>)>
@@ -105,16 +106,16 @@ namespace scribo
internal::find_left_link(objects, left_link, i, dmax, c);
}
- trace::exiting("scribo::text::grouping::group_with_single_left_link");
+ trace::exiting("scribo::primitive::link::with_single_left_link");
return left_link;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::link
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_SINGLE_LEFT_LINK_HH
+#endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_LEFT_LINK_HH
diff --git a/scribo/text/grouping/group_with_single_right_link.hh
b/scribo/primitive/link/with_single_right_link.hh
similarity index 73%
rename from scribo/text/grouping/group_with_single_right_link.hh
rename to scribo/primitive/link/with_single_right_link.hh
index ae3fdf1..bd15698 100644
--- a/scribo/text/grouping/group_with_single_right_link.hh
+++ b/scribo/primitive/link/with_single_right_link.hh
@@ -23,14 +23,14 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_SINGLE_RIGHT_LINK_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_SINGLE_RIGHT_LINK_HH
+#ifndef SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_RIGHT_LINK_HH
+# define SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_RIGHT_LINK_HH
/// \file
///
/// Link text objects with their right neighbor.
///
-/// \todo Merge code with text::grouping::group_with_single_right_link.hh
+/// \todo Merge code with primitive::link::with_single_right_link.hh
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -43,10 +43,11 @@
# include <mln/util/array.hh>
+# include <scribo/core/object_links.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/object_image.hh>
-# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/find_right_link.hh>
+# include <scribo/primitive/internal/init_link_array.hh>
+# include <scribo/primitive/internal/find_right_link.hh>
//FIXME: not generic.
# include <mln/core/alias/dpoint2d.hh>
@@ -54,10 +55,10 @@
namespace scribo
{
- namespace text
+ namespace primitive
{
- namespace grouping
+ namespace link
{
/// Map each text object to its right bounding box neighbor
@@ -70,23 +71,23 @@ namespace scribo
/// \return an mln::util::array. Map a bounding box to its right neighbor.
template <typename L>
inline
- mln::util::array<unsigned>
- group_with_single_right_link(const object_image(L)& objects,
- unsigned neighb_max_distance);
+ object_links<L>
+ with_single_right_link(const object_image(L)& objects,
+ unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
inline
- mln::util::array<unsigned>
- group_with_single_right_link(const object_image(L)& objects,
- unsigned neighb_max_distance)
+ object_links<L>
+ with_single_right_link(const object_image(L)& objects,
+ unsigned neighb_max_distance)
{
- trace::entering("scribo::text::grouping::group_with_single_right_link");
+ trace::entering("scribo::primitive::link::with_single_right_link");
mln_precondition(objects.is_valid());
- mln::util::array<unsigned> right_link(objects.nlabels().next());
+ object_links<L> right_link(objects, objects.nlabels().next());
internal::init_link_array(right_link);
mln::util::array<mln_result(accu::center<mln_psite(L)>)>
@@ -104,16 +105,16 @@ namespace scribo
internal::find_right_link(objects, right_link, i, dmax, c);
}
- trace::exiting("scribo::text::grouping::group_with_single_right_link");
+ trace::exiting("scribo::primitive::link::with_single_right_link");
return right_link;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::text::grouping
+ } // end of namespace scribo::primitive::link
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_SINGLE_RIGHT_LINK_HH
+#endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_RIGHT_LINK_HH
diff --git a/scribo/src/extract/primitive/extract_discontinued_hlines.cc
b/scribo/src/extract/primitive/extract_discontinued_hlines.cc
index 8d4c367..127ca0f 100644
--- a/scribo/src/extract/primitive/extract_discontinued_hlines.cc
+++ b/scribo/src/extract/primitive/extract_discontinued_hlines.cc
@@ -29,7 +29,7 @@
#include <mln/io/pbm/all.hh>
#include <mln/data/convert.hh>
-#include <scribo/extract/primitive/lines_h_discontinued.hh>
+#include <scribo/primitive/extract/lines_h_discontinued.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
value::label_16 nlines;
image2d<bool> lines
= data::convert(bool(),
- scribo::extract::primitive::lines_h_discontinued(input,
+ scribo::primitive::extract::lines_h_discontinued(input,
c8(),
nlines,
atoi(argv[2]),
diff --git a/scribo/src/extract/primitive/extract_discontinued_lines.cc
b/scribo/src/extract/primitive/extract_discontinued_lines.cc
index 6568928..da3faf9 100644
--- a/scribo/src/extract/primitive/extract_discontinued_lines.cc
+++ b/scribo/src/extract/primitive/extract_discontinued_lines.cc
@@ -29,8 +29,8 @@
#include <mln/io/pbm/all.hh>
#include <mln/data/convert.hh>
-#include <scribo/extract/primitive/lines_h_discontinued.hh>
-#include <scribo/extract/primitive/lines_v_discontinued.hh>
+#include <scribo/primitive/extract/lines_h_discontinued.hh>
+#include <scribo/primitive/extract/lines_v_discontinued.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
value::label_16 nhlines;
image2d<bool> hlines
= data::convert(bool(),
- scribo::extract::primitive::lines_h_discontinued(input,
+ scribo::primitive::extract::lines_h_discontinued(input,
c8(),
nhlines,
atoi(argv[2]),
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
value::label_16 nvlines;
image2d<bool> vlines
= data::convert(bool(),
- scribo::extract::primitive::lines_v_discontinued(input,
+ scribo::primitive::extract::lines_v_discontinued(input,
c8(),
nvlines,
atoi(argv[2]),
diff --git a/scribo/src/extract/primitive/extract_discontinued_vlines.cc
b/scribo/src/extract/primitive/extract_discontinued_vlines.cc
index af1f079..5e71ec0 100644
--- a/scribo/src/extract/primitive/extract_discontinued_vlines.cc
+++ b/scribo/src/extract/primitive/extract_discontinued_vlines.cc
@@ -29,7 +29,7 @@
#include <mln/io/pbm/all.hh>
#include <mln/data/convert.hh>
-#include <scribo/extract/primitive/lines_v_discontinued.hh>
+#include <scribo/primitive/extract/lines_v_discontinued.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
value::label_16 nlines;
image2d<bool> lines
= data::convert(bool(),
- scribo::extract::primitive::lines_v_discontinued(input,
+ scribo::primitive::extract::lines_v_discontinued(input,
c8(),
nlines,
atoi(argv[2]),
diff --git a/scribo/src/extract/primitive/extract_thick_hlines.cc
b/scribo/src/extract/primitive/extract_thick_hlines.cc
index ae8cbd6..efa158a 100644
--- a/scribo/src/extract/primitive/extract_thick_hlines.cc
+++ b/scribo/src/extract/primitive/extract_thick_hlines.cc
@@ -29,7 +29,7 @@
#include <mln/io/pbm/all.hh>
#include <mln/data/convert.hh>
-#include <scribo/extract/primitive/lines_h_thick.hh>
+#include <scribo/primitive/extract/lines_h_thick.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
value::label_16 nlines;
image2d<bool> lines
= data::convert(bool(),
- scribo::extract::primitive::lines_h_thick(input,
+ scribo::primitive::extract::lines_h_thick(input,
c8(),
nlines,
atoi(argv[2])));
diff --git a/scribo/src/extract/primitive/extract_thick_vlines.cc
b/scribo/src/extract/primitive/extract_thick_vlines.cc
index 49bec1e..2a5f8ee 100644
--- a/scribo/src/extract/primitive/extract_thick_vlines.cc
+++ b/scribo/src/extract/primitive/extract_thick_vlines.cc
@@ -29,7 +29,7 @@
#include <mln/io/pbm/all.hh>
#include <mln/data/convert.hh>
-#include <scribo/extract/primitive/lines_v_thick.hh>
+#include <scribo/primitive/extract/lines_v_thick.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
value::label_16 nlines;
image2d<bool> lines
= data::convert(bool(),
- scribo::extract::primitive::lines_v_thick(input,
+ scribo::primitive::extract::lines_v_thick(input,
c8(),
nlines,
atoi(argv[2])));
diff --git a/scribo/src/extract/primitive/find_discontinued_lines.cc
b/scribo/src/extract/primitive/find_discontinued_lines.cc
index ac3725a..eaf2d59 100644
--- a/scribo/src/extract/primitive/find_discontinued_lines.cc
+++ b/scribo/src/extract/primitive/find_discontinued_lines.cc
@@ -35,8 +35,8 @@
#include <scribo/debug/usage.hh>
#include <scribo/core/object_image.hh>
-#include <scribo/extract/primitive/lines_h_pattern.hh>
-#include <scribo/extract/primitive/lines_v_pattern.hh>
+#include <scribo/primitive/extract/lines_h_pattern.hh>
+#include <scribo/primitive/extract/lines_v_pattern.hh>
const char *args_desc[][2] =
{
@@ -63,8 +63,8 @@ int main(int argc, char *argv[])
I input;
io::pbm::load(input, argv[1]);
- I hlines = scribo::extract::primitive::lines_h_pattern(input, atoi(argv[2]));
- I vlines = scribo::extract::primitive::lines_v_pattern(input, atoi(argv[2]));
+ I hlines = scribo::primitive::extract::lines_h_pattern(input, atoi(argv[2]));
+ I vlines = scribo::primitive::extract::lines_v_pattern(input, atoi(argv[2]));
image2d<value::rgb8> out = debug::superpose(input, hlines, literal::red);
out = debug::superpose(out, vlines, literal::green);
diff --git a/scribo/src/extract/primitive/find_single_lines.cc
b/scribo/src/extract/primitive/find_single_lines.cc
index bd7b559..afe518b 100644
--- a/scribo/src/extract/primitive/find_single_lines.cc
+++ b/scribo/src/extract/primitive/find_single_lines.cc
@@ -34,9 +34,9 @@
#include <scribo/debug/usage.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/extract/primitive/lines_h_single.hh>
-#include <scribo/extract/primitive/lines_v_single.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/lines_h_single.hh>
+#include <scribo/primitive/extract/lines_v_single.hh>
const char *args_desc[][2] =
{
@@ -71,16 +71,16 @@ int main(int argc, char *argv[])
value::label_16 nhlines;
object_image(L)
- objects = scribo::extract::primitive::objects(input, c8(), nhlines);
+ objects = scribo::primitive::extract::objects(input, c8(), nhlines);
object_image(L)
- hlines = scribo::extract::primitive::lines_h_single(objects,
+ hlines = scribo::primitive::extract::lines_h_single(objects,
atoi(argv[2]),
atof(argv[3]));
object_image(L)
- vlines = scribo::extract::primitive::lines_v_single(objects,
+ vlines = scribo::primitive::extract::lines_v_single(objects,
atoi(argv[4]),
atof(argv[5]));
diff --git a/scribo/src/extract/primitive/find_thick_lines.cc
b/scribo/src/extract/primitive/find_thick_lines.cc
index ed5fb8c..993bf42 100644
--- a/scribo/src/extract/primitive/find_thick_lines.cc
+++ b/scribo/src/extract/primitive/find_thick_lines.cc
@@ -35,11 +35,11 @@
#include <scribo/debug/usage.hh>
#include <scribo/core/object_image.hh>
-#include <scribo/extract/primitive/lines_h_thick.hh>
-#include <scribo/extract/primitive/lines_v_thick.hh>
+#include <scribo/primitive/extract/lines_h_thick.hh>
+#include <scribo/primitive/extract/lines_v_thick.hh>
-#include <scribo/extract/primitive/lines_h_single.hh>
-#include <scribo/extract/primitive/lines_v_single.hh>
+#include <scribo/primitive/extract/lines_h_single.hh>
+#include <scribo/primitive/extract/lines_v_single.hh>
#include <mln/util/timer.hh>
@@ -85,20 +85,20 @@ int main(int argc, char *argv[])
t.start();
object_image(L)
- hlines = scribo::extract::primitive::lines_h_thick(input, c8(),
+ hlines = scribo::primitive::extract::lines_h_thick(input, c8(),
nhlines, atoi(argv[2])),
- vlines = scribo::extract::primitive::lines_v_thick(input, c8(),
+ vlines = scribo::primitive::extract::lines_v_thick(input, c8(),
nvlines, atoi(argv[2]));
std::cout << "lines thick done" << std::endl;
std::cout << t << std::endl;
t.restart();
- hlines = scribo::extract::primitive::lines_h_single(hlines,
+ hlines = scribo::primitive::extract::lines_h_single(hlines,
atoi(argv[2]),
10);
- vlines = scribo::extract::primitive::lines_v_single(vlines,
+ vlines = scribo::primitive::extract::lines_v_single(vlines,
atoi(argv[2]),
10);
diff --git a/scribo/src/filter/large_objects.cc b/scribo/src/filter/large_objects.cc
index 51ab029..d2e91c5 100644
--- a/scribo/src/filter/large_objects.cc
+++ b/scribo/src/filter/large_objects.cc
@@ -62,7 +62,7 @@ int main(int argc, char *argv[])
value::label_16 nobjects;
typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
obj_ima_t objects
- = scribo::extract::primitive::objects(input, c8(), nobjects);
+ = scribo::primitive::extract::objects(input, c8(), nobjects);
obj_ima_t filtered = scribo::filter::large_objects(objects, atoi(argv[2]));
io::pbm::save(data::convert(bool(), filtered), argv[3]);
diff --git a/scribo/src/filter/small_objects.cc b/scribo/src/filter/small_objects.cc
index fed6252..f9a318e 100644
--- a/scribo/src/filter/small_objects.cc
+++ b/scribo/src/filter/small_objects.cc
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
value::label_16 nobjects;
typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
obj_ima_t objects
- = scribo::extract::primitive::objects(input, c8(), nobjects);
+ = scribo::primitive::extract::objects(input, c8(), nobjects);
obj_ima_t filtered = scribo::filter::small_objects(objects, atoi(argv[2]));
io::pbm::save(data::convert(bool(), filtered), argv[3]);
diff --git a/scribo/src/filter/thick_objects.cc b/scribo/src/filter/thick_objects.cc
index 288402c..91fba14 100644
--- a/scribo/src/filter/thick_objects.cc
+++ b/scribo/src/filter/thick_objects.cc
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
value::label_16 nobjects;
typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
obj_ima_t objects
- = scribo::extract::primitive::objects(input, c8(), nobjects);
+ = scribo::primitive::extract::objects(input, c8(), nobjects);
obj_ima_t filtered = scribo::filter::thick_objects(objects, atoi(argv[2]));
io::pbm::save(data::convert(bool(), filtered), argv[3]);
diff --git a/scribo/src/filter/thin_objects.cc b/scribo/src/filter/thin_objects.cc
index 9129231..9da3981 100644
--- a/scribo/src/filter/thin_objects.cc
+++ b/scribo/src/filter/thin_objects.cc
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
value::label_16 nobjects;
typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
obj_ima_t objects
- = scribo::extract::primitive::objects(input, c8(), nobjects);
+ = scribo::primitive::extract::objects(input, c8(), nobjects);
obj_ima_t filtered = scribo::filter::thin_objects(objects, atoi(argv[2]));
io::pbm::save(data::convert(bool(), filtered), argv[3]);
diff --git a/scribo/src/recognition.cc b/scribo/src/recognition.cc
index 97f2880..f9ea901 100644
--- a/scribo/src/recognition.cc
+++ b/scribo/src/recognition.cc
@@ -36,11 +36,12 @@
#include <mln/core/alias/neighb2d.hh>
-#include <scribo/extract/primitive/objects.hh>
+#include <scribo/primitive/extract/objects.hh>
-#include <scribo/text/grouping/group_with_several_left_links.hh>
-#include <scribo/text/grouping/group_with_several_right_links.hh>
-#include <scribo/text/grouping/group_from_double_link.hh>
+#include <scribo/primitive/group/apply.hh>
+#include <scribo/primitive/link/with_several_left_links.hh>
+#include <scribo/primitive/link/with_several_right_links.hh>
+#include <scribo/primitive/group/from_double_link.hh>
#include <scribo/filter/small_objects.hh>
#include <scribo/filter/thin_objects.hh>
#include <scribo/text/recognition.hh>
@@ -75,22 +76,24 @@ int main(int argc, char* argv[])
io::pbm::load(input, argv[1]);
/// Extract text.
- typedef mln_ch_value_(image2d<bool>,value::label_16) lbl_t;
+ typedef mln_ch_value_(image2d<bool>,value::label_16) L;
value::label_16 nbboxes;
- object_image(lbl_t)
- objects = scribo::extract::primitive::objects(input, c8(), nbboxes);
+ object_image(L)
+ objects = scribo::primitive::extract::objects(input, c8(), nbboxes);
/// Filter non interesting objects
objects = filter::small_objects(objects, 4);
- objects = filter::thin_objects<lbl_t>(objects, 2);
+ objects = filter::thin_objects<L>(objects, 2);
/// Group objects.
- mln::util::array<unsigned> left_link
- = text::grouping::group_with_several_left_links<lbl_t>(objects, 30);
- mln::util::array<unsigned> right_link
- = text::grouping::group_with_several_right_links(objects, 30);
- objects = text::grouping::group_from_double_link(objects, left_link, right_link);
-
+ object_links<L> left_link
+ = primitive::link::with_several_left_links(objects, 30);
+ object_links<L> right_link
+ = primitive::link::with_several_right_links(objects, 30);
+ object_groups<L>
+ groups = primitive::group::from_double_link(objects, left_link, right_link);
+
+ objects = primitive::group::apply(objects, groups);
/// Try to recognize text in grouped objects.
scribo::text::recognition(objects, "fra", argv[2]);
diff --git a/scribo/src/table/erase.cc b/scribo/src/table/erase.cc
index 3cb441e..671296a 100644
--- a/scribo/src/table/erase.cc
+++ b/scribo/src/table/erase.cc
@@ -34,8 +34,8 @@
#include <scribo/table/erase.hh>
-#include <scribo/extract/primitive/lines_h_discontinued.hh>
-#include <scribo/extract/primitive/lines_v_discontinued.hh>
+#include <scribo/primitive/extract/lines_h_discontinued.hh>
+#include <scribo/primitive/extract/lines_v_discontinued.hh>
#include <scribo/debug/usage.hh>
@@ -70,10 +70,10 @@ int main(int argc, char* argv[])
label_16 nhlines, nvlines;
object_image(lbl_t)
- lbl_v = extract::primitive::lines_v_discontinued(input, c8(),
+ lbl_v = primitive::extract::lines_v_discontinued(input, c8(),
nvlines, 51, 8);
object_image(lbl_t)
- lbl_h = extract::primitive::lines_h_discontinued(input, c8(),
+ lbl_h = primitive::extract::lines_h_discontinued(input, c8(),
nhlines, 51, 6);
image2d<bool> input_notables
diff --git a/scribo/src/table_rebuild_opening.cc b/scribo/src/table_rebuild_opening.cc
index 8e12467..a13a00f 100644
--- a/scribo/src/table_rebuild_opening.cc
+++ b/scribo/src/table_rebuild_opening.cc
@@ -35,8 +35,8 @@
#include <scribo/table/rebuild.hh>
#include <scribo/table/erase.hh>
-#include <scribo/extract/primitive/lines_h_thick.hh>
-#include <scribo/extract/primitive/lines_v_thick.hh>
+#include <scribo/primitive/extract/lines_h_thick.hh>
+#include <scribo/primitive/extract/lines_v_thick.hh>
#include <scribo/make/debug_filename.hh>
int usage(const char *name)
@@ -64,12 +64,12 @@ int main(int argc, char* argv[])
value::label_16 nbboxes;
lines_t hlines
- = scribo::extract::primitive::lines_h_thick(input,
+ = scribo::primitive::extract::lines_h_thick(input,
c8(),
nbboxes,
51);
lines_t vlines
- = scribo::extract::primitive::lines_v_thick(input,
+ = scribo::primitive::extract::lines_v_thick(input,
c8(),
nbboxes,
51);
diff --git a/scribo/src/table_rebuild_rank.cc b/scribo/src/table_rebuild_rank.cc
index 5e0d339..1c6b921 100644
--- a/scribo/src/table_rebuild_rank.cc
+++ b/scribo/src/table_rebuild_rank.cc
@@ -37,8 +37,8 @@
#include <scribo/table/rebuild.hh>
#include <scribo/table/erase.hh>
-#include <scribo/extract/primitive/lines_h_discontinued.hh>
-#include <scribo/extract/primitive/lines_v_discontinued.hh>
+#include <scribo/primitive/extract/lines_h_discontinued.hh>
+#include <scribo/primitive/extract/lines_v_discontinued.hh>
#include <scribo/make/debug_filename.hh>
int usage(const char *name)
@@ -66,13 +66,13 @@ int main(int argc, char* argv[])
value::label_16 nbboxes;
lines_t hlines
- = scribo::extract::primitive::lines_h_discontinued(input,
+ = scribo::primitive::extract::lines_h_discontinued(input,
c8(),
nbboxes,
51,
6);
lines_t vlines
- = scribo::extract::primitive::lines_v_discontinued(input,
+ = scribo::primitive::extract::lines_v_discontinued(input,
c8(),
nbboxes,
51,
diff --git a/scribo/src/text/grouping/group_from_double_link.cc
b/scribo/src/text/grouping/group_from_double_link.cc
index aa47ac6..bcd768f 100644
--- a/scribo/src/text/grouping/group_from_double_link.cc
+++ b/scribo/src/text/grouping/group_from_double_link.cc
@@ -32,14 +32,17 @@
#include <mln/literal/colors.hh>
#include <mln/io/pbm/load.hh>
#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/label_16.hh>
+#include <scribo/core/object_links.hh>
#include <scribo/core/object_image.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_single_left_link.hh>
-#include <scribo/text/grouping/group_with_single_right_link.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/group/apply.hh>
+#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
-#include <scribo/text/grouping/group_from_double_link.hh>
+#include <scribo/primitive/group/from_double_link.hh>
#include <scribo/filter/small_objects.hh>
#include <scribo/debug/save_bboxes_image.hh>
@@ -77,15 +80,16 @@ int main(int argc, char *argv[])
io::pbm::load(input, argv[1]);
value::label_16 nbboxes;
- typedef object_image(image2d<value::label_16>) text_t;
- text_t text = extract::primitive::objects(input, c8(), nbboxes);
+ typedef image2d<value::label_16> L;
+ typedef object_image(L) text_t;
+ text_t text = primitive::extract::objects(input, c8(), nbboxes);
text = filter::small_objects(text, 4);
- mln::util::array<unsigned> left_link
- = text::grouping::group_with_single_left_link(text, atoi(argv[2]));
- mln::util::array<unsigned> right_link
- = text::grouping::group_with_single_right_link(text, atoi(argv[3]));
+ object_links<L> left_link
+ = primitive::link::with_single_left_link(text, atoi(argv[2]));
+ object_links<L> right_link
+ = primitive::link::with_single_right_link(text, atoi(argv[3]));
std::cout << "BEFORE - nbboxes = " << nbboxes <<
std::endl;
@@ -110,8 +114,10 @@ int main(int argc, char *argv[])
// scribo::make::debug_filename("lbl_before.ppm"));
// With validation.
- text_t grouped_text
- = text::grouping::group_from_double_link(text, left_link, right_link);
+ object_groups<L> groups
+ = primitive::group::from_double_link(text, left_link, right_link);
+
+ text_t grouped_text = primitive::group::apply(text, groups);
io::ppm::save(mln::labeling::colorize(value::rgb8(),
grouped_text,
diff --git a/scribo/src/text/grouping/group_from_double_several_links.cc
b/scribo/src/text/grouping/group_from_double_several_links.cc
index e22239d..de9eb20 100644
--- a/scribo/src/text/grouping/group_from_double_several_links.cc
+++ b/scribo/src/text/grouping/group_from_double_several_links.cc
@@ -34,14 +34,14 @@
#include <mln/io/ppm/save.hh>
#include <mln/literal/colors.hh>
-#include <mln/util/timer.hh>
#include <mln/util/array.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_several_left_links.hh>
-#include <scribo/text/grouping/group_with_several_right_links.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/group/apply.hh>
+#include <scribo/primitive/link/with_several_left_links.hh>
+#include <scribo/primitive/link/with_several_right_links.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
-#include <scribo/text/grouping/group_from_double_link.hh>
+#include <scribo/primitive/group/from_double_link.hh>
#include <scribo/filter/small_objects.hh>
#include <scribo/debug/save_bboxes_image.hh>
@@ -64,40 +64,27 @@ int main(int argc, char* argv[])
scribo::make::internal::debug_filename_prefix =
"group_with_double_several_links";
- mln::util::timer t, t2;
image2d<bool> input;
- std::cout << "Loading" << std::endl;
- t.start();
io::pbm::load(input, argv[1]);
- std::cout << t << std::endl;
value::label_16 nbboxes;
+ typedef image2d<value::label_16> L;
std::cout << "extract bboxes" << std::endl;
- t.restart();
- t2.start();
- typedef object_image(image2d<value::label_16>) text_t;
- text_t text = scribo::extract::primitive::objects(input, c8(), nbboxes);
- std::cout << t << std::endl;
+ typedef object_image(L) text_t;
+ text_t text = scribo::primitive::extract::objects(input, c8(), nbboxes);
+
- mln::util::timer t3;
std::cout << "Remove small components" << std::endl;
- t.restart();
- t3.start();
text = filter::small_objects(text,4);
- std::cout << t << std::endl;
std::cout << "Group with left link" << std::endl;
- t.restart();
- mln::util::array<unsigned> left_link
- = text::grouping::group_with_several_left_links(text, 30);
- std::cout << t << std::endl;
+ object_links<L> left_link
+ = primitive::link::with_several_left_links(text, 30);
std::cout << "Group with right link" << std::endl;
- t.restart();
- mln::util::array<unsigned> right_link
- = text::grouping::group_with_several_right_links(text, 30);
- std::cout << t << std::endl;
+ object_links<L> right_link
+ = primitive::link::with_several_right_links(text, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes <<
std::endl;
@@ -109,12 +96,11 @@ int main(int argc, char* argv[])
// With validation.
std::cout << "Group from double link" << std::endl;
- t.restart();
- text_t grouped_text
- = text::grouping::group_from_double_link(text, left_link, right_link);
- std::cout << t << std::endl;
- std::cout << "Full process: " << t2 << std::endl;
- std::cout << "Cleanup and grouping process: " << t3 <<
std::endl;
+
+ object_groups<L> groups
+ = primitive::group::from_double_link(text, left_link, right_link);
+
+ text_t grouped_text = primitive::group::apply(text, groups);
io::ppm::save(mln::labeling::colorize(value::rgb8(),
grouped_text,
diff --git a/scribo/src/text/grouping/group_from_graph.cc
b/scribo/src/text/grouping/group_from_graph.cc
index de98ff9..8b99c1b 100644
--- a/scribo/src/text/grouping/group_from_graph.cc
+++ b/scribo/src/text/grouping/group_from_graph.cc
@@ -33,9 +33,10 @@
#include <mln/literal/colors.hh>
#include <mln/labeling/colorize.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_graph.hh>
-#include <scribo/text/grouping/group_from_graph.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/link/with_graph.hh>
+#include <scribo/primitive/group/from_graph.hh>
+#include <scribo/primitive/group/apply.hh>
#include <scribo/debug/save_bboxes_image.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
@@ -61,10 +62,11 @@ int main(int argc, char* argv[])
io::pbm::load(input, argv[1]);
value::label_16 nbboxes;
- typedef object_image(image2d<value::label_16>) text_t;
- text_t text = extract::primitive::objects(input, c8(), nbboxes);
+ typedef image2d<value::label_16> L;
+ typedef object_image(L) text_t;
+ text_t text = primitive::extract::objects(input, c8(), nbboxes);
- mln::util::graph g = text::grouping::group_with_graph(text, 30);
+ mln::util::graph g = primitive::link::with_graph(text, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes.next() <<
std::endl;
scribo::debug::save_linked_bboxes_image(input,
@@ -76,8 +78,10 @@ int main(int argc, char* argv[])
// text.nlabels()),
// scribo::make::debug_filename("lbl_before.ppm"));
- text_t grouped_text
- = text::grouping::group_from_graph(text, g);
+ object_groups<L> groups
+ = primitive::group::from_graph(text, g);
+
+ text_t grouped_text = primitive::group::apply(text, groups);
std::cout << "AFTER - nbboxes = " <<
grouped_text.bboxes().nelements() << std::endl;
diff --git a/scribo/src/text/grouping/group_from_rag.cc
b/scribo/src/text/grouping/group_from_rag.cc
index 944624c..5bc8b86 100644
--- a/scribo/src/text/grouping/group_from_rag.cc
+++ b/scribo/src/text/grouping/group_from_rag.cc
@@ -44,9 +44,9 @@
#include <mln/util/graph.hh>
#include <mln/accu/center.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_rag.hh>
-//#include <scribo/text/grouping/group_from_rag.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/link/with_rag.hh>
+//#include <scribo/primitive/group/from_rag.hh>
#include <scribo/filter/small_objects.hh>
#include <scribo/filter/thin_objects.hh>
@@ -173,7 +173,7 @@ int main(int argc, char* argv[])
typedef image2d<value::label_16> L;
value::label_16 nbboxes;
typedef object_image(L) objects_t;
- objects_t objects = extract::primitive::objects(input, c8(), nbboxes);
+ objects_t objects = primitive::extract::objects(input, c8(), nbboxes);
/// First filtering.
objects_t filtered_objects
@@ -188,7 +188,7 @@ int main(int argc, char* argv[])
/// Getting objects links from a Region Adjacency graph.
- mln_VAR(rag_data, text::grouping::group_with_rag(filtered_objects, c8()));
+ mln_VAR(rag_data, primitive::link::with_rag(filtered_objects, c8()));
mln_VAR(v_ima, scribo::graph::compute_vertex(accu::center<point2d>(),
diff --git a/scribo/src/text/grouping/group_from_several_graph.cc
b/scribo/src/text/grouping/group_from_several_graph.cc
index 1db26a7..946e80f 100644
--- a/scribo/src/text/grouping/group_from_several_graph.cc
+++ b/scribo/src/text/grouping/group_from_several_graph.cc
@@ -39,9 +39,11 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_several_graphes.hh>
-#include <scribo/text/grouping/group_from_graph.hh>
+#include <scribo/core/object_groups.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/link/with_several_graphes.hh>
+#include <scribo/primitive/group/from_graph.hh>
+#include <scribo/primitive/group/apply.hh>
#include <scribo/debug/save_bboxes_image.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
@@ -67,10 +69,11 @@ int main(int argc, char* argv[])
io::pbm::load(input, argv[1]);
value::label_16 nbboxes;
- typedef object_image(image2d<value::label_16>) text_t;
- text_t text = scribo::extract::primitive::objects(input, c8(), nbboxes);
+ typedef image2d<value::label_16> L;
+ typedef object_image(L) text_t;
+ text_t text = scribo::primitive::extract::objects(input, c8(), nbboxes);
- mln::util::graph g = text::grouping::group_with_several_graphes(text, 30);
+ mln::util::graph g = primitive::link::with_several_graphes(text, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes.next() <<
std::endl;
scribo::debug::save_linked_bboxes_image(input,
@@ -78,7 +81,9 @@ int main(int argc, char* argv[])
literal::red, literal::cyan,
scribo::make::debug_filename("left_linked.ppm"));
- text_t grouped_text = text::grouping::group_from_graph(text, g);
+ object_groups<L> groups = primitive::group::from_graph(text, g);
+
+ text_t grouped_text = primitive::group::apply(text, groups);
std::cout << "AFTER - nbboxes = " <<
grouped_text.bboxes().nelements() << std::endl;
diff --git a/scribo/src/text/grouping/group_from_several_left_links.cc
b/scribo/src/text/grouping/group_from_several_left_links.cc
index cdc65ae..a153e0c 100644
--- a/scribo/src/text/grouping/group_from_several_left_links.cc
+++ b/scribo/src/text/grouping/group_from_several_left_links.cc
@@ -40,9 +40,10 @@
#include <mln/io/ppm/save.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_several_left_links.hh>
-#include <scribo/text/grouping/group_from_single_link.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/group/apply.hh>
+#include <scribo/primitive/link/with_several_left_links.hh>
+#include <scribo/primitive/group/from_single_link.hh>
#include <scribo/debug/save_bboxes_image.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
@@ -68,13 +69,14 @@ int main(int argc, char* argv[])
io::pbm::load(input, argv[1]);
value::label_16 nbboxes;
- typedef object_image(image2d<value::label_16>) text_t;
- text_t text = scribo::extract::primitive::objects(input, c8(), nbboxes);
+ typedef image2d<value::label_16> L;
+ typedef object_image(L) text_t;
+ text_t text = scribo::primitive::extract::objects(input, c8(), nbboxes);
{
std::cout << "* Left grouping" << std::endl;
- mln::util::array<unsigned> left_link
- = text::grouping::group_with_several_left_links(text, 30);
+ object_links<L> left_link
+ = primitive::link::with_several_left_links(text, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes <<
std::endl;
scribo::debug::save_linked_bboxes_image(input,
@@ -82,9 +84,11 @@ int main(int argc, char* argv[])
literal::red, literal::cyan,
scribo::make::debug_filename("left_links.ppm"));
- text_t grouped_text
- = text::grouping::group_from_single_link(text, left_link);
+ object_groups<L>
+ groups = primitive::group::from_single_link(text, left_link);
+
+ text_t grouped_text = primitive::group::apply(text, groups);
std::cout << "AFTER - nbboxes = " <<
grouped_text.bboxes().nelements() << std::endl;
io::ppm::save(mln::labeling::colorize(value::rgb8(),
grouped_text,
diff --git a/scribo/src/text/grouping/group_from_single_link.cc
b/scribo/src/text/grouping/group_from_single_link.cc
index 58a7f2f..f408d66 100644
--- a/scribo/src/text/grouping/group_from_single_link.cc
+++ b/scribo/src/text/grouping/group_from_single_link.cc
@@ -37,10 +37,11 @@
#include <mln/io/pbm/load.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_single_left_link.hh>
-#include <scribo/text/grouping/group_with_single_right_link.hh>
-#include <scribo/text/grouping/group_from_single_link.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/group/from_single_link.hh>
+#include <scribo/primitive/group/apply.hh>
#include <scribo/debug/save_bboxes_image.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
@@ -68,13 +69,14 @@ int main(int argc, char* argv[])
io::pbm::load(input, argv[1]);
value::label_16 nbboxes;
- typedef object_image(image2d<value::label_16>) text_t;
- text_t text = scribo::extract::primitive::objects(input, c8(), nbboxes);
+ typedef image2d<value::label_16> L;
+ typedef object_image(L) text_t;
+ text_t text = scribo::primitive::extract::objects(input, c8(), nbboxes);
{
std::cout << "* Left grouping" << std::endl;
- mln::util::array<unsigned> left_link
- = text::grouping::group_with_single_left_link(text, 30);
+ object_links<L> left_link
+ = primitive::link::with_single_left_link(text, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes <<
std::endl;
scribo::debug::save_linked_bboxes_image(input,
@@ -86,8 +88,10 @@ int main(int argc, char* argv[])
// text.nlabels()),
// scribo::make::debug_filename("lbl_before.ppm"));
- text_t grouped_text
- = text::grouping::group_from_single_link(text, left_link);
+ object_groups<L>
+ groups = primitive::group::from_single_link(text, left_link);
+
+ text_t grouped_text = primitive::group::apply(text, groups);
std::cout << "AFTER - nbboxes = " <<
grouped_text.bboxes().nelements() << std::endl;
io::ppm::save(mln::labeling::colorize(value::rgb8(),
@@ -101,8 +105,8 @@ int main(int argc, char* argv[])
{
std::cout << "* Left grouping" << std::endl;
- mln::util::array<unsigned> right_link
- = text::grouping::group_with_single_right_link(text, 30);
+ object_links<L> right_link
+ = primitive::link::with_single_right_link(text, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes <<
std::endl;
scribo::debug::save_linked_bboxes_image(input,
@@ -114,8 +118,10 @@ int main(int argc, char* argv[])
// text.nlabels()),
// scribo::make::debug_filename("lbl_before.ppm"));
- text_t grouped_text
- = text::grouping::group_from_single_link(text, right_link);
+ object_groups<L>
+ groups = primitive::group::from_single_link(text, right_link);
+
+ text_t grouped_text = primitive::group::apply(text, groups);
io::ppm::save(mln::labeling::colorize(value::rgb8(),
grouped_text,
diff --git a/scribo/src/text_in_photo.cc b/scribo/src/text_in_photo.cc
index d51ba37..b18825e 100644
--- a/scribo/src/text_in_photo.cc
+++ b/scribo/src/text_in_photo.cc
@@ -38,15 +38,16 @@
#include <mln/literal/colors.hh>
#include <mln/value/rgb8.hh>
+#include <mln/value/label_16.hh>
#include <mln/draw/box.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_single_left_link.hh>
-#include <scribo/text/grouping/group_with_single_right_link.hh>
-#include <scribo/text/grouping/group_from_double_link.hh>
-#include <scribo/text/grouping/group_from_single_link.hh>
-#include <scribo/text/grouping/internal/have_link_valid.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/group/apply.hh>
+#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/group/from_double_link.hh>
+#include <scribo/primitive/group/from_single_link.hh>
#include <scribo/filter/small_objects.hh>
#include <scribo/filter/thin_objects.hh>
#include <scribo/filter/thick_objects.hh>
@@ -91,7 +92,7 @@ highlighted.");
/// Finding objects.
value::label_16 nobjects;
object_image(L)
- objects = scribo::extract::primitive::objects(input, c8(), nobjects);
+ objects = scribo::primitive::extract::objects(input, c8(), nobjects);
/// First filtering.
@@ -106,10 +107,10 @@ highlighted.");
math::min(input.ncols(), input.nrows()) / 5);
/// Grouping potential objects
- mln::util::array<unsigned> left_link
- = text::grouping::group_with_single_left_link(filtered_objects, 30);
- mln::util::array<unsigned> right_link
- = text::grouping::group_with_single_right_link(filtered_objects, 30);
+ object_links<L> left_link
+ = primitive::link::with_single_left_link(filtered_objects, 30);
+ object_links<L> right_link
+ = primitive::link::with_single_right_link(filtered_objects, 30);
#ifndef NOUT
@@ -124,14 +125,13 @@ highlighted.");
#endif
// Trying to group objects
- mln::util::array<unsigned> parent_link;
- text::grouping::group_from_double_link(filtered_objects,
- left_link, right_link,
- parent_link);
+ object_groups<L>
+ groups = primitive::group::from_double_link(filtered_objects,
+ left_link, right_link);
// Remove objects part of groups with less than 3 objects.
mln::util::array<bool>
- to_be_kept = filter::small_object_groups(parent_link, 3);
+ to_be_kept = filter::small_object_groups(groups, 3);
// FOR DEBUGGING PURPOSE.
@@ -155,17 +155,19 @@ highlighted.");
/// This time a single link is enough since non-wanted objects have
/// been removed.
left_link
- = text::grouping::group_with_single_left_link(filtered_objects, 30);
+ = primitive::link::with_single_left_link(filtered_objects, 30);
/// Grouping objects again.
- object_image(L) grouped_objects
- = text::grouping::group_from_single_link(filtered_objects, left_link);
+ groups = primitive::group::from_single_link(filtered_objects, left_link);
+
+ object_image(L)
+ grouped_objects = primitive::group::apply(filtered_objects, groups);
#ifndef NOUT
/// FOR DEBUG PURPOSE.
- for (unsigned i = 1; i < grouped_objects.nlabels(); ++i)
+ for (unsigned i = 1; i <= grouped_objects.nlabels(); ++i)
mln::draw::box(decision_image, grouped_objects.bbox(i), literal::blue);
io::ppm::save(decision_image,
scribo::make::debug_filename("decision_image.ppm"));
diff --git a/scribo/table/extract.hh b/scribo/table/extract.hh
index a553ccc..2e652d2 100644
--- a/scribo/table/extract.hh
+++ b/scribo/table/extract.hh
@@ -41,9 +41,9 @@
# include <scribo/core/object_image.hh>
# include <scribo/table/rebuild.hh>
# include <scribo/table/erase.hh>
-# include <scribo/extract/primitive/lines_h_pattern.hh>
-# include <scribo/extract/primitive/lines_v_pattern.hh>
-# include <scribo/extract/primitive/objects.hh>
+# include <scribo/primitive/extract/lines_h_pattern.hh>
+# include <scribo/primitive/extract/lines_v_pattern.hh>
+# include <scribo/primitive/extract/objects.hh>
# include <scribo/debug/save_bboxes_image.hh>
@@ -87,13 +87,13 @@ namespace scribo
mlc_equal(mln_value(I), bool)::check();
image2d<bool>
- bhlines = scribo::extract::primitive::lines_h_pattern(input, 51),
- bvlines = scribo::extract::primitive::lines_v_pattern(input, 51);
+ bhlines = scribo::primitive::extract::lines_h_pattern(input, 51),
+ bvlines = scribo::primitive::extract::lines_v_pattern(input, 51);
V nhlines, nvlines;
object_image(mln_ch_value(I,V))
- hlines = scribo::extract::primitive::objects(bhlines, c8(), nhlines),
- vlines = scribo::extract::primitive::objects(bvlines, c8(), nvlines);
+ hlines = scribo::primitive::extract::objects(bhlines, c8(), nhlines),
+ vlines = scribo::primitive::extract::objects(bvlines, c8(), nvlines);
typedef mln::util::couple<mln_ch_value(I,V),
mln::util::couple<mln::util::array<box<mln_site(I)> >,
diff --git a/scribo/table/internal/repair_lines.hh
b/scribo/table/internal/repair_lines.hh
index 7c307e8..f197979 100644
--- a/scribo/table/internal/repair_lines.hh
+++ b/scribo/table/internal/repair_lines.hh
@@ -74,6 +74,8 @@ namespace scribo
namespace internal
{
+ using namespace mln;
+
/// Repair lines which have small discontinuities.
/// FIXME: buggy. Sometimes few lines move or shrink!
///
@@ -127,7 +129,7 @@ namespace scribo
typedef
extension_ima<
const image_if<L,
- fun::neq_v2b_expr_<pw::value_<L>,
+ mln::fun::neq_v2b_expr_<pw::value_<L>,
pw::cst_<literal::zero_t> > >, const L> tbb_ima_t;
tbb_ima_t tbb_ima = extend(l | (pw::value(l) != pw::cst(literal::zero)), l);
diff --git a/scribo/tests/filter/small_and_large_bboxes.cc
b/scribo/tests/filter/small_and_large_bboxes.cc
index 38aa85e..2d765df 100644
--- a/scribo/tests/filter/small_and_large_bboxes.cc
+++ b/scribo/tests/filter/small_and_large_bboxes.cc
@@ -34,9 +34,10 @@
#include <scribo/core/object_image.hh>
-#include <scribo/extract/primitive/objects.hh>
-#include <scribo/text/grouping/group_with_graph.hh>
-#include <scribo/text/grouping/group_from_graph.hh>
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/group/apply.hh>
+#include <scribo/primitive/link/with_graph.hh>
+#include <scribo/primitive/group/from_graph.hh>
#include <scribo/filter/small_objects.hh>
#include <scribo/util/text.hh>
@@ -72,10 +73,11 @@ int main(int argc, char* argv[])
io::pbm::load(input, img.c_str());
value::label_16 nbboxes;
- typedef object_image(image2d<value::label_16>) text_t;
- text_t text = extract::primitive::objects(input, c8(), nbboxes);
+ typedef image2d<value::label_16> L;
+ typedef object_image(L) text_t;
+ text_t text = primitive::extract::objects(input, c8(), nbboxes);
- mln::util::graph g = text::grouping::group_with_graph(text, 30);
+ mln::util::graph g = primitive::link::with_graph(text, 30);
mln_assertion(nbboxes == 12u);
@@ -85,21 +87,21 @@ int main(int argc, char* argv[])
// literal::red, literal::cyan,
// "test_graph_left_linked.ppm");
- text_t grouped_text
- = text::grouping::group_from_graph(text, g);
+ object_groups<L> groups = primitive::group::from_graph(text, g);
+ text_t grouped_text = primitive::group::apply(text, groups);
// std::cout << "AFTER - nbboxes = " <<
grouped_text.nbboxes().next() << std::endl;
//
// scribo::debug::save_bboxes_image(input, grouped_text.bboxes(),
// literal::red,
// "test_graph_grouped_text.ppm");
- mln_assertion(grouped_text.nbboxes() == 6u);
+ mln_assertion(grouped_text.nlabels() == 6u);
text_t
filtered_text = scribo::filter::small_objects(grouped_text, 20);
- mln_assertion(filtered_text.nbboxes() == 2u);
+ mln_assertion(filtered_text.nlabels() == 2u);
// scribo::debug::save_bboxes_image(input, filtered_text.bboxes(),
// literal::red,
diff --git a/scribo/tests/table/extract_lines_with_rank.cc
b/scribo/tests/table/extract_lines_with_rank.cc
index 4ff6d89..e7f13df 100644
--- a/scribo/tests/table/extract_lines_with_rank.cc
+++ b/scribo/tests/table/extract_lines_with_rank.cc
@@ -38,10 +38,8 @@
#include <mln/io/pgm/save.hh>
-#include <scribo/extract/primitive/lines_h_discontinued.hh>
-#include <scribo/extract/primitive/lines_v_discontinued.hh>
-
-#include <scribo/debug/save_table_image.hh>
+#include <scribo/primitive/extract/lines_h_discontinued.hh>
+#include <scribo/primitive/extract/lines_v_discontinued.hh>
#include <scribo/tests/data.hh>
@@ -76,11 +74,16 @@ int main(int argc, char *argv[])
typedef object_image(image2d<value::label_8>) lbl_t;
lbl_t
- hlbl = scribo::extract::primitive::lines_h_discontinued(input, c8(),
+ hlbl = scribo::primitive::extract::lines_h_discontinued(input, c8(),
nbboxes, 11, 2);
lbl_t
- vlbl = scribo::extract::primitive::lines_v_discontinued(input, c8(),
+ vlbl = scribo::primitive::extract::lines_v_discontinued(input, c8(),
nbboxes, 11, 2);
+
+ // Background values are meaningless, we set them to an arbitrary value.
+ hboxes(0) = hlbl.bbox(0);
+ vboxes(0) = vlbl.bbox(0);
+
mln_assertion(hlbl.bboxes() == hboxes);
mln_assertion(vlbl.bboxes() == vboxes);
}
diff --git a/scribo/tests/unit_test/unit-tests.mk b/scribo/tests/unit_test/unit-tests.mk
index 6fdb4d8..237581f 100644
--- a/scribo/tests/unit_test/unit-tests.mk
+++ b/scribo/tests/unit_test/unit-tests.mk
@@ -7,7 +7,9 @@ scribo_core_all \
scribo_core_central_sites \
scribo_core_erase_objects \
scribo_core_macros \
+scribo_core_object_groups \
scribo_core_object_image \
+scribo_core_object_links \
scribo_debug_all \
scribo_debug_save_bboxes_image \
scribo_debug_save_label_image \
@@ -17,29 +19,62 @@ scribo_debug_usage \
scribo_draw_all \
scribo_draw_bounding_box_links \
scribo_draw_bounding_boxes \
-scribo_extract_primitive_canvas \
-scribo_extract_primitive_cells \
-scribo_extract_primitive_lines_discontinued \
-scribo_extract_primitive_lines_h_discontinued \
-scribo_extract_primitive_lines_h_pattern \
-scribo_extract_primitive_lines_h_thick \
-scribo_extract_primitive_lines_pattern \
-scribo_extract_primitive_lines_thick \
-scribo_extract_primitive_lines_v_discontinued \
-scribo_extract_primitive_lines_v_pattern \
-scribo_extract_primitive_lines_v_thick \
-scribo_extract_primitive_objects \
scribo_filter_all \
scribo_filter_large_objects \
+scribo_filter_small_object_groups \
scribo_filter_small_objects \
scribo_filter_thick_objects \
scribo_filter_thin_objects \
+scribo_fun_v2b_small_objects_filter \
scribo_make_all \
scribo_make_debug_filename \
scribo_make_influence_zone_graph \
scribo_make_text \
scribo_preprocessing_all \
scribo_preprocessing_unskew \
+scribo_primitive_all \
+scribo_primitive_extract_all \
+scribo_primitive_extract_canvas \
+scribo_primitive_extract_cells \
+scribo_primitive_extract_lines_discontinued \
+scribo_primitive_extract_lines_h_discontinued \
+scribo_primitive_extract_lines_h_pattern \
+scribo_primitive_extract_lines_h_single \
+scribo_primitive_extract_lines_h_thick \
+scribo_primitive_extract_lines_pattern \
+scribo_primitive_extract_lines_thick \
+scribo_primitive_extract_lines_v_discontinued \
+scribo_primitive_extract_lines_v_pattern \
+scribo_primitive_extract_lines_v_single \
+scribo_primitive_extract_lines_v_thick \
+scribo_primitive_extract_objects \
+scribo_primitive_group_all \
+scribo_primitive_group_apply \
+scribo_primitive_group_filter_non_aligned \
+scribo_primitive_group_filter_non_h_aligned \
+scribo_primitive_group_filter_non_v_aligned \
+scribo_primitive_group_from_double_link \
+scribo_primitive_group_from_graph \
+scribo_primitive_group_from_single_link \
+scribo_primitive_internal_all \
+scribo_primitive_internal_find_graph_link \
+scribo_primitive_internal_find_left_link \
+scribo_primitive_internal_find_right_link \
+scribo_primitive_internal_find_root \
+scribo_primitive_internal_have_link_valid \
+scribo_primitive_internal_init_link_array \
+scribo_primitive_internal_is_link_valid \
+scribo_primitive_internal_update_graph_link \
+scribo_primitive_internal_update_link_array \
+scribo_primitive_link_all \
+scribo_primitive_link_merge_double_link \
+scribo_primitive_link_with_graph \
+scribo_primitive_link_with_rag \
+scribo_primitive_link_with_several_graphes \
+scribo_primitive_link_with_several_left_links \
+scribo_primitive_link_with_several_right_links \
+scribo_primitive_link_with_single_left_link \
+scribo_primitive_link_with_single_right_link \
scribo_table_align_lines_horizontaly \
scribo_table_align_lines_verticaly \
scribo_table_all \
@@ -57,25 +92,6 @@ scribo_table_repair_vertical_lines \
scribo_text_all \
scribo_text_clean \
scribo_text_extract_lines \
-scribo_text_grouping_all \
-scribo_text_grouping_group_from_double_link \
-scribo_text_grouping_group_from_graph \
-scribo_text_grouping_group_from_single_link \
-scribo_text_grouping_group_with_graph \
-scribo_text_grouping_group_with_several_graphes \
-scribo_text_grouping_group_with_several_left_links \
-scribo_text_grouping_group_with_several_right_links \
-scribo_text_grouping_group_with_single_left_link \
-scribo_text_grouping_group_with_single_right_link \
-scribo_text_grouping_internal_all \
-scribo_text_grouping_internal_find_graph_link \
-scribo_text_grouping_internal_find_left_link \
-scribo_text_grouping_internal_find_right_link \
-scribo_text_grouping_internal_find_root \
-scribo_text_grouping_internal_init_link_array \
-scribo_text_grouping_internal_is_link_valid \
-scribo_text_grouping_internal_update_graph_link \
-scribo_text_grouping_internal_update_link_array \
scribo_util_all \
scribo_util_text
@@ -85,7 +101,9 @@ scribo_core_all_SOURCES = scribo_core_all.cc
scribo_core_central_sites_SOURCES = scribo_core_central_sites.cc
scribo_core_erase_objects_SOURCES = scribo_core_erase_objects.cc
scribo_core_macros_SOURCES = scribo_core_macros.cc
+scribo_core_object_groups_SOURCES = scribo_core_object_groups.cc
scribo_core_object_image_SOURCES = scribo_core_object_image.cc
+scribo_core_object_links_SOURCES = scribo_core_object_links.cc
scribo_debug_all_SOURCES = scribo_debug_all.cc
scribo_debug_save_bboxes_image_SOURCES = scribo_debug_save_bboxes_image.cc
scribo_debug_save_label_image_SOURCES = scribo_debug_save_label_image.cc
@@ -95,29 +113,62 @@ scribo_debug_usage_SOURCES = scribo_debug_usage.cc
scribo_draw_all_SOURCES = scribo_draw_all.cc
scribo_draw_bounding_box_links_SOURCES = scribo_draw_bounding_box_links.cc
scribo_draw_bounding_boxes_SOURCES = scribo_draw_bounding_boxes.cc
-scribo_extract_primitive_canvas_SOURCES = scribo_extract_primitive_canvas.cc
-scribo_extract_primitive_cells_SOURCES = scribo_extract_primitive_cells.cc
-scribo_extract_primitive_lines_discontinued_SOURCES =
scribo_extract_primitive_lines_discontinued.cc
-scribo_extract_primitive_lines_h_discontinued_SOURCES =
scribo_extract_primitive_lines_h_discontinued.cc
-scribo_extract_primitive_lines_h_pattern_SOURCES =
scribo_extract_primitive_lines_h_pattern.cc
-scribo_extract_primitive_lines_h_thick_SOURCES =
scribo_extract_primitive_lines_h_thick.cc
-scribo_extract_primitive_lines_pattern_SOURCES =
scribo_extract_primitive_lines_pattern.cc
-scribo_extract_primitive_lines_thick_SOURCES = scribo_extract_primitive_lines_thick.cc
-scribo_extract_primitive_lines_v_discontinued_SOURCES =
scribo_extract_primitive_lines_v_discontinued.cc
-scribo_extract_primitive_lines_v_pattern_SOURCES =
scribo_extract_primitive_lines_v_pattern.cc
-scribo_extract_primitive_lines_v_thick_SOURCES =
scribo_extract_primitive_lines_v_thick.cc
-scribo_extract_primitive_objects_SOURCES = scribo_extract_primitive_objects.cc
scribo_filter_all_SOURCES = scribo_filter_all.cc
scribo_filter_large_objects_SOURCES = scribo_filter_large_objects.cc
+scribo_filter_small_object_groups_SOURCES = scribo_filter_small_object_groups.cc
scribo_filter_small_objects_SOURCES = scribo_filter_small_objects.cc
scribo_filter_thick_objects_SOURCES = scribo_filter_thick_objects.cc
scribo_filter_thin_objects_SOURCES = scribo_filter_thin_objects.cc
+scribo_fun_v2b_small_objects_filter_SOURCES = scribo_fun_v2b_small_objects_filter.cc
scribo_make_all_SOURCES = scribo_make_all.cc
scribo_make_debug_filename_SOURCES = scribo_make_debug_filename.cc
scribo_make_influence_zone_graph_SOURCES = scribo_make_influence_zone_graph.cc
scribo_make_text_SOURCES = scribo_make_text.cc
scribo_preprocessing_all_SOURCES = scribo_preprocessing_all.cc
scribo_preprocessing_unskew_SOURCES = scribo_preprocessing_unskew.cc
+scribo_primitive_all_SOURCES = scribo_primitive_all.cc
+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_lines_discontinued_SOURCES =
scribo_primitive_extract_lines_discontinued.cc
+scribo_primitive_extract_lines_h_discontinued_SOURCES =
scribo_primitive_extract_lines_h_discontinued.cc
+scribo_primitive_extract_lines_h_pattern_SOURCES =
scribo_primitive_extract_lines_h_pattern.cc
+scribo_primitive_extract_lines_h_single_SOURCES =
scribo_primitive_extract_lines_h_single.cc
+scribo_primitive_extract_lines_h_thick_SOURCES =
scribo_primitive_extract_lines_h_thick.cc
+scribo_primitive_extract_lines_pattern_SOURCES =
scribo_primitive_extract_lines_pattern.cc
+scribo_primitive_extract_lines_thick_SOURCES = scribo_primitive_extract_lines_thick.cc
+scribo_primitive_extract_lines_v_discontinued_SOURCES =
scribo_primitive_extract_lines_v_discontinued.cc
+scribo_primitive_extract_lines_v_pattern_SOURCES =
scribo_primitive_extract_lines_v_pattern.cc
+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_objects_SOURCES = scribo_primitive_extract_objects.cc
+scribo_primitive_group_all_SOURCES = scribo_primitive_group_all.cc
+scribo_primitive_group_apply_SOURCES = scribo_primitive_group_apply.cc
+scribo_primitive_group_filter_non_aligned_SOURCES =
scribo_primitive_group_filter_non_aligned.cc
+scribo_primitive_group_filter_non_h_aligned_SOURCES =
scribo_primitive_group_filter_non_h_aligned.cc
+scribo_primitive_group_filter_non_v_aligned_SOURCES =
scribo_primitive_group_filter_non_v_aligned.cc
+scribo_primitive_group_from_double_link_SOURCES =
scribo_primitive_group_from_double_link.cc
+scribo_primitive_group_from_graph_SOURCES = scribo_primitive_group_from_graph.cc
+scribo_primitive_group_from_single_link_SOURCES =
scribo_primitive_group_from_single_link.cc
+scribo_primitive_internal_all_SOURCES = scribo_primitive_internal_all.cc
+scribo_primitive_internal_find_graph_link_SOURCES =
scribo_primitive_internal_find_graph_link.cc
+scribo_primitive_internal_find_left_link_SOURCES =
scribo_primitive_internal_find_left_link.cc
+scribo_primitive_internal_find_right_link_SOURCES =
scribo_primitive_internal_find_right_link.cc
+scribo_primitive_internal_find_root_SOURCES = scribo_primitive_internal_find_root.cc
+scribo_primitive_internal_have_link_valid_SOURCES =
scribo_primitive_internal_have_link_valid.cc
+scribo_primitive_internal_init_link_array_SOURCES =
scribo_primitive_internal_init_link_array.cc
+scribo_primitive_internal_is_link_valid_SOURCES =
scribo_primitive_internal_is_link_valid.cc
+scribo_primitive_internal_update_graph_link_SOURCES =
scribo_primitive_internal_update_graph_link.cc
+scribo_primitive_internal_update_link_array_SOURCES =
scribo_primitive_internal_update_link_array.cc
+scribo_primitive_link_all_SOURCES = scribo_primitive_link_all.cc
+scribo_primitive_link_merge_double_link_SOURCES =
scribo_primitive_link_merge_double_link.cc
+scribo_primitive_link_with_graph_SOURCES = scribo_primitive_link_with_graph.cc
+scribo_primitive_link_with_rag_SOURCES = scribo_primitive_link_with_rag.cc
+scribo_primitive_link_with_several_graphes_SOURCES =
scribo_primitive_link_with_several_graphes.cc
+scribo_primitive_link_with_several_left_links_SOURCES =
scribo_primitive_link_with_several_left_links.cc
+scribo_primitive_link_with_several_right_links_SOURCES =
scribo_primitive_link_with_several_right_links.cc
+scribo_primitive_link_with_single_left_link_SOURCES =
scribo_primitive_link_with_single_left_link.cc
+scribo_primitive_link_with_single_right_link_SOURCES =
scribo_primitive_link_with_single_right_link.cc
scribo_table_align_lines_horizontaly_SOURCES = scribo_table_align_lines_horizontaly.cc
scribo_table_align_lines_verticaly_SOURCES = scribo_table_align_lines_verticaly.cc
scribo_table_all_SOURCES = scribo_table_all.cc
@@ -135,24 +186,5 @@ scribo_table_repair_vertical_lines_SOURCES =
scribo_table_repair_vertical_lines.
scribo_text_all_SOURCES = scribo_text_all.cc
scribo_text_clean_SOURCES = scribo_text_clean.cc
scribo_text_extract_lines_SOURCES = scribo_text_extract_lines.cc
-scribo_text_grouping_all_SOURCES = scribo_text_grouping_all.cc
-scribo_text_grouping_group_from_double_link_SOURCES =
scribo_text_grouping_group_from_double_link.cc
-scribo_text_grouping_group_from_graph_SOURCES = scribo_text_grouping_group_from_graph.cc
-scribo_text_grouping_group_from_single_link_SOURCES =
scribo_text_grouping_group_from_single_link.cc
-scribo_text_grouping_group_with_graph_SOURCES = scribo_text_grouping_group_with_graph.cc
-scribo_text_grouping_group_with_several_graphes_SOURCES =
scribo_text_grouping_group_with_several_graphes.cc
-scribo_text_grouping_group_with_several_left_links_SOURCES =
scribo_text_grouping_group_with_several_left_links.cc
-scribo_text_grouping_group_with_several_right_links_SOURCES =
scribo_text_grouping_group_with_several_right_links.cc
-scribo_text_grouping_group_with_single_left_link_SOURCES =
scribo_text_grouping_group_with_single_left_link.cc
-scribo_text_grouping_group_with_single_right_link_SOURCES =
scribo_text_grouping_group_with_single_right_link.cc
-scribo_text_grouping_internal_all_SOURCES = scribo_text_grouping_internal_all.cc
-scribo_text_grouping_internal_find_graph_link_SOURCES =
scribo_text_grouping_internal_find_graph_link.cc
-scribo_text_grouping_internal_find_left_link_SOURCES =
scribo_text_grouping_internal_find_left_link.cc
-scribo_text_grouping_internal_find_right_link_SOURCES =
scribo_text_grouping_internal_find_right_link.cc
-scribo_text_grouping_internal_find_root_SOURCES =
scribo_text_grouping_internal_find_root.cc
-scribo_text_grouping_internal_init_link_array_SOURCES =
scribo_text_grouping_internal_init_link_array.cc
-scribo_text_grouping_internal_is_link_valid_SOURCES =
scribo_text_grouping_internal_is_link_valid.cc
-scribo_text_grouping_internal_update_graph_link_SOURCES =
scribo_text_grouping_internal_update_graph_link.cc
-scribo_text_grouping_internal_update_link_array_SOURCES =
scribo_text_grouping_internal_update_link_array.cc
scribo_util_all_SOURCES = scribo_util_all.cc
scribo_util_text_SOURCES = scribo_util_text.cc
diff --git a/scribo/text/all.hh b/scribo/text/all.hh
index 000d5b9..d28510c 100644
--- a/scribo/text/all.hh
+++ b/scribo/text/all.hh
@@ -44,6 +44,5 @@ namespace scribo
# include <scribo/text/extract_lines.hh>
//# include <scribo/text/recognition.hh>
# include <scribo/text/clean.hh>
-# include <scribo/text/grouping/all.hh>
#endif // ! SCRIBO_TEXT_ALL_HH
diff --git a/scribo/text/extract_lines.hh b/scribo/text/extract_lines.hh
index 1d70f85..44dca50 100644
--- a/scribo/text/extract_lines.hh
+++ b/scribo/text/extract_lines.hh
@@ -47,10 +47,11 @@
# include <mln/util/graph.hh>
# include <mln/value/label_16.hh>
-# include <scribo/extract/primitive/objects.hh>
-# include <scribo/text/grouping/group_with_several_left_links.hh>
-# include <scribo/text/grouping/group_with_several_right_links.hh>
-# include <scribo/text/grouping/group_from_double_link.hh>
+# include <scribo/primitive/extract/objects.hh>
+# include <scribo/primitive/group/apply.hh>
+# include <scribo/primitive/link/with_several_left_links.hh>
+# include <scribo/primitive/link/with_several_right_links.hh>
+# include <scribo/primitive/group/from_double_link.hh>
# ifndef SCRIBO_NDEBUG
# include <mln/literal/colors.hh>
@@ -100,8 +101,9 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
- typedef object_image(mln_ch_value(I,V)) text_t;
- text_t text = scribo::extract::primitive::objects(input, nbh, nbboxes);
+ typedef mln_ch_value(I,V) L;
+ typedef object_image(L) text_t;
+ text_t text = scribo::primitive::extract::objects(input, nbh, nbboxes);
# ifndef SCRIBO_NDEBUG
debug::save_bboxes_image(input, text.bboxes(), literal::red,
@@ -109,10 +111,10 @@ namespace scribo
# endif // ! SCRIBO_NDEBUG
//Link character bboxes to their left neighboor if possible.
- mln::util::array<unsigned> left_link
- = text::grouping::group_with_several_left_links(text, 30);
- mln::util::array<unsigned> right_link
- = text::grouping::group_with_several_right_links(text, 30);
+ object_links<L> left_link
+ = primitive::link::with_several_left_links(text, 30);
+ object_links<L> right_link
+ = primitive::link::with_several_right_links(text, 30);
# ifndef SCRIBO_NDEBUG
scribo::debug::save_linked_bboxes_image(input,
@@ -123,8 +125,12 @@ namespace scribo
# endif // ! SCRIBO_NDEBUG
//Merge character bboxes through a graph.
- text_t grouped_text
- = text::grouping::group_from_double_link(text, left_link, right_link);
+
+ object_groups<L>
+ groups = primitive::group::from_double_link(text,
+ left_link, right_link);
+
+ text_t grouped_text = primitive::group::apply(text, groups);
# ifndef SCRIBO_NDEBUG
debug::save_bboxes_image(input, grouped_text.bboxes(),
diff --git a/scribo/text/grouping/internal/all.hh b/scribo/text/grouping/internal/all.hh
deleted file mode 100644
index 257d524..0000000
--- a/scribo/text/grouping/internal/all.hh
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (C) 2009 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_TEXT_GROUPING_INTERNAL_ALL_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_ALL_HH
-
-/// \file
-///
-/// Include all headers located in scribo/text/grouping/internal.
-
-namespace scribo
-{
-
- namespace text
- {
-
- namespace grouping
- {
-
- /// Namespace of internal routines grouping text components.
- namespace internal
- {
-
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
-
- } // end of namespace scribo::text
-
-} // end of namespace scribo
-
-
-# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/is_link_valid.hh>
-# include <scribo/text/grouping/internal/find_root.hh>
-# include <scribo/text/grouping/internal/find_graph_link.hh>
-# include <scribo/text/grouping/internal/find_right_link.hh>
-# include <scribo/text/grouping/internal/update_graph_link.hh>
-# include <scribo/text/grouping/internal/update_link_array.hh>
-# include <scribo/text/grouping/internal/find_left_link.hh>
-
-
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_ALL_HH
diff --git a/scribo/text/grouping/internal/find_left_link.hh
b/scribo/text/grouping/internal/find_left_link.hh
deleted file mode 100644
index 93d4b95..0000000
--- a/scribo/text/grouping/internal/find_left_link.hh
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (C) 2009 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_TEXT_GROUPING_INTERNAL_FIND_LEFT_LINK_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_FIND_LEFT_LINK_HH
-
-/// \file
-///
-/// Find the left neighbor of a line of text if exists.
-
-# include <mln/core/concept/image.hh>
-
-# include <mln/math/abs.hh>
-
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_image.hh>
-# include <scribo/text/grouping/internal/update_link_array.hh>
-
-//FIXME: not generic.
-# include <mln/core/alias/dpoint2d.hh>
-
-namespace scribo
-{
-
- namespace text
- {
-
- namespace grouping
- {
-
- namespace internal
- {
-
- /// Find the left neighbor of a line of text if exists.
- ///
- /// \param objects An image of objects.
- /// \param left_link The left neighbors.
- /// \param current_comp A text line id.
- /// \param dmax The maximum lookup distance.
- /// \param c The lookup start point.
- template <typename L>
- void
- find_left_link(const object_image(L)& objects,
- mln::util::array<unsigned>& left_link,
- unsigned current_comp,
- int dmax,
- const mln_site(L)& c);
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L>
- void
- find_left_link(const object_image(L)& objects,
- mln::util::array<unsigned>& left_link,
- unsigned current_comp,
- int dmax,
- const mln_site(L)& c)
- {
- ///FIXME: the following code is not generic...
- /// First site on the right of the central site
- mln_site(L) p = c + mln::left;
-
- while (objects.domain().has(p) // Not outside image domain
- && (objects(p) == literal::zero // Is the background
- || objects(p) == current_comp // Is the current component
- || left_link[objects(p)] == current_comp) // Creates a loop
- && math::abs(p.col() - c.col()) < dmax) // Not to far
- --p.col();
-
- update_link_array(objects, left_link, p, c, current_comp, dmax);
- }
-
-# endif // MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
-
- } // end of namespace scribo::text
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_FIND_LEFT_LINK_HH
diff --git a/scribo/text/grouping/internal/find_right_link.hh
b/scribo/text/grouping/internal/find_right_link.hh
deleted file mode 100644
index 5ef0853..0000000
--- a/scribo/text/grouping/internal/find_right_link.hh
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (C) 2009 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_TEXT_GROUPING_INTERNAL_FIND_RIGHT_LINK_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_FIND_RIGHT_LINK_HH
-
-/// \file
-///
-/// Find the right neighbor of a line of text if exists.
-
-# include <mln/core/concept/image.hh>
-
-# include <mln/math/abs.hh>
-
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_image.hh>
-# include <scribo/text/grouping/internal/update_link_array.hh>
-
-//FIXME: not generic.
-# include <mln/core/alias/dpoint2d.hh>
-
-namespace scribo
-{
-
- namespace text
- {
-
- namespace grouping
- {
-
- namespace internal
- {
-
- using namespace mln;
-
- /// Find the right neighbor of a line of text if exists.
- ///
- /// \param text The lines of text.
- /// \param right_link The right neighbors.
- /// \param current_comp A text line id.
- /// \param dmax The maximum lookup distance.
- /// \param c The lookup start point.
- //
- template <typename L>
- void
- find_right_link(const object_image(L)& text,
- mln::util::array<unsigned>& right_link,
- unsigned current_comp,
- int dmax,
- const mln_site(L)& c);
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L>
- void
- find_right_link(const object_image(L)& objects,
- mln::util::array<unsigned>& right_link,
- unsigned current_comp,
- int dmax,
- const mln_site(L)& c)
- {
- ///FIXME: the following code is not generic...
- /// First site on the right of the central site
- mln_site(L) p = c + mln::right;
-
- while (objects.domain().has(p) // Not outside image domain
- && (objects(p) == literal::zero // Is the background
- || objects(p) == current_comp // Is the current component
- || right_link[objects(p)] == current_comp) // Creates a loop
- && math::abs(p.col() - c.col()) < dmax) // Not too far
- ++p.col();
-
- update_link_array(objects, right_link, p, c, current_comp, dmax);
- }
-
-# endif // MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
-
- } // end of namespace scribo::text
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_FIND_RIGHT_LINK_HH
diff --git a/scribo/text/grouping/internal/update_graph_link.hh
b/scribo/text/grouping/internal/update_graph_link.hh
deleted file mode 100644
index 3f5c199..0000000
--- a/scribo/text/grouping/internal/update_graph_link.hh
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (C) 2009 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_TEXT_GROUPING_INTERNAL_UPDATE_GRAPH_LINK_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_GRAPH_LINK_HH
-
-/// \file
-///
-/// Update graph edges if a valid neighbor is found.
-
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/graph.hh>
-# include <mln/math/abs.hh>
-
-namespace scribo
-{
-
- namespace text
- {
-
- namespace grouping
- {
-
- namespace internal
- {
-
- using namespace mln;
-
-
- /// Update graph edges if a valid neighbor is found.
- ///
- /// \param[in] lbl_ A label image.
- /// \param[in] g_ A graph.
- /// \param[in] p A site of \p lbl_.
- /// \param[in] c A site of \p lbl_.
- /// \param[in] i A vertex id.
- /// \param[in] dmax The maximum distance allowed to look for a
- /// neighbor.
- //
- template <typename I, typename G>
- void
- update_graph_link(const Image<I>& lbl_, Graph<G>& g_,
- const mln_site(I)& p, const mln_site(I)& c,
- unsigned i, int dmax);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename I, typename G>
- inline
- void
- update_graph_link(const Image<I>& lbl_, Graph<G>& g_,
- const mln_site(I)& p, const mln_site(I)& c,
- unsigned i, int dmax)
- {
- trace::entering("scribo::text::grouping::internal::update_graph_link");
-
- const I& lbl = exact(lbl_);
- G& g = exact(g_);
-
- mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
- mln_precondition(exact(lbl).is_valid());
- mln_precondition(g.is_valid());
-
- if (lbl.domain().has(p) && lbl(p) != literal::zero && lbl(p) != i
- && (math::abs(p.col() - c.col())) < dmax)
- g.add_edge(lbl(p), i);
-
- trace::exiting("scribo::text::grouping::internal::update_graph_link");
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::text::grouping::internal
-
- } // end of namespace scribo::text::grouping
-
- } // end of namespace scribo::text
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_GRAPH_LINK_HH
--
1.5.6.5