Olena-patches
Threads by month
- ----- 2025 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
August 2010
- 6 participants
- 204 discussions

09 Aug '10
* src/debug/show_links_bbox_overlap.cc,
* src/debug/show_links_center_aligned.cc,
* src/debug/show_links_non_h_aligned.cc,
* src/debug/show_links_several_right.cc,
* src/debug/show_links_several_right_overlap.cc,
* src/debug/show_links_single_down.cc,
* src/debug/show_links_single_down_left_aligned.cc,
* src/debug/show_links_single_down_right_aligned.cc,
* src/debug/show_links_single_left.cc,
* src/debug/show_links_single_left_dmax_ratio.cc,
* src/debug/show_links_single_right.cc,
* src/debug/show_links_single_right_dmax_ratio.cc,
* src/debug/show_links_single_up.cc,
* src/debug/show_links_single_up_left_aligned.cc,
* src/debug/show_links_single_up_right_aligned.cc,
* src/debug/show_objects_large.cc,
* src/debug/show_objects_large_small.cc,
* src/debug/show_objects_small.cc,
* src/debug/show_objects_thick.cc,
* src/debug/show_objects_thin.cc,
* src/filter/objects_large.cc,
* src/filter/objects_small.cc,
* src/filter/objects_thick.cc,
* src/filter/objects_thin.cc,
* src/filter/objects_with_holes.cc,
* src/filter/objects_with_holes_pgm.cc,
* src/preprocessing/preprocess.cc,
* src/preprocessing/split_bg_fg.cc,
* src/preprocessing/unskew.cc,
* src/primitive/extract/extract_discontinued_hlines.cc,
* src/primitive/extract/extract_discontinued_lines.cc,
* src/primitive/extract/extract_discontinued_vlines.cc,
* src/primitive/extract/extract_thick_hlines.cc,
* src/primitive/extract/extract_thick_vlines.cc,
* src/primitive/find/find_discontinued_lines.cc,
* src/primitive/find/find_single_lines.cc,
* src/primitive/find/find_thick_and_single_lines.cc,
* src/primitive/find/find_thick_lines.cc,
* src/primitive/group/Makefile.am,
* src/primitive/group/group_from_double_link.cc,
* src/primitive/group/group_from_double_several_links.cc,
* src/primitive/group/group_from_several_left_links.cc,
* src/primitive/group/group_from_single_link.cc,
* src/table/erase.cc,
* src/text/cleantxt.cc: Here.
---
scribo/ChangeLog | 50 ++++++++++++++++
scribo/src/debug/show_links_bbox_overlap.cc | 19 +++---
scribo/src/debug/show_links_center_aligned.cc | 19 +++---
scribo/src/debug/show_links_non_h_aligned.cc | 25 +++++----
scribo/src/debug/show_links_several_right.cc | 27 ++++-----
.../src/debug/show_links_several_right_overlap.cc | 36 ++++++-----
scribo/src/debug/show_links_single_down.cc | 31 +++++-----
.../debug/show_links_single_down_left_aligned.cc | 24 ++++----
.../debug/show_links_single_down_right_aligned.cc | 27 +++++----
scribo/src/debug/show_links_single_left.cc | 31 +++++-----
.../src/debug/show_links_single_left_dmax_ratio.cc | 44 ++++++++------
scribo/src/debug/show_links_single_right.cc | 35 ++++++-----
.../debug/show_links_single_right_dmax_ratio.cc | 36 ++++++-----
scribo/src/debug/show_links_single_up.cc | 37 ++++++-----
.../src/debug/show_links_single_up_left_aligned.cc | 27 +++++----
.../debug/show_links_single_up_right_aligned.cc | 27 +++++----
scribo/src/debug/show_objects_large.cc | 27 +++++----
scribo/src/debug/show_objects_large_small.cc | 41 +++++--------
scribo/src/debug/show_objects_small.cc | 27 +++++----
scribo/src/debug/show_objects_thick.cc | 26 +++++----
scribo/src/debug/show_objects_thin.cc | 24 ++++----
scribo/src/filter/objects_large.cc | 30 +++++----
scribo/src/filter/objects_small.cc | 22 ++++---
scribo/src/filter/objects_thick.cc | 30 +++++----
scribo/src/filter/objects_thin.cc | 30 +++++----
scribo/src/filter/objects_with_holes.cc | 27 +++++----
scribo/src/filter/objects_with_holes_pgm.cc | 23 +++++---
scribo/src/preprocessing/preprocess.cc | 27 ++++++---
scribo/src/preprocessing/split_bg_fg.cc | 14 +++--
scribo/src/preprocessing/unskew.cc | 22 ++++---
.../extract/extract_discontinued_hlines.cc | 26 +++++----
.../extract/extract_discontinued_lines.cc | 47 ++++++++-------
.../extract/extract_discontinued_vlines.cc | 27 +++++----
.../src/primitive/extract/extract_thick_hlines.cc | 25 +++++----
.../src/primitive/extract/extract_thick_vlines.cc | 25 +++++----
.../src/primitive/find/find_discontinued_lines.cc | 17 +++--
scribo/src/primitive/find/find_single_lines.cc | 35 ++++++-----
.../primitive/find/find_thick_and_single_lines.cc | 29 +++++-----
scribo/src/primitive/find/find_thick_lines.cc | 20 +++---
scribo/src/primitive/group/Makefile.am | 15 ++---
.../src/primitive/group/group_from_double_link.cc | 61 ++++++++-----------
.../group/group_from_double_several_links.cc | 34 ++++++-----
.../group/group_from_several_left_links.cc | 32 +++++-----
.../src/primitive/group/group_from_single_link.cc | 62 ++++++++++----------
scribo/src/table/erase.cc | 15 +++--
scribo/src/text/cleantxt.cc | 45 ++++++++++-----
46 files changed, 769 insertions(+), 611 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index b186c47..4865134 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,55 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix compilation of Scribo tools.
+
+ * src/debug/show_links_bbox_overlap.cc,
+ * src/debug/show_links_center_aligned.cc,
+ * src/debug/show_links_non_h_aligned.cc,
+ * src/debug/show_links_several_right.cc,
+ * src/debug/show_links_several_right_overlap.cc,
+ * src/debug/show_links_single_down.cc,
+ * src/debug/show_links_single_down_left_aligned.cc,
+ * src/debug/show_links_single_down_right_aligned.cc,
+ * src/debug/show_links_single_left.cc,
+ * src/debug/show_links_single_left_dmax_ratio.cc,
+ * src/debug/show_links_single_right.cc,
+ * src/debug/show_links_single_right_dmax_ratio.cc,
+ * src/debug/show_links_single_up.cc,
+ * src/debug/show_links_single_up_left_aligned.cc,
+ * src/debug/show_links_single_up_right_aligned.cc,
+ * src/debug/show_objects_large.cc,
+ * src/debug/show_objects_large_small.cc,
+ * src/debug/show_objects_small.cc,
+ * src/debug/show_objects_thick.cc,
+ * src/debug/show_objects_thin.cc,
+ * src/filter/objects_large.cc,
+ * src/filter/objects_small.cc,
+ * src/filter/objects_thick.cc,
+ * src/filter/objects_thin.cc,
+ * src/filter/objects_with_holes.cc,
+ * src/filter/objects_with_holes_pgm.cc,
+ * src/preprocessing/preprocess.cc,
+ * src/preprocessing/split_bg_fg.cc,
+ * src/preprocessing/unskew.cc,
+ * src/primitive/extract/extract_discontinued_hlines.cc,
+ * src/primitive/extract/extract_discontinued_lines.cc,
+ * src/primitive/extract/extract_discontinued_vlines.cc,
+ * src/primitive/extract/extract_thick_hlines.cc,
+ * src/primitive/extract/extract_thick_vlines.cc,
+ * src/primitive/find/find_discontinued_lines.cc,
+ * src/primitive/find/find_single_lines.cc,
+ * src/primitive/find/find_thick_and_single_lines.cc,
+ * src/primitive/find/find_thick_lines.cc,
+ * src/primitive/group/Makefile.am,
+ * src/primitive/group/group_from_double_link.cc,
+ * src/primitive/group/group_from_double_several_links.cc,
+ * src/primitive/group/group_from_several_left_links.cc,
+ * src/primitive/group/group_from_single_link.cc,
+ * src/table/erase.cc,
+ * src/text/cleantxt.cc: Here.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Catch up with the current interface of scribo::debug::usage.
* src/debug/show_links_bottom_aligned.cc,
diff --git a/scribo/src/debug/show_links_bbox_overlap.cc b/scribo/src/debug/show_links_bbox_overlap.cc
index eae1cd3..477720d 100644
--- a/scribo/src/debug/show_links_bbox_overlap.cc
+++ b/scribo/src/debug/show_links_bbox_overlap.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,7 +38,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
#include <scribo/filter/object_links_bbox_overlap.hh>
@@ -64,10 +65,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show valid or invalid links according the bboxes overlap.",
+ "Show valid or invalid links according"
+ " the bboxes overlap.",
"input.pbm ratio output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
image2d<bool> input;
io::pbm::load(input, argv[1]);
@@ -75,17 +76,17 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Finding right links.
object_links<L> right_links
- = primitive::link::with_single_right_link(objects);
+ = primitive::link::with_single_right_link(comps);
// Filtering.
object_links<L> hratio_filtered_links
- = filter::object_links_bbox_overlap(objects, right_links, atof(argv[2]));
+ = filter::object_links_bbox_overlap(right_links, atof(argv[2]));
// Debug image.
diff --git a/scribo/src/debug/show_links_center_aligned.cc b/scribo/src/debug/show_links_center_aligned.cc
index dfcb775..727e7e9 100644
--- a/scribo/src/debug/show_links_center_aligned.cc
+++ b/scribo/src/debug/show_links_center_aligned.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,7 +38,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/filter/object_links_center_aligned.hh>
@@ -62,10 +63,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show valid or invalid links according the horizontal alignment (based on center line).",
+ "Show valid or invalid links according the "
+ "horizontal alignment (based on center line).",
"input.pbm max_alpha output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
image2d<bool> input;
io::pbm::load(input, argv[1]);
@@ -73,17 +74,17 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Finding right links.
object_links<L> right_links
- = primitive::link::with_single_right_link(objects);
+ = primitive::link::with_single_right_link(comps);
// Filtering.
object_links<L> filtered_links
- = filter::object_links_center_aligned(objects, right_links, atof(argv[2]));
+ = filter::object_links_center_aligned(right_links, atof(argv[2]));
// Debug image.
image2d<value::rgb8> decision_image
diff --git a/scribo/src/debug/show_links_non_h_aligned.cc b/scribo/src/debug/show_links_non_h_aligned.cc
index 04d3de5..89ddf62 100644
--- a/scribo/src/debug/show_links_non_h_aligned.cc
+++ b/scribo/src/debug/show_links_non_h_aligned.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,10 +38,10 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
-#include <scribo/filter/object_links_non_h_aligned.hh>
+#include <scribo/filter/object_links_non_aligned_simple.hh>
#include <scribo/debug/decision_image.hh>
#include <scribo/debug/links_decision_image.hh>
@@ -64,10 +65,11 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show valid or invalid links according the horizontal alignment (based on top and bottom lines).",
+ "Show valid or invalid links according the "
+ "horizontal alignment (based on top and "
+ "bottom lines).",
"input.pbm delta output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
image2d<bool> input;
io::pbm::load(input, argv[1]);
@@ -75,17 +77,18 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
-
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Finding right links.
object_links<L> right_links
- = primitive::link::with_single_right_link(objects);
+ = primitive::link::with_single_right_link(comps);
// Filtering.
object_links<L> filtered_links
- = filter::object_links_non_h_aligned(objects, right_links, atoi(argv[2]));
+ = filter::object_links_non_aligned_simple(right_links,
+ anchor::MassCenter,
+ atoi(argv[2]));
// Debug image.
diff --git a/scribo/src/debug/show_links_several_right.cc b/scribo/src/debug/show_links_several_right.cc
index 05e4a74..a70b2fb 100644
--- a/scribo/src/debug/show_links_several_right.cc
+++ b/scribo/src/debug/show_links_several_right.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,8 +29,6 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
-#include <mln/data/convert.hh>
-
#include <mln/value/rgb8.hh>
#include <mln/value/label_16.hh>
#include <mln/literal/colors.hh>
@@ -37,7 +36,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_several_right_links.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -49,8 +48,10 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common value : 30)" },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
+ { "max_nbh_dist", " Maximum distance for neighborhood search."
+ "(common value : 30)" },
{0, 0}
};
@@ -65,8 +66,7 @@ int main(int argc, char* argv[])
return scribo::debug::usage(argv,
"Show sucessful/unsuccessful right links between components.",
"input.pbm max_nbh_dist output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
image2d<bool> input;
io::pbm::load(input, argv[1]);
@@ -74,17 +74,12 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Finding right links.
object_links<L> right_link
- = primitive::link::with_several_right_links(objects, atoi(argv[2]));
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
+ = primitive::link::with_several_right_links(comps, atoi(argv[2]));
image2d<value::rgb8> decision_image
= scribo::debug::several_links_decision_image(input,
diff --git a/scribo/src/debug/show_links_several_right_overlap.cc b/scribo/src/debug/show_links_several_right_overlap.cc
index f2824f3..05eb72e 100644
--- a/scribo/src/debug/show_links_several_right_overlap.cc
+++ b/scribo/src/debug/show_links_several_right_overlap.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -41,7 +42,7 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/internal/link_several_dmax_base.hh>
#include <scribo/primitive/link/internal/compute_anchor.hh>
#include <scribo/primitive/link/compute_several.hh>
@@ -67,12 +68,16 @@ namespace scribo
typedef mln_site(L) P;
several_right_overlap_debug_functor(const I& input,
- const object_image(L)& objects,
+ const component_set<L>& comps,
float dmax)
- : super_(objects, dmax, 3)
+ : super_(comps, dmax)
{
+ this->anchors_.append(anchor::Top);
+ this->anchors_.append(anchor::Bottom);
+ this->anchors_.append(anchor::Center);
+
output_ = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ scribo::draw::bounding_boxes(output_, comps, literal::blue);
mln_postcondition(output_.is_valid());
}
@@ -86,8 +91,7 @@ namespace scribo
if (c.first() != anchor::Invalid)
{
mln_site(L)
- p = primitive::link::internal::compute_anchor(this->objects_,
- this->mass_centers_,
+ p = primitive::link::internal::compute_anchor(this->components_,
current_object,
c.first());
mln::draw::line(output_, p, c.second(), literal::green);
@@ -99,9 +103,9 @@ namespace scribo
mln_site(L)
start_point_(unsigned current_object, anchor::Type anchor)
{
- return primitive::link::internal::compute_anchor(this->objects_,
- this->mass_centers_,
- current_object, anchor);
+ return primitive::link::internal::compute_anchor(this->components_,
+ current_object,
+ anchor);
}
@@ -134,10 +138,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful right links between components.",
+ "Show sucessful/unsuccessful right links "
+ "between components.",
"input.pbm max_nbh_dist output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -146,12 +150,12 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Write debug image.
several_right_overlap_debug_functor<I, L> functor(input,
- objects, atof(argv[2]));
+ comps, atof(argv[2]));
primitive::link::compute_several(functor);
io::ppm::save(functor.output_, argv[3]);
diff --git a/scribo/src/debug/show_links_single_down.cc b/scribo/src/debug/show_links_single_down.cc
index 37325d2..342a08f 100644
--- a/scribo/src/debug/show_links_single_down.cc
+++ b/scribo/src/debug/show_links_single_down.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,8 +40,8 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/internal/link_ms_dmax_base.hh>
+#include <scribo/primitive/extract/components.hh>
+#include <scribo/primitive/link/internal/link_single_dmax_base.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -54,23 +55,23 @@ namespace scribo
template <typename I, typename L>
struct single_down_link_debug_functor
- : primitive::link::internal::link_ms_dmax_base<L,
- single_down_link_debug_functor<I, L> >
+ : primitive::link::internal::link_single_dmax_base<L,
+ single_down_link_debug_functor<I, L> >
{
typedef single_down_link_debug_functor<I, L> self_t;
typedef
- primitive::link::internal::link_ms_dmax_base<L, self_t> super_;
+ primitive::link::internal::link_single_dmax_base<L, self_t> super_;
public:
typedef mln_site(L) P;
single_down_link_debug_functor(const I& input,
- const object_image(L)& objects,
+ const component_set<L>& comps,
float dmax)
- : super_(objects, dmax, 0)
+ : super_(comps, dmax, anchor::Vertical)
{
output_ = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ scribo::draw::bounding_boxes(output_, comps, literal::blue);
mln_postcondition(output_.is_valid());
}
@@ -134,10 +135,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful down links between components.",
+ "Show sucessful/unsuccessful down links "
+ "between components.",
"input.pbm max_nbh_dist output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -146,11 +147,11 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Write debug image.
- single_down_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
+ single_down_link_debug_functor<I, L> functor(input, comps, atof(argv[2]));
primitive::link::compute(functor);
io::ppm::save(functor.output_, argv[3]);
diff --git a/scribo/src/debug/show_links_single_down_left_aligned.cc b/scribo/src/debug/show_links_single_down_left_aligned.cc
index b094d6e..18eb04e 100644
--- a/scribo/src/debug/show_links_single_down_left_aligned.cc
+++ b/scribo/src/debug/show_links_single_down_left_aligned.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -41,7 +42,7 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_down_link.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/filter/object_links_left_aligned.hh>
@@ -54,7 +55,8 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "dmax", "The maximum lookup distance. (common value : 300)" },
{0, 0}
};
@@ -70,8 +72,7 @@ int main(int argc, char* argv[])
return scribo::debug::usage(argv,
"Show sucessful/unsuccessful down links between components.",
"input.pbm dmax output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -80,20 +81,21 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
object_links<L>
- down_links = primitive::link::with_single_down_link(objects,
+ down_links = primitive::link::with_single_down_link(comps,
atof(argv[2]),
anchor::Left);
// Filtering.
- down_links = filter::object_links_left_aligned(objects, down_links, 5);
+ down_links = filter::object_links_left_aligned(down_links, 5);
- scribo::debug::save_linked_bboxes_image(input, objects, down_links,
+ scribo::debug::save_linked_bboxes_image(input, down_links,
literal::blue, literal::green,
- argv[3], anchor::ActualLeft);
+ anchor::ActualLeft,
+ argv[3]);
}
diff --git a/scribo/src/debug/show_links_single_down_right_aligned.cc b/scribo/src/debug/show_links_single_down_right_aligned.cc
index 9a12c0d..6c53711 100644
--- a/scribo/src/debug/show_links_single_down_right_aligned.cc
+++ b/scribo/src/debug/show_links_single_down_right_aligned.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -41,7 +42,7 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_down_link.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/filter/object_links_right_aligned.hh>
@@ -54,7 +55,8 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "dmax", "The maximum lookup distance. (common value : 300)" },
{0, 0}
};
@@ -68,10 +70,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful down links between components.",
+ "Show sucessful/unsuccessful down links "
+ "between components.",
"input.pbm dmax output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -80,20 +82,21 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
object_links<L>
- down_links = primitive::link::with_single_down_link(objects,
+ down_links = primitive::link::with_single_down_link(comps,
atof(argv[2]),
anchor::Right);
// Filtering.
- down_links = filter::object_links_right_aligned(objects, down_links, 5);
+ down_links = filter::object_links_right_aligned(down_links, 5);
- scribo::debug::save_linked_bboxes_image(input, objects, down_links,
+ scribo::debug::save_linked_bboxes_image(input, down_links,
literal::blue, literal::green,
- argv[3], anchor::ActualRight);
+ anchor::ActualRight,
+ argv[3]);
}
diff --git a/scribo/src/debug/show_links_single_left.cc b/scribo/src/debug/show_links_single_left.cc
index 8c55afc..bd79bbb 100644
--- a/scribo/src/debug/show_links_single_left.cc
+++ b/scribo/src/debug/show_links_single_left.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,7 +40,7 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
#include <scribo/primitive/link/internal/link_single_dmax_base.hh>
#include <scribo/primitive/link/compute.hh>
@@ -55,23 +56,23 @@ namespace scribo
template <typename I, typename L>
struct single_left_link_debug_functor
- : primitive::link::internal::link_ms_dmax_base<L,
- single_left_link_debug_functor<I, L> >
+ : primitive::link::internal::link_single_dmax_base<L,
+ single_left_link_debug_functor<I, L> >
{
typedef single_left_link_debug_functor<I, L> self_t;
typedef
- primitive::link::internal::link_ms_dmax_base<L, self_t> super_;
+ primitive::link::internal::link_single_dmax_base<L, self_t> super_;
public:
typedef mln_site(L) P;
single_left_link_debug_functor(const I& input,
- const object_image(L)& objects,
+ const component_set<L>& components,
float dmax)
- : super_(objects, dmax)
+ : super_(components, dmax, anchor::Horizontal)
{
output_ = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ scribo::draw::bounding_boxes(output_, components, literal::blue);
mln_postcondition(output_.is_valid());
}
@@ -135,10 +136,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful left links between components.",
+ "Show sucessful/unsuccessful left links "
+ "between components.",
"input.pbm max_nbh_dist output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -147,12 +148,12 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> components
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Write debug image.
- single_left_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
- primitive::link::compute(functor);
+ single_left_link_debug_functor<I, L> functor(input, components, atof(argv[2]));
+ primitive::link::compute(functor, anchor::MassCenter);
io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_links_single_left_dmax_ratio.cc b/scribo/src/debug/show_links_single_left_dmax_ratio.cc
index e133507..9b48a42 100644
--- a/scribo/src/debug/show_links_single_left_dmax_ratio.cc
+++ b/scribo/src/debug/show_links_single_left_dmax_ratio.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,9 +40,9 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
-#include <scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh>
+#include <scribo/primitive/link/internal/link_single_dmax_ratio_base.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -55,23 +56,27 @@ namespace scribo
template <typename I, typename L>
struct single_left_link_debug_functor
- : primitive::link::internal::link_ms_dmax_ratio_base<L,
- single_left_link_debug_functor<I, L> >
+ : primitive::link::internal::link_single_dmax_ratio_base<L,
+ primitive::link::internal::dmax_default,
+ single_left_link_debug_functor<I, L> >
{
typedef single_left_link_debug_functor<I, L> self_t;
+ typedef primitive::link::internal::dmax_default dmax_fun_t;
typedef
- primitive::link::internal::link_ms_dmax_ratio_base<L, self_t> super_;
+ primitive::link::internal::link_single_dmax_ratio_base<L,
+ dmax_fun_t,
+ self_t> super_;
public:
typedef mln_site(L) P;
single_left_link_debug_functor(const I& input,
- const object_image(L)& objects,
+ const component_set<L>& components,
float dmax_ratio)
- : super_(objects, dmax_ratio)
+ : super_(components, anchor::Horizontal, dmax_fun_t(dmax_ratio))
{
output_ = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ scribo::draw::bounding_boxes(output_, components, literal::blue);
mln_postcondition(output_.is_valid());
}
@@ -121,8 +126,10 @@ namespace scribo
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
- { "max_nbh_dist_ratio", "Size ratio defining the maximum lookup distance. (common value : 3)" },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
+ { "max_nbh_dist_ratio", "Size ratio defining the maximum lookup distance."
+ "(common value : 3)" },
{0, 0}
};
@@ -135,10 +142,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful left links between components.",
+ "Show sucessful/unsuccessful left links "
+ "between components.",
"input.pbm max_nbh_dist_ratio output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -147,12 +154,13 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> components
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Write debug image.
- single_left_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
- primitive::link::compute(functor);
+ single_left_link_debug_functor<I, L>
+ functor(input, components, atof(argv[2]));
+ primitive::link::compute(functor, anchor::MassCenter);
io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_links_single_right.cc b/scribo/src/debug/show_links_single_right.cc
index 7a25306..0dd2ea3 100644
--- a/scribo/src/debug/show_links_single_right.cc
+++ b/scribo/src/debug/show_links_single_right.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,9 +40,9 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
-#include <scribo/primitive/link/internal/link_ms_dmax_base.hh>
+#include <scribo/primitive/link/internal/link_single_dmax_base.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -55,23 +56,23 @@ namespace scribo
template <typename I, typename L>
struct single_right_link_debug_functor
- : primitive::link::internal::link_ms_dmax_base<L,
+ : primitive::link::internal::link_single_dmax_base<L,
single_right_link_debug_functor<I, L> >
{
typedef single_right_link_debug_functor<I, L> self_t;
typedef
- primitive::link::internal::link_ms_dmax_base<L, self_t> super_;
+ primitive::link::internal::link_single_dmax_base<L, self_t> super_;
public:
typedef mln_site(L) P;
single_right_link_debug_functor(const I& input,
- const object_image(L)& objects,
+ const component_set<L>& components,
float dmax)
- : super_(objects, dmax)
+ : super_(components, dmax, anchor::Horizontal)
{
output_ = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ scribo::draw::bounding_boxes(output_, components, literal::blue);
mln_postcondition(output_.is_valid());
}
@@ -121,7 +122,8 @@ namespace scribo
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "max_nbh_dist", "The maximum lookup distance. (common value : 30)" },
{0, 0}
};
@@ -135,10 +137,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful right links between components.",
+ "Show sucessful/unsuccessful right links "
+ "between components.",
"input.pbm max_nbh_dist output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -147,12 +149,13 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> components
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Write debug image.
- single_right_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
- primitive::link::compute(functor);
+ single_right_link_debug_functor<I, L>
+ functor(input, components, atof(argv[2]));
+ primitive::link::compute(functor, anchor::MassCenter);
io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_links_single_right_dmax_ratio.cc b/scribo/src/debug/show_links_single_right_dmax_ratio.cc
index 806114c..5b292ed 100644
--- a/scribo/src/debug/show_links_single_right_dmax_ratio.cc
+++ b/scribo/src/debug/show_links_single_right_dmax_ratio.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,9 +40,9 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
-#include <scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh>
+#include <scribo/primitive/link/internal/link_single_dmax_ratio_base.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -55,23 +56,25 @@ namespace scribo
template <typename I, typename L>
struct single_right_link_debug_functor
- : primitive::link::internal::link_ms_dmax_ratio_base<L,
- single_right_link_debug_functor<I, L> >
+ : primitive::link::internal::link_single_dmax_ratio_base<L,
+ primitive::link::internal::dmax_default,
+ single_right_link_debug_functor<I, L> >
{
typedef single_right_link_debug_functor<I, L> self_t;
+ typedef primitive::link::internal::dmax_default dmax_fun_t;
typedef
- primitive::link::internal::link_ms_dmax_ratio_base<L, self_t> super_;
+ primitive::link::internal::link_single_dmax_ratio_base<L, dmax_fun_t, self_t> super_;
public:
typedef mln_site(L) P;
single_right_link_debug_functor(const I& input,
- const object_image(L)& objects,
+ const component_set<L>& components,
float dmax_ratio)
- : super_(objects, dmax_ratio)
+ : super_(components, anchor::Horizontal, dmax_fun_t(dmax_ratio))
{
output_ = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ scribo::draw::bounding_boxes(output_, components, literal::blue);
mln_postcondition(output_.is_valid());
}
@@ -135,10 +138,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful right links between components.",
+ "Show sucessful/unsuccessful right links "
+ "between components.",
"input.pbm max_nbh_dist_ratio output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -147,12 +150,13 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> components
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Write debug image.
- single_right_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
- primitive::link::compute(functor);
+ single_right_link_debug_functor<I, L>
+ functor(input, components, atof(argv[2]));
+ primitive::link::compute(functor, anchor::MassCenter);
io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_links_single_up.cc b/scribo/src/debug/show_links_single_up.cc
index 59c8ce5..d71b1fe 100644
--- a/scribo/src/debug/show_links_single_up.cc
+++ b/scribo/src/debug/show_links_single_up.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,8 +40,8 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/internal/link_ms_dmax_base.hh>
+#include <scribo/primitive/extract/components.hh>
+#include <scribo/primitive/link/internal/link_single_dmax_base.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -54,23 +55,23 @@ namespace scribo
template <typename I, typename L>
struct single_up_link_debug_functor
- : primitive::link::internal::link_ms_dmax_base<L,
+ : primitive::link::internal::link_single_dmax_base<L,
single_up_link_debug_functor<I, L> >
{
typedef single_up_link_debug_functor<I, L> self_t;
typedef
- primitive::link::internal::link_ms_dmax_base<L, self_t> super_;
+ primitive::link::internal::link_single_dmax_base<L, self_t> super_;
public:
typedef mln_site(L) P;
single_up_link_debug_functor(const I& input,
- const object_image(L)& objects,
- float dmax)
- : super_(objects, dmax)
+ const component_set<L>& components,
+ float dmax)
+ : super_(components, dmax, anchor::Vertical)
{
output_ = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ scribo::draw::bounding_boxes(output_, components, literal::blue);
mln_postcondition(output_.is_valid());
}
@@ -120,7 +121,8 @@ namespace scribo
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "max_nbh_dist", "The maximum lookup distance. (common value : 30)" },
{0, 0}
};
@@ -134,10 +136,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful up links between components.",
+ "Show sucessful/unsuccessful up links "
+ "between components.",
"input.pbm max_nbh_dist output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -146,12 +148,13 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> components
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
// Write debug image.
- single_up_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
- primitive::link::compute(functor);
+ single_up_link_debug_functor<I, L>
+ functor(input, components, atof(argv[2]));
+ primitive::link::compute(functor, anchor::MassCenter);
io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_links_single_up_left_aligned.cc b/scribo/src/debug/show_links_single_up_left_aligned.cc
index 5239619..2bb865f 100644
--- a/scribo/src/debug/show_links_single_up_left_aligned.cc
+++ b/scribo/src/debug/show_links_single_up_left_aligned.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -41,7 +42,7 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_up_link.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/filter/object_links_left_aligned.hh>
@@ -54,7 +55,8 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "dmax", "The maximum lookup distance. (common value : 300)" },
{0, 0}
};
@@ -68,10 +70,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful up links between components.",
+ "Show sucessful/unsuccessful up links "
+ "between components.",
"input.pbm dmax output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -80,21 +82,22 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
object_links<L>
- up_links = primitive::link::with_single_up_link(objects,
+ up_links = primitive::link::with_single_up_link(comps,
atof(argv[2]),
anchor::Left);
// Filtering.
- up_links = filter::object_links_left_aligned(objects, up_links, 5);
+ up_links = filter::object_links_left_aligned(up_links, 5);
- scribo::debug::save_linked_bboxes_image(input, objects, up_links,
+ scribo::debug::save_linked_bboxes_image(input, up_links,
literal::blue, literal::green,
- argv[3], anchor::ActualLeft);
+ anchor::ActualLeft,
+ argv[3]);
}
diff --git a/scribo/src/debug/show_links_single_up_right_aligned.cc b/scribo/src/debug/show_links_single_up_right_aligned.cc
index 8c1841e..5cba3b4 100644
--- a/scribo/src/debug/show_links_single_up_right_aligned.cc
+++ b/scribo/src/debug/show_links_single_up_right_aligned.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -41,7 +42,7 @@
#include <mln/draw/line.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/link/with_single_up_link.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/filter/object_links_right_aligned.hh>
@@ -54,7 +55,8 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "dmax", "The maximum lookup distance. (common value : 300)" },
{0, 0}
};
@@ -68,10 +70,10 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful up links between components.",
+ "Show sucessful/unsuccessful up links "
+ "between components.",
"input.pbm dmax output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
typedef image2d<bool> I;
I input;
@@ -80,19 +82,20 @@ int main(int argc, char* argv[])
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
object_links<L>
- up_links = primitive::link::with_single_up_link(objects,
+ up_links = primitive::link::with_single_up_link(comps,
atof(argv[2]),
anchor::Right);
// Filtering.
- up_links = filter::object_links_right_aligned(objects, up_links, 5);
+ up_links = filter::object_links_right_aligned(up_links, 5);
- scribo::debug::save_linked_bboxes_image(input, objects, up_links,
+ scribo::debug::save_linked_bboxes_image(input, up_links,
literal::blue, literal::green,
- argv[3], anchor::ActualRight);
+ anchor::ActualRight,
+ argv[3]);
}
diff --git a/scribo/src/debug/show_objects_large.cc b/scribo/src/debug/show_objects_large.cc
index aac7a9f..a09ea78 100644
--- a/scribo/src/debug/show_objects_large.cc
+++ b/scribo/src/debug/show_objects_large.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,7 +38,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_large.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/usage.hh>
@@ -45,7 +46,8 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "max_card", " Maximum cardinality in a component." },
{0, 0}
};
@@ -54,13 +56,14 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
- "Show components having a too high cardinality.",
+ "Show components having a too high "
+ "cardinality.",
"input.pbm min_card output.ppm",
- args_desc,
- "A color image. Components with high cardinality have their bounding boxes drawn in red, others in green.");
+ args_desc);
trace::entering("main");
@@ -69,16 +72,16 @@ int main(int argc, char *argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::red);
+ scribo::draw::bounding_boxes(output, comps, literal::red);
- object_image(L) filtered_objects
- = scribo::filter::objects_large(objects, atoi(argv[2]));
- scribo::draw::bounding_boxes(output, filtered_objects, literal::green);
+ component_set<L> filtered_comps
+ = scribo::filter::components_large(comps, atoi(argv[2]));
+ scribo::draw::bounding_boxes(output, filtered_comps, literal::green);
io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_objects_large_small.cc b/scribo/src/debug/show_objects_large_small.cc
index e72e5e1..35062d3 100644
--- a/scribo/src/debug/show_objects_large_small.cc
+++ b/scribo/src/debug/show_objects_large_small.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,17 +38,18 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_large.hh>
#include <scribo/filter/objects_small.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/usage.hh>
-#include <scribo/debug/save_object_diff.hh>
+#include <scribo/debug/save_comp_diff.hh>
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "min_card", " Minimum cardinality in a component." },
{ "max_card", " Maximum cardinality in a component." },
{0, 0}
@@ -57,13 +59,14 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 5)
return scribo::debug::usage(argv,
- "Show components not being too small nor too large.",
+ "Show components not being too small nor too"
+ "large.",
"input.pbm min_card max_card output.ppm",
- args_desc,
- "A color image. Too small components are drawn in red, too large components in orange and others in green.");
+ args_desc);
trace::entering("main");
@@ -72,29 +75,17 @@ int main(int argc, char *argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
- object_image(L) filter(objects);
+ component_set<L> filter(comps);
if (atoi(argv[2]) != 0)
- filter = scribo::filter::objects_small(filter, atoi(argv[2]));
+ filter = scribo::filter::components_small(filter, atoi(argv[2]));
if (atoi(argv[3]) != 0)
- filter = scribo::filter::objects_large(filter, atoi(argv[3]));
+ filter = scribo::filter::components_large(filter, atoi(argv[3]));
- image2d<value::rgb8> output;
- initialize(output, objects);
- data::fill(output, literal::black);
-
- for_all_components(i, objects.bboxes())
- data::fill(((output | objects.bbox(i)).rw() | (pw::value(objects) == i)).rw(), literal::red);
-
- for_all_components(i, filter.bboxes())
- data::fill(((output | filter.bbox(i)).rw() | (pw::value(filter) == i)).rw(), literal::green);
-
-
-
- io::ppm::save(output, argv[4]);
+ scribo::debug::save_comp_diff(comps, filter, argv[4]);
}
diff --git a/scribo/src/debug/show_objects_small.cc b/scribo/src/debug/show_objects_small.cc
index a5afb26..ce6ee18 100644
--- a/scribo/src/debug/show_objects_small.cc
+++ b/scribo/src/debug/show_objects_small.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,7 +38,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_small.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/usage.hh>
@@ -45,7 +46,8 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "min_card", " Minimum cardinality in a component.. (Common value : 6)" },
{0, 0}
};
@@ -54,13 +56,14 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
- "Show components having a too low cardinality.",
+ "Show components having a too low "
+ "cardinality.",
"input.pbm min_card output.ppm",
- args_desc,
- "A color image. Components with low cardinality have their bounding boxes drawn in red, others in green.");
+ args_desc);
trace::entering("main");
@@ -69,16 +72,16 @@ int main(int argc, char *argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::red);
+ scribo::draw::bounding_boxes(output, comps, literal::red);
- object_image(L) filtered_objects
- = scribo::filter::objects_small(objects, atoi(argv[2]));
- scribo::draw::bounding_boxes(output, filtered_objects, literal::green);
+ component_set<L> filtered_comps
+ = scribo::filter::components_small(comps, atoi(argv[2]));
+ scribo::draw::bounding_boxes(output, filtered_comps, literal::green);
io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_objects_thick.cc b/scribo/src/debug/show_objects_thick.cc
index 4157ac3..728e55f 100644
--- a/scribo/src/debug/show_objects_thick.cc
+++ b/scribo/src/debug/show_objects_thick.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,15 +38,16 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
-#include <scribo/filter/objects_thin.hh>
+#include <scribo/primitive/extract/components.hh>
+#include <scribo/filter/objects_thick.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
- { "input.pbm", " A binary image. True for objects and False for the background." },
+ { "input.pbm", " A binary image. True for objects and False for the "
+ "background." },
{ "max_thickness", "Maximum bounding box thickness. (common value: 300)" },
{0, 0}
};
@@ -54,13 +56,13 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Show components being to thick.",
"input.pbm max_thickness output.ppm",
- args_desc,
- "A color image. Too thick components have their bounding boxes drawn in red.");
+ args_desc);
trace::entering("main");
@@ -69,16 +71,16 @@ int main(int argc, char *argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::red);
+ scribo::draw::bounding_boxes(output, comps, literal::red);
- object_image(L) filtered_objects
- = scribo::filter::objects_thin(objects, atoi(argv[2]));
- scribo::draw::bounding_boxes(output, filtered_objects, literal::green);
+ component_set<L> filtered_comps
+ = scribo::filter::objects_thick(comps, atoi(argv[2]));
+ scribo::draw::bounding_boxes(output, filtered_comps, literal::green);
io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_objects_thin.cc b/scribo/src/debug/show_objects_thin.cc
index 4223fef..3479fd6 100644
--- a/scribo/src/debug/show_objects_thin.cc
+++ b/scribo/src/debug/show_objects_thin.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,7 +38,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_thin.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/usage.hh>
@@ -45,7 +46,8 @@
const char *args_desc[][2] =
{
- { "input.pbm", " A binary image. True for objects and False for the background." },
+ { "input.pbm", " A binary image. True for objects and False for the "
+ "background." },
{ "min_thickness", "Minimum bounding box thickness. (common value: 1)" },
{0, 0}
};
@@ -54,13 +56,13 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Show components being to thin.",
"input.pbm min_thickness output.ppm",
- args_desc,
- "A color image. Too thin components have their bounding boxes drawn in red.");
+ args_desc);
trace::entering("main");
@@ -69,16 +71,16 @@ int main(int argc, char *argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- object_image(L) objects
- = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nbboxes);
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::red);
+ scribo::draw::bounding_boxes(output, comps, literal::red);
- object_image(L) filtered_objects
- = scribo::filter::objects_thin(objects, atoi(argv[2]));
- scribo::draw::bounding_boxes(output, filtered_objects, literal::green);
+ component_set<L> filtered_comps
+ = scribo::filter::components_thin(comps, atoi(argv[2]));
+ scribo::draw::bounding_boxes(output, filtered_comps, literal::green);
io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/filter/objects_large.cc b/scribo/src/filter/objects_large.cc
index a665032..a017467 100644
--- a/scribo/src/filter/objects_large.cc
+++ b/scribo/src/filter/objects_large.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -30,28 +31,29 @@
#include <mln/value/label_16.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_large.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'True' for objects, 'False'\
-for the background." },
- { "max_area", "The maximum object area value. Objects with an area greater\
-than this value are removed." },
+ { "input.pbm", "A binary image. 'True' for objects, 'False' for the "
+ "background." },
+ { "max_area", "The maximum object area value. Objects with an area greater"
+ " than this value are removed." },
{0, 0}
};
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Filter too large objects",
"input.pbm max_area output.pbm",
- args_desc,
- "A binary image.");
+ args_desc);
trace::entering("main");
@@ -59,13 +61,15 @@ int main(int argc, char *argv[])
I input;
io::pbm::load(input, argv[1]);
- value::label_16 nobjects;
- typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
- obj_ima_t objects
- = scribo::primitive::extract::objects(input, c8(), nobjects);
+ typedef value::label_16 V;
+ V nobjects;
+ typedef image2d<V> L;
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nobjects);
- obj_ima_t filtered = scribo::filter::objects_large(objects, atoi(argv[2]));
- io::pbm::save(data::convert(bool(), filtered), argv[3]);
+ component_set<L>
+ filtered = scribo::filter::components_large(comps, atoi(argv[2]));
+ io::pbm::save(data::convert(bool(), filtered.labeled_image()), argv[3]);
trace::exiting("main");
diff --git a/scribo/src/filter/objects_small.cc b/scribo/src/filter/objects_small.cc
index ce57f00..977c7b1 100644
--- a/scribo/src/filter/objects_small.cc
+++ b/scribo/src/filter/objects_small.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -29,6 +30,7 @@
#include <mln/io/pbm/all.hh>
#include <mln/value/label_16.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_small.hh>
#include <scribo/debug/usage.hh>
@@ -44,13 +46,13 @@ or equal to this value are removed." },
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Filter too small objects",
"input.pbm min_area output.pbm",
- args_desc,
- "A binary image.");
+ args_desc);
trace::entering("main");
@@ -58,13 +60,15 @@ int main(int argc, char *argv[])
I input;
io::pbm::load(input, argv[1]);
- value::label_16 nobjects;
- typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
- obj_ima_t objects
- = scribo::primitive::extract::objects(input, c8(), nobjects);
+ typedef value::label_16 V;
+ V nobjects;
+ typedef image2d<V> L;
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nobjects);
- obj_ima_t filtered = scribo::filter::objects_small(objects, atoi(argv[2]));
- io::pbm::save(data::convert(bool(), filtered), argv[3]);
+ component_set<L>
+ filtered = scribo::filter::components_small(comps, atoi(argv[2]));
+ io::pbm::save(data::convert(bool(), filtered.labeled_image()), argv[3]);
trace::exiting("main");
diff --git a/scribo/src/filter/objects_thick.cc b/scribo/src/filter/objects_thick.cc
index 495c9e0..2b0a235 100644
--- a/scribo/src/filter/objects_thick.cc
+++ b/scribo/src/filter/objects_thick.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -29,28 +30,29 @@
#include <mln/io/pbm/all.hh>
#include <mln/value/label_16.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_thick.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'True' for objects, 'False'\
-for the background." },
- { "max_thick", "The maximum object thickness value. Objects with bounding\
-box hight or width higher than this value are removed." },
+ { "input.pbm", "A binary image. 'True' for objects, 'False' for the "
+ "background." },
+ { "max_thick", "The maximum object thickness value. Objects with bounding"
+ " box hight or width higher than this value are removed." },
{0, 0}
};
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Filter too thick objects",
"input.pbm max_thick output.pbm",
- args_desc,
- "A binary image.");
+ args_desc);
trace::entering("main");
@@ -58,13 +60,15 @@ int main(int argc, char *argv[])
I input;
io::pbm::load(input, argv[1]);
- value::label_16 nobjects;
- typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
- obj_ima_t objects
- = scribo::primitive::extract::objects(input, c8(), nobjects);
+ typedef value::label_16 V;
+ V nobjects;
+ typedef image2d<V> L;
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nobjects);
- obj_ima_t filtered = scribo::filter::objects_thick(objects, atoi(argv[2]));
- io::pbm::save(data::convert(bool(), filtered), argv[3]);
+ component_set<L>
+ filtered = scribo::filter::objects_thick(comps, atoi(argv[2]));
+ io::pbm::save(data::convert(bool(), filtered.labeled_image()), argv[3]);
trace::exiting("main");
diff --git a/scribo/src/filter/objects_thin.cc b/scribo/src/filter/objects_thin.cc
index d1be415..b537184 100644
--- a/scribo/src/filter/objects_thin.cc
+++ b/scribo/src/filter/objects_thin.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -29,28 +30,29 @@
#include <mln/io/pbm/all.hh>
#include <mln/value/label_16.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_thin.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'True' for objects, 'False'\
-for the background." },
- { "min_thin", "The minimum object thinness value. Objects with bounding\
-box hight or width less than or equal to this value are removed." },
+ { "input.pbm", "A binary image. 'True' for objects, 'False' for the "
+ "background." },
+ { "min_thin", "The minimum object thinness value. Objects with bounding "
+ "box hight or width less than or equal to this value are removed." },
{0, 0}
};
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Filter too thin objects",
"input.pbm min_thin output.pbm",
- args_desc,
- "A binary image.");
+ args_desc);
trace::entering("main");
@@ -58,13 +60,15 @@ int main(int argc, char *argv[])
I input;
io::pbm::load(input, argv[1]);
- value::label_16 nobjects;
- typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
- obj_ima_t objects
- = scribo::primitive::extract::objects(input, c8(), nobjects);
+ typedef value::label_16 V;
+ V nobjects;
+ typedef image2d<V> L;
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nobjects);
- obj_ima_t filtered = scribo::filter::objects_thin(objects, atoi(argv[2]));
- io::pbm::save(data::convert(bool(), filtered), argv[3]);
+ component_set<L>
+ filtered = scribo::filter::components_thin(comps, atoi(argv[2]));
+ io::pbm::save(data::convert(bool(), filtered.labeled_image()), argv[3]);
trace::exiting("main");
diff --git a/scribo/src/filter/objects_with_holes.cc b/scribo/src/filter/objects_with_holes.cc
index 0ebf89f..20fe839 100644
--- a/scribo/src/filter/objects_with_holes.cc
+++ b/scribo/src/filter/objects_with_holes.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -29,13 +30,14 @@
#include <mln/io/pbm/all.hh>
#include <mln/value/label_16.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/filter/objects_with_holes.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'True' for objects, 'False'\
-for the background." },
+ { "input.pbm", "A binary image. 'True' for objects, 'False' for the "
+ "background." },
{ "min_holes_count", "The minimum holes per objects." },
{0, 0}
};
@@ -43,13 +45,13 @@ for the background." },
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Filter objects with holes",
"input.pbm min_holes_count output.pbm",
- args_desc,
- "A binary image.");
+ args_desc);
trace::entering("main");
@@ -57,13 +59,16 @@ int main(int argc, char *argv[])
I input;
io::pbm::load(input, argv[1]);
- value::label_16 nobjects;
- typedef object_image(mln_ch_value_(I,value::label_16)) obj_ima_t;
- obj_ima_t objects
- = scribo::primitive::extract::objects(input, c8(), nobjects);
+ typedef value::label_16 V;
+ V nobjects;
+ typedef image2d<V> L;
+ component_set<L> comps
+ = scribo::primitive::extract::components(input, c8(), nobjects);
- obj_ima_t filtered = scribo::filter::objects_with_holes(objects, atoi(argv[2]));
- io::pbm::save(data::convert(bool(), filtered), argv[3]);
+ component_set<L>
+ filtered = scribo::filter::objects_with_holes(comps, atoi(argv[2]), 0);
+
+ io::pbm::save(data::convert(bool(), filtered.valid_comps_image_()), argv[3]);
trace::exiting("main");
diff --git a/scribo/src/filter/objects_with_holes_pgm.cc b/scribo/src/filter/objects_with_holes_pgm.cc
index c834538..40988c8 100644
--- a/scribo/src/filter/objects_with_holes_pgm.cc
+++ b/scribo/src/filter/objects_with_holes_pgm.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,8 +38,8 @@
const char *args_desc[][2] =
{
- { "input.pgm", "A label image. 'True' for objects, 'False'\
-for the background." },
+ { "input.pgm", "A labeled image. 'True' for objects, 'False' for the "
+ "background." },
{ "min_holes_count", "The minimum holes per objects." },
{0, 0}
};
@@ -46,13 +47,13 @@ for the background." },
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Filter objects with holes",
"input.pgm min_holes_count output.pbm",
- args_desc,
- "A binary image.");
+ args_desc);
trace::entering("main");
@@ -60,11 +61,15 @@ int main(int argc, char *argv[])
I input;
io::pgm::load(input, argv[1]);
- value::label_8 nobjects = data::compute(accu::meta::stat::max(), input);
- object_image(I) objects(input, nobjects);
+ typedef value::label_8 V;
+ typedef image2d<V> L;
- object_image(I) filtered = scribo::filter::objects_with_holes(objects, atoi(argv[2]));
- io::pbm::save(data::convert(bool(), filtered), argv[3]);
+ V nobjects = data::compute(accu::meta::stat::max(), input);
+ component_set<L> comps(input, nobjects);
+
+ component_set<L>
+ filtered = scribo::filter::objects_with_holes(comps, atoi(argv[2]), 0);
+ io::pbm::save(data::convert(bool(), filtered.valid_comps_image_()), argv[3]);
trace::exiting("main");
diff --git a/scribo/src/preprocessing/preprocess.cc b/scribo/src/preprocessing/preprocess.cc
index 8c34930..322bfef 100644
--- a/scribo/src/preprocessing/preprocess.cc
+++ b/scribo/src/preprocessing/preprocess.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -25,6 +26,8 @@
#include <mln/core/image/image2d.hh>
+#include <mln/data/convert.hh>
+
#include <mln/value/int_u8.hh>
#include <mln/value/label_16.hh>
@@ -33,8 +36,8 @@
#include <mln/logical/not.hh>
-#include <scribo/binarization/simple.hh>
-#include <scribo/preprocessing/unskew.hh>
+#include <scribo/binarization/global_threshold_auto.hh>
+#include <scribo/preprocessing/deskew.hh>
#include <scribo/filter/objects_small.hh>
#include <scribo/filter/objects_thin.hh>
@@ -54,7 +57,7 @@ int main(int argc, char *argv[])
return scribo::debug::usage(argv,
"Generic image preprocessing",
"input.pgm output.pbm",
- args_desc, "A binary image.");
+ args_desc);
trace::entering("main");
@@ -62,13 +65,19 @@ int main(int argc, char *argv[])
I input;
io::pgm::load(input, argv[1]);
- image2d<bool> input_bw = scribo::binarization::simple(input);
+ image2d<bool>
+ input_bw = scribo::binarization::global_threshold_auto(input);
logical::not_inplace(input_bw);
- input_bw = scribo::filter::objects_small(input_bw, c8(), value::label_16(), 3);
- input_bw = scribo::filter::objects_thin(input_bw, c8(), value::label_16(), 1);
-
- input_bw = scribo::preprocessing::unskew(input_bw).first();
+ input_bw = scribo::filter::components_small(input_bw, c8(),
+ value::label_16(), 3);
+ input_bw = scribo::filter::components_thin(input_bw, c8(),
+ value::label_16(), 1);
+
+ image2d<value::int_u8>
+ input_gl = data::convert(value::int_u8(), input_bw);
+ input_gl = scribo::preprocessing::deskew(input_gl);
+ input_bw = data::convert(bool(), input_gl);
logical::not_inplace(input_bw);
io::pbm::save(input_bw, argv[2]);
diff --git a/scribo/src/preprocessing/split_bg_fg.cc b/scribo/src/preprocessing/split_bg_fg.cc
index de7bd02..270093c 100644
--- a/scribo/src/preprocessing/split_bg_fg.cc
+++ b/scribo/src/preprocessing/split_bg_fg.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -24,7 +25,8 @@
// executable file might be covered by the GNU General Public License.
#include <mln/core/image/image2d.hh>
-#include <mln/io/ppm/all.hh>
+#include <mln/io/magick/load.hh>
+#include <mln/io/ppm/save.hh>
#include <scribo/preprocessing/split_bg_fg.hh>
#include <scribo/debug/usage.hh>
@@ -32,7 +34,7 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A color image." },
+ { "input.*", "An image." },
{ "lambda", "Lambda value. (FIX Description)" },
{ "delta", "Delta value. (FIX Description)" },
{ "fg.ppm", "The foreground image (1st output)." },
@@ -50,12 +52,12 @@ int main(int argc, char *argv[])
if (argc != 6)
return scribo::debug::usage(argv,
"Split background and foreground.",
- "input.pbm lambda delta fg.ppm bg.ppm",
- args_desc, "The foreground image.");
+ "input.* lambda delta fg.ppm bg.ppm",
+ args_desc);
typedef image2d<value::rgb8> I;
I input;
- io::ppm::load(input, argv[1]);
+ io::magick::load(input, argv[1]);
util::couple<I,I>
bg_fg = scribo::preprocessing::split_bg_fg(input,
diff --git a/scribo/src/preprocessing/unskew.cc b/scribo/src/preprocessing/unskew.cc
index b8c1979..9ac32ec 100644
--- a/scribo/src/preprocessing/unskew.cc
+++ b/scribo/src/preprocessing/unskew.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -24,15 +25,16 @@
// executable file might be covered by the GNU General Public License.
#include <mln/core/image/image2d.hh>
-#include <mln/io/pbm/all.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/all.hh>
-#include <scribo/preprocessing/unskew.hh>
+#include <scribo/preprocessing/deskew.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'True' for objects, 'false' for background." },
+ { "input.pgm", "A gray level image." },
{0, 0}
};
@@ -45,14 +47,14 @@ int main(int argc, char *argv[])
if (argc != 3)
return scribo::debug::usage(argv,
- "Unskew a binary image",
- "input.pbm output.pbm",
- args_desc, "A binary image.");
+ "Unskew a gray level image",
+ "input.pgm output.pgm",
+ args_desc);
- image2d<bool> input;
- io::pbm::load(input, argv[1]);
+ image2d<value::int_u8> input;
+ io::pgm::load(input, argv[1]);
- io::pbm::save(scribo::preprocessing::unskew(input).first(), argv[2]);
+ io::pgm::save(scribo::preprocessing::deskew(input), argv[2]);
mln::trace::exiting("main");
}
diff --git a/scribo/src/primitive/extract/extract_discontinued_hlines.cc b/scribo/src/primitive/extract/extract_discontinued_hlines.cc
index 127ca0f..67498af 100644
--- a/scribo/src/primitive/extract/extract_discontinued_hlines.cc
+++ b/scribo/src/primitive/extract/extract_discontinued_hlines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -44,28 +45,29 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 5)
return scribo::debug::usage(argv,
"Extract discontinued horizontal lines",
"input.pbm length rank output.pbm",
- args_desc,
- "A binary image of horizontal lines.");
+ args_desc);
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- value::label_16 nlines;
- image2d<bool> lines
- = data::convert(bool(),
- scribo::primitive::extract::lines_h_discontinued(input,
- c8(),
- nlines,
- atoi(argv[2]),
- atoi(argv[3])));
- io::pbm::save(lines, argv[4]);
+ typedef value::label_16 V;
+ typedef image2d<V> L;
+ V nlines;
+ component_set<L>
+ lines = scribo::primitive::extract::lines_h_discontinued(input,
+ c8(),
+ nlines,
+ atoi(argv[2]),
+ atoi(argv[3]));
+ io::pbm::save(data::convert(bool(), lines.labeled_image()), argv[4]);
trace::exiting("main");
}
diff --git a/scribo/src/primitive/extract/extract_discontinued_lines.cc b/scribo/src/primitive/extract/extract_discontinued_lines.cc
index da3faf9..e5f1483 100644
--- a/scribo/src/primitive/extract/extract_discontinued_lines.cc
+++ b/scribo/src/primitive/extract/extract_discontinued_lines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -45,38 +46,42 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 5)
return scribo::debug::usage(argv,
"Extract discontinued horizontal and vertical lines",
"input.pbm length rank output.pbm",
- args_desc,
- "A binary image of horizontal and vertical lines.");
+ args_desc);
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- value::label_16 nhlines;
- image2d<bool> hlines
- = data::convert(bool(),
- scribo::primitive::extract::lines_h_discontinued(input,
- c8(),
- nhlines,
- atoi(argv[2]),
- atoi(argv[3])));
- value::label_16 nvlines;
- image2d<bool> vlines
- = data::convert(bool(),
- scribo::primitive::extract::lines_v_discontinued(input,
- c8(),
- nvlines,
- atoi(argv[2]),
- atoi(argv[3])));
+ typedef value::label_16 V;
+ typedef image2d<V> L;
- data::fill((hlines | pw::value(vlines)).rw(), true);
- io::pbm::save(hlines, argv[4]);
+ V nhlines;
+ component_set<L>
+ hlines = scribo::primitive::extract::lines_h_discontinued(input,
+ c8(),
+ nhlines,
+ atoi(argv[2]),
+ atoi(argv[3]));
+
+ V nvlines;
+ component_set<L> vlines
+ = scribo::primitive::extract::lines_v_discontinued(input,
+ c8(),
+ nvlines,
+ atoi(argv[2]),
+ atoi(argv[3]));
+
+ L& hlines_ima = hlines.labeled_image_();
+ image2d<bool> output = data::convert(bool(), hlines_ima);
+ data::fill((output | (pw::value(vlines.labeled_image()) != 0u)).rw(), true);
+ io::pbm::save(output, argv[4]);
trace::exiting("main");
}
diff --git a/scribo/src/primitive/extract/extract_discontinued_vlines.cc b/scribo/src/primitive/extract/extract_discontinued_vlines.cc
index 5e71ec0..68cd7d9 100644
--- a/scribo/src/primitive/extract/extract_discontinued_vlines.cc
+++ b/scribo/src/primitive/extract/extract_discontinued_vlines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -44,28 +45,30 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 5)
return scribo::debug::usage(argv,
"Extract discontinued vertical lines",
"input.pbm length rank output.pbm",
- args_desc,
- "A binary image of vertical lines.");
+ args_desc);
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- value::label_16 nlines;
- image2d<bool> lines
- = data::convert(bool(),
- scribo::primitive::extract::lines_v_discontinued(input,
- c8(),
- nlines,
- atoi(argv[2]),
- atoi(argv[3])));
- io::pbm::save(lines, argv[4]);
+ typedef value::label_16 V;
+ V nlines;
+ typedef image2d<V> L;
+
+ component_set<L>
+ vlines = scribo::primitive::extract::lines_v_discontinued(input,
+ c8(),
+ nlines,
+ atoi(argv[2]),
+ atoi(argv[3]));
+ io::pbm::save(data::convert(bool(), vlines.labeled_image()), argv[4]);
trace::exiting("main");
}
diff --git a/scribo/src/primitive/extract/extract_thick_hlines.cc b/scribo/src/primitive/extract/extract_thick_hlines.cc
index efa158a..136c2f9 100644
--- a/scribo/src/primitive/extract/extract_thick_hlines.cc
+++ b/scribo/src/primitive/extract/extract_thick_hlines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -43,27 +44,29 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Extract thick horizontal lines",
"input.pbm length output.pbm",
- args_desc,
- "A binary image of horizontal lines.");
+ args_desc);
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- value::label_16 nlines;
- image2d<bool> lines
- = data::convert(bool(),
- scribo::primitive::extract::lines_h_thick(input,
- c8(),
- nlines,
- atoi(argv[2])));
- io::pbm::save(lines, argv[3]);
+ typedef value::label_16 V;
+ V nlines;
+ typedef image2d<V> L;
+
+ component_set<L>
+ lines = scribo::primitive::extract::lines_h_thick(input,
+ c8(),
+ nlines,
+ atoi(argv[2]));
+ io::pbm::save(data::convert(bool(), lines.labeled_image()), argv[3]);
trace::exiting("main");
}
diff --git a/scribo/src/primitive/extract/extract_thick_vlines.cc b/scribo/src/primitive/extract/extract_thick_vlines.cc
index 2a5f8ee..7c38268 100644
--- a/scribo/src/primitive/extract/extract_thick_vlines.cc
+++ b/scribo/src/primitive/extract/extract_thick_vlines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -43,27 +44,29 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
"Extract thick vertical lines",
"input.pbm length output.pbm",
- args_desc,
- "A binary image of vertical lines.");
+ args_desc);
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- value::label_16 nlines;
- image2d<bool> lines
- = data::convert(bool(),
- scribo::primitive::extract::lines_v_thick(input,
- c8(),
- nlines,
- atoi(argv[2])));
- io::pbm::save(lines, argv[3]);
+ typedef value::label_16 V;
+ V nlines;
+ typedef image2d<V> L;
+
+ component_set<L>
+ lines = scribo::primitive::extract::lines_v_thick(input,
+ c8(),
+ nlines,
+ atoi(argv[2]));
+ io::pbm::save(data::convert(bool(), lines.labeled_image()), argv[3]);
trace::exiting("main");
}
diff --git a/scribo/src/primitive/find/find_discontinued_lines.cc b/scribo/src/primitive/find/find_discontinued_lines.cc
index 1ed77e3..244cae5 100644
--- a/scribo/src/primitive/find/find_discontinued_lines.cc
+++ b/scribo/src/primitive/find/find_discontinued_lines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -49,13 +50,14 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 4)
return scribo::debug::usage(argv,
- "Extract discontinued horizontal and vertical lines",
+ "Extract discontinued horizontal and "
+ "vertical lines",
"input.pbm length output.ppm",
- args_desc,
- "A color image. Horizontal lines are in red and vertical lines in green.");
+ args_desc);
trace::entering("main");
@@ -68,7 +70,7 @@ int main(int argc, char *argv[])
nvlines;
typedef image2d<value::label_16> L;
- object_image(L)
+ component_set<L>
hlines = scribo::primitive::extract::lines_h_discontinued(input,
c8(),
nhlines,
@@ -80,8 +82,9 @@ int main(int argc, char *argv[])
atoi(argv[2]),
8);
- image2d<value::rgb8> out = debug::superpose(input, hlines, literal::red);
- out = debug::superpose(out, vlines, literal::green);
+ image2d<value::rgb8>
+ out = mln::debug::superpose(input, hlines.labeled_image(), literal::red);
+ out = mln::debug::superpose(out, vlines.labeled_image(), literal::green);
io::ppm::save(out, argv[3]);
diff --git a/scribo/src/primitive/find/find_single_lines.cc b/scribo/src/primitive/find/find_single_lines.cc
index afe518b..16e216f 100644
--- a/scribo/src/primitive/find/find_single_lines.cc
+++ b/scribo/src/primitive/find/find_single_lines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009,2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -34,7 +35,7 @@
#include <scribo/debug/usage.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/extract/lines_h_single.hh>
#include <scribo/primitive/extract/lines_v_single.hh>
@@ -52,15 +53,16 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 7)
return scribo::debug::usage(argv,
- "Extract single horizontal and vertical lines. \
-\n Common argument values: 100 10 100 10",
- "<input.pbm> <length> <hbratio> <vbratio>\
- <output.pbm>",
- args_desc,
- "A binary image of horizontal and vertical single lines.");
+ "Extract single horizontal and vertical "
+ "lines.\n Common argument values: 100 10 "
+ "100 10",
+ "<input.pbm> <length> <hbratio> <vbratio> "
+ "<output.pbm>",
+ args_desc);
trace::entering("main");
@@ -70,22 +72,23 @@ int main(int argc, char *argv[])
typedef image2d<value::label_16> L;
value::label_16 nhlines;
- object_image(L)
- objects = scribo::primitive::extract::objects(input, c8(), nhlines);
+ component_set<L>
+ comps = scribo::primitive::extract::components(input, c8(), nhlines);
- object_image(L)
- hlines = scribo::primitive::extract::lines_h_single(objects,
+ component_set<L>
+ hlines = scribo::primitive::extract::lines_h_single(comps,
atoi(argv[2]),
atof(argv[3]));
- object_image(L)
- vlines = scribo::primitive::extract::lines_v_single(objects,
+ component_set<L>
+ vlines = scribo::primitive::extract::lines_v_single(comps,
atoi(argv[4]),
atof(argv[5]));
- image2d<value::rgb8> out = debug::superpose(input, hlines, literal::red);
- out = debug::superpose(out, vlines, literal::green);
+ image2d<value::rgb8>
+ out = mln::debug::superpose(input, hlines.labeled_image(), literal::red);
+ out = mln::debug::superpose(out, vlines.labeled_image(), literal::green);
io::ppm::save(out, argv[6]);
trace::exiting("main");
diff --git a/scribo/src/primitive/find/find_thick_and_single_lines.cc b/scribo/src/primitive/find/find_thick_and_single_lines.cc
index fa66e29..cf88571 100644
--- a/scribo/src/primitive/find/find_thick_and_single_lines.cc
+++ b/scribo/src/primitive/find/find_thick_and_single_lines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -34,10 +35,8 @@
#include <scribo/debug/usage.hh>
-#include <scribo/core/object_image.hh>
-
-# include <scribo/primitive/extract/lines_v_thick_and_single.hh>
-# include <scribo/primitive/extract/lines_h_thick_and_single.hh>
+#include <scribo/primitive/extract/lines_v_thick_and_single.hh>
+#include <scribo/primitive/extract/lines_h_thick_and_single.hh>
const char *args_desc[][2] =
{
@@ -57,13 +56,12 @@ int main(int argc, char *argv[])
if (argc != 7)
return scribo::debug::usage(argv,
- "Extract thick horizontal and vertical lines.\
-\n Common argument values: 150 10 150 10.",
- "<input.pbm> <vlength> <vratio> <hlength>\
- <hratio> <output.ppm>",
- args_desc,
- "A color image. Horizontal lines are in red\
- and vertical lines in green.");
+ "Extract thick horizontal and vertical "
+ "lines.\n Common argument values: 150 10 "
+ "150 10.",
+ "<input.pbm> <vlength> <vratio> <hlength>"
+ " <hratio> <output.ppm>",
+ args_desc);
trace::entering("main");
@@ -77,7 +75,7 @@ int main(int argc, char *argv[])
nhlines,
nvlines;
- object_image(L)
+ component_set<L>
hlines = primitive::extract::lines_h_thick_and_single(input, c8(),
nhlines,
atoi(argv[2]),
@@ -87,8 +85,9 @@ int main(int argc, char *argv[])
atoi(argv[4]),
atoi(argv[5]));
- image2d<value::rgb8> out = mln::debug::superpose(input, hlines, literal::red);
- out = mln::debug::superpose(out, vlines, literal::green);
+ image2d<value::rgb8>
+ out = mln::debug::superpose(input, hlines.labeled_image(), literal::red);
+ out = mln::debug::superpose(out, vlines.labeled_image(), literal::green);
io::ppm::save(out, argv[6]);
diff --git a/scribo/src/primitive/find/find_thick_lines.cc b/scribo/src/primitive/find/find_thick_lines.cc
index 045b34d..8966b81 100644
--- a/scribo/src/primitive/find/find_thick_lines.cc
+++ b/scribo/src/primitive/find/find_thick_lines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -34,7 +35,6 @@
#include <scribo/debug/usage.hh>
-#include <scribo/core/object_image.hh>
#include <scribo/primitive/extract/lines_h_thick.hh>
#include <scribo/primitive/extract/lines_v_thick.hh>
@@ -54,15 +54,14 @@ const char *args_desc[][2] =
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
if (argc != 5)
return scribo::debug::usage(argv,
- "Extract thick horizontal and vertical lines.\
-\n Common argument values: 150 150.",
+ "Extract thick horizontal and vertical "
+ "lines.\n Common argument values: 150 150.",
"<input.pbm> <vlength> <hlength> <output.ppm>",
- args_desc,
- "A color image. Horizontal lines are in red\
- and vertical lines in green.");
+ args_desc);
trace::entering("main");
@@ -76,14 +75,15 @@ int main(int argc, char *argv[])
nhlines,
nvlines;
- object_image(L)
+ component_set<L>
hlines = scribo::primitive::extract::lines_h_thick(input, c8(),
nhlines, atoi(argv[2])),
vlines = scribo::primitive::extract::lines_v_thick(input, c8(),
nvlines, atoi(argv[3]));
- image2d<value::rgb8> out = debug::superpose(input, hlines, literal::red);
- out = debug::superpose(out, vlines, literal::green);
+ image2d<value::rgb8>
+ out = mln::debug::superpose(input, hlines.labeled_image(), literal::red);
+ out = mln::debug::superpose(out, vlines.labeled_image(), literal::green);
io::ppm::save(out, argv[4]);
diff --git a/scribo/src/primitive/group/Makefile.am b/scribo/src/primitive/group/Makefile.am
index 92a81fc..afc4f8e 100644
--- a/scribo/src/primitive/group/Makefile.am
+++ b/scribo/src/primitive/group/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+# (LRDE).
#
# This file is part of Olena.
#
@@ -18,21 +19,19 @@ include $(top_srcdir)/scribo/scribo.mk
bin_PROGRAMS = \
group_from_double_link \
- group_from_double_link_filter_non_aligned \
group_from_double_several_links \
- group_from_graph \
- group_from_several_graph \
group_from_several_left_links \
group_from_single_link
group_from_double_link_SOURCES = group_from_double_link.cc
-group_from_double_link_filter_non_aligned_SOURCES = group_from_double_link_filter_non_aligned.cc
group_from_double_several_links_SOURCES = group_from_double_several_links.cc
-group_from_graph_SOURCES = group_from_graph.cc
-group_from_several_graph_SOURCES = group_from_several_graph.cc
group_from_several_left_links_SOURCES = group_from_several_left_links.cc
group_from_single_link_SOURCES = group_from_single_link.cc
## FIXME: Does not compile.
-## bin_PROGRAMS += group_from_rag
+## bin_PROGRAMS += group_from_rag \
+## group_from_graph \
+## group_from_several_graph \
## group_from_rag_SOURCES = group_from_rag.cc
+## group_from_graph_SOURCES = group_from_graph.cc
+## group_from_several_graph_SOURCES = group_from_several_graph.cc
\ No newline at end of file
diff --git a/scribo/src/primitive/group/group_from_double_link.cc b/scribo/src/primitive/group/group_from_double_link.cc
index 9e8a6b3..00c68df 100644
--- a/scribo/src/primitive/group/group_from_double_link.cc
+++ b/scribo/src/primitive/group/group_from_double_link.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,7 +38,7 @@
#include <scribo/core/object_links.hh>
#include <scribo/core/object_image.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.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>
@@ -53,10 +54,12 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'True' for objects, 'False'\
-for the background." },
- { "hlmax", "Maximum distance between two grouped objects while browsing on the left." },
- { "hrmax", "Maximum distance between two grouped objects while browsing on the right." },
+ { "input.pbm", "A binary image. 'True' for objects, 'False' for the "
+ "background." },
+ { "hlmax", "Maximum distance between two grouped objects while browsing "
+ "on the left." },
+ { "hrmax", "Maximum distance between two grouped objects while browsing "
+ "on the right." },
{ "prefix", "Output names prefix" },
{0, 0}
};
@@ -68,10 +71,10 @@ int main(int argc, char *argv[])
if (argc != 5)
return scribo::debug::usage(argv,
- "Group potential text objects using a double validation link.",
+ "Group potential text objects using a double"
+ "validation link.",
"input.pbm hlmax hrmax prefix",
- args_desc,
- "Several images showing the process.");
+ args_desc);
scribo::make::internal::debug_filename_prefix = argv[4];
@@ -81,10 +84,10 @@ int main(int argc, char *argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- typedef object_image(L) text_t;
- text_t text = primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L>
+ text = primitive::extract::components(input, c8(), nbboxes);
- text = filter::objects_small(text, 4);
+ text = filter::components_small(text, 4);
object_links<L> left_link
= primitive::link::with_single_left_link(text, atoi(argv[2]));
@@ -93,41 +96,29 @@ int main(int argc, char *argv[])
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
-// scribo::debug::save_linked_textbboxes_image(input,
-// text, left_link,
-// literal::red, literal::cyan,
-// scribo::make::debug_filename("left_linked.ppm"));
-// scribo::debug::save_linked_textbboxes_image(input,
-// text, right_link,
-// literal::red, literal::cyan,
-// scribo::make::debug_filename("right_linked.ppm"));
-
scribo::debug::save_linked_bboxes_image(input,
- text, left_link, right_link,
+ left_link, right_link,
literal::red, literal::cyan, literal::yellow,
literal::green,
+ anchor::MassCenter,
scribo::make::debug_filename("links.ppm"));
-// io::ppm::save(mln::labeling::colorize(value::rgb8(),
-// text.label_image(),
-// text.nlabels()),
-// scribo::make::debug_filename("lbl_before.ppm"));
-
// With validation.
object_groups<L> groups
- = primitive::group::from_double_link(text, left_link, right_link);
+ = primitive::group::from_double_link(left_link, right_link);
- text_t grouped_text = primitive::group::apply(text, groups);
+ component_set<L> grouped_text = primitive::group::apply(groups);
io::ppm::save(mln::labeling::colorize(value::rgb8(),
- grouped_text,
- grouped_text.nlabels()),
+ grouped_text.labeled_image(),
+ grouped_text.nelements()),
scribo::make::debug_filename("label_color.ppm"));
- std::cout << "AFTER double grouping - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
+ std::cout << "AFTER double grouping - nbboxes = "
+ << grouped_text.nelements() << std::endl;
- scribo::debug::save_bboxes_image(input, grouped_text.bboxes(),
- literal::red,
- scribo::make::debug_filename("bboxes.ppm"));
+ scribo::debug::save_bboxes_image(input, grouped_text,
+ scribo::make::debug_filename("bboxes.ppm"),
+ literal::red);
}
diff --git a/scribo/src/primitive/group/group_from_double_several_links.cc b/scribo/src/primitive/group/group_from_double_several_links.cc
index 5b591c2..2a49b33 100644
--- a/scribo/src/primitive/group/group_from_double_several_links.cc
+++ b/scribo/src/primitive/group/group_from_double_several_links.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -36,7 +37,7 @@
#include <mln/literal/colors.hh>
#include <mln/util/array.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.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>
@@ -71,46 +72,47 @@ int main(int argc, char* argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
std::cout << "extract bboxes" << std::endl;
- typedef object_image(L) text_t;
- text_t text = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L>
+ comps = scribo::primitive::extract::components(input, c8(), nbboxes);
std::cout << "Remove small components" << std::endl;
- text = filter::objects_small(text,4);
+ comps = filter::components_small(comps, 4);
std::cout << "Group with left link" << std::endl;
object_links<L> left_link
- = primitive::link::with_several_left_links(text, 30);
+ = primitive::link::with_several_left_links(comps, 30);
std::cout << "Group with right link" << std::endl;
object_links<L> right_link
- = primitive::link::with_several_right_links(text, 30);
+ = primitive::link::with_several_right_links(comps, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
scribo::debug::save_linked_bboxes_image(input,
- text, left_link, right_link,
+ left_link, right_link,
literal::red, literal::cyan, literal::yellow,
literal::green,
+ anchor::Center,
scribo::make::debug_filename("links.ppm"));
// With validation.
std::cout << "Group from double link" << std::endl;
object_groups<L> groups
- = primitive::group::from_double_link(text, left_link, right_link);
+ = primitive::group::from_double_link(left_link, right_link);
- text_t grouped_text = primitive::group::apply(text, groups);
+ component_set<L> grouped_comps = primitive::group::apply(groups);
io::ppm::save(mln::labeling::colorize(value::rgb8(),
- grouped_text,
- grouped_text.nlabels()),
+ grouped_comps.labeled_image(),
+ grouped_comps.nelements()),
scribo::make::debug_filename("label_color.ppm"));
- std::cout << "AFTER double grouping - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
+ std::cout << "AFTER double grouping - nbboxes = " << grouped_comps.nelements() << std::endl;
- scribo::debug::save_bboxes_image(input, grouped_text.bboxes(),
- literal::red,
- scribo::make::debug_filename("bboxes.ppm"));
+ scribo::debug::save_bboxes_image(input, grouped_comps,
+ scribo::make::debug_filename("bboxes.ppm"),
+ literal::red);
}
diff --git a/scribo/src/primitive/group/group_from_several_left_links.cc b/scribo/src/primitive/group/group_from_several_left_links.cc
index a153e0c..ef70a19 100644
--- a/scribo/src/primitive/group/group_from_several_left_links.cc
+++ b/scribo/src/primitive/group/group_from_several_left_links.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -40,7 +41,7 @@
#include <mln/io/ppm/save.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/group/apply.hh>
#include <scribo/primitive/link/with_several_left_links.hh>
#include <scribo/primitive/group/from_single_link.hh>
@@ -70,33 +71,34 @@ int main(int argc, char* argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- typedef object_image(L) text_t;
- text_t text = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L>
+ comps = scribo::primitive::extract::components(input, c8(), nbboxes);
{
std::cout << "* Left grouping" << std::endl;
object_links<L> left_link
- = primitive::link::with_several_left_links(text, 30);
+ = primitive::link::with_several_left_links(comps, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
scribo::debug::save_linked_bboxes_image(input,
- text, left_link,
+ left_link,
literal::red, literal::cyan,
scribo::make::debug_filename("left_links.ppm"));
object_groups<L>
- groups = primitive::group::from_single_link(text, left_link);
+ groups = primitive::group::from_single_link(left_link);
- text_t grouped_text = primitive::group::apply(text, groups);
- std::cout << "AFTER - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
+ component_set<L> grouped_comps = primitive::group::apply(groups);
+ std::cout << "AFTER - nbboxes = " << grouped_comps.nelements()
+ << std::endl;
io::ppm::save(mln::labeling::colorize(value::rgb8(),
- grouped_text,
- grouped_text.nlabels()),
- scribo::make::debug_filename("left_label_color.ppm"));
- scribo::debug::save_bboxes_image(input, grouped_text.bboxes(),
- literal::red,
- scribo::make::debug_filename("left_bboxes.ppm"));
+ grouped_comps.labeled_image(),
+ grouped_comps.nelements()),
+ scribo::make::debug_filename("left_label_color.ppm"));
+ scribo::debug::save_bboxes_image(input, grouped_comps,
+ scribo::make::debug_filename("left_bboxes.ppm"),
+ literal::red);
}
}
diff --git a/scribo/src/primitive/group/group_from_single_link.cc b/scribo/src/primitive/group/group_from_single_link.cc
index f408d66..5b5f710 100644
--- a/scribo/src/primitive/group/group_from_single_link.cc
+++ b/scribo/src/primitive/group/group_from_single_link.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,7 +38,7 @@
#include <mln/io/pbm/load.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.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>
@@ -70,68 +71,67 @@ int main(int argc, char* argv[])
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- typedef object_image(L) text_t;
- text_t text = scribo::primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L>
+ comps = scribo::primitive::extract::components(input, c8(), nbboxes);
{
std::cout << "* Left grouping" << std::endl;
object_links<L> left_link
- = primitive::link::with_single_left_link(text, 30);
+ = primitive::link::with_single_left_link(comps, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
scribo::debug::save_linked_bboxes_image(input,
- text, left_link,
+ left_link,
literal::red, literal::cyan,
scribo::make::debug_filename("left_links.ppm"));
// io::ppm::save(mln::labeling::colorize(value::rgb8(),
-// text,
-// text.nlabels()),
+// comps,
+// comps.nlabels()),
// scribo::make::debug_filename("lbl_before.ppm"));
object_groups<L>
- groups = primitive::group::from_single_link(text, left_link);
+ groups = primitive::group::from_single_link(left_link);
- text_t grouped_text = primitive::group::apply(text, groups);
+ component_set<L> grouped_comps = primitive::group::apply(groups);
- std::cout << "AFTER - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
+ std::cout << "AFTER - nbboxes = " << grouped_comps.nelements() << std::endl;
io::ppm::save(mln::labeling::colorize(value::rgb8(),
- grouped_text,
- grouped_text.nlabels()),
- scribo::make::debug_filename("left_label_color.ppm"));
- scribo::debug::save_bboxes_image(input, grouped_text.bboxes(),
- literal::red,
- scribo::make::debug_filename("left_bboxes.ppm"));
+ grouped_comps.labeled_image(),
+ grouped_comps.nelements()),
+ scribo::make::debug_filename("left_label_color.ppm"));
+ scribo::debug::save_bboxes_image(input, grouped_comps,
+ scribo::make::debug_filename("left_bboxes.ppm"), literal::red);
}
{
std::cout << "* Left grouping" << std::endl;
object_links<L> right_link
- = primitive::link::with_single_right_link(text, 30);
+ = primitive::link::with_single_right_link(comps, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
scribo::debug::save_linked_bboxes_image(input,
- text, right_link,
+ right_link,
literal::red, literal::cyan,
scribo::make::debug_filename("right_links.ppm"));
// io::ppm::save(mln::labeling::colorize(value::rgb8(),
-// text,
-// text.nlabels()),
+// comps,
+// comps.nlabels()),
// scribo::make::debug_filename("lbl_before.ppm"));
object_groups<L>
- groups = primitive::group::from_single_link(text, right_link);
+ groups = primitive::group::from_single_link(right_link);
- text_t grouped_text = primitive::group::apply(text, groups);
+ component_set<L> grouped_comps = primitive::group::apply(groups);
io::ppm::save(mln::labeling::colorize(value::rgb8(),
- grouped_text,
- grouped_text.nlabels()),
- scribo::make::debug_filename("right_label_color.ppm"));
- std::cout << "AFTER - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
-
- scribo::debug::save_bboxes_image(input, grouped_text.bboxes(),
- literal::red,
- scribo::make::debug_filename("right_bboxes.ppm"));
+ grouped_comps.labeled_image(),
+ grouped_comps.nelements()),
+ scribo::make::debug_filename("right_label_color.ppm"));
+ std::cout << "AFTER - nbboxes = " << grouped_comps.nelements() << std::endl;
+
+ scribo::debug::save_bboxes_image(input, grouped_comps,
+ scribo::make::debug_filename("right_bboxes.ppm"),
+ literal::red);
}
diff --git a/scribo/src/table/erase.cc b/scribo/src/table/erase.cc
index 29546bb..2870798 100644
--- a/scribo/src/table/erase.cc
+++ b/scribo/src/table/erase.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -58,22 +59,22 @@ int main(int argc, char* argv[])
return scribo::debug::usage(argv,
"Remove tables from a binary image.",
"input.pbm output.pbm",
- args_desc,
- "A binary image without tables.");
+ args_desc);
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- typedef image2d<label_16> lbl_t;
+ typedef value::label_16 V;
+ typedef image2d<V> L;
/// Extracting vertical and horizontal lines.
- label_16 nhlines, nvlines;
- object_image(lbl_t)
+ V nhlines, nvlines;
+ component_set<L>
lbl_v = primitive::extract::lines_v_discontinued(input, c8(),
nvlines, 51, 8);
- object_image(lbl_t)
+ component_set<L>
lbl_h = primitive::extract::lines_h_discontinued(input, c8(),
nhlines, 51, 6);
diff --git a/scribo/src/text/cleantxt.cc b/scribo/src/text/cleantxt.cc
index f303448..78aa5e6 100644
--- a/scribo/src/text/cleantxt.cc
+++ b/scribo/src/text/cleantxt.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -31,18 +32,22 @@
#include <mln/logical/not.hh>
#include <mln/core/alias/neighb2d.hh>
-#include <mln/core/alias/w_window2d_int.hh>
-#include <mln/make/w_window2d_int.hh>
+#include <mln/value/int_u16.hh>
+#include <scribo/text/merging.hh>
+#include <scribo/primitive/extract/components.hh>
+#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
+#include <scribo/primitive/group/from_single_link.hh>
#include <scribo/text/clean.hh>
#include <scribo/debug/usage.hh>
+#include <scribo/make/debug_filename.hh>
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'True' for objects, 'False'\
-for the background." },
+ { "input.pbm", "A binary image. 'True' for objects, 'False' for the "
+ "background." },
{ "out.pbm", "A cleaned up binary image." },
{0, 0}
};
@@ -58,22 +63,34 @@ int main(int argc, char* argv[])
return scribo::debug::usage(argv,
"Cleanup text areas.",
"input.pbm out.pbm",
- args_desc,
- "");
+ args_desc);
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- int vals[] = { 0, 9, 0, 9, 0,
- 9, 6, 4, 6, 9,
- 0, 4, 0, 4, 0,
- 9, 6, 4, 6, 9,
- 0, 9, 0, 9, 0 };
- w_window2d_int dmap_win = mln::make::w_window2d_int(vals);
+ scribo::make::internal::debug_filename_prefix = argv[2];
- io::pbm::save(scribo::text::clean(logical::not_(input), dmap_win), argv[2]);
+ typedef image2d<value::int_u16> L;
+ value::int_u16 ncomps;
+ component_set<L>
+ comps = primitive::extract::components(input, c8(), ncomps);
+
+ object_links<L>
+ links = primitive::link::with_single_left_link_dmax_ratio(comps, 2);
+
+ object_groups<L>
+ groups = primitive::group::from_single_link(links);
+
+ line_set<L> lines(groups);
+ lines = text::merging(lines);
+
+ logical::not_inplace(input);
+
+ for_all_lines(l, lines)
+ io::pbm::save(scribo::text::clean(lines(l), input),
+ scribo::make::debug_filename("text.pbm"));
trace::exiting("main");
}
--
1.5.6.5
1
0

last-svn-commit-434-ga0961e1 Catch up with the current interface of scribo::debug::usage.
by Guillaume Lazzara 09 Aug '10
by Guillaume Lazzara 09 Aug '10
09 Aug '10
* src/debug/show_links_bottom_aligned.cc,
* src/debug/show_links_top_aligned.cc,
* src/misc/negate.cc,
* src/misc/superpose.cc,
* src/preprocessing/rotate_90.cc,
* src/primitive/extract/lines_pattern.cc,
* src/primitive/find/find_pattern_lines.cc,
* src/table/extract.cc: Here.
---
scribo/ChangeLog | 13 ++++++++++
scribo/src/debug/show_links_bottom_aligned.cc | 6 ++--
scribo/src/debug/show_links_top_aligned.cc | 12 +++++----
scribo/src/misc/negate.cc | 5 ++-
scribo/src/misc/superpose.cc | 7 ++---
scribo/src/preprocessing/rotate_90.cc | 30 +++++++++++++++++++++-
scribo/src/primitive/extract/lines_pattern.cc | 6 ++--
scribo/src/primitive/find/find_pattern_lines.cc | 9 ++++---
scribo/src/table/extract.cc | 7 ++---
9 files changed, 68 insertions(+), 27 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index a8bffd2..b186c47 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,18 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Catch up with the current interface of scribo::debug::usage.
+
+ * src/debug/show_links_bottom_aligned.cc,
+ * src/debug/show_links_top_aligned.cc,
+ * src/misc/negate.cc,
+ * src/misc/superpose.cc,
+ * src/preprocessing/rotate_90.cc,
+ * src/primitive/extract/lines_pattern.cc,
+ * src/primitive/find/find_pattern_lines.cc,
+ * src/table/extract.cc: Here.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Replace the use of object_image with component_set.
* core/erase_objects.hh,
diff --git a/scribo/src/debug/show_links_bottom_aligned.cc b/scribo/src/debug/show_links_bottom_aligned.cc
index 337032a..bf858dc 100644
--- a/scribo/src/debug/show_links_bottom_aligned.cc
+++ b/scribo/src/debug/show_links_bottom_aligned.cc
@@ -65,10 +65,10 @@ int main(int argc, char* argv[])
if (argc != 5)
return scribo::debug::usage(argv,
- "Show valid or invalid links according the horizontal alignment (based on bottom line).",
+ "Show valid or invalid links according the"
+ "horizontal alignment (based on bottom line).",
"input.pbm max_dist max_alpha output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
image2d<bool> input;
io::pbm::load(input, argv[1]);
diff --git a/scribo/src/debug/show_links_top_aligned.cc b/scribo/src/debug/show_links_top_aligned.cc
index ff01221..9efcb6d 100644
--- a/scribo/src/debug/show_links_top_aligned.cc
+++ b/scribo/src/debug/show_links_top_aligned.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -48,7 +49,8 @@
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the background." },
+ { "input.pbm", "A binary image. True for objects and False for the "
+ "background." },
{ "max_dist", "Maximum distance lookup (common value 45)" },
{ "max_alpha", "Max angle between two object tops. (common value : 5)" },
{0, 0}
@@ -63,10 +65,10 @@ int main(int argc, char* argv[])
if (argc != 5)
return scribo::debug::usage(argv,
- "Show valid or invalid links according the horizontal alignment (based on top line).",
+ "Show valid or invalid links according the "
+ "horizontal alignment (based on top line).",
"input.pbm max_dist max_alpha output.ppm",
- args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ args_desc);
image2d<bool> input;
io::pbm::load(input, argv[1]);
diff --git a/scribo/src/misc/negate.cc b/scribo/src/misc/negate.cc
index 9c35f1c..da6fad6 100644
--- a/scribo/src/misc/negate.cc
+++ b/scribo/src/misc/negate.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -46,7 +47,7 @@ int main(int argc, char *argv[])
return scribo::debug::usage(argv,
"Negate a binary image",
"input.pbm output.pbm",
- args_desc, "A binary image.");
+ args_desc);
image2d<bool> input;
io::pbm::load(input, argv[1]);
diff --git a/scribo/src/misc/superpose.cc b/scribo/src/misc/superpose.cc
index 8449987..6cb5e1d 100644
--- a/scribo/src/misc/superpose.cc
+++ b/scribo/src/misc/superpose.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -49,9 +50,7 @@ int main(int argc, char *argv[])
return scribo::debug::usage(argv,
"Superpose two binary images",
"input.pbm data.pbm output.ppm",
- args_desc,
- "A color image. Data from 'data.pbm' is \
-colored in red.");
+ args_desc);
image2d<bool> input;
io::pbm::load(input, argv[1]);
diff --git a/scribo/src/preprocessing/rotate_90.cc b/scribo/src/preprocessing/rotate_90.cc
index 3c4e84f..c5e9536 100644
--- a/scribo/src/preprocessing/rotate_90.cc
+++ b/scribo/src/preprocessing/rotate_90.cc
@@ -1,3 +1,28 @@
+// Copyright (C) 2010 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.
+
#include <mln/core/image/image2d.hh>
#include <mln/value/rgb8.hh>
#include <mln/io/magick/load.hh>
@@ -13,7 +38,8 @@ const char *args_desc[][2] =
{
{ "input.*", "An image." },
{ "output.ppm", "A rotated image." },
- { "positive", "if set to 1, performs a +90 rotation; -90 otherwise. (default: 0)" },
+ { "positive", "if set to 1, performs a +90 rotation; -90 otherwise. "
+ "(default: 0)" },
{0, 0}
};
@@ -26,7 +52,7 @@ int main(int argc, char *argv[])
if (argc != 3 && argc != 4)
return scribo::debug::usage(argv,
"Fast +90/-90 rotation",
- "input.* output.ppm",
+ "input.* output.ppm <positive>",
args_desc);
diff --git a/scribo/src/primitive/extract/lines_pattern.cc b/scribo/src/primitive/extract/lines_pattern.cc
index d794c71..d2ad562 100644
--- a/scribo/src/primitive/extract/lines_pattern.cc
+++ b/scribo/src/primitive/extract/lines_pattern.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -51,8 +52,7 @@ int main(int argc, char *argv[])
return scribo::debug::usage(argv,
"Extract horizontal lines patterns",
"input.pbm length delta output.pbm",
- args_desc,
- "A binary image of lines.");
+ args_desc);
trace::entering("main");
diff --git a/scribo/src/primitive/find/find_pattern_lines.cc b/scribo/src/primitive/find/find_pattern_lines.cc
index 3d8a98f..540328b 100644
--- a/scribo/src/primitive/find/find_pattern_lines.cc
+++ b/scribo/src/primitive/find/find_pattern_lines.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -52,10 +53,10 @@ int main(int argc, char *argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Extract discontinued horizontal and vertical lines",
+ "Extract discontinued horizontal and "
+ "vertical lines",
"input.pbm length output.ppm",
- args_desc,
- "A color image. Horizontal lines are in red and vertical lines in green.");
+ args_desc);
trace::entering("main");
diff --git a/scribo/src/table/extract.cc b/scribo/src/table/extract.cc
index c510753..c3a7271 100644
--- a/scribo/src/table/extract.cc
+++ b/scribo/src/table/extract.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -55,9 +56,7 @@ int main(int argc, char* argv[])
return scribo::debug::usage(argv,
"Extract tables from a binary image.",
"input.pbm output.dump output.ppm",
- args_desc,
- "A color images. 'White' color means \
-the background, other colors indicates cells.");
+ args_desc);
trace::entering("main");
--
1.5.6.5
1
0

last-svn-commit-433-g0877158 Replace the use of object_image with component_set.
by Guillaume Lazzara 09 Aug '10
by Guillaume Lazzara 09 Aug '10
09 Aug '10
* core/erase_objects.hh,
* debug/several_links_decision_image.hh,
* filter/object_groups_size_ratio.hh,
* filter/object_links_bbox_w_ratio.hh,
* filter/object_links_center_aligned.hh,
* filter/object_links_left_aligned.hh,
* filter/object_links_right_aligned.hh,
* filter/objects_h_thick.hh,
* filter/objects_h_thin.hh,
* filter/objects_size_ratio.hh,
* filter/objects_v_thick.hh,
* filter/objects_v_thin.hh,
* primitive/extract/lines_h_thick_and_single.hh,
* primitive/extract/lines_v_thick_and_single.hh,
* primitive/group/from_graph.hh,
* primitive/internal/find_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_closest_links.hh,
* primitive/link/with_several_right_links.hh,
* primitive/link/with_single_down_link.hh,
* primitive/link/with_single_up_link.hh: Replace the use of
object_image with component_set.
---
scribo/ChangeLog | 30 ++++++
scribo/core/erase_objects.hh | 18 ++--
scribo/debug/several_links_decision_image.hh | 47 ++++-----
scribo/filter/object_groups_size_ratio.hh | 11 +-
scribo/filter/object_links_bbox_w_ratio.hh | 19 ++--
scribo/filter/object_links_center_aligned.hh | 10 +--
scribo/filter/object_links_left_aligned.hh | 13 +--
scribo/filter/object_links_right_aligned.hh | 16 ++--
scribo/filter/objects_h_thick.hh | 82 +++++++--------
scribo/filter/objects_h_thin.hh | 106 ++++++++++----------
scribo/filter/objects_size_ratio.hh | 65 +++++++------
scribo/filter/objects_v_thick.hh | 86 ++++++++--------
scribo/filter/objects_v_thin.hh | 105 ++++++++++----------
.../primitive/extract/lines_h_thick_and_single.hh | 16 ++--
.../primitive/extract/lines_v_thick_and_single.hh | 15 ++--
scribo/primitive/group/from_graph.hh | 17 ++--
scribo/primitive/internal/find_graph_link.hh | 33 ++++---
scribo/primitive/link/with_graph.hh | 32 +++---
scribo/primitive/link/with_rag.hh | 24 +++--
scribo/primitive/link/with_several_graphes.hh | 35 ++++---
scribo/primitive/link/with_several_left_links.hh | 83 ++++++----------
.../link/with_several_right_closest_links.hh | 70 ++++++-------
scribo/primitive/link/with_several_right_links.hh | 95 +++++++-----------
scribo/primitive/link/with_single_down_link.hh | 30 +++---
scribo/primitive/link/with_single_up_link.hh | 33 +++---
25 files changed, 532 insertions(+), 559 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 2d5510a..a8bffd2 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,35 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Replace the use of object_image with component_set.
+
+ * core/erase_objects.hh,
+ * debug/several_links_decision_image.hh,
+ * filter/object_groups_size_ratio.hh,
+ * filter/object_links_bbox_w_ratio.hh,
+ * filter/object_links_center_aligned.hh,
+ * filter/object_links_left_aligned.hh,
+ * filter/object_links_right_aligned.hh,
+ * filter/objects_h_thick.hh,
+ * filter/objects_h_thin.hh,
+ * filter/objects_size_ratio.hh,
+ * filter/objects_v_thick.hh,
+ * filter/objects_v_thin.hh,
+ * primitive/extract/lines_h_thick_and_single.hh,
+ * primitive/extract/lines_v_thick_and_single.hh,
+ * primitive/group/from_graph.hh,
+ * primitive/internal/find_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_closest_links.hh,
+ * primitive/link/with_several_right_links.hh,
+ * primitive/link/with_single_down_link.hh,
+ * primitive/link/with_single_up_link.hh: Replace the use of
+ object_image with component_set.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Small fixes in Scribo.
* core/component_info.hh (is_valid): Check the bounding box
diff --git a/scribo/core/erase_objects.hh b/scribo/core/erase_objects.hh
index 3e401f0..931024e 100644
--- a/scribo/core/erase_objects.hh
+++ b/scribo/core/erase_objects.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,7 +29,7 @@
/// \file
///
-/// Remove the content of bounding boxes from an image.
+/// Erase components in an image.
# include <mln/core/concept/image.hh>
# include <mln/core/site_set/box.hh>
@@ -36,6 +37,7 @@
# include <mln/pw/all.hh>
# include <mln/util/array.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/core/macros.hh>
namespace scribo
@@ -46,13 +48,12 @@ namespace scribo
/// Remove labeled components from a binary image.
///
/// \param[in,out] input_ A binary image.
- /// \param[in] objects An image of objects (object value must be
- /// different from 0).
+ /// \param[in] comps A set of components to be erased.
///
//
template <typename I, typename L>
void
- erase_objects(Image<I>& input, const Image<L>& objects);
+ erase_objects(Image<I>& input, const component_set<L>& comps);
# ifndef MLN_INCLUDE_ONLY
@@ -61,18 +62,17 @@ namespace scribo
template <typename I, typename L>
void
erase_objects(Image<I>& input_,
- const Image<L>& objects_)
+ const component_set<L>& comps)
{
trace::entering("scribo::erase_objects");
mlc_equal(mln_value(I),bool)::check();
I& input = exact(input_);
- I& objects = exact(objects_);
mln_precondition(input.is_valid());
- mln_precondition(objects.is_valid());
- data::fill((input | (pw::value(objects) != pw::cst(literal::zero))).rw(),
+ data::fill((input | (pw::value(comps.labeled_image())
+ != pw::cst(literal::zero))).rw(),
false);
trace::exiting("scribo::erase_objects");
diff --git a/scribo/debug/several_links_decision_image.hh b/scribo/debug/several_links_decision_image.hh
index 3446287..73e66a1 100644
--- a/scribo/debug/several_links_decision_image.hh
+++ b/scribo/debug/several_links_decision_image.hh
@@ -94,10 +94,9 @@ namespace scribo
trace::entering("scribo::debug::several_links_decision_image");
const I& input = exact(input_);
- const object_image(L)& objects = links.object_image_();
+ const component_set<L>& comps = links.components();
mln_precondition(input.is_valid());
- mln_precondition(objects.is_valid());
mln_precondition(links.is_valid());
mln_precondition(filtered_links.is_valid());
@@ -106,60 +105,56 @@ namespace scribo
image2d<value::rgb8>
links_decision_image = data::convert(value::rgb8(), input);
- for_all_components(i, objects.bboxes())
- mln::draw::box(links_decision_image, objects.bbox(i), literal::blue);
+ for_all_comps(c, comps)
+ mln::draw::box(links_decision_image, comps(c).bbox(), literal::blue);
- // Computing mass centers.
- mln::util::array<mln_result(accu::center<mln_psite(I)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for (unsigned i = 1; i < links.size(); ++i)
+ for_all_links(l, links)
{
-
- if (links[i] != i)
+ if (links(l) != l)
{
value::rgb8 value = literal::green;
- if (links[i] != filtered_links[i])
+ if (links(l) != filtered_links(l))
value = literal::red;
- mln_site(L) c = objects.bbox(i).center();
+ mln_site(L) c = comps(l).bbox().pcenter();
// Right link from the top anchor.
mln_site(L) a1 = c;
- a1.row() = objects.bbox(i).pmin().row()
- + (c.row() - objects.bbox(i).pmin().row()) / 4;
+ a1.row() = comps(l).bbox().pmin().row()
+ + (c.row() - comps(l).bbox().pmin().row()) / 4;
// Right link from the central site
- mln_site(I) p1 = mass_centers[i];
+ mln_site(I) p1 = comps(l).mass_center();
// Right link from the bottom anchor.
mln_site(L) a2 = c;
- a2.row() = objects.bbox(i).pmax().row()
- - (c.row() - objects.bbox(i).pmin().row()) / 4;
+ a2.row() = comps(l).bbox().pmax().row()
+ - (c.row() - comps(l).bbox().pmin().row()) / 4;
mln_site(L)
a1_bak = a1,
a2_bak = a2;
+ const L& lbl_ima = comps.labeled_image();
+
mln_site(L) tmp;
- while(objects.domain().has(a1)
- || objects.domain().has(a2)
- || objects.domain().has(p1))
+ while(lbl_ima.domain().has(a1)
+ || lbl_ima.domain().has(a2)
+ || lbl_ima.domain().has(p1))
{
- if (internal::draw_line(objects, links_decision_image, links[i],
+ if (internal::draw_line(lbl_ima, links_decision_image, links(l),
a1_bak, a1, value))
break;
else
++a1.col();
- if (internal::draw_line(objects, links_decision_image, links[i],
- mass_centers[i], p1, value))
+ if (internal::draw_line(lbl_ima, links_decision_image, links(l),
+ comps(l).mass_center(), p1, value))
break;
else
++p1.col();
- if (internal::draw_line(objects, links_decision_image, links[i],
+ if (internal::draw_line(lbl_ima, links_decision_image, links(l),
a2_bak, a2, value))
break;
else
diff --git a/scribo/filter/object_groups_size_ratio.hh b/scribo/filter/object_groups_size_ratio.hh
index 1c05560..94d9b1b 100644
--- a/scribo/filter/object_groups_size_ratio.hh
+++ b/scribo/filter/object_groups_size_ratio.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -63,7 +64,7 @@ namespace scribo
mln_precondition(groups.is_valid());
- const object_image(L)& objects = groups.object_image_();
+ const component_set<L>& comps = groups.components();
// FIXME: estimating the group size should be removed once
// available in the object_group structure.
@@ -73,9 +74,9 @@ namespace scribo
group_size(groups.size(), 0),
invalid_object_in_group(groups.size(), 0);
- for_all_ncomponents(i, objects.nlabels())
+ for_all_comps(i, comps)
{
- if ((objects.bbox(i).nrows() / objects.bbox(i).ncols())
+ if ((comps(i).bbox().nrows() / comps(i).bbox().ncols())
>= max_size_ratio)
++invalid_object_in_group[groups[i]];
@@ -86,7 +87,7 @@ namespace scribo
output(0) = 0;
for (unsigned i = 1; i < output.size(); ++i)
if ((invalid_object_in_group[groups[i]] / static_cast<float>(group_size[groups[i]])) >= max_invalid_ratio_per_group
- || !components(i).is_valid())
+ || !comps(i).is_valid())
output(i) = 0;
trace::exiting("scribo::filter::object_groups_size_ratio");
diff --git a/scribo/filter/object_links_bbox_w_ratio.hh b/scribo/filter/object_links_bbox_w_ratio.hh
index 7cc99c3..0bb373f 100644
--- a/scribo/filter/object_links_bbox_w_ratio.hh
+++ b/scribo/filter/object_links_bbox_w_ratio.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,8 +29,10 @@
/// \file
///
-/// Invalidate links between two objects with too different height or
-/// width.
+/// Invalidate links between two objects with too different width.
+///
+/// \todo rename to object_links_bbox_h_ratio (h for horizontal) to be
+/// consistent with other routine names.
# include <mln/util/array.hh>
@@ -50,7 +53,6 @@ namespace scribo
/*! \brief Invalidate links between two objects with too different
width.
- \param[in] objects An object image.
\param[in] links Link objects information.
\param[in] min_w_ratio The minimum width ratio of two linked
bounding boxes.
@@ -59,8 +61,7 @@ namespace scribo
*/
template <typename L>
object_links<L>
- object_links_bbox_w_ratio(const object_image(L)& objects,
- const object_links<L>& links,
+ object_links_bbox_w_ratio(const object_links<L>& links,
float min_w_ratio);
@@ -69,17 +70,15 @@ namespace scribo
template <typename L>
object_links<L>
- object_links_bbox_w_ratio(const object_image(L)& objects,
- const object_links<L>& links,
+ object_links_bbox_w_ratio(const object_links<L>& links,
float min_w_ratio)
{
trace::entering("scribo::filter::object_links_bbox_w_ratio");
- mln_precondition(objects.is_valid());
mln_precondition(links.is_valid());
object_links<L>
- output = object_links_bbox_ratio(objects, links, 1, min_w_ratio);
+ output = object_links_bbox_ratio(links, 1, min_w_ratio);
trace::exiting("scribo::filter::object_links_bbox_w_ratio");
return output;
diff --git a/scribo/filter/object_links_center_aligned.hh b/scribo/filter/object_links_center_aligned.hh
index 8d89e73..da18b00 100644
--- a/scribo/filter/object_links_center_aligned.hh
+++ b/scribo/filter/object_links_center_aligned.hh
@@ -36,7 +36,6 @@
# include <scribo/core/macros.hh>
# include <scribo/core/object_links.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/filter/object_links_non_aligned_simple.hh>
@@ -74,8 +73,7 @@ namespace scribo
*/
template <typename L>
object_links<L>
- object_links_center_aligned(const object_image(L)& objects,
- const object_links<L>& links,
+ object_links_center_aligned(const object_links<L>& links,
float max_alpha);
@@ -84,17 +82,15 @@ namespace scribo
template <typename L>
object_links<L>
- object_links_center_aligned(const object_image(L)& objects,
- const object_links<L>& links,
+ object_links_center_aligned(const object_links<L>& links,
float max_alpha)
{
trace::entering("scribo::filter::object_links_center_aligned");
- mln_precondition(objects.is_valid());
mln_precondition(links.is_valid());
object_links<L>
- output = object_links_non_aligned_simple(objects, links,
+ output = object_links_non_aligned_simple(links,
anchor::Center, max_alpha);
trace::exiting("scribo::filter::object_links_center_aligned");
diff --git a/scribo/filter/object_links_left_aligned.hh b/scribo/filter/object_links_left_aligned.hh
index a352d71..059b423 100644
--- a/scribo/filter/object_links_left_aligned.hh
+++ b/scribo/filter/object_links_left_aligned.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -52,7 +53,6 @@ namespace scribo
/*! \brief Invalidate links between two objects if their left are not
aligned.
- \param[in] objects An object image.
\param[in] links Object links information.
\param[in] max_alpha Maximum angle value (degrees).
@@ -82,8 +82,7 @@ namespace scribo
*/
template <typename L>
object_links<L>
- object_links_left_aligned(const object_image(L)& objects,
- const object_links<L>& links,
+ object_links_left_aligned(const object_links<L>& links,
float max_alpha);
@@ -92,17 +91,15 @@ namespace scribo
template <typename L>
object_links<L>
- object_links_left_aligned(const object_image(L)& objects,
- const object_links<L>& links,
+ object_links_left_aligned(const object_links<L>& links,
float max_alpha)
{
trace::entering("scribo::filter::object_links_left_aligned");
- mln_precondition(objects.is_valid());
mln_precondition(links.is_valid());
object_links<L>
- output = object_links_non_aligned_simple(objects, links,
+ output = object_links_non_aligned_simple(links,
anchor::Left,
max_alpha);
diff --git a/scribo/filter/object_links_right_aligned.hh b/scribo/filter/object_links_right_aligned.hh
index ee964a3..dfb06c7 100644
--- a/scribo/filter/object_links_right_aligned.hh
+++ b/scribo/filter/object_links_right_aligned.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -81,9 +82,8 @@ namespace scribo
*/
template <typename L>
object_links<L>
- object_links_right_aligned(const object_image(L)& objects,
- const object_links<L>& links,
- float max_alpha);
+ object_links_right_aligned(const object_links<L>& links,
+ float max_alpha);
# ifndef MLN_INCLUDE_ONLY
@@ -91,17 +91,15 @@ namespace scribo
template <typename L>
object_links<L>
- object_links_right_aligned(const object_image(L)& objects,
- const object_links<L>& links,
- float max_alpha)
+ object_links_right_aligned(const object_links<L>& links,
+ float max_alpha)
{
trace::entering("scribo::filter::object_links_right_aligned");
- mln_precondition(objects.is_valid());
mln_precondition(links.is_valid());
object_links<L>
- output = object_links_non_aligned_simple(objects, links,
+ output = object_links_non_aligned_simple(links,
anchor::Right,
max_alpha);
diff --git a/scribo/filter/objects_h_thick.hh b/scribo/filter/objects_h_thick.hh
index 9709346..9422798 100644
--- a/scribo/filter/objects_h_thick.hh
+++ b/scribo/filter/objects_h_thick.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -33,10 +34,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_image.hh>
-# include <scribo/primitive/extract/objects.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/filter/internal/compute.hh>
@@ -48,12 +46,12 @@ namespace scribo
using namespace mln;
- /// Remove objects horizontaly thicker or equal to \p max_thickness.
+ /// Remove objects horizontaly thicker or equal to \p min_thickness.
///
/// \param[in] input_ A binary image.
/// \param[in] nbh_ A neighborhood used in labeling algorithms.
/// \param[in] label_type The label type used for labeling.
- /// \param[in] max_thickness The maximum thickness value.
+ /// \param[in] min_thickness The maximum thickness value.
///
/// \result A binary image without thick objects.
//
@@ -63,21 +61,21 @@ namespace scribo
objects_h_thick(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned max_thickness);
+ unsigned min_thickness);
- /// Remove objects horizontaly thicker or equal to \p max_thickness.
+ /// Remove objects horizontaly thicker or equal to \p min_thickness.
///
- /// \param[in] objects An object image.
- /// \param[in] max_thickness The maximum thickness value.
+ /// \param[in] comps Component data.
+ /// \param[in] min_thickness The minimum thickness value.
///
- /// \result An object image without too thick objects.
+ /// \result A component data set without too thick components.
//
template <typename L>
inline
- object_image(L)
- objects_h_thick(const object_image(L)& objects,
- unsigned max_thickness);
+ component_set<L>
+ objects_h_thick(const component_set<L>& comps,
+ unsigned min_thickness);
@@ -87,8 +85,8 @@ namespace scribo
namespace internal
{
- /// Filter Functor. Return false for all objects which are too
- /// large.
+ /// Filter Functor. Return false for all components which are
+ /// thick.
template <typename L>
struct h_thick_object_filter
: Function_v2b< h_thick_object_filter<L> >
@@ -96,48 +94,48 @@ namespace scribo
/// Constructor
///
- /// \param[in] objects An object image.
- /// \param[in] max_thickness the maximum thickness allowed.
+ /// \param[in] comps Component data.
+ /// \param[in] min_thickness the minimum thickness allowed.
//
- h_thick_object_filter(const object_image(L)& objects,
- unsigned max_thickness)
- : objects_(objects), max_thickness_(max_thickness)
+ h_thick_object_filter(const component_set<L>& comps,
+ unsigned min_thickness)
+ : comps_(comps), min_thickness_(min_thickness)
{
}
/// Constructor
///
- /// \param[in] max_thickness the maximum thickness allowed.
+ /// \param[in] min_thickness the minimum thickness allowed.
//
- h_thick_object_filter(unsigned max_thickness)
- : max_thickness_(max_thickness)
+ h_thick_object_filter(unsigned min_thickness)
+ : min_thickness_(min_thickness)
{
}
/// Set the underlying object image.
//
- void update_objects(const object_image(L)& objects)
+ void update_objects(const component_set<L>& comps)
{
- objects_ = objects;
+ comps_ = comps;
}
- /// Return false if the objects is thicker than
- /// \p max_thickness_.
+ /// Return false if the component is thicker than
+ /// \p min_thickness_.
///
/// \param[in] l An image value.
bool operator()(const mln_value(L)& l) const
{
if (l == literal::zero)
return true;
- return objects_.bbox(l).nrows() < max_thickness_;
+ return comps_(l).bbox().height() > min_thickness_;
}
- /// An object image.
- object_image(L) objects_;
+ /// Components data.
+ component_set<L> comps_;
- /// The maximum thickness.
- unsigned max_thickness_;
+ /// The minimum thickness.
+ unsigned min_thickness_;
};
@@ -150,7 +148,7 @@ namespace scribo
objects_thick(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned max_thickness)
+ unsigned min_thickness)
{
trace::entering("scribo::filter::objects_h_thick");
@@ -160,7 +158,7 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
- internal::h_thick_object_filter<V> functor(max_thickness);
+ internal::h_thick_object_filter<V> functor(min_thickness);
mln_concrete(I)
output = internal::compute(input, nbh, label_type, functor);
@@ -171,16 +169,14 @@ namespace scribo
template <typename L>
inline
- object_image(L)
- objects_h_thick(const object_image(L)& objects,
- unsigned max_thickness)
+ component_set<L>
+ objects_h_thick(const component_set<L>& comps,
+ unsigned min_thickness)
{
trace::entering("scribo::filter::objects_h_thick");
- mln_precondition(objects.is_valid());
-
- internal::h_thick_object_filter<L> functor(objects, max_thickness);
- object_image(L) output = internal::compute(objects, functor);
+ internal::h_thick_object_filter<L> functor(comps, min_thickness);
+ component_set<L> output = internal::compute(comps, functor);
trace::exiting("scribo::filter::objects_h_thick");
return output;
diff --git a/scribo/filter/objects_h_thin.hh b/scribo/filter/objects_h_thin.hh
index 2b098ac..56c6ab7 100644
--- a/scribo/filter/objects_h_thin.hh
+++ b/scribo/filter/objects_h_thin.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,15 +29,13 @@
/// \file
///
-/// Remove too thin objects.
+/// Remove too thin components.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_image.hh>
-# include <scribo/primitive/extract/objects.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/filter/internal/compute.hh>
namespace scribo
{
@@ -46,14 +45,14 @@ namespace scribo
using namespace mln;
- /// Remove objects thinner or equal to \p min_thickness.
+ /// Remove components thinner or equal to \p min_thinness.
///
/// \param[in] input_ a binary image.
/// \param[in] nbh_ a neighborhood used in labeling algorithms.
/// \param[in] label_type the label type used for labeling.
- /// \param[in] min_thickness the minimum thickness value.
+ /// \param[in] min_thinness the minimum thinness value.
///
- /// \result A binary image without h_thin objects.
+ /// \result A binary image without h_thin components.
//
template <typename I, typename N, typename V>
inline
@@ -61,20 +60,20 @@ namespace scribo
objects_h_thin(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned min_thickness);
+ unsigned min_thinness);
- /// Remove lines of text thinner or equal to \p min_thickness.
+ /// Remove lines of text thinner or equal to \p min_thinness.
///
- /// \param[in] objects An object image.
- /// \param[in] min_thickness the minimum thickness value.
+ /// \param[in] comps A component set.
+ /// \param[in] min_thinness the minimum thinness value.
///
- /// \result An object image without too thin vertical objects.
+ /// \result An object image without too thin vertical components.
//
template <typename L>
inline
- object_image(L)
- objects_h_thin(const object_image(L)& text,
- unsigned min_thickness);
+ component_set<L>
+ objects_h_thin(const component_set<L>& comps,
+ unsigned min_thinness);
# ifndef MLN_INCLUDE_ONLY
@@ -84,7 +83,7 @@ namespace scribo
/// Filter Functor.
- /// Return false for all objects which are too large.
+ /// Return false for all components which are too large.
template <typename L>
struct objects_h_thin_filter
: Function_v2b< objects_h_thin_filter<L> >
@@ -93,19 +92,36 @@ namespace scribo
/// Constructor
///
- /// \param[in] objects object bounding boxes.
- /// \param[in] min_thickness the minimum of vertical thickness
+ /// \param[in] comps A component set.
+ /// \param[in] min_thinness the minimum of vertical thinness
/// allowed.
//
- objects_h_thin_filter(const object_image(L)& objects,
- unsigned min_thickness)
- : objects_(objects), min_thickness_(min_thickness)
+ objects_h_thin_filter(const component_set<L>& comps,
+ unsigned min_thinness)
+ : comps_(comps), min_thinness_(min_thinness)
+ {
+ }
+
+
+ /// Constructor
+ ///
+ /// \param[in] min_thinness the maximum thinness allowed.
+ //
+ objects_h_thin_filter(unsigned min_thinness)
+ : min_thinness_(min_thinness)
{
}
+ /// Set the underlying component set.
+ //
+ void update_objects(const component_set<L>& comps)
+ {
+ comps_ = comps;
+ }
- /// Return false if the objects is thinner than
- /// \p min_thickness_.
+
+ /// Return false if the components is thinner than
+ /// \p min_thinness_.
///
/// \param[in] l An image value.
//
@@ -113,14 +129,14 @@ namespace scribo
{
if (l == literal::zero)
return true;
- return objects_.bbox(l).ncols() > min_thickness_;
+ return comps_(l).bbox().ncols() > min_thinness_;
}
/// Component bounding boxes.
- object_image(L) objects_;
+ component_set<L> comps_;
- /// The minimum vertical thickness.
- unsigned min_thickness_;
+ /// The minimum vertical thinness.
+ unsigned min_thinness_;
};
@@ -133,7 +149,7 @@ namespace scribo
objects_h_thin(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned min_thickness)
+ unsigned min_thinness)
{
trace::entering("scribo::filter::objects_h_thin");
@@ -143,18 +159,10 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
- V nlabels;
- typedef mln_ch_value(I,V) lbl_t;
- object_image(lbl_t) objects
- = primitive::extract::objects(input, nbh, nlabels);
-
- typedef internal::objects_h_thin_filter<lbl_t> func_t;
- func_t fv2b(objects, min_thickness);
- objects.relabel(fv2b);
+ internal::objects_h_thin_filter<V> functor(min_thinness);
+ mln_concrete(I)
+ output = internal::compute(input, nbh, label_type, functor);
- mln_concrete(I) output = duplicate(input);
- data::fill((output | pw::value(objects) == pw::cst(literal::zero)).rw(),
- false);
trace::exiting("scribo::filter::objects_h_thin");
return output;
@@ -163,20 +171,16 @@ namespace scribo
template <typename L>
inline
- object_image(L)
- objects_h_thin(const object_image(L)& objects,
- unsigned min_thickness)
+ component_set<L>
+ objects_h_thin(const component_set<L>& comps,
+ unsigned min_thinness)
{
trace::entering("scribo::filter::objects_h_thin");
- mln_precondition(objects.is_valid());
-
- typedef internal::objects_h_thin_filter<L> func_t;
- func_t is_not_too_h_thin(objects, min_thickness);
+ internal::objects_h_thin_filter<L>
+ is_not_too_h_thin(comps, min_thinness);
- object_image(L) output;
- output.init_from_(objects);
- output.relabel(is_not_too_h_thin);
+ component_set<L> output = internal::compute(comps, is_not_too_h_thin);
trace::exiting("scribo::filter::objects_h_thin");
return output;
diff --git a/scribo/filter/objects_size_ratio.hh b/scribo/filter/objects_size_ratio.hh
index cd12b2e..55de80d 100644
--- a/scribo/filter/objects_size_ratio.hh
+++ b/scribo/filter/objects_size_ratio.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,11 +29,11 @@
/// \file
///
-///
+/// \brief Invalidate components with a width/height ratio too low.
# include <mln/core/concept/function.hh>
-# include <scribo/core/object_image.hh>
+# include <scribo/core/component_set.hh>
namespace scribo
@@ -42,10 +43,18 @@ namespace scribo
{
using namespace mln;
+ /// \brief Invalidate components with a height/width ratio too low.
+ ///
+ /// Compute the ratio height/width from the component bounding
+ /// boxes and compare it to \p size_ratio.
+ ///
+ /// If the height/width ratio is lower than min_size_ratio then
+ /// the component is invalidated.
+ //
template <typename L>
- object_image(L)
- objects_size_ratio(const object_image(L)& objects,
- float size_ratio);
+ component_set<L>
+ objects_size_ratio(const component_set<L>& comps,
+ float min_size_ratio);
# ifndef MLN_INCLUDE_ONLY
@@ -56,16 +65,15 @@ namespace scribo
/// Filter Functor.
- /// Return false for all objects which have a bad ratio.
+ /// Return false for all components having a too low size ratio.
+ //
template <typename L>
- struct objects_size_ratio_filter
- : Function_v2b< objects_size_ratio_filter<L> >
+ struct components_size_ratio_filter
+ : Function_v2b< components_size_ratio_filter<L> >
{
- typedef accu::shape::bbox<mln_psite(L)> box_accu_t;
-
- objects_size_ratio_filter(const object_image(L)& objects,
- float ratio)
- : objects_(objects), ratio_(ratio)
+ components_size_ratio_filter(const component_set<L>& comps,
+ float min_size_ratio)
+ : comps_(comps), min_size_ratio_(min_size_ratio)
{
}
@@ -73,14 +81,14 @@ namespace scribo
{
if (l == literal::zero)
return true;
- return (objects_.bbox(l).nrows() / static_cast<float>(objects_.bbox(l).ncols())) < ratio_;
+ return (comps_(l).bbox().height() / static_cast<float>(comps_(l).bbox().width())) >= min_size_ratio_;
}
- /// Component bounding boxes.
- object_image(L) objects_;
+ /// Components data.
+ component_set<L> comps_;
- /// The maximum size ratio.
- float ratio_;
+ /// The minimum size ratio.
+ float min_size_ratio_;
};
@@ -89,21 +97,18 @@ namespace scribo
template <typename L>
- object_image(L)
- objects_size_ratio(const object_image(L)& objects,
- float size_ratio)
+ component_set<L>
+ objects_size_ratio(const component_set<L>& comps,
+ float min_size_ratio)
{
trace::entering("scribo::primitive::objects_size_ratio");
- mln_precondition(objects.is_valid());
-
- typedef internal::objects_size_ratio_filter<L> func_t;
- func_t has_bad_ratio(objects, size_ratio);
+ typedef internal::components_size_ratio_filter<L> func_t;
+ func_t has_valid_size_ratio(comps, min_size_ratio);
- object_image(L) output;
- output.init_from_(objects);
- output.relabel(has_bad_ratio);
+ component_set<L> output = comps.duplicate();
+ output.update_tags(has_valid_size_ratio, component::Ignored);
trace::exiting("scribo::primitive::objects_size_ratio");
return output;
@@ -117,4 +122,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_FILTER_OBJECTs_SIZE_RATIO_HH
+#endif // ! SCRIBO_FILTER_OBJECTS_SIZE_RATIO_HH
diff --git a/scribo/filter/objects_v_thick.hh b/scribo/filter/objects_v_thick.hh
index 730e144..7b25d87 100644
--- a/scribo/filter/objects_v_thick.hh
+++ b/scribo/filter/objects_v_thick.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,15 +29,12 @@
/// \file
///
-/// Remove too verticaly thick objects.
+/// Remove too verticaly thick components.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_image.hh>
-# include <scribo/primitive/extract/objects.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/filter/internal/compute.hh>
@@ -48,14 +46,14 @@ namespace scribo
using namespace mln;
- /// Remove objects verticaly thicker or equal to \p max_thickness.
+ /// Remove components verticaly thicker or equal to \p min_thickness.
///
/// \param[in] input_ A binary image.
/// \param[in] nbh_ A neighborhood used in labeling algorithms.
/// \param[in] label_type The label type used for labeling.
- /// \param[in] max_thickness The maximum thickness value.
+ /// \param[in] min_thickness The maximum thickness value.
///
- /// \result A binary image without thick objects.
+ /// \result A binary image without thick components.
//
template <typename I, typename N, typename V>
inline
@@ -63,21 +61,21 @@ namespace scribo
objects_v_thick(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned max_thickness);
+ unsigned min_thickness);
- /// Remove objects verticaly thicker or equal to \p max_thickness.
+ /// Remove components verticaly thicker or equal to \p min_thickness.
///
- /// \param[in] objects An object image.
- /// \param[in] max_thickness The maximum thickness value.
+ /// \param[in] comps A component set.
+ /// \param[in] min_thickness The maximum thickness value.
///
- /// \result An object image without too thick objects.
+ /// \result An object image without too thick components.
//
template <typename L>
inline
- object_image(L)
- objects_v_thick(const object_image(L)& objects,
- unsigned max_thickness);
+ component_set<L>
+ objects_v_thick(const component_set<L>& comps,
+ unsigned min_thickness);
@@ -87,7 +85,7 @@ namespace scribo
namespace internal
{
- /// Filter Functor. Return false for all objects which are too
+ /// Filter Functor. Return false for all components which are too
/// large.
template <typename L>
struct v_thick_object_filter
@@ -96,48 +94,48 @@ namespace scribo
/// Constructor
///
- /// \param[in] objects An object image.
- /// \param[in] max_thickness the maximum thickness allowed.
+ /// \param[in] comps A component set.
+ /// \param[in] min_thickness the maximum thickness allowed.
//
- v_thick_object_filter(const object_image(L)& objects,
- unsigned max_thickness)
- : objects_(objects), max_thickness_(max_thickness)
+ v_thick_object_filter(const component_set<L>& comps,
+ unsigned min_thickness)
+ : comps_(comps), min_thickness_(min_thickness)
{
}
/// Constructor
///
- /// \param[in] max_thickness the maximum thickness allowed.
+ /// \param[in] min_thickness the maximum thickness allowed.
//
- v_thick_object_filter(unsigned max_thickness)
- : max_thickness_(max_thickness)
+ v_thick_object_filter(unsigned min_thickness)
+ : min_thickness_(min_thickness)
{
}
- /// Set the underlying object image.
+ /// Set the underlying component set.
//
- void update_objects(const object_image(L)& objects)
+ void update_objects(const component_set<L>& comps)
{
- objects_ = objects;
+ comps_ = comps;
}
- /// Return false if the objects is thicker than
- /// \p max_thickness_.
+ /// Return false if the components is thicker than
+ /// \p min_thickness_.
///
/// \param[in] l An image value.
bool operator()(const mln_value(L)& l) const
{
if (l == literal::zero)
return true;
- return objects_.bbox(l).nrows() < max_thickness_;
+ return comps_(l).bbox().nrows() > min_thickness_;
}
- /// An object image.
- object_image(L) objects_;
+ /// A component set.
+ component_set<L> comps_;
- /// The maximum thickness.
- unsigned max_thickness_;
+ /// The min thickness.
+ unsigned min_thickness_;
};
@@ -150,7 +148,7 @@ namespace scribo
objects_thick(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned max_thickness)
+ unsigned min_thickness)
{
trace::entering("scribo::filter::objects_v_thick");
@@ -160,7 +158,7 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
- internal::v_thick_object_filter<V> functor(max_thickness);
+ internal::v_thick_object_filter<V> functor(min_thickness);
mln_concrete(I)
output = internal::compute(input, nbh, label_type, functor);
@@ -171,16 +169,14 @@ namespace scribo
template <typename L>
inline
- object_image(L)
- objects_v_thick(const object_image(L)& objects,
- unsigned max_thickness)
+ component_set<L>
+ objects_v_thick(const component_set<L>& comps,
+ unsigned min_thickness)
{
trace::entering("scribo::filter::objects_v_thick");
- mln_precondition(objects.is_valid());
-
- internal::v_thick_object_filter<L> functor(objects, max_thickness);
- object_image(L) output = internal::compute(objects, functor);
+ internal::v_thick_object_filter<L> functor(comps, min_thickness);
+ component_set<L> output = internal::compute(comps, functor);
trace::exiting("scribo::filter::objects_v_thick");
return output;
diff --git a/scribo/filter/objects_v_thin.hh b/scribo/filter/objects_v_thin.hh
index 6564d30..52e10af 100644
--- a/scribo/filter/objects_v_thin.hh
+++ b/scribo/filter/objects_v_thin.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,15 +29,14 @@
/// \file
///
-/// Remove too thin objects.
+/// Remove too thin components.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/util/array.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/filter/internal/compute.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/primitive/extract/objects.hh>
namespace scribo
{
@@ -46,14 +46,14 @@ namespace scribo
using namespace mln;
- /// Remove objects thinner or equal to \p min_thickness.
+ /// Remove components thinner or equal to \p min_thinness.
///
/// \param[in] input_ a binary image.
/// \param[in] nbh_ a neighborhood used in labeling algorithms.
/// \param[in] label_type the label type used for labeling.
- /// \param[in] min_thickness the minimum thickness value.
+ /// \param[in] min_thinness the minimum thinness value.
///
- /// \result A binary image without v_thin objects.
+ /// \result A binary image without v_thin components.
//
template <typename I, typename N, typename V>
inline
@@ -61,20 +61,20 @@ namespace scribo
objects_v_thin(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned min_thickness);
+ unsigned min_thinness);
- /// Remove lines of text thinner or equal to \p min_thickness.
+ /// Remove lines of text thinner or equal to \p min_thinness.
///
- /// \param[in] objects An object image.
- /// \param[in] min_thickness the minimum thickness value.
+ /// \param[in] comps A component set.
+ /// \param[in] min_thinness the minimum thinness value.
///
- /// \result An object image without too thin vertical objects.
+ /// \result An object image without too thin vertical components.
//
template <typename L>
inline
- object_image(L)
- objects_v_thin(const object_image(L)& text,
- unsigned min_thickness);
+ component_set<L>
+ components_v_thin(const component_set<L>& text,
+ unsigned min_thinness);
# ifndef MLN_INCLUDE_ONLY
@@ -93,19 +93,36 @@ namespace scribo
/// Constructor
///
- /// \param[in] objects object bounding boxes.
- /// \param[in] min_thickness the minimum of vertical thickness
+ /// \param[in] comps A component set.
+ /// \param[in] min_thinness the minimum of vertical thinness
/// allowed.
//
- objects_v_thin_filter(const object_image(L)& objects,
- unsigned min_thickness)
- : objects_(objects), min_thickness_(min_thickness)
+ objects_v_thin_filter(const component_set<L>& comps,
+ unsigned min_thinness)
+ : comps_(comps), min_thinness_(min_thinness)
{
}
- /// Return false if the objects is thinner than
- /// \p min_thickness_.
+ /// Constructor
+ ///
+ /// \param[in] min_thinness the maximum thinness allowed.
+ //
+ objects_v_thin_filter(unsigned min_thinness)
+ : min_thinness_(min_thinness)
+ {
+ }
+
+ /// Set the underlying component set.
+ //
+ void update_objects(const component_set<L>& comps)
+ {
+ comps_ = comps;
+ }
+
+
+ /// Return false if the components is thinner than
+ /// \p min_thinness_.
///
/// \param[in] l An image value.
//
@@ -113,14 +130,14 @@ namespace scribo
{
if (l == literal::zero)
return true;
- return objects_.bbox(l).nrows() > min_thickness_;
+ return comps_.bbox(l).nrows() > min_thinness_;
}
/// Component bounding boxes.
- object_image(L) objects_;
+ component_set<L> comps_;
- /// The minimum vertical thickness.
- unsigned min_thickness_;
+ /// The minimum vertical thinness.
+ unsigned min_thinness_;
};
@@ -133,7 +150,7 @@ namespace scribo
objects_v_thin(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned min_thickness)
+ unsigned min_thinness)
{
trace::entering("scribo::filter::objects_v_thin");
@@ -144,18 +161,9 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
- V nlabels;
- typedef mln_ch_value(I,V) lbl_t;
- object_image(lbl_t) objects
- = primitive::extract::objects(input, nbh, nlabels);
-
- typedef internal::objects_v_thin_filter<lbl_t> func_t;
- func_t fv2b(objects, min_thickness);
- objects.relabel(fv2b);
-
- mln_concrete(I) output = duplicate(input);
- data::fill((output | (pw::value(objects) == pw::cst(literal::zero))).rw(),
- false);
+ internal::objects_v_thin_filter<V> fv2b(min_thinness);
+ mln_concrete(I)
+ output = internal::compute(input, nbh, label_type, fv2b);
trace::exiting("scribo::filter::objects_v_thin");
return output;
@@ -164,20 +172,15 @@ namespace scribo
template <typename L>
inline
- object_image(L)
- objects_v_thin(const object_image(L)& objects,
- unsigned min_thickness)
+ component_set<L>
+ objects_v_thin(const component_set<L>& comps,
+ unsigned min_thinness)
{
trace::entering("scribo::filter::objects_v_thin");
- mln_precondition(objects.is_valid());
-
- typedef internal::objects_v_thin_filter<L> func_t;
- func_t is_not_too_v_thin(objects, min_thickness);
-
- object_image(L) output;
- output.init_from_(objects);
- output.relabel(is_not_too_v_thin);
+ internal::objects_v_thin_filter<L>
+ is_not_too_v_thin(comps, min_thinness);
+ component_set<L> output = internal::compute(comps, is_not_too_v_thin);
trace::exiting("scribo::filter::objects_v_thin");
return output;
diff --git a/scribo/primitive/extract/lines_h_thick_and_single.hh b/scribo/primitive/extract/lines_h_thick_and_single.hh
index 3b3185b..551e5d8 100644
--- a/scribo/primitive/extract/lines_h_thick_and_single.hh
+++ b/scribo/primitive/extract/lines_h_thick_and_single.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,7 +40,6 @@
# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
-# include <scribo/primitive/extract/objects.hh>
# include <scribo/primitive/extract/lines_h_thick.hh>
# include <scribo/primitive/extract/lines_h_single.hh>
@@ -59,8 +59,9 @@ namespace scribo
/// Extract horizontal thick lines in a binary image.
/*!
- * Only non discontinued lines are correctly extracted with this routine.
- * Only lines matching the given criterions are kept in the result.
+ * Only non discontinued lines are correctly extracted with this
+ * routine. Only lines matching the given criterions are kept
+ * in the result.
*
* \param[in] input_ A binary image.
* \param[in] nbh_ The neighborhood used for labeling image
@@ -74,7 +75,7 @@ namespace scribo
* \return An image in which lines are labeled.
*/
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_h_thick_and_single(const Image<I>& input_,
const Neighborhood<N>& nbh_,
V& nlines,
@@ -117,7 +118,7 @@ namespace scribo
template <typename I, typename N, typename V>
inline
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_h_thick_and_single(const Image<I>& input,
const Neighborhood<N>& nbh,
V& nlines,
@@ -130,8 +131,7 @@ namespace scribo
nlines,
min_line_length,
h_w_ratio);
-
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
output = lines_h_thick(input, nbh, nlines, min_line_length);
output = lines_h_single(output, min_line_length, h_w_ratio);
diff --git a/scribo/primitive/extract/lines_v_thick_and_single.hh b/scribo/primitive/extract/lines_v_thick_and_single.hh
index eba25ab..c19ba5a 100644
--- a/scribo/primitive/extract/lines_v_thick_and_single.hh
+++ b/scribo/primitive/extract/lines_v_thick_and_single.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,7 +40,6 @@
# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
-# include <scribo/primitive/extract/objects.hh>
# include <scribo/primitive/extract/lines_v_thick.hh>
# include <scribo/primitive/extract/lines_v_single.hh>
@@ -58,8 +58,9 @@ namespace scribo
/// Extract vertical thick lines in a binary image.
/*!
- * Only non discontinued lines are correctly extracted with this routine.
- * Only lines matching the given criterions are kept in the result.
+ * Only non discontinued lines are correctly extracted with this
+ * routine. Only lines matching the given criterions are kept
+ * in the result.
*
* \param[in] input_ A binary image.
* \param[in] nbh_ The neighborhood used for labeling image
@@ -73,7 +74,7 @@ namespace scribo
* \return An image in which lines are labeled.
*/
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_v_thick_and_single(const Image<I>& input_,
const Neighborhood<N>& nbh_,
V& nlines,
@@ -116,7 +117,7 @@ namespace scribo
template <typename I, typename N, typename V>
inline
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_v_thick_and_single(const Image<I>& input,
const Neighborhood<N>& nbh,
V& nlines,
@@ -129,7 +130,7 @@ namespace scribo
nlines,
min_line_length, h_w_ratio);
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
output = lines_v_thick(input, nbh, nlines, min_line_length);
output = lines_v_single(output, min_line_length, h_w_ratio);
diff --git a/scribo/primitive/group/from_graph.hh b/scribo/primitive/group/from_graph.hh
index 602be90..37a5718 100644
--- a/scribo/primitive/group/from_graph.hh
+++ b/scribo/primitive/group/from_graph.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -64,14 +65,14 @@ namespace scribo
/// Group objects according to a graph of links
///
- /// \param[in] objects An object image.
+ /// \param[in] comps A component set.
/// \param[in] g_ The graph of object links.
///
/// \return Object groups information.
//
template <typename L, typename G>
object_groups<L>
- from_graph(const object_image(L)& objects,
+ from_graph(const component_set<L>& comps,
const Graph<G>& g_);
@@ -87,8 +88,8 @@ namespace scribo
struct map_vertex_to_representative_id_functor
{
- map_vertex_to_representative_id_functor(const object_image(L)& objects)
- : vertextorep(objects)
+ map_vertex_to_representative_id_functor(const component_set<L>& comps)
+ : vertextorep(comps)
{
}
@@ -148,7 +149,7 @@ namespace scribo
template <typename L, typename G>
inline
object_groups<L>
- from_graph(const object_image(L)& objects,
+ from_graph(const component_set<L>& comps,
const Graph<G>& g_)
{
trace::entering("scribo::primitive::group::from_graph");
@@ -157,10 +158,10 @@ namespace scribo
mln_assertion(g.is_valid());
- internal::map_vertex_to_representative_id_functor<L> f(objects);
+ internal::map_vertex_to_representative_id_functor<L> f(comps);
canvas::browsing::depth_first_search(g, f);
- object_groups<L> groups(objects);
+ object_groups<L> groups(comps);
groups.init_(f.vertextorep);
trace::exiting("scribo::primitive::group::from_graph");
diff --git a/scribo/primitive/internal/find_graph_link.hh b/scribo/primitive/internal/find_graph_link.hh
index f5a1039..7176153 100644
--- a/scribo/primitive/internal/find_graph_link.hh
+++ b/scribo/primitive/internal/find_graph_link.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,19 +29,22 @@
/// \file
///
-/// Find the right neighbor of a line of text if exists.
+/// Find the right neighbor of a component if exists.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/graph.hh>
+//FIXME: not generic.
+# include <mln/core/alias/dpoint2d.hh>
+
# include <mln/math/abs.hh>
# include <mln/util/array.hh>
-# include <scribo/primitive/internal/update_graph_link.hh>
-//FIXME: not generic.
-# include <mln/core/alias/dpoint2d.hh>
+# include <scribo/core/component_set.hh>
+
+# include <scribo/primitive/internal/update_graph_link.hh>
namespace scribo
@@ -52,10 +56,10 @@ namespace scribo
namespace internal
{
- /// Find a neighbor of a text line in a specific range if it exists.
+ /// Find a neighbor of a component in a specific range if it exists.
///
/// \param g_ The link graph.
- /// \param text The lines of text.
+ /// \param comps A component set.
/// \param current_comp The current line being processed.
/// \param dmax The maximum lookup distance.
/// \param c Start point of the neighbor lookup.
@@ -63,7 +67,7 @@ namespace scribo
template <typename G, typename L>
void
find_graph_link(Graph<G>& g_,
- const object_image(L)& text,
+ const component_set<L>& comps,
unsigned current_comp,
int dmax,
const mln_site(L)& c);
@@ -73,7 +77,7 @@ namespace scribo
template <typename G, typename L>
void
find_graph_link(Graph<G>& g_,
- const object_image(L)& text,
+ const component_set<L>& comps,
unsigned current_comp,
int dmax,
const mln_site(L)& c)
@@ -82,18 +86,19 @@ namespace scribo
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;
- while (text.domain().has(p) && (text(p) == literal::zero
- || text(p) == current_comp)
+ const L& lbl = comps.labeled_image();
+
+ while (comps.domain().has(p) && (lbl(p) == literal::zero
+ || lbl(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(comps, g, p, c, current_comp, dmax);
trace::exiting("scribo::primitive::internal::find_graph_link");
}
@@ -102,7 +107,7 @@ namespace scribo
} // end of namespace scribo::primitive::internal
- } // end of namespace scribo::text
+ } // end of namespace scribo::primitive
} // end of namespace scribo
diff --git a/scribo/primitive/link/with_graph.hh b/scribo/primitive/link/with_graph.hh
index 2d579aa..efe4721 100644
--- a/scribo/primitive/link/with_graph.hh
+++ b/scribo/primitive/link/with_graph.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -42,6 +43,7 @@
# include <mln/util/graph.hh>
# include <scribo/core/macros.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/primitive/internal/find_graph_link.hh>
@@ -55,12 +57,14 @@ namespace scribo
namespace link
{
+ using namespace mln;
+
/*!
Construct the links between each line of text and store
it as a graph.
Look up for neighbors on the right of each box.
- \param[in] objects An object image.
+ \param[in] comps A component set.
\param[in] neighb_max_distance The maximum distance allowed to
look for a neighbor.
@@ -68,8 +72,8 @@ namespace scribo
*/
template <typename L>
mln::util::graph
- with_graph(const object_image(L)& objects,
- unsigned neighb_max_distance);
+ with_graph(const component_set<L>& comps,
+ unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
@@ -77,32 +81,26 @@ namespace scribo
template <typename L>
inline
mln::util::graph
- with_graph(const object_image(L)& objects,
+ with_graph(const component_set<L>& comps,
unsigned neighb_max_distance)
{
trace::entering("scribo::primitive::link::with_graph");
- mln_precondition(objects.is_valid());
-
- mln::util::graph g(objects.nlabels().next());
+ mln::util::graph g(comps.nelements().next());
- for_all_ncomponents(i, objects.nlabels())
+ for_all_comps(i, comps)
{
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
+ unsigned midcol = (comps(i).bbox().pmax().col()
+ - comps(i).bbox().pmin().col()) / 2;
int dmax = midcol + neighb_max_distance;
- mln::util::array<mln_result(accu::center<mln_psite(L)>)>
- mass_center = labeling::compute(accu::meta::center(),
- objects,
- objects.nlabels());
-
// -------
// | |
// | X------->
// | |
// -------
- internal::find_graph_link(g, objects, i, dmax, mass_center[i]);
+ internal::find_graph_link(g, comps, i, dmax,
+ comps(i).mass_center());
}
trace::exiting("scribo::primitive::link::with_graph");
diff --git a/scribo/primitive/link/with_rag.hh b/scribo/primitive/link/with_rag.hh
index 3638ec7..e66d87e 100644
--- a/scribo/primitive/link/with_rag.hh
+++ b/scribo/primitive/link/with_rag.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -29,7 +30,7 @@
/// \file
///
-/// Link objects with a region adjacency graph.
+/// Link components with a region adjacency graph.
# include <mln/core/concept/neighborhood.hh>
@@ -42,7 +43,7 @@
# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
+# include <scribo/core/component_set.hh>
namespace scribo
@@ -57,10 +58,12 @@ namespace scribo
using namespace mln;
+ /// \brief Link components with a region adjacency graph.
+ //
template <typename L, typename N>
util::couple<mln::util::graph, mln_concrete(L)>
- with_rag(const object_image(L)& objects,
- const Neighborhood<N>& nbh);
+ with_rag(const component_set<L>& comps,
+ const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
@@ -68,20 +71,21 @@ namespace scribo
template <typename L, typename N>
util::couple<mln::util::graph, mln_concrete(L)>
- with_rag(const object_image(L)& objects,
- const Neighborhood<N>& nbh)
+ with_rag(const component_set<L>& comps,
+ const Neighborhood<N>& nbh)
{
trace::entering("scribo::primitive::link::with_rag");
- mln_precondition(objects.is_valid());
+ mln_precondition(comps.is_valid());
mln_concrete(L)
- iz = transform::influence_zone_geodesic(objects, nbh);
+ iz = transform::influence_zone_geodesic(comps.labeled_image(),
+ nbh);
mln::util::graph
g = mln::make::influence_zone_adjacency_graph(iz,
nbh,
- objects.nlabels());
+ comps.nelements());
trace::exiting("scribo::primitive::link::with_rag");
return make::couple(g, iz);
diff --git a/scribo/primitive/link/with_several_graphes.hh b/scribo/primitive/link/with_several_graphes.hh
index 98d631e..acfccbc 100644
--- a/scribo/primitive/link/with_several_graphes.hh
+++ b/scribo/primitive/link/with_several_graphes.hh
@@ -39,7 +39,9 @@
# include <mln/util/array.hh>
# include <mln/util/graph.hh>
+
# include <scribo/core/macros.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/primitive/internal/find_graph_link.hh>
namespace scribo
@@ -51,11 +53,13 @@ namespace scribo
namespace link
{
+ using namespace mln;
+
/// Link character bounding boxes with several graphes.
/// Look up for neighbors on the left of each box.
template <typename L>
mln::util::graph
- with_several_graphes(const object_image(L)& objects,
+ with_several_graphes(const component_set<L>& comps,
unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
@@ -63,25 +67,20 @@ namespace scribo
template <typename L>
inline
mln::util::graph
- with_several_graphes(const object_image(L)& objects,
+ with_several_graphes(const component_set<L>& comps,
unsigned neighb_max_distance)
{
trace::entering("scribo::primitive::link::with_several_graphes");
- mln::util::graph g(objects.nlabels().next());
+ mln::util::graph g(comps.nelements().next());
- for_all_ncomponents(i, objects.nlabels())
+ for_all_comps(i, comps)
{
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
+ unsigned midcol = (comps(i).bbox().pmax().col()
+ - comps(i).bbox().pmin().col()) / 2;
int dmax = midcol + neighb_max_distance;
- mln::util::array<mln_result(accu::center<mln_psite(L)>)>
- mass_center = labeling::compute(accu::meta::center(),
- objects,
- objects.nlabels());
-
- mln_site(L) c = mass_center(i);
+ mln_site(L) c = comps(i).mass_center();
// -------
// | X------->
@@ -98,16 +97,18 @@ namespace scribo
/// Left link from the top anchor.
mln_site(L) a1 = c;
- a1.row() = objects.bbox(i).pmin().row() + (c.row() - objects.bbox(i).pmin().row()) / 4;
- internal::find_graph_link(g, objects, i, dmax, a1);
+ a1.row() = comps(i).bbox().pmin().row()
+ + (c.row() - comps(i).bbox().pmin().row()) / 4;
+ internal::find_graph_link(g, comps, i, dmax, a1);
/// First site on the right of the central site
- internal::find_graph_link(g, objects, i, dmax, c);
+ internal::find_graph_link(g, comps, i, dmax, c);
/// Left link from the bottom anchor.
mln_site(L) a2 = c;
- a2.row() = objects.bbox(i).pmax().row() - (c.row() - objects.bbox(i).pmin().row()) / 4;
- internal::find_graph_link(g, objects, i, dmax, a2);
+ a2.row() = comps(i).bbox().pmax().row()
+ - (c.row() - comps(i).bbox().pmin().row()) / 4;
+ internal::find_graph_link(g, comps, i, dmax, a2);
}
diff --git a/scribo/primitive/link/with_several_left_links.hh b/scribo/primitive/link/with_several_left_links.hh
index 5a685a1..3f9a0cd 100644
--- a/scribo/primitive/link/with_several_left_links.hh
+++ b/scribo/primitive/link/with_several_left_links.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -35,9 +36,10 @@
# include <mln/util/array.hh>
+# include <scribo/primitive/link/with_single_left_link.hh>
# include <scribo/core/object_links.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/core/macros.hh>
-# include <scribo/util/text.hh>
namespace scribo
@@ -53,11 +55,12 @@ namespace scribo
/// if possible.
/// Iterate to the right but link boxes to the left.
///
- /// \return an mln::util::array. Map a bounding box to its left neighbor.
+ /// \return object links data.
+ //
template <typename L>
inline
object_links<L>
- with_several_left_links(const object_image(L)& objects,
+ with_several_left_links(const component_set<L>& objects,
unsigned neighb_max_distance);
@@ -65,7 +68,7 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_several_left_links(const object_image(L)& objects);
+ with_several_left_links(const component_set<L>& comps);
# ifndef MLN_INCLUDE_ONLY
@@ -73,29 +76,11 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_several_left_links(const object_image(L)& objects,
+ with_several_left_links(const component_set<L>& comps,
unsigned neighb_max_distance)
{
trace::entering("scribo::primitive::link::with_several_left_links");
- mln_precondition(objects.is_valid());
-
- 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());
-
- primitive::internal::init_link_array(link_1);
- primitive::internal::init_link_array(link_2);
- primitive::internal::init_link_array(link_3);
-
- mln::util::array<mln_result(accu::center<mln_psite(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
// -------
// <------X |
// | |
@@ -105,41 +90,33 @@ namespace scribo
// | |
// <------X |
// -------
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + neighb_max_distance;
- mln_site(L) c = objects.bbox(i).center();
+ // FIXME: make it faster.
+ internal::single_left_functor<L>
+ functor(comps, neighb_max_distance);
+ object_links<L> link_center = compute(functor, anchor::Center);
+ object_links<L> link_top = compute(functor, anchor::Top);
+ object_links<L> link_bot = compute(functor, anchor::Bottom);
- /// Left link from the top anchor.
- mln_site(L) a1 = c;
- a1.row() = objects.bbox(i).pmin().row() + (c.row() - objects.bbox(i).pmin().row()) / 4;
- primitive::internal::find_left_link(objects, link_1, i, dmax, a1);
- /// Left link from the central site
- primitive::internal::find_left_link(objects, link_2, i,
- dmax, mass_centers[i]);
+ object_links<L> final_link(comps);
- /// Left link from the bottom anchor.
- mln_site(L) a2 = c;
- a2.row() = objects.bbox(i).pmax().row() - (c.row() - objects.bbox(i).pmin().row()) / 4;
- primitive::internal::find_left_link(objects, link_3, i, dmax, a2);
- }
-
- for_all_ncomponents(i, objects.nlabels())
+ for_all_comps(i, comps)
{
- if (link_2[i] != i)
- final_link[i] = link_2[i];
- else if (link_1[i] == link_3[i])
- final_link[i] = link_1[i];
- else if (link_1[i] != i && link_3[i] == i)
- final_link[i] = link_1[i];
- else if (link_3[i] != i && link_1[i] == i)
- final_link[i] = link_3[i];
+ if (link_center(i) != i)
+ final_link(i) = link_center(i);
+ else if (link_top(i) == link_bot(i))
+ final_link(i) = link_top(i);
+ else if (link_top(i) != i && link_bot(i) == i)
+ final_link(i) = link_top(i);
+ else if (link_bot(i) != i && link_top(i) == i)
+ final_link(i) = link_bot(i);
else
- final_link[i] = i;
+ final_link(i) = i;
}
+
+
trace::exiting("scribo::primitive::link::with_several_left_links");
return final_link;
}
@@ -148,9 +125,9 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_several_left_links(const object_image(L)& objects)
+ with_several_left_links(const component_set<L>& comps)
{
- return with_several_left_links(objects);
+ return with_several_left_links(comps);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/primitive/link/with_several_right_closest_links.hh b/scribo/primitive/link/with_several_right_closest_links.hh
index 629d0b0..da1e75b 100644
--- a/scribo/primitive/link/with_several_right_closest_links.hh
+++ b/scribo/primitive/link/with_several_right_closest_links.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -33,20 +34,21 @@
/// Merge code with primitive::link::with_single_right_link.hh
///
/// \todo Factor code with primitive::link::with_several_right_links
+///
+/// FIXME: rewrite the code with functors -> See with_several_right_links
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
+# include <mln/math/abs.hh>
+
# include <mln/extension/fill.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/primitive/internal/init_link_array.hh>
-# include <scribo/primitive/internal/find_right_link.hh>
-# include <scribo/util/text.hh>
+# include <scribo/core/object_links.hh>
namespace scribo
@@ -71,14 +73,14 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_several_right_closest_links(const object_image(L)& objects,
+ with_several_right_closest_links(const component_set<L>& comps,
unsigned neighb_max_distance);
/// \overload
template <typename L>
inline
object_links<L>
- with_several_right_closest_links(const object_image(L)& objects);
+ with_several_right_closest_links(const component_set<L>& comps);
# ifndef MLN_INCLUDE_ONLY
@@ -114,31 +116,21 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_several_right_closest_links(const object_image(L)& objects,
+ with_several_right_closest_links(const component_set<L>& comps,
unsigned neighb_max_distance)
{
trace::entering("scribo::primitive::link::with_several_right_closest_links");
- mln_precondition(objects.is_valid());
-
- extension::fill(objects, 0);
+ extension::fill(comps.labeled_image_(), 0);
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());
-
- primitive::internal::init_link_array(link_1);
- primitive::internal::init_link_array(link_2);
- primitive::internal::init_link_array(link_3);
-
- mln::util::array<mln_result(accu::center<mln_psite(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
+ link_1(comps), link_2(comps), link_3(comps), final_link(comps);
+ link_1.init();
+ link_2.init();
+ link_3.init();
- for_all_ncomponents(i, objects.nlabels())
+ for_all_comps(i, comps)
{
// -------
// | a1------->
@@ -150,31 +142,31 @@ namespace scribo
// | a2------->
// -------
- float midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
+ float midcol = (comps(i).bbox().pmax().col()
+ - comps(i).bbox().pmin().col()) / 2;
float dmax = midcol + neighb_max_distance;
- mln_site(L) c = objects.bbox(i).center();
+ mln_site(L) c = comps(i).bbox().center();
algebra::vec<3, mln::util::couple<bool, mln_site(L)> > res;
// Right link from the top anchor.
mln_site(L) a1 = c;
- a1.row() = objects.bbox(i).pmin().row()
- + (c.row() - objects.bbox(i).pmin().row()) / 4;
- res[0] = primitive::internal::find_right_link(objects, link_1,
+ a1.row() = comps(i).bbox().pmin().row()
+ + (c.row() - comps(i).bbox().pmin().row()) / 4;
+ res[0] = primitive::internal::find_right_link(comps, link_1,
i, dmax, a1);
// Right link from the central site
- res[1] = primitive::internal::find_right_link(objects, link_2,
+ res[1] = primitive::internal::find_right_link(comps, link_2,
i, dmax,
- mass_centers[i]);
+ comps(i).mass_center());
// Right link from the bottom anchor.
mln_site(L) a2 = c;
- a2.row() = objects.bbox(i).pmax().row()
- - (c.row() - objects.bbox(i).pmin().row()) / 4;
- res[2] = primitive::internal::find_right_link(objects, link_3,
+ a2.row() = comps(i).bbox().pmax().row()
+ - (c.row() - comps(i).bbox().pmin().row()) / 4;
+ res[2] = primitive::internal::find_right_link(comps, link_3,
i, dmax, a2);
// Try to find the closest object.
@@ -185,7 +177,7 @@ namespace scribo
// If there exists a link and the site is not outside the
// image domain.
if (res[closest_idx].first())
- final_link[i] = objects(res[closest_idx].second());
+ final_link[i] = comps(res[closest_idx].second());
else
final_link[i] = i;
}
@@ -198,9 +190,9 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_several_right_closest_links(const object_image(L)& objects)
+ with_several_right_closest_links(const component_set<L>& comps)
{
- return with_several_right_closest_links(objects, mln_max(unsigned));
+ return with_several_right_closest_links(comps, mln_max(unsigned));
}
diff --git a/scribo/primitive/link/with_several_right_links.hh b/scribo/primitive/link/with_several_right_links.hh
index 14d3229..d75ac7b 100644
--- a/scribo/primitive/link/with_several_right_links.hh
+++ b/scribo/primitive/link/with_several_right_links.hh
@@ -37,9 +37,10 @@
# include <mln/util/array.hh>
+# include <scribo/primitive/link/with_single_right_link.hh>
# include <scribo/core/object_links.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/core/macros.hh>
-# include <scribo/util/text.hh>
namespace scribo
@@ -57,88 +58,64 @@ namespace scribo
/// if possible.
/// Iterate to the right but link boxes to the right.
///
- /// \return an mln::util::array. Map a bounding box to its right neighbor.
+ /// \return Object links.
+ //
template <typename L>
inline
object_links<L>
- with_several_right_links(const object_image(L)& objects,
+ with_several_right_links(const component_set<L>& comps,
unsigned neighb_max_distance);
/// \overload
template <typename L>
inline
object_links<L>
- with_several_right_links(const object_image(L)& objects);
+ with_several_right_links(const component_set<L>& comps);
# ifndef MLN_INCLUDE_ONLY
+
template <typename L>
inline
object_links<L>
- with_several_right_links(const object_image(L)& objects,
+ with_several_right_links(const component_set<L>& comps,
unsigned neighb_max_distance)
{
trace::entering("scribo::primitive::link::with_several_right_links");
- mln_precondition(objects.is_valid());
-
- 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());
+ // -------
+ // | X------->
+ // | |
+ // | |
+ // | X------->
+ // | |
+ // | |
+ // | X------->
+ // -------
- internal::init_link_array(link_1);
- internal::init_link_array(link_2);
- internal::init_link_array(link_3);
+ // FIXME: make it faster.
+ internal::single_right_functor<L>
+ functor(comps, neighb_max_distance);
+ object_links<L> link_center = compute(functor, anchor::Center);
+ object_links<L> link_top = compute(functor, anchor::Top);
+ object_links<L> link_bot = compute(functor, anchor::Bottom);
- mln::util::array<mln_result(accu::center<mln_psite(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
+ object_links<L> final_link(comps);
- for_all_ncomponents(i, objects.nlabels())
+ for_all_comps(i, comps)
{
- // -------
- // | X------->
- // | |
- // | |
- // | X------->
- // | |
- // | |
- // | X------->
- // -------
- float midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- float dmax = midcol + neighb_max_distance;
-
- mln_site(L) c = objects.bbox(i).center();
-
- /// Right link from the top anchor.
- mln_site(L) a1 = c;
- a1.row() = objects.bbox(i).pmin().row() + (c.row() - objects.bbox(i).pmin().row()) / 4;
- internal::find_right_link(objects, link_1, i, dmax, a1);
-
- /// Right link from the central site
- internal::find_right_link(objects, link_2, i, dmax, mass_centers[i]);
-
- /// Right link from the bottom anchor.
- mln_site(L) a2 = c;
- a2.row() = objects.bbox(i).pmax().row() - (c.row() - objects.bbox(i).pmin().row()) / 4;
- internal::find_right_link(objects, link_3, i, dmax, a2);
-
-
- if (link_2[i] != i)
- final_link[i] = link_2[i];
- else if (link_1[i] == link_3[i])
- final_link[i] = link_1[i];
- else if (link_1[i] != i && link_3[i] == i)
- final_link[i] = link_1[i];
- else if (link_3[i] != i && link_1[i] == i)
- final_link[i] = link_3[i];
+ if (link_center(i) != i)
+ final_link(i) = link_center(i);
+ else if (link_top(i) == link_bot(i))
+ final_link(i) = link_top(i);
+ else if (link_top(i) != i && link_bot(i) == i)
+ final_link(i) = link_top(i);
+ else if (link_bot(i) != i && link_top(i) == i)
+ final_link(i) = link_bot(i);
else
- final_link[i] = i;
+ final_link(i) = i;
}
trace::exiting("scribo::primitive::link::with_several_right_links");
@@ -149,9 +126,9 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_several_right_links(const object_image(L)& objects)
+ with_several_right_links(const component_set<L>& comps)
{
- return with_several_right_links(objects, mln_max(unsigned));
+ return with_several_right_links(comps, mln_max(unsigned));
}
diff --git a/scribo/primitive/link/with_single_down_link.hh b/scribo/primitive/link/with_single_down_link.hh
index 7e4e82c..01c6f7e 100644
--- a/scribo/primitive/link/with_single_down_link.hh
+++ b/scribo/primitive/link/with_single_down_link.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -43,7 +44,6 @@
# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/core/object_links.hh>
# include <scribo/primitive/link/internal/find_link.hh>
@@ -63,7 +63,7 @@ namespace scribo
/// \brief Link objects with their down neighbor if exists.
///
- /// \param[in] objects An object image.
+ /// \param[in] comps A component set.
/// \param[in] neighb_max_distance The maximum distance allowed
/// to seach a neighbor object.
/// \param[in] anchor The neighborhod lookup start point.
@@ -73,7 +73,7 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_down_link(const object_image(L)& objects,
+ with_single_down_link(const component_set<L>& comps,
unsigned neighb_max_distance,
anchor::Type anchor);
@@ -83,7 +83,7 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_down_link(const object_image(L)& objects,
+ with_single_down_link(const component_set<L>& comps,
unsigned neighb_max_distance);
@@ -92,7 +92,7 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_down_link(const object_image(L)& objects);
+ with_single_down_link(const component_set<L>& comps);
# ifndef MLN_INCLUDE_ONLY
@@ -113,8 +113,8 @@ namespace scribo
public:
typedef mln_site(L) P;
- single_down_functor(const object_image(L)& objects, unsigned dmax)
- : sdowner_(objects, dmax, anchor::Vertical)
+ single_down_functor(const component_set<L>& comps, unsigned dmax)
+ : sdowner_(comps, dmax, anchor::Vertical)
{
}
@@ -134,16 +134,14 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_down_link(const object_image(L)& objects,
+ with_single_down_link(const component_set<L>& comps,
unsigned neighb_max_distance,
anchor::Type anchor)
{
trace::entering("scribo::primitive::link::with_single_down_link");
- mln_precondition(objects.is_valid());
-
internal::single_down_functor<L>
- functor(objects, neighb_max_distance);
+ functor(comps, neighb_max_distance);
object_links<L> output = compute(functor, anchor);
@@ -155,10 +153,10 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_down_link(const object_image(L)& objects,
+ with_single_down_link(const component_set<L>& comps,
unsigned neighb_max_distance)
{
- return with_single_down_link(objects, neighb_max_distance,
+ return with_single_down_link(comps, neighb_max_distance,
anchor::MassCenter);
}
@@ -166,9 +164,9 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_down_link(const object_image(L)& objects)
+ with_single_down_link(const component_set<L>& comps)
{
- return with_single_down_link(objects, mln_max(unsigned));
+ return with_single_down_link(comps, mln_max(unsigned));
}
diff --git a/scribo/primitive/link/with_single_up_link.hh b/scribo/primitive/link/with_single_up_link.hh
index 8781128..4062275 100644
--- a/scribo/primitive/link/with_single_up_link.hh
+++ b/scribo/primitive/link/with_single_up_link.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,7 +29,7 @@
/// \file
///
-/// Link text objects with their up neighbor.
+/// Link components with their up neighbor.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -61,9 +62,9 @@ namespace scribo
namespace link
{
- /// \brief Link objects with their up neighbor if exists.
+ /// \brief Link components with their up neighbor if exists.
///
- /// \param[in] objects An object image.
+ /// \param[in] comps A component set.
/// \param[in] neighb_max_distance The maximum distance allowed
/// to seach a neighbor object.
/// \param[in] anchor The neighborhod lookup start point.
@@ -73,7 +74,7 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_up_link(const object_image(L)& objects,
+ with_single_up_link(const component_set<L>& comps,
unsigned neighb_max_distance,
anchor::Type anchor);
@@ -83,7 +84,7 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_up_link(const object_image(L)& objects,
+ with_single_up_link(const component_set<L>& comps,
unsigned neighb_max_distance);
@@ -93,7 +94,7 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_up_link(const object_image(L)& objects);
+ with_single_up_link(const component_set<L>& comps);
# ifndef MLN_INCLUDE_ONLY
@@ -114,8 +115,8 @@ namespace scribo
public:
typedef mln_site(L) P;
- single_up_functor(const object_image(L)& objects, unsigned dmax)
- : super_(objects, dmax, anchor::Vertical)
+ single_up_functor(const component_set<L>& comps, unsigned dmax)
+ : super_(comps, dmax, anchor::Vertical)
{
}
@@ -135,16 +136,14 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_up_link(const object_image(L)& objects,
+ with_single_up_link(const component_set<L>& comps,
unsigned neighb_max_distance,
anchor::Type anchor)
{
trace::entering("scribo::primitive::link::with_single_up_link");
- mln_precondition(objects.is_valid());
-
internal::single_up_functor<L>
- functor(objects, neighb_max_distance);
+ functor(comps, neighb_max_distance);
object_links<L> output = compute(functor, anchor);
@@ -155,10 +154,10 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_up_link(const object_image(L)& objects,
+ with_single_up_link(const component_set<L>& comps,
unsigned neighb_max_distance)
{
- return with_single_up_link(objects, neighb_max_distance,
+ return with_single_up_link(comps, neighb_max_distance,
anchor::MassCenter);
}
@@ -166,9 +165,9 @@ namespace scribo
template <typename L>
inline
object_links<L>
- with_single_up_link(const object_image(L)& objects)
+ with_single_up_link(const component_set<L>& comps)
{
- return with_single_up_link(objects, mln_max(unsigned));
+ return with_single_up_link(comps, mln_max(unsigned));
}
--
1.5.6.5
1
0
* core/component_info.hh (is_valid): Check the bounding box
validity.
* core/macros.hh: Add a new macro.
* debug/decision_image.hh: Remove deprecated preconditions and add
missing includes.
* debug/save_linked_bboxes_image.hh: Add the anchor type as
argument.
* draw/bounding_box_links.hh: Add the anchor type as argument and
make use of component information.
* draw/bounding_boxes.hh: Check the component validity.
* filter/object_links_non_aligned_simple.hh: Update doc.
* filter/objects_with_holes.hh: Remove debug and timers. Add
missing includes.
* primitive/extract/lines_pattern.hh: Use the window template
parameter instead of an exact window type.
* primitive/link/internal/find_several_links.hh: Update code with
new interfaces.
* primitive/link/internal/link_functor_base.hh
(nanchors()): Remove this method.
(labeled_image()): Add a const version.
* primitive/link/internal/link_several_dmax_base.hh
(nanchors(), anchors()): New methods.
Introduce 'direction_' attribute.
* debug/several_links_decision_image.hh: Remove deprecated
preconditions.
* src/debug/show_links_single_left.cc: Update include.
* table/internal/align_lines.hh,
* table/rebuild.hh: Make use of component_set structure.
* debug/text_areas_image.hh,
* primitive/regroup/from_single_left_link_wrt_h_ratio.hh: Add
missing includes.
* src/contest/hdibco-2010/Makefile.am: Do not consider this tool
as a test anymore.
---
scribo/ChangeLog | 48 ++++++
scribo/core/component_info.hh | 2 +-
scribo/core/macros.hh | 3 +
scribo/debug/decision_image.hh | 21 ++-
scribo/debug/save_linked_bboxes_image.hh | 82 ++++------
scribo/debug/several_links_decision_image.hh | 3 +-
scribo/debug/text_areas_image.hh | 3 +-
scribo/draw/bounding_box_links.hh | 140 +++++------------
scribo/draw/bounding_boxes.hh | 5 +-
scribo/filter/object_links_non_aligned_simple.hh | 3 +-
scribo/filter/objects_with_holes.hh | 162 +++-----------------
scribo/primitive/extract/lines_pattern.hh | 3 +-
.../primitive/link/internal/find_several_links.hh | 6 +-
.../primitive/link/internal/link_functor_base.hh | 45 ++----
.../link/internal/link_several_dmax_base.hh | 93 +++++++----
.../regroup/from_single_left_link_wrt_h_ratio.hh | 6 +-
scribo/src/contest/hdibco-2010/Makefile.am | 4 +-
scribo/src/debug/show_links_single_left.cc | 2 +-
scribo/table/internal/align_lines.hh | 55 ++++---
scribo/table/rebuild.hh | 75 +++++-----
20 files changed, 317 insertions(+), 444 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index e0da752..2d5510a 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,53 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Small fixes in Scribo.
+
+ * core/component_info.hh (is_valid): Check the bounding box
+ validity.
+
+ * core/macros.hh: Add a new macro.
+
+ * debug/decision_image.hh: Remove deprecated preconditions and add
+ missing includes.
+
+ * draw/bounding_boxes.hh: Check the component validity.
+
+ * filter/object_links_non_aligned_simple.hh: Update doc.
+
+ * filter/objects_with_holes.hh: Remove debug and timers. Add
+ missing includes.
+
+ * primitive/extract/lines_pattern.hh: Use the window template
+ parameter instead of an exact window type.
+
+ * primitive/link/internal/find_several_links.hh: Update code with
+ new interfaces.
+
+ * primitive/link/internal/link_functor_base.hh
+ (nanchors()): Remove this method.
+ (labeled_image()): Add a const version.
+
+ * primitive/link/internal/link_several_dmax_base.hh
+ (nanchors(), anchors()): New methods.
+ Introduce 'direction_' attribute.
+
+ * debug/several_links_decision_image.hh: Remove deprecated
+ preconditions.
+
+ * src/debug/show_links_single_left.cc: Update include.
+
+ * table/internal/align_lines.hh,
+ * table/rebuild.hh: Make use of component_set structure.
+
+ * debug/text_areas_image.hh,
+ * primitive/regroup/from_single_left_link_wrt_h_ratio.hh: Add
+ missing includes.
+
+ * src/contest/hdibco-2010/Makefile.am: Do not consider this tool
+ as a test anymore.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add missing includes and headers in AFP's dedicated code.
* src/afp/components.hh,
diff --git a/scribo/core/component_info.hh b/scribo/core/component_info.hh
index 4ee438c..56f7799 100644
--- a/scribo/core/component_info.hh
+++ b/scribo/core/component_info.hh
@@ -176,7 +176,7 @@ namespace scribo
bool
component_info::is_valid() const
{
- return tag_ != component::Ignored;
+ return tag_ != component::Ignored && bbox_.is_valid();
}
diff --git a/scribo/core/macros.hh b/scribo/core/macros.hh
index 040220c..07a101a 100644
--- a/scribo/core/macros.hh
+++ b/scribo/core/macros.hh
@@ -58,4 +58,7 @@
# define for_all_lines_info(E, S) \
for_all_comp_data(E, S)
+# define for_all_anchors(E, S) \
+ for_all_elements(E, S)
+
#endif // ! SCRIBO_CORE_MACROS_HH
diff --git a/scribo/debug/decision_image.hh b/scribo/debug/decision_image.hh
index 7f881d3..1bf2643 100644
--- a/scribo/debug/decision_image.hh
+++ b/scribo/debug/decision_image.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -35,9 +36,12 @@
# include <mln/value/rgb8.hh>
# include <mln/literal/colors.hh>
# include <mln/util/array.hh>
+# include <mln/draw/box.hh>
+# include <mln/draw/line.hh>
+# include <scribo/core/tag/anchor.hh>
# include <scribo/core/object_groups.hh>
-# include <scribo/draw/bounding_boxes.hh>
+# include <scribo/primitive/link/internal/compute_anchor.hh>
namespace scribo
@@ -105,8 +109,6 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(groups.is_valid());
mln_precondition(filtered_groups.is_valid());
- mln_precondition(groups.size() == filtered_groups.size());
- mln_precondition(groups.components_id_() != filtered_groups.components_id_());
/// Fixme: check that components has been computed from input.
image2d<value::rgb8>
@@ -114,9 +116,11 @@ namespace scribo
for (unsigned i = 1; i < groups.size(); ++i)
if (groups(i) != filtered_groups(i))
- mln::draw::box(decision_image, components(i).bbox(), literal::red);
+ mln::draw::box(decision_image, components(i).bbox(),
+ literal::red);
else
- mln::draw::box(decision_image, components(i).bbox(), literal::green);
+ mln::draw::box(decision_image, components(i).bbox(),
+ literal::green);
trace::exiting("scribo::debug::decision_image");
return decision_image;
@@ -138,8 +142,6 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(links.is_valid());
mln_precondition(filtered_links.is_valid());
- mln_precondition(links.size() == filtered_links.size());
- mln_precondition(links.object_image_() != filtered_links.object_image_());
/// Fixme: check that components has been computed from input.
image2d<value::rgb8>
@@ -155,7 +157,8 @@ namespace scribo
{
mln_site(L)
p1 = primitive::link::internal::compute_anchor(comps, i, anchor),
- p2 = primitive::link::internal::compute_anchor(comps, links(i), anchor);
+ p2 = primitive::link::internal::compute_anchor(comps, links(i),
+ anchor);
value::rgb8 value = literal::green;
if (links(i) != filtered_links(i))
diff --git a/scribo/debug/save_linked_bboxes_image.hh b/scribo/debug/save_linked_bboxes_image.hh
index ef70435..d4c940a 100644
--- a/scribo/debug/save_linked_bboxes_image.hh
+++ b/scribo/debug/save_linked_bboxes_image.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -38,6 +39,7 @@
# include <mln/value/rgb8.hh>
# include <mln/util/array.hh>
# include <mln/io/ppm/save.hh>
+# include <mln/literal/colors.hh>
# include <scribo/core/object_links.hh>
# include <scribo/core/component_set.hh>
@@ -57,7 +59,6 @@ namespace scribo
/// Save the line of components links image.
///
/// \param[in,out] input The binary from where the components are extracted.
- /// \param[in] components An object image.
/// \param[in] link_array Lines of components links.
/// \param[in] box_value Value used to draw line bounding boxes.
/// \param[in] link_value Value used to draw line links.
@@ -67,12 +68,11 @@ namespace scribo
template <typename I, typename L>
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
const object_links<L>& array,
const value::rgb8& box_value,
const value::rgb8& link_value,
- const std::string& filename,
- anchor::Type anchor);
+ anchor::Type anchor,
+ const std::string& filename);
/// \overload
/// The default anchor type is set to anchor::Center.
@@ -80,7 +80,6 @@ namespace scribo
template <typename I, typename L>
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
const object_links<L>& array,
const value::rgb8& box_value,
const value::rgb8& link_value,
@@ -89,7 +88,6 @@ namespace scribo
/// Save the line of components left and right links image.
///
/// \param[in,out] input The binary from where the components are extracted.
- /// \param[in] components An object image.
/// \param[in] left_link Lines of components left links.
/// \param[in] right_link Lines of components right links.
/// \param[in] box_value Value used to draw line bounding boxes.
@@ -98,18 +96,17 @@ namespace scribo
template <typename I, typename L>
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
const object_links<L>& left_link,
const object_links<L>& right_link,
const value::rgb8& box_value,
const value::rgb8& link_value,
+ anchor::Type anchor,
const std::string& filename);
/// Save the line of components left and right links image.
/// Draw also validated links.
///
/// \param[in,out] input The binary from where the components are extracted.
- /// \param[in] components An object image.
/// \param[in] left_link Lines of components left links.
/// \param[in] right_link Lines of components right links.
/// \param[in] box_value Value used to draw line bounding boxes.
@@ -121,20 +118,19 @@ namespace scribo
inline
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
const object_links<L>& left_link,
const object_links<L>& right_link,
const value::rgb8& box_value,
const value::rgb8& left_link_value,
const value::rgb8& right_link_value,
const value::rgb8& validated_link_value,
+ anchor::Type anchor,
const std::string& filename);
/// Save the line link graph image.
///
/// \param[in,out] input The binary from where the components are extracted.
- /// \param[in] components An object image.
/// \param[in] g The link graph.
/// \param[in] box_value Value used to draw line bounding boxes.
/// \param[in] link_value Value used to draw line links.
@@ -142,10 +138,10 @@ namespace scribo
template <typename I, typename L, typename G>
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
const Graph<G>& g,
const value::rgb8& box_value,
const value::rgb8& link_value,
+ anchor::Type anchor,
const std::string& filename);
@@ -156,20 +152,19 @@ namespace scribo
inline
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
- const object_links<L>& array,
+ const object_links<L>& links,
const value::rgb8& box_value,
const value::rgb8& link_value,
- const std::string& filename,
- anchor::Type anchor)
+ anchor::Type anchor,
+ const std::string& filename)
{
trace::entering("scribo::debug::save_linked_bboxes_image");
mln_precondition(exact(input).is_valid());
mln_ch_value(I,value::rgb8) tmp = data::convert(value::rgb8(), input);
- draw::bounding_boxes(tmp, components, box_value);
- draw::bounding_box_links(tmp, array, link_value, anchor);
+ draw::bounding_boxes(tmp, links.components(), box_value);
+ draw::bounding_box_links(tmp, links, link_value, anchor);
mln::io::ppm::save(tmp, filename);
@@ -181,14 +176,13 @@ namespace scribo
inline
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
- const object_links<L>& array,
+ const object_links<L>& links,
const value::rgb8& box_value,
const value::rgb8& link_value,
const std::string& filename)
{
- save_linked_bboxes_image(input, components, array, box_value,
- link_value, filename, anchor::Center);
+ save_linked_bboxes_image(input, links, box_value,
+ link_value, anchor::Center, filename);
}
@@ -197,26 +191,21 @@ namespace scribo
inline
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
const object_links<L>& left_link,
const object_links<L>& right_link,
const value::rgb8& box_value,
const value::rgb8& value,
const std::string& filename)
{
- trace::entering("scribo::debug::save_linked_bboxes_image");
- mln_precondition(exact(input).is_valid());
-
- mln_ch_value(I,value::rgb8) tmp = data::convert(value::rgb8(), input);
-
- draw::bounding_boxes(tmp, components, box_value);
- draw::bounding_box_links(tmp, components.mass_centers(),
- left_link, right_link,
- value);
-
- mln::io::ppm::save(tmp, filename);
-
- trace::exiting("scribo::debug::save_linked_bboxes_image");
+ save_linked_bboxes_image(input,
+ left_link,
+ right_link,
+ box_value,
+ literal::yellow,
+ literal::cyan,
+ value,
+ anchor::Center,
+ filename);
}
@@ -224,13 +213,13 @@ namespace scribo
inline
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
const object_links<L>& left_link,
const object_links<L>& right_link,
const value::rgb8& box_value,
const value::rgb8& left_link_value,
const value::rgb8& right_link_value,
const value::rgb8& validated_link_value,
+ anchor::Type anchor,
const std::string& filename)
{
trace::entering("scribo::debug::save_linked_bboxes_image");
@@ -238,16 +227,12 @@ namespace scribo
mln_ch_value(I,value::rgb8) tmp = data::convert(value::rgb8(), input);
- mln::util::array<mln_result(accu::center<mln_psite(L)>)>
- mass_center = labeling::compute(accu::meta::center(),
- components.labeled_image(),
- components.nelements());
-
- draw::bounding_boxes(tmp, components, box_value);
- draw::bounding_box_links(tmp, mass_center,
+ draw::bounding_boxes(tmp, left_link.components(), box_value);
+ draw::bounding_box_links(tmp,
left_link, right_link,
left_link_value, right_link_value,
- validated_link_value);
+ validated_link_value,
+ anchor);
mln::io::ppm::save(tmp, filename);
@@ -260,10 +245,10 @@ namespace scribo
inline
void
save_linked_bboxes_image(const Image<I>& input,
- const component_set<L>& components,
const Graph<G>& g,
const value::rgb8& box_value,
const value::rgb8& link_value,
+ anchor::Type anchor,
const std::string& filename)
{
trace::entering("scribo::debug::save_linked_bboxes_image");
@@ -272,8 +257,9 @@ namespace scribo
mln_ch_value(I,value::rgb8) tmp = data::convert(value::rgb8(), input);
- draw::bounding_boxes(tmp, components, box_value);
- draw::bounding_box_links(tmp, components, g, link_value);
+ draw::bounding_boxes(tmp, exact(g).components(), box_value);
+ draw::bounding_box_links(tmp, exact(g).components(), g, link_value,
+ anchor);
mln::io::ppm::save(tmp, filename);
diff --git a/scribo/debug/several_links_decision_image.hh b/scribo/debug/several_links_decision_image.hh
index ca70d44..3446287 100644
--- a/scribo/debug/several_links_decision_image.hh
+++ b/scribo/debug/several_links_decision_image.hh
@@ -100,8 +100,7 @@ namespace scribo
mln_precondition(objects.is_valid());
mln_precondition(links.is_valid());
mln_precondition(filtered_links.is_valid());
- mln_precondition(links.size() == filtered_links.size());
- mln_precondition(links.object_image_() != filtered_links.object_image_());
+
/// Fixme: check that objects has been computed from input.
image2d<value::rgb8>
diff --git a/scribo/debug/text_areas_image.hh b/scribo/debug/text_areas_image.hh
index f6a2f0f..eab208d 100644
--- a/scribo/debug/text_areas_image.hh
+++ b/scribo/debug/text_areas_image.hh
@@ -45,8 +45,9 @@
# include <mln/math/max.hh>
-# include <scribo/core/component_set.hh>
+# include <mln/literal/black.hh>
+# include <scribo/core/component_set.hh>
namespace scribo
{
diff --git a/scribo/draw/bounding_box_links.hh b/scribo/draw/bounding_box_links.hh
index 2ee5173..f2c9804 100644
--- a/scribo/draw/bounding_box_links.hh
+++ b/scribo/draw/bounding_box_links.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -77,32 +78,9 @@ namespace scribo
/// Draw left, right and validated lists of bounding box links.
- /// Draw from the bounding box centers.
+ /// Draw from anchors.
///
/// \param[in,out] input_ An image where to draw.
- /// \param[in] bboxes Bounding boxes.
- /// \param[in] left_link Bounding box left links.
- /// \param[in] right_link Bounding box right links.
- /// \param[in] left_link_value Value used to draw left links.
- /// \param[in] right_link_value Value used to draw right links.
- /// \param[in] validated_link_value Value used to draw validated links.
- template <typename I, typename L>
- inline
- void
- bounding_box_links(Image<I>& input_,
- const mln::util::array< box<mln_site(I)> >& bboxes,
- const object_links<L>& left_link,
- const object_links<L>& right_link,
- const mln_value(I)& left_link_value,
- const mln_value(I)& right_link_value,
- const mln_value(I)& validated_link_value);
-
-
- /// Draw left, right and validated lists of bounding box links.
- /// Draw from the bounding box mass centers.
- ///
- /// \param[in,out] input_ An image where to draw.
- /// \param[in] mass_centers Bounding box mass centers.
/// \param[in] left_link Bounding box left links.
/// \param[in] right_link Bounding box right links.
/// \param[in] left_link_value Value used to draw left links.
@@ -112,12 +90,12 @@ namespace scribo
inline
void
bounding_box_links(Image<I>& input_,
- const mln::util::array<mln_site(I)::vec>& mass_centers,
const object_links<L>& left_link,
const object_links<L>& right_link,
const mln_value(I)& left_link_value,
const mln_value(I)& right_link_value,
- const mln_value(I)& validated_link_value);
+ const mln_value(I)& validated_link_value,
+ anchor::Type anchor);
/// Draw a graph of bounding box links.
@@ -131,7 +109,6 @@ namespace scribo
inline
void
bounding_box_links(Image<I>& input_,
- const mln::util::array< box<mln_site(I)> >& bboxes,
const Graph<G>& g_,
const mln_value(I)& link_value);
@@ -155,28 +132,28 @@ namespace scribo
/// Draw a link graph in an image.
/// Functor to be passed to depth_first_search.
- template <typename I>
+ template <typename I, typename G>
struct draw_graph_edges_functor
{
/// Constructor
///
/// \param[in,out] ima The image where to draw.
- /// \param[in] textbboxes The line of text bounding boxes.
/// \param[in] value The value used to draw the links.
draw_graph_edges_functor(I& ima,
- const mln::util::array<box<mln_site(I)> >& textbboxes,
const mln_value(I)& value)
- : ima_(ima), textbboxes_(textbboxes), value_(value)
+ : ima_(ima), value_(value)
{}
/// Initialize the functor.
///
/// \param[in] g The graph this functor will work on.
- template <typename G>
void
init(const Graph<G>& g)
- { deja_vu.resize(exact(g).v_nmax(), false); }
+ {
+ g_ = g;
+ deja_vu.resize(exact(g).v_nmax(), false);
+ }
/// All components/vertices have been treated.
void final()
@@ -196,8 +173,8 @@ namespace scribo
void added_to_queue(unsigned id)
{
deja_vu[id] = true;
- mln::draw::line(ima_, textbboxes_[current_vertex].center(),
- textbboxes_[id].center(), value_);
+ mln::draw::line(ima_, g_.components()(current_vertex).bbox().pcenter(),
+ g_.components()(id).bbox().pcenter(), value_);
}
/// Treating a new vertex.
@@ -215,9 +192,6 @@ namespace scribo
/// The image where to draw.
I& ima_;
- /// Line of text bounding boxes.
- const mln::util::array<box<mln_site(I)> >& textbboxes_;
-
/// Value to be used to draw links.
mln_value(I) value_;
@@ -226,6 +200,8 @@ namespace scribo
/// Store whether a vertex has been already seen or not.
std::vector<bool> deja_vu;
+
+ G g_;
};
} // end of namespace scribo::draw::internal
@@ -245,13 +221,13 @@ namespace scribo
mln_precondition(input.is_valid());
- const component_set<L>& comp_set = links.components();
+ const component_set<L>& comps = links.components();
for_all_links(i, links)
if (links(i) != i && links(i) != 0)
{
mln_site(L)
- p1 = primitive::link::internal::compute_anchor(comp_set, i, anchor),
- p2 = primitive::link::internal::compute_anchor(comp_set, links(i), anchor);
+ p1 = primitive::link::internal::compute_anchor(comps, i, anchor),
+ p2 = primitive::link::internal::compute_anchor(comps, links(i), anchor);
mln::draw::line(input, p1, p2, value);
}
@@ -275,12 +251,12 @@ namespace scribo
inline
void
bounding_box_links(Image<I>& input_,
- const mln::util::array<mln_site(I)::vec>& mass_centers,
const object_links<L>& left_link,
const object_links<L>& right_link,
const mln_value(I)& left_link_value,
const mln_value(I)& right_link_value,
- const mln_value(I)& validated_link_value)
+ const mln_value(I)& validated_link_value,
+ anchor::Type anchor)
{
trace::entering("scribo::draw::bounding_box_links");
@@ -289,6 +265,8 @@ namespace scribo
typedef mln_site(I) P;
+ const component_set<L>& comps = left_link.components();
+
mln_dpsite(P) dleft = literal::zero;
dleft[0] = 2;
mln_dpsite(P) dright = literal::zero;
@@ -296,19 +274,26 @@ namespace scribo
for_all_links(i, left_link)
{
mln::draw::line(input,
- internal::shift_site(input, mass_centers[i], dleft),
internal::shift_site(input,
- mass_centers[left_link(i)],
+ primitive::link::internal::compute_anchor(comps, i, anchor),
+ dleft),
+ internal::shift_site(input,
+ primitive::link::internal::compute_anchor(comps, left_link(i), anchor),
dleft),
left_link_value);
+
+
mln::draw::line(input,
- internal::shift_site(input, mass_centers[i], dright),
internal::shift_site(input,
- mass_centers[right_link(i)],
- dright),
+ primitive::link::internal::compute_anchor(comps, i, anchor),
+ dleft),
+ internal::shift_site(input,
+ primitive::link::internal::compute_anchor(comps, right_link(i), anchor),
+ dleft),
right_link_value);
+
mln::util::couple<bool, unsigned>
nbh = primitive::internal::is_link_valid(left_link,
right_link,
@@ -316,78 +301,29 @@ namespace scribo
if (nbh.first())
mln::draw::line(input,
- mass_centers[i],
- mass_centers[nbh.second()],
+ primitive::link::internal::compute_anchor(comps, right_link(i), anchor),
+ primitive::link::internal::compute_anchor(comps, nbh.second(), anchor),
validated_link_value);
- input(mass_centers[i]) = validated_link_value;
}
trace::exiting("scribo::draw::bounding_box_links");
}
- template <typename I, typename L>
- inline
- void
- bounding_box_links(Image<I>& input_,
- const mln::util::array< box<mln_site(I)> >& bboxes,
- const object_links<L>& left_link,
- const object_links<L>& right_link,
- const mln_value(I)& left_link_value,
- const mln_value(I)& right_link_value,
- const mln_value(I)& validated_link_value)
- {
- trace::entering("scribo::draw::bounding_box_links");
-
- I& input = exact(input_);
- mln_precondition(input.is_valid());
-
- typedef mln_site(I) P;
- mln_site(I)::vec dleft = literal::origin;
- dleft[0] = 2;
- mln_site(I)::vec dright = literal::origin;
- dright[0] = -2;
- for_all_links(i, left_link)
- {
- mln::draw::line(input,
- bboxes[i].center() + dleft,
- bboxes[left_link(i)].center() + dleft,
- left_link_value);
-
- mln::draw::line(input,
- bboxes[i].center() + dright,
- bboxes[right_link(i)].center() + dright,
- right_link_value);
-
- mln::util::couple<bool, unsigned>
- nbh = primitive::internal::is_link_valid(left_link,
- right_link,
- i);
-
- if (nbh.first())
- mln::draw::line(input,
- bboxes[i].center(),
- bboxes[nbh.second()].center(),
- validated_link_value);
- }
-
- trace::exiting("scribo::draw::bounding_box_links");
- }
template <typename I, typename G>
inline
void
bounding_box_links(Image<I>& input,
- const mln::util::array< box<mln_site(I)> >& bboxes,
const Graph<G>& g,
const mln_value(I)& link_value)
{
trace::entering("scribo::draw::bounding_box_links");
mln_precondition(exact(input).is_valid());
- mln_precondition(exact(g).v_nmax() == bboxes.nelements());
- internal::draw_graph_edges_functor<I> f(exact(input), bboxes, link_value);
+
+ internal::draw_graph_edges_functor<I,G> f(exact(input), link_value);
mln::canvas::browsing::depth_first_search(g, f);
trace::exiting("scribo::draw::bounding_box_links");
diff --git a/scribo/draw/bounding_boxes.hh b/scribo/draw/bounding_boxes.hh
index 93f4067..d2a6384 100644
--- a/scribo/draw/bounding_boxes.hh
+++ b/scribo/draw/bounding_boxes.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -99,7 +100,7 @@ namespace scribo
mln_precondition(input.is_valid());
for_all_comps(i, components)
- if (components(i).bbox().is_valid())
+ if (components(i).is_valid())
mln::draw::box(input, components(i).bbox(), value);
trace::exiting("scribo::draw::bounding_boxes");
diff --git a/scribo/filter/object_links_non_aligned_simple.hh b/scribo/filter/object_links_non_aligned_simple.hh
index e9dc5f5..1f56d85 100644
--- a/scribo/filter/object_links_non_aligned_simple.hh
+++ b/scribo/filter/object_links_non_aligned_simple.hh
@@ -55,8 +55,7 @@ namespace scribo
\param[in] max_alpha Maximum angle value (degrees).
- Exemple with dim == 1 and anchor == 1 (bottom
- horizontal filter):
+ Exemple with anchor == 1 (bottom horizontal filter):
\verbatim
diff --git a/scribo/filter/objects_with_holes.hh b/scribo/filter/objects_with_holes.hh
index 9e781fa..fdad0d9 100644
--- a/scribo/filter/objects_with_holes.hh
+++ b/scribo/filter/objects_with_holes.hh
@@ -33,7 +33,7 @@
# include <sstream>
-# include <mln/core/concept/image.hh>
+# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/routine/extend.hh>
# include <mln/core/image/dmorph/extended.hh>
@@ -95,7 +95,7 @@ namespace scribo
inline
component_set<L>
components_with_two_holes(const component_set<L>& components,
- unsigned min_size);
+ unsigned min_size);
# ifndef MLN_INCLUDE_ONLY
@@ -129,8 +129,6 @@ namespace scribo
for_all_comps(i, components)
if (components(i).is_valid())
{
- std::cout << components(i).bbox() << std::endl;
- std::cout << components(i).tag() << std::endl;
mln_box(L) b = components(i).bbox();
b.enlarge(1);
@@ -183,10 +181,10 @@ namespace scribo
const L& lbl = components.labeled_image();
- std::cout << "components.nlabels = " << components.nelements() << std::endl;
+// std::cout << "components.nlabels = " << components.nelements() << std::endl;
- util::timer timer_;
- timer_.start();
+// util::timer timer_;
+// timer_.start();
// init
{
@@ -199,19 +197,19 @@ namespace scribo
// FIXME: Improve.
- util::timer t2;
- t2.start();
+// util::timer t2;
+// t2.start();
bboxes_ima = internal::compute_bboxes_image(components);
- float t2_ = t2;
- std::cout << "compute bboxes image " << t2_ << std::endl;
+// float t2_ = t2;
+// std::cout << "compute bboxes image " << t2_ << std::endl;
to_keep(0) = true;
}
- float t_ = timer_;
- std::cout << "init = " << t_ << std::endl;
+// float t_ = timer_;
+// std::cout << "init = " << t_ << std::endl;
// 1st pass
- timer_.restart();
+// timer_.restart();
{
util::array<int> dp = positive_offsets_wrt(lbl, nbh);
const unsigned n_nbhs = dp.nelements();
@@ -241,14 +239,14 @@ namespace scribo
} // for_all(pxl)
}
- t_ = timer_;
- std::cout << "1st pass = " << t_ << std::endl;
+// t_ = timer_;
+// std::cout << "1st pass = " << t_ << std::endl;
// FIXME: Iterate over another label when a label is marked as
// "to be kept".
// 2nd pass
- timer_.restart();
+// timer_.restart();
{
unsigned kept = 0;
mln_fwd_pixter(const L) pxl(bboxes_ima); // Forward.
@@ -293,15 +291,15 @@ namespace scribo
// }
}
- float t_ = timer_;
- std::cout << "2nd pass = " << t_ << std::endl;
+// float t_ = timer_;
+// std::cout << "2nd pass = " << t_ << std::endl;
- std::cout << "kept = " << kept << std::endl;
+// std::cout << "kept = " << kept << std::endl;
// debug::println(parent);
// std::cout << bg_comps << std::endl;
// std::cout << to_keep << std::endl;
- timer_.restart();
+// timer_.restart();
if (kept == components.nelements())
{
@@ -311,8 +309,8 @@ namespace scribo
component_set<L> output = components.duplicate();
output.update_tags(to_keep, component::Ignored);
- t_ = timer_;
- std::cout << "init output = " << t_ << std::endl;
+// t_ = timer_;
+// std::cout << "init output = " << t_ << std::endl;
trace::exiting("scribo::filter::objects_with_holes");
return output;
@@ -330,7 +328,7 @@ namespace scribo
{
trace::entering("scribo::filter::objects_with_holes");
- std::cout << components.nelements() << std::endl;
+// std::cout << components.nelements() << std::endl;
typedef component_set<L> O;
neighb2d nbh = c8();
@@ -366,7 +364,7 @@ namespace scribo
}
// 1st pass
- std::cout << "1st pass" << std::endl;
+// std::cout << "1st pass" << std::endl;
{
util::array<int> dp = positive_offsets_wrt(lbl, nbh);
const unsigned n_nbhs = dp.nelements();
@@ -398,7 +396,7 @@ namespace scribo
}
// 2nd pass
- std::cout << "2nd pass" << std::endl;
+// std::cout << "2nd pass" << std::endl;
{
unsigned kept = 0;
mln_fwd_pixter(const L) pxl(bboxes_ima); // Forward.
@@ -458,118 +456,6 @@ namespace scribo
}
-
-// template <typename L>
-// inline
-// component_set<L>
-// objects_with_holes(const component_set<L>& components,
-// unsigned min_holes_count)
-// {
-// trace::entering("scribo::filter::objects_with_holes");
-
-// mln_precondition(components.is_valid());
-
-
-// L bboxes_ima;
-// initialize(bboxes_ima, components);
-// data::fill(bboxes_ima, literal::zero);
-
-// for_all_components(i, components.bboxes())
-// mln::draw::box(bboxes_ima, components.bbox(i), i);
-
-// util::array<util::set<mln_value(L)> > first_bg_comp(
-// static_cast<unsigned>(components.nlabels()) + 1);
-
-// fun::i2v::array<bool>
-// to_keep(static_cast<unsigned>(components.nlabels()) + 1,
-// false);
-// to_keep(0) = true;
-
-// mln_value(L) nbglabels;
-// L bg_lbl = labeling::background(components, c8(), nbglabels);
-
-// unsigned kept;
-// mln_piter(L) p(bboxes_ima.domain());
-// for_all(p)
-// {
-// if (bboxes_ima(p) == literal::zero)
-// continue;
-
-// if (bg_lbl(p) != 0)
-// if (! first_bg_comp(bboxes_ima(p)).has(bg_lbl(p)))
-// if (first_bg_comp(bboxes_ima(p)).nelements() < min_holes_count - 1)
-// first_bg_comp(bboxes_ima(p)).insert(bg_lbl(p));
-// else
-// {
-// to_keep(bboxes_ima(p)) == true;
-// ++kept;
-// }
-// }
-
-// component_set<L> output;
-// if (kept == components.nlabels())
-// output = components;
-// else
-// output = internal::compute(components, to_keep);
-
-// trace::exiting("scribo::filter::objects_with_holes");
-// return output;
-// }
-
-
- template <typename L>
- inline
- component_set<L>
- objects_with_holes_slow(const component_set<L>& components,
- unsigned min_holes_count)
- {
- trace::entering("scribo::filter::objects_with_holes");
-
- mln_precondition(components.is_valid());
-
- fun::i2v::array<bool>
- to_keep(static_cast<unsigned>(components.nlabels()) + 1,
- true);
-
- bool to_remove = false;
- for_all_comps(i, components)
- if (components(i).tag() != component::Ignored)
- {
- mln_domain(L) b = components(i).bbox();
- b.enlarge(1);
-
- mln_ch_value(L, bool) tmp(b);
- data::fill(tmp, true);
- data::fill((tmp | ((components | components.bbox(i)) | (pw::value(components) == pw::cst(i))).domain()).rw(), false);
-
- typedef accu::math::count<mln_value(L)> accu_t;
- mln_value(L) nlabels;
- util::array<unsigned> counts
- = labeling::blobs_and_compute(tmp,
- c8(), nlabels,
- accu_t()).second();
- unsigned nholes = 0;
- for_all_comp_data(j, counts)
- if (counts(j) > 4u)
- ++nholes;
-
- if (nholes < min_holes_count)
- {
- to_keep(i) = false;
- to_remove = true;
- }
- }
-
- component_set<L> output;
- if (! to_remove)
- output = components;
- else
- output = internal::compute(components, to_keep);
-
- trace::exiting("scribo::filter::objects_with_holes");
- return output;
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::filter
diff --git a/scribo/primitive/extract/lines_pattern.hh b/scribo/primitive/extract/lines_pattern.hh
index bc23012..c68b577 100644
--- a/scribo/primitive/extract/lines_pattern.hh
+++ b/scribo/primitive/extract/lines_pattern.hh
@@ -58,7 +58,6 @@ namespace scribo
using namespace mln;
-
/// Extract lines with a specific pattern
///
/// \param[in] input_ A binary image.
@@ -109,7 +108,7 @@ namespace scribo
initialize(output, input);
mln_piter(I) p(input.domain());
- mln_qiter(window2d) q(win, p);
+ mln_qiter(W) q(win, p);
bool is_foreground;
for_all(p)
{
diff --git a/scribo/primitive/link/internal/find_several_links.hh b/scribo/primitive/link/internal/find_several_links.hh
index d379021..8cca3bd 100644
--- a/scribo/primitive/link/internal/find_several_links.hh
+++ b/scribo/primitive/link/internal/find_several_links.hh
@@ -91,10 +91,10 @@ namespace scribo
functor.initialize_link(current_object); // <-- initialize_link
- for (unsigned anchor_ = 0; anchor_ < functor.nanchors(); ++anchor_) // <-- nanchor
+ for_all_anchors(a, functor.anchors()) // <-- nanchor && anchors
{
// FIXME : See fixme at the beginning of this file.
- anchor::Type anchor = static_cast<anchor::Type>(anchor_);
+ anchor::Type anchor = functor.anchors()[a];
mln_site(scribo_support_(F))
start_point = functor.start_point(current_object, anchor), // <-- start_point
@@ -102,7 +102,7 @@ namespace scribo
mln_postcondition(p == start_point);
- while (functor.objects().domain().has(p)
+ while (functor.labeled_image().domain().has(p)
&& ! functor.is_potential_link(current_object,
start_point, p) // <-- is_potential_link
&& functor.verify_link_criterion(current_object,
diff --git a/scribo/primitive/link/internal/link_functor_base.hh b/scribo/primitive/link/internal/link_functor_base.hh
index f2641ad..ad3d71b 100644
--- a/scribo/primitive/link/internal/link_functor_base.hh
+++ b/scribo/primitive/link/internal/link_functor_base.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -72,15 +73,10 @@ namespace scribo
typedef mln_site(L) P;
typedef mln::util::couple<anchor::Type, P> couple_t;
- link_functor_base(const component_set<L>& components, unsigned nanchors);
-
/// \overload
- /// \p nanchors is set to 1.
link_functor_base(const component_set<L>& components);
- unsigned nanchors() const;
-
const object_links<L>& links() const;
unsigned link(unsigned object) const;
@@ -171,11 +167,12 @@ namespace scribo
mln_site(L) start_point_(unsigned current_object,
anchor::Type anchor);
+ const L& labeled_image() const;
+
protected:
object_links<L> links_;
const component_set<L> components_;
const L& labeled_image_;
- unsigned nanchors_;
};
@@ -186,25 +183,10 @@ namespace scribo
template <typename L, typename E>
inline
link_functor_base<L,E>::link_functor_base(
- const component_set<L>& components,
- unsigned nanchors)
- : links_(components),
- components_(components),
- labeled_image_(this->components_.labeled_image()),
- nanchors_(nanchors)
- {
- links_.init();
- }
-
-
- template <typename L, typename E>
- inline
- link_functor_base<L,E>::link_functor_base(
const component_set<L>& components)
: links_(components),
components_(components),
- labeled_image_(this->components_.labeled_image()),
- nanchors_(1)
+ labeled_image_(this->components_.labeled_image())
{
links_.init();
}
@@ -212,15 +194,6 @@ namespace scribo
template <typename L, typename E>
inline
- unsigned
- link_functor_base<L,E>::nanchors() const
- {
- return nanchors_;
- }
-
-
- template <typename L, typename E>
- inline
const object_links<L>&
link_functor_base<L,E>::links() const
{
@@ -403,6 +376,14 @@ namespace scribo
}
+ template <typename L, typename E>
+ inline
+ const L&
+ link_functor_base<L,E>::labeled_image() const
+ {
+ return labeled_image_;
+ }
+
// Default implementation for delegated methods.
diff --git a/scribo/primitive/link/internal/link_several_dmax_base.hh b/scribo/primitive/link/internal/link_several_dmax_base.hh
index e1f42ff..3b4ec4b 100644
--- a/scribo/primitive/link/internal/link_several_dmax_base.hh
+++ b/scribo/primitive/link/internal/link_several_dmax_base.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,8 +29,11 @@
/// \file
///
-/// Base class for link functors using mass centers and a given max
-/// distance.
+/// Base class for link functors using several anchors and a maximum
+/// lookup distance.
+///
+/// FIXME: make it more generic to support different
+/// anchor::Direction.
# include <mln/accu/center.hh>
@@ -60,8 +64,8 @@ namespace scribo
namespace internal
{
- /// \brief Base class for link functors using mass centers and
- /// a given max distance.
+ /// \brief Base class for link functors using several anchors
+ /// and a maximum lookup distance.
//
template <typename L, typename E>
class link_several_dmax_base
@@ -74,14 +78,14 @@ namespace scribo
public:
- link_several_dmax_base(const object_image(L)& objects,
- unsigned neighb_max_distance,
- unsigned nanchors);
+ link_several_dmax_base(const component_set<L>& comps,
+ unsigned neighb_max_distance);
bool verify_link_criterion_(unsigned current_object,
- const P& start_point, const P& p) const;
+ const P& start_point,
+ const P& p) const;
void start_processing_object_(unsigned current_object);
@@ -91,13 +95,17 @@ namespace scribo
void initialize_link_(unsigned current_object);
couple_t finalize_link_(unsigned current_object);
-
+ unsigned nanchors() const;
+ const util::array<anchor::Type>& anchors() const;
protected:
- mln::util::array<ms_t> mass_centers_;
+ mln::util::array<anchor::Type> anchors_;
mln::util::array<couple_t> potential_links_;
float dmax_;
float neighb_max_distance_;
+ anchor::Direction direction_;
+
+ using super_::labeled_image_;
};
@@ -107,17 +115,17 @@ namespace scribo
template <typename L, typename E>
inline
link_several_dmax_base<L, E>::link_several_dmax_base(
- const object_image(L)& objects,
- unsigned neighb_max_distance,
- unsigned nanchors)
+ const component_set<L>& comps,
+ unsigned neighb_max_distance)
- : super_(objects, nanchors),
+ : super_(comps),
dmax_(0),
- neighb_max_distance_(neighb_max_distance)
+ neighb_max_distance_(neighb_max_distance),
+ direction_(anchor::Horizontal) // FIXME: make it an
+ // argument when this
+ // functor is generic
+ // enough..
{
-
- mass_centers_ = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
}
template <typename L, typename E>
@@ -130,7 +138,7 @@ namespace scribo
{
(void) current_object;
- float dist = math::abs(p.col() - start_point.col());
+ float dist = math::abs(p[direction_] - start_point[direction_]);
return dist <= dmax_; // Not too far
}
@@ -142,8 +150,8 @@ namespace scribo
unsigned current_object)
{
float
- midcol = (this->objects_.bbox(current_object).pmax().col()
- - this->objects_.bbox(current_object).pmin().col()) / 2;
+ midcol = (this->components_(current_object).bbox().pmax()[direction_]
+ - this->components_(current_object).bbox().pmin()[direction_]) / 2;
dmax_ = midcol + neighb_max_distance_;
}
@@ -168,7 +176,6 @@ namespace scribo
link_several_dmax_base<L, E>::initialize_link_(unsigned current_object)
{
(void) current_object;
- this->links_.clear();
this->potential_links_.clear();
}
@@ -188,8 +195,8 @@ namespace scribo
{
for(unsigned i = 0; i < this->potential_links_.nelements(); ++i)
{
- tmp = math::abs(this->objects_.bbox(current_object).pmax().col()
- - this->potential_links_(i).second().col());
+ tmp = math::abs(this->components_(current_object).bbox().pmax()[direction_]
+ - this->potential_links_(i).second()[direction_]);
dist.append(tmp);
if (tmp < min)
min = tmp;
@@ -198,6 +205,9 @@ namespace scribo
mln_assertion(min != mln_max(unsigned));
// Keep closest links and compute vertical overlap.
+ //
+ // FIXME: not using direction_ attribute. This code is not
+ // generic enough!
unsigned
nratio = 0,
id_max_ratio = 0;
@@ -207,17 +217,17 @@ namespace scribo
if (dist[i] < (1.2 * min))
{
unsigned
- other_object = this->objects_(potential_links_(i).second());
+ other_object = labeled_image_(potential_links_(i).second());
nbh_id = other_object;
float
dr
- = math::min(this->objects_.bbox(current_object).pmax().row(),
- this->objects_.bbox(other_object).pmax().row())
- - math::min(this->objects_.bbox(current_object).pmin().row(),
- this->objects_.bbox(other_object).pmin().row()),
- dh = this->objects_.bbox(other_object).pmax().row()
- - this->objects_.bbox(other_object).pmin().row(),
+ = math::min(this->components_(current_object).bbox().pmax().row(),
+ this->components_(other_object).bbox().pmax().row())
+ - math::min(this->components_(current_object).bbox().pmin().row(),
+ this->components_(other_object).bbox().pmin().row()),
+ dh = this->components_(other_object).bbox().pmax().row()
+ - this->components_(other_object).bbox().pmin().row(),
ratio = dr / dh;
overlap.append(ratio);
@@ -237,7 +247,7 @@ namespace scribo
if (nratio == 1)
{
this->links_(current_object)
- = this->objects_(potential_links_(id_max_ratio).second());
+ = labeled_image_(potential_links_(id_max_ratio).second());
return potential_links_(id_max_ratio);
}
@@ -249,6 +259,23 @@ namespace scribo
}
+ template <typename L, typename E>
+ inline
+ const util::array<anchor::Type>&
+ link_several_dmax_base<L, E>::anchors() const
+ {
+ return anchors_;
+ }
+
+ template <typename L, typename E>
+ inline
+ unsigned
+ link_several_dmax_base<L,E>::nanchors() const
+ {
+ return anchors_.nelements();
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh b/scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh
index 23adfc2..0eedbb8 100644
--- a/scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh
+++ b/scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh
@@ -46,12 +46,14 @@
# include <scribo/core/macros.hh>
# include <scribo/core/component_set.hh>
# include <scribo/core/object_links.hh>
+# include <scribo/core/object_groups.hh>
# include <scribo/filter/object_links_bbox_h_ratio.hh>
-# include <scribo/primitive/link/internal/find_link.hh>
-# include <scribo/primitive/link/internal/link_single_dmax_base.hh>
+# include <scribo/primitive/link/with_single_left_link.hh>
# include <scribo/primitive/link/compute.hh>
+# include <scribo/primitive/group/apply.hh>
+# include <scribo/primitive/group/from_single_link.hh>
namespace scribo
diff --git a/scribo/src/contest/hdibco-2010/Makefile.am b/scribo/src/contest/hdibco-2010/Makefile.am
index 44add64..a59e424 100644
--- a/scribo/src/contest/hdibco-2010/Makefile.am
+++ b/scribo/src/contest/hdibco-2010/Makefile.am
@@ -19,9 +19,7 @@
include $(top_srcdir)/scribo/tests/tests.mk
-check_PROGRAMS = sauvola_ms_hdibco
+bin_PROGRAMS = sauvola_ms_hdibco
sauvola_ms_hdibco_SOURCES = sauvola_ms_hdibco.cc
-
-TESTS = $(check_PROGRAMS)
diff --git a/scribo/src/debug/show_links_single_left.cc b/scribo/src/debug/show_links_single_left.cc
index 26f78e2..8c55afc 100644
--- a/scribo/src/debug/show_links_single_left.cc
+++ b/scribo/src/debug/show_links_single_left.cc
@@ -41,7 +41,7 @@
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
-#include <scribo/primitive/link/internal/link_ms_dmax_base.hh>
+#include <scribo/primitive/link/internal/link_single_dmax_base.hh>
#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
diff --git a/scribo/table/internal/align_lines.hh b/scribo/table/internal/align_lines.hh
index 9af00fc..01f9c39 100644
--- a/scribo/table/internal/align_lines.hh
+++ b/scribo/table/internal/align_lines.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -41,6 +42,7 @@
# include <mln/math/round.hh>
# include <scribo/core/macros.hh>
+# include <scribo/core/component_set.hh>
namespace scribo
@@ -93,12 +95,13 @@ namespace scribo
** and all bboxes referenced in this set are aligned on the same row or col.
**
*/
- template <typename P>
+ template <typename L>
mln::util::array<int>
align_lines(unsigned nsites,
int min_coord,
int max_coord,
- mln::util::array<box<P> >& line_bboxes,
+ const component_set<L>& lines,
+ component_set<L>& aligned_lines,
unsigned dim,
unsigned max_alignment_diff);
@@ -107,12 +110,13 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
- template <typename P>
+ template <typename L>
mln::util::array<int>
align_lines(unsigned nsites,
int min_coord,
int max_coord,
- mln::util::array<box<P> >& line_bboxes,
+ const component_set<L>& lines,
+ component_set<L>& aligned_lines,
unsigned dim,
unsigned max_alignment_diff)
{
@@ -120,58 +124,57 @@ namespace scribo
mln_precondition(nsites > 0);
- mln::util::array< mln::util::set<unsigned> > lines;
+ mln::util::array< mln::util::set<unsigned> > rlines;
lines.resize(nsites);
// Map components with actual lines.
- for_all_comps(i, line_bboxes)
+ for_all_comps(i, lines)
{
- int minline = line_bboxes[i].pmin()[dim] - max_alignment_diff;
+ int minline = lines(i).bbox().pmin()[dim] - max_alignment_diff;
minline = (minline < min_coord ? min_coord : minline);
- int maxline = line_bboxes[i].pmax()[dim] + max_alignment_diff;
+ int maxline = lines(i).bbox().pmax()[dim] + max_alignment_diff;
maxline = (maxline > max_coord ? max_coord : maxline);
for (int line = minline;
line <= maxline; ++line)
- lines[line].insert(i);
+ rlines[line].insert(i);
}
// Init box2line
- mln::util::array<int> box2line;
- box2line.resize(line_bboxes.nelements());
- for_all_elements(i, box2line)
- box2line[i] = -1;
+ mln::util::array<int>
+ box2line(unsigned(lines.nelements()) + 1, -1);
// Find the line with the highest element count.
unsigned max_nelts = 0;
- for_all_elements(i, lines)
- if (max_nelts < lines[i].nelements())
- max_nelts = lines[i].nelements();
+ for_all_elements(i, rlines)
+ if (max_nelts < rlines[i].nelements())
+ max_nelts = rlines[i].nelements();
// Aligning lines
// FIXME: not optimal... Make it faster!
// We may do too much iterations (while loop) and some of them may
// be done for nothing...
+ aligned_lines = duplicate(lines);
mln::util::array<int> newlines;
math::round<int> round;
while (max_nelts > 0)
{
- for_all_elements(i, lines)
- if (lines[i].nelements() == max_nelts)
+ for_all_elements(i, rlines)
+ if (rlines[i].nelements() == max_nelts)
{
accu::stat::mean<unsigned> mean;
- for_all_elements(j, lines[i])
- if (box2line[lines[i][j]] == -1)
- mean.take(line_bboxes[lines[i][j]].center()[dim]);
+ for_all_elements(j, rlines[i])
+ if (box2line[rlines[i][j]] == -1)
+ mean.take(lines(rlines[i][j]).bbox().pcenter()[dim]);
if (mean.is_valid())
{
for_all_elements(j, lines[i])
- if (box2line[lines[i][j]] == -1)
+ if (box2line[rlines[i][j]] == -1)
{
- line_bboxes[lines[i][j]].pmin()[dim] = round(mean.to_result());
- line_bboxes[lines[i][j]].pmax()[dim] = round(mean.to_result());
- box2line[lines[i][j]] = round(mean.to_result());
+ lines(rlines[i][j]).bbox().pmin()[dim] = round(mean.to_result());
+ lines(rlines[i][j]).bbox().pmax()[dim] = round(mean.to_result());
+ box2line[rlines[i][j]] = round(mean.to_result());
}
newlines.append(round(mean.to_result()));
}
diff --git a/scribo/table/rebuild.hh b/scribo/table/rebuild.hh
index c4029cf..f593153 100644
--- a/scribo/table/rebuild.hh
+++ b/scribo/table/rebuild.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -71,29 +72,29 @@ namespace scribo
** cell is labeled. The second argument are the aligned and connected
** table line bounding boxes.
*/
- template <typename I, typename V>
- mln::util::couple<mln_ch_value(I,V),
- mln::util::couple<mln::util::array<box<mln_site(I)> >,
- mln::util::array<box<mln_site(I)> > > >
+ template <typename I, typename L>
+ mln::util::couple<L,
+ mln::util::couple<component_set<L>,
+ component_set<L> > >
rebuild(const Image<I>& input_,
- const mln::util::couple<mln::util::array<box<mln_site(I)> >,
- mln::util::array<box<mln_site(I)> > >& linebboxes_,
+ const component_set<L>& vlines,
+ const component_set<L>& hlines,
unsigned max_dist_lines,
- V& ncells);
+ mln_value(L)& ncells);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename V>
- mln::util::couple<mln_ch_value(I,V),
- mln::util::couple<mln::util::array<box<mln_site(I)> >,
- mln::util::array<box<mln_site(I)> > > >
+ template <typename I, typename L>
+ mln::util::couple<L,
+ mln::util::couple<component_set<L>,
+ component_set<L> > >
rebuild(const Image<I>& input_,
- const mln::util::couple<mln::util::array<box<mln_site(I)> >,
- mln::util::array<box<mln_site(I)> > >& linebboxes_,
+ const component_set<L>& vlines,
+ const component_set<L>& hlines,
unsigned max_dist_lines,
- V& ncells)
+ mln_value(L)& ncells)
{
trace::entering("scribo::table::rebuild");
const I& input = exact(input_);
@@ -101,34 +102,33 @@ namespace scribo
mlc_equal(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
- mln::util::couple<mln::util::array<box<mln_site(I)> >,
- mln::util::array<box<mln_site(I)> > > linebboxes = linebboxes_;
-
- scribo::debug::save_table_image(input, linebboxes,
+# ifndef SCRIBO_DEBUG
+ scribo::debug::save_table_image(input, vlines, hlines,
literal::red, "table-raw.ppm");
+# endif
- mln::util::array<int> rows = align_lines_horizontaly(input, linebboxes.second(), 5);
- mln::util::array<int> cols = align_lines_verticaly(input, linebboxes.first(), 5);
+ mln::util::array<int> rows = align_lines_horizontaly(input, vlines, 5);
+ mln::util::array<int> cols = align_lines_verticaly(input, hlines, 5);
-# ifndef SCRIBO_NDEBUG
- scribo::debug::save_table_image(input, linebboxes,
+# ifndef SCRIBO_DEBUG
+ scribo::debug::save_table_image(input, vlines, hlines,
literal::red, "table-aligned.ppm");
# endif
- repair_vertical_lines(input, linebboxes, 10);
- repair_horizontal_lines(input, linebboxes, 10);
+ repair_vertical_lines(input, vlines, 10);
+ repair_horizontal_lines(input, hlines, 10);
-# ifndef SCRIBO_NDEBUG
- scribo::debug::save_table_image(input, linebboxes,
+# ifndef SCRIBO_DEBUG
+ scribo::debug::save_table_image(input, vlines, hlines,
literal::red, "table-repaired.ppm");
# endif
// Connect vertical lines with horizontal lines.
- connect_vertical_lines(rows, linebboxes, input, max_dist_lines);
- connect_horizontal_lines(cols, linebboxes, input, max_dist_lines);
+ connect_vertical_lines(rows, vlines, hlines, input, max_dist_lines);
+ connect_horizontal_lines(cols, vlines, hlines, input, max_dist_lines);
-# ifndef SCRIBO_NDEBUG
- scribo::debug::save_table_image(input, linebboxes,
+# ifndef SCRIBO_DEBUG
+ scribo::debug::save_table_image(input, vlines, hlines,
literal::red, "table-connected.ppm");
# endif
@@ -136,15 +136,16 @@ namespace scribo
mln_ch_value(I,bool) res;
initialize(res, input);
data::fill(res, false);
- for_all_elements(i, linebboxes.first())
- mln::draw::box(res, linebboxes.first()[i], true);
- for_all_elements(i, linebboxes.second())
- mln::draw::box(res, linebboxes.second()[i], true);
+ for_all_comps(i, vlines)
+ mln::draw::box(res, vlines(i).bbox(), true);
+ for_all_comps(i, hlines)
+ mln::draw::box(res, hlines(i).bbox(), true);
- mln_ch_value(I,V) lbl = labeling::background(res, c8(), ncells);
+ L lbl = labeling::background(res, c8(), ncells);
trace::exiting("scribo::table::rebuild");
- return mln::make::couple(lbl, linebboxes);
+ return mln::make::couple(lbl,
+ mln::make::couple(vlines, hlines));
}
--
1.5.6.5
1
0

last-svn-commit-431-g8559cd7 Add missing includes and headers in AFP's dedicated code.
by Guillaume Lazzara 09 Aug '10
by Guillaume Lazzara 09 Aug '10
09 Aug '10
* src/afp/components.hh,
* src/afp/link.hh,
* src/afp/regroup.hh: Add missing includes and headers.
---
scribo/ChangeLog | 8 +++++
scribo/src/afp/components.hh | 69 +++++++++++++++++++++++++++++++-----------
scribo/src/afp/link.hh | 49 ++++++++++++++++++++++++++---
scribo/src/afp/regroup.hh | 36 ++++++++++++++++++++++
4 files changed, 139 insertions(+), 23 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index d346428..e0da752 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,13 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add missing includes and headers in AFP's dedicated code.
+
+ * src/afp/components.hh,
+ * src/afp/link.hh,
+ * src/afp/regroup.hh: Add missing includes and headers.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add new routines in Scribo.
* debug/highlight_text_area.hh,
diff --git a/scribo/src/afp/components.hh b/scribo/src/afp/components.hh
index fd463eb..7359d16 100644
--- a/scribo/src/afp/components.hh
+++ b/scribo/src/afp/components.hh
@@ -1,21 +1,53 @@
-#include <mln/io/pbm/load.hh>
-#include <mln/io/pgm/save.hh>
-
-#include <mln/extension/adjust.hh>
-#include <mln/extension/fill.hh>
-#include <mln/data/fill.hh>
-#include <mln/accu/shape/bbox.hh>
-
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/core/image/dmorph/image_if.hh>
-#include <mln/pw/value.hh>
-#include <mln/debug/println.hh>
-
-#include <mln/util/timer.hh>
-#include <mln/labeling/foreground.hh>
-#include <mln/labeling/wrap.hh>
-#include <mln/extension/fill.hh>
-#include <mln/data/compare.hh>
+// Copyright (C) 2010 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_SRC_AFP_COMPONENTS_HH
+# define SCRIBO_SRC_AFP_COMPONENTS_HH
+
+/// \file
+///
+/// Specific implementation for AFP use case.
+
+# include <mln/io/pbm/load.hh>
+# include <mln/io/pgm/save.hh>
+
+# include <mln/extension/adjust.hh>
+# include <mln/extension/fill.hh>
+# include <mln/data/fill.hh>
+# include <mln/accu/shape/bbox.hh>
+
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/core/image/dmorph/image_if.hh>
+# include <mln/pw/value.hh>
+# include <mln/debug/println.hh>
+
+# include <mln/util/timer.hh>
+# include <mln/labeling/foreground.hh>
+# include <mln/labeling/wrap.hh>
+# include <mln/extension/fill.hh>
+# include <mln/data/compare.hh>
namespace mln
@@ -193,3 +225,4 @@ namespace mln
} // mln
+#endif // ! SCRIBO_SRC_AFP_COMPONENTS_HH
diff --git a/scribo/src/afp/link.hh b/scribo/src/afp/link.hh
index fc23991..dfcde88 100644
--- a/scribo/src/afp/link.hh
+++ b/scribo/src/afp/link.hh
@@ -1,8 +1,43 @@
-#include <mln/geom/ncols.hh>
-#include <mln/geom/nrows.hh>
-#include <mln/util/couple.hh>
-#include <scribo/core/component_set.hh>
-#include <scribo/core/macros.hh>
+// Copyright (C) 2010 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_SRC_AFP_LINK_HH
+# define SCRIBO_SRC_AFP_LINK_HH
+
+/// \file
+///
+/// Specific implementation for AFP use case.
+
+# include <mln/geom/ncols.hh>
+# include <mln/geom/nrows.hh>
+# include <mln/util/couple.hh>
+# include <mln/math/max.hh>
+
+# include <scribo/core/object_links.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/core/macros.hh>
namespace scribo
{
@@ -13,6 +48,8 @@ namespace scribo
namespace link
{
+ using namespace mln;
+
template <typename L>
util::couple<object_links<L>, object_links<L> >
@@ -137,3 +174,5 @@ namespace scribo
} // end of namespace scribo::primitive
} // end of namespace scribo
+
+#endif // ! SCRIBO_SRC_AFP_LINK_HH
diff --git a/scribo/src/afp/regroup.hh b/scribo/src/afp/regroup.hh
index 44b5438..aacde7e 100644
--- a/scribo/src/afp/regroup.hh
+++ b/scribo/src/afp/regroup.hh
@@ -1,6 +1,40 @@
+// Copyright (C) 2010 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_SRC_AFP_REGROUP_HH
+# define SCRIBO_SRC_AFP_REGROUP_HH
+
+/// \file
+///
+/// Specific implementation for AFP use case.
+
#include <mln/geom/ncols.hh>
#include <mln/geom/nrows.hh>
#include <mln/util/couple.hh>
+
+#include <scribo/core/object_groups.hh>
#include <scribo/core/component_set.hh>
#include <scribo/core/macros.hh>
@@ -81,3 +115,5 @@ namespace scribo
} // end of namespace scribo::primitive
} // end of namespace scribo
+
+#endif // ! SCRIBO_SRC_AFP_REGROUP_HH
--
1.5.6.5
1
0
* debug/highlight_text_area.hh,
* debug/save_bboxes_image.hh: Add a new overload.
* debug/save_comp_diff.hh,
* debug/text_areas_image.hh,
* primitive/regroup/from_single_left_link_wrt_h_ratio.hh: New.
---
scribo/ChangeLog | 11 ++
scribo/debug/highlight_text_area.hh | 50 ++++++++
scribo/debug/save_bboxes_image.hh | 34 +++++-
scribo/debug/save_comp_diff.hh | 105 ++++++++++++++++
scribo/debug/text_areas_image.hh | 131 ++++++++++++++++++++
...ink.hh => from_single_left_link_wrt_h_ratio.hh} | 45 ++++---
6 files changed, 356 insertions(+), 20 deletions(-)
create mode 100644 scribo/debug/save_comp_diff.hh
create mode 100644 scribo/debug/text_areas_image.hh
copy scribo/primitive/regroup/{from_single_left_link.hh => from_single_left_link_wrt_h_ratio.hh} (73%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 3b441f7..d346428 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,16 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new routines in Scribo.
+
+ * debug/highlight_text_area.hh,
+ * debug/save_bboxes_image.hh: Add a new overload.
+
+ * debug/save_comp_diff.hh,
+ * debug/text_areas_image.hh,
+ * primitive/regroup/from_single_left_link_wrt_h_ratio.hh: New.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Remove deprecated files.
* core/internal/link_functor_base.hh,
diff --git a/scribo/debug/highlight_text_area.hh b/scribo/debug/highlight_text_area.hh
index 5ab15b9..1ff673e 100644
--- a/scribo/debug/highlight_text_area.hh
+++ b/scribo/debug/highlight_text_area.hh
@@ -45,6 +45,7 @@
# include <scribo/core/component_set.hh>
# include <scribo/core/line_set.hh>
+# include <mln/geom/rotate.hh>
namespace scribo
{
@@ -244,6 +245,55 @@ namespace scribo
}
+ template <typename I, typename L>
+ mln_ch_value(I, value::rgb8)
+ highlight_text_area_rotated(const Image<I>& input_,
+ const scribo::component_set<L>& components,
+ double angle, box2d rb)
+ {
+ trace::entering("scribo::debug::highlight_text_area");
+
+ const I& input = exact(input_);
+
+ mln_precondition(input.is_valid());
+ mlc_is(mln_value(I), value::rgb8)::check();
+
+ typedef mln_ch_value(I, bool) mask_t;
+ mask_t mask;
+ initialize(mask, input);
+ data::fill(mask, false);
+
+ mln::util::array<mln_box(I)> bbox(unsigned(components.nelements()) + 1);
+
+ for_all_comps(i, components)
+ if (components(i).is_valid())
+ {
+ bbox(i) = components(i).bbox();
+ bbox(i).pmin().row() += rb.pmin().row();
+ bbox(i).pmin().col() += rb.pmin().col();
+ bbox(i).pmax().row() += rb.pmin().row();
+ bbox(i).pmax().col() += rb.pmin().col();
+
+ bbox(i) = mln::geom::rotate(bbox(i), - angle,
+ input.domain().pcenter());
+ }
+
+ for_all_comps(i, components)
+ if (components(i).is_valid())
+ data::fill((mask | bbox(i)).rw(), true);
+
+ internal::mask_non_text<mask_t, mln_value(I)> f(mask);
+ mln_ch_value(I, value::rgb8) output = data::transform(input, f);
+
+ for_all_comps(i, components)
+ if (components(i).is_valid())
+ mln::draw::box(output, bbox(i), literal::red);
+
+ trace::exiting("scribo::debug::highlight_text_area");
+ return output;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/debug/save_bboxes_image.hh b/scribo/debug/save_bboxes_image.hh
index f406e08..ee781c1 100644
--- a/scribo/debug/save_bboxes_image.hh
+++ b/scribo/debug/save_bboxes_image.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -76,6 +77,14 @@ namespace scribo
const line_set<L>& lines,
const std::string& filename);
+ /// \overload.
+ template <typename I, typename L>
+ inline
+ void
+ save_bboxes_image(const Image<I>& input,
+ const component_set<L>& comps,
+ const std::string& filename,
+ const value::rgb8& value);
# ifndef MLN_INCLUDE_ONLY
@@ -132,6 +141,29 @@ namespace scribo
}
+ template <typename I, typename L>
+ inline
+ void
+ save_bboxes_image(const Image<I>& input,
+ const component_set<L>& comps,
+ const std::string& filename,
+ const value::rgb8& value)
+ {
+ trace::entering("scribo::debug::save_bboxes_image");
+ mln_precondition(exact(input).is_valid());
+
+ mln_ch_value(I, value::rgb8)
+ output = data::convert(value::rgb8(), input);
+
+ for_all_comps(c, comps)
+ if (comps(c).is_valid())
+ mln::draw::box(output, comps(c).bbox(), value);
+
+ mln::io::ppm::save(output, filename);
+ trace::exiting("scribo::debug::save_bboxes_image");
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::debug
diff --git a/scribo/debug/save_comp_diff.hh b/scribo/debug/save_comp_diff.hh
new file mode 100644
index 0000000..f1f93f0
--- /dev/null
+++ b/scribo/debug/save_comp_diff.hh
@@ -0,0 +1,105 @@
+// Copyright (C) 2009, 2010 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_DEBUG_SAVE_COMP_DIFF_HH
+# define SCRIBO_DEBUG_SAVE_COMP_DIFF_HH
+
+/// \file
+///
+/// Show the difference between two object images.
+
+# include <mln/core/image/image2d.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/data/fill.hh>
+# include <mln/labeling/colorize.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/io/ppm/save.hh>
+# include <mln/literal/black.hh>
+# include <mln/literal/colors.hh>
+# include <mln/pw/all.hh>
+# include <mln/core/image/dmorph/image_if.hh>
+
+# include <scribo/core/macros.hh>
+# include <scribo/core/component_set.hh>
+
+namespace scribo
+{
+
+ namespace debug
+ {
+
+ using namespace mln;
+
+ /*! \brief Show the difference between two object images.
+
+ \param[in] lbl A component set.
+ \param[in] lbl_2 Another component set.
+ \param[in] filename The output filename.
+
+ */
+ template <typename L, typename L2>
+ void
+ save_comp_diff(const component_set<L>& cset_1,
+ const component_set<L2>& cset_2,
+ const std::string& filename);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename L, typename L2>
+ void
+ save_comp_diff(const component_set<L>& cset_1,
+ const component_set<L2>& cset_2,
+ const std::string& filename)
+ {
+ trace::entering("scribo::debug::save_comp_diff");
+
+ image2d<value::rgb8> output;
+ initialize(output, cset_1.labeled_image());
+
+ data::fill(output, literal::black);
+
+ for_all_comps(i, cset_1)
+ data::fill(((output | cset_1(i).bbox()).rw() | (pw::value(cset_1.labeled_image()) == i)).rw(), literal::red);
+
+ for_all_comps(i, cset_2)
+ data::fill(((output | cset_2(i).bbox()).rw() | (pw::value(cset_2.labeled_image()) == i)).rw(), literal::green);
+
+ io::ppm::save(output, filename);
+
+ trace::exiting("scribo::debug::save_comp_diff");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace scribo::debug
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_DEBUG_SAVE_COMP_DIFF_HH
diff --git a/scribo/debug/text_areas_image.hh b/scribo/debug/text_areas_image.hh
new file mode 100644
index 0000000..f6a2f0f
--- /dev/null
+++ b/scribo/debug/text_areas_image.hh
@@ -0,0 +1,131 @@
+// Copyright (C) 2010 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_DEBUG_TEXT_AREAS_IMAGE_HH
+# define SCRIBO_DEBUG_TEXT_AREAS_IMAGE_HH
+
+/// \file
+///
+/// \brief Compute an image including detected text areas only.
+
+# include <mln/core/concept/image.hh>
+
+# include <mln/core/image/imorph/tr_image.hh>
+
+# include <mln/core/var.hh>
+# include <mln/core/routine/duplicate.hh>
+
+# include <mln/data/paste.hh>
+# include <mln/data/fill.hh>
+
+# include <mln/fun/x2x/translation.hh>
+
+# include <mln/math/max.hh>
+
+# include <scribo/core/component_set.hh>
+
+
+namespace scribo
+{
+
+ namespace debug
+ {
+
+ using namespace mln;
+
+ /*! \brief Compute an image including detected text areas only.
+
+ */
+ template <typename I, typename L>
+ mln_concrete(I)
+ text_areas_image(const Image<I>& input_rgb,
+ const scribo::component_set<L>& comps);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename L>
+ mln_concrete(I)
+ text_areas_image(const Image<I>& input_rgb_,
+ const scribo::component_set<L>& comps)
+ {
+ trace::entering("scribo::debug::text_areas_image");
+
+ const I& input_rgb = exact(input_rgb_);
+ mln_precondition(input_rgb.is_valid());
+
+ typedef mln_site(I) P;
+
+ unsigned shift = 5;
+ float height = 1, width = 0;
+ for_all_comps(i, comps)
+ if (comps(i).is_valid())
+ {
+ height += comps(i).bbox().nrows() + shift;
+ width = math::max(static_cast<float>(comps(i).bbox().ncols()),
+ width);
+ }
+ if (width == 0)
+ width = 1;
+
+ I output(height, width);
+ data::fill(output, literal::black);
+
+ algebra::vec<2, float> dv;
+ dv[0] = 0;
+ dv[1] = 0;
+ for_all_comps(i, comps)
+ if (comps(i).is_valid())
+ {
+ mln_VAR(tmp, duplicate(input_rgb | comps(i).bbox()));
+
+ typedef mln::fun::x2x::translation<P::dim, float> trans_t;
+ trans_t trans(dv - comps(i).bbox().pmin().to_vec());
+
+ mln_domain(I)
+ tr_box(comps(i).bbox().pmin().to_vec() + trans.t(),
+ comps(i).bbox().pmax().to_vec() + trans.t());
+
+ tr_image<mln_domain(I), tmp_t, trans_t> tr_ima(tr_box, tmp, trans);
+
+ data::paste(tr_ima, output);
+ dv[0] += comps(i).bbox().nrows() + shift;
+ }
+
+ trace::exiting("scribo::debug::text_areas_image");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace scribo::debug
+
+} // end of namespace scribo
+
+
+#endif // ! SCRIBO_DEBUG_TEXT_AREAS_IMAGE_HH
diff --git a/scribo/primitive/regroup/from_single_left_link.hh b/scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh
similarity index 73%
copy from scribo/primitive/regroup/from_single_left_link.hh
copy to scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh
index adb5b06..23adfc2 100644
--- a/scribo/primitive/regroup/from_single_left_link.hh
+++ b/scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh
@@ -23,12 +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_PRIMITIVE_RELINK_FROM_SINGLE_LEFT_LINK_HH
-# define SCRIBO_PRIMITIVE_RELINK_FROM_SINGLE_LEFT_LINK_HH
+#ifndef SCRIBO_PRIMITIVE_REGROUP_FROM_SINGLE_LEFT_LINK_WRT_H_RATIO_HH
+# define SCRIBO_PRIMITIVE_REGROUP_FROM_SINGLE_LEFT_LINK_WRT_H_RATIO_HH
/// \file
///
-/// \brief Regroup groups with their left neighbor.
+/// \brief Regroup groups with their left neighbor w.r.t. their height
+/// ratio.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -45,11 +46,8 @@
# include <scribo/core/macros.hh>
# include <scribo/core/component_set.hh>
# include <scribo/core/object_links.hh>
-# include <scribo/core/object_groups.hh>
-# include <scribo/primitive/group/apply.hh>
-# include <scribo/primitive/group/from_single_link.hh>
-# include <scribo/primitive/link/with_single_left_link.hh>
+# include <scribo/filter/object_links_bbox_h_ratio.hh>
# include <scribo/primitive/link/internal/find_link.hh>
# include <scribo/primitive/link/internal/link_single_dmax_base.hh>
@@ -65,7 +63,8 @@ namespace scribo
namespace regroup
{
- /// \brief Regroup groups with their left neighbor.
+ /// \brief Regroup groups with their left neighbor w.r.t. their
+ /// height ratio.
///
/// \param[in] groups Groups data.
/// \param[in] The maximum distance allowed to seach a neighbor object.
@@ -75,16 +74,18 @@ namespace scribo
template <typename L>
inline
object_groups<L>
- from_single_left_link(const object_groups<L>& groups,
- unsigned neighb_max_distance);
+ from_single_left_link_wrt_h_ratio(const object_groups<L>& groups,
+ unsigned neighb_max_distance,
+ double hratio);
/// \overload
/// Max distance is set to mln_max(unsigned).
+ /// hratio is set to 1.60f.
template <typename L>
inline
object_groups<L>
- from_single_left_link(const object_groups<L>& groups);
+ from_single_left_link_wrt_h_ratio(const object_groups<L>& groups);
# ifndef MLN_INCLUDE_ONLY
@@ -95,10 +96,11 @@ namespace scribo
template <typename L>
inline
object_groups<L>
- from_single_left_link(const object_groups<L>& groups,
- unsigned neighb_max_distance)
+ from_single_left_link_wrt_h_ratio(const object_groups<L>& groups,
+ unsigned neighb_max_distance,
+ double hratio)
{
- trace::entering("scribo::primitive::regroup::from_single_left_link");
+ trace::entering("scribo::primitive::regroup::from_single_left_link_wrt_h_ratio");
mln_precondition(groups.is_valid());
@@ -110,7 +112,11 @@ namespace scribo
components = primitive::group::apply(groups, relabel_fun);
object_links<L>
- links = primitive::link::with_single_left_link(components, neighb_max_distance);
+ links = primitive::link::with_single_left_link(components,
+ neighb_max_distance);
+
+ links = filter::object_links_bbox_h_ratio(links, hratio);
+
object_groups<L>
new_groups = primitive::group::from_single_link(links);
@@ -119,7 +125,7 @@ namespace scribo
output(g) = new_groups(relabel_fun(g));
- trace::exiting("scribo::primitive::regroup::from_single_left_link");
+ trace::exiting("scribo::primitive::regroup::from_single_left_link_wrt_h_ratio");
return output;
}
@@ -127,9 +133,10 @@ namespace scribo
template <typename L>
inline
object_groups<L>
- from_single_left_link(const object_groups<L>& groups)
+ from_single_left_link_wrt_h_ratio(const object_groups<L>& groups)
{
- return from_single_left_link(groups, mln_max(unsigned));
+ return from_single_left_link_wrt_h_ratio(groups,
+ mln_max(unsigned), 1.60f);
}
@@ -141,4 +148,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_PRIMITIVE_LINK_FROM_SINGLE_LEFT_LINK_HH
+#endif // ! SCRIBO_PRIMITIVE_REGROUP_FROM_SINGLE_LEFT_LINK_WRT_H_RATIO_HH
--
1.5.6.5
1
0
* core/internal/link_functor_base.hh,
* debug/save_object_diff.hh,
* make/text.hh,
* primitive/internal/update_link_array.hh,
* primitive/link/internal/anchors_3.hh,
* primitive/link/internal/link_ms_dmax_base.hh,
* primitive/link/internal/link_ms_dmax_ratio_base.hh,
* src/pbm_lines_in_doc.cc: Remove.
---
scribo/ChangeLog | 13 +
scribo/core/internal/link_functor_base.hh | 119 --------
scribo/debug/save_object_diff.hh | 98 -------
scribo/make/text.hh | 180 ------------
scribo/primitive/internal/update_link_array.hh | 105 -------
scribo/primitive/link/internal/anchors_3.hh | 147 ----------
.../primitive/link/internal/link_ms_dmax_base.hh | 164 -----------
.../link/internal/link_ms_dmax_ratio_base.hh | 170 -----------
scribo/src/pbm_lines_in_doc.cc | 299 --------------------
9 files changed, 13 insertions(+), 1282 deletions(-)
delete mode 100644 scribo/core/internal/link_functor_base.hh
delete mode 100644 scribo/debug/save_object_diff.hh
delete mode 100644 scribo/make/text.hh
delete mode 100644 scribo/primitive/internal/update_link_array.hh
delete mode 100644 scribo/primitive/link/internal/anchors_3.hh
delete mode 100644 scribo/primitive/link/internal/link_ms_dmax_base.hh
delete mode 100644 scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh
delete mode 100644 scribo/src/pbm_lines_in_doc.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index cef5ea4..3b441f7 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,18 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Remove deprecated files.
+
+ * core/internal/link_functor_base.hh,
+ * debug/save_object_diff.hh,
+ * make/text.hh,
+ * primitive/internal/update_link_array.hh,
+ * primitive/link/internal/anchors_3.hh,
+ * primitive/link/internal/link_ms_dmax_base.hh,
+ * primitive/link/internal/link_ms_dmax_ratio_base.hh,
+ * src/pbm_lines_in_doc.cc: Remove.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix many tests in Scribo.
* all.hh,
diff --git a/scribo/core/internal/link_functor_base.hh b/scribo/core/internal/link_functor_base.hh
deleted file mode 100644
index addba06..0000000
--- a/scribo/core/internal/link_functor_base.hh
+++ /dev/null
@@ -1,119 +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_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_HH
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_HH
-
-/// \file
-///
-/// Base class for link functors.
-
-# include <mln/core/concept/image.hh>
-
-# include <mln/math/abs.hh>
-
-# include <mln/util/array.hh>
-# include <mln/util/couple.hh>
-
-# include <scribo/core/concept/link_functor.hh>
-
-# include <scribo/core/object_image.hh>
-# include <scribo/core/object_links.hh>
-
-# include <scribo/primitive/internal/init_link_array.hh>
-
-
-namespace scribo
-{
-
- namespace internal
- {
-
- /// \brief Base class for link functors.
- template <typename L, typename E>
- class link_functor_base : public Link_Functor<E>
- {
- public:
-
- typedef L support;
-
- link_functor_base(const object_image(L)& objects);
-
- const object_links<L>& links() const;
-
- unsigned link(unsigned object) const;
- const object_image(L)& objects() const;
-
- protected:
- object_links<L> links_;
- const object_image(L) objects_;
- };
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L, typename E>
- inline
- link_functor_base<L,E>::link_functor_base(const object_image(L)& objects)
- : links_(objects, static_cast<unsigned>(objects.nlabels()) + 1),
- objects_(objects)
- {
- primitive::internal::init_link_array(links_);
- }
-
- template <typename L, typename E>
- inline
- const object_links<L>&
- link_functor_base<L,E>::links() const
- {
- return links_;
- }
-
- template <typename L, typename E>
- inline
- unsigned
- link_functor_base<L,E>::link(unsigned object) const
- {
- return links_[object];
- }
-
- template <typename L, typename E>
- inline
- const object_image(L)&
- link_functor_base<L,E>::objects() const
- {
- return objects_;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::internal
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_HH
diff --git a/scribo/debug/save_object_diff.hh b/scribo/debug/save_object_diff.hh
deleted file mode 100644
index e4f49f4..0000000
--- a/scribo/debug/save_object_diff.hh
+++ /dev/null
@@ -1,98 +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_DEBUG_SAVE_OBJECT_DIFF_HH
-# define SCRIBO_DEBUG_SAVE_OBJECT_DIFF_HH
-
-/// \file
-///
-/// Show the difference between two object images.
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/concept/image.hh>
-# include <mln/data/fill.hh>
-# include <mln/labeling/colorize.hh>
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/save.hh>
-# include <mln/literal/black.hh>
-# include <mln/literal/colors.hh>
-# include <mln/pw/all.hh>
-# include <mln/core/image/dmorph/image_if.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
-
-namespace scribo
-{
-
- namespace debug
- {
-
- using namespace mln;
-
- /*! \brief Show the difference between two object images.
-
- \param[in] lbl An object image.
- \param[in] lbl_2 Another object image.
- \param[in] filename The output filename.
-
- */
- template <typename L, typename L2>
- void
- save_object_diff(const object_image(L)& lbl, const object_image(L2)& lbl_2,
- const std::string& filename);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L, typename L2>
- void
- save_object_diff(const object_image(L)& lbl, const object_image(L2)& lbl_2,
- const std::string& filename)
- {
- image2d<value::rgb8> output;
- initialize(output, lbl_2);
-
- data::fill(output, literal::black);
-
- for_all_components(i, lbl.bboxes())
- data::fill(((output | lbl.bbox(i)).rw() | (pw::value(lbl) == i)).rw(), literal::red);
-
- for_all_components(i, lbl_2.bboxes())
- data::fill(((output | lbl_2.bbox(i)).rw() | (pw::value(lbl_2) == i)).rw(), literal::green);
-
- io::ppm::save(output, filename);
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::debug
-
-} // end of namespace scribo
-
-#endif // ! SCRIBO_DEBUG_SAVE_OBJECT_DIFF_HH
diff --git a/scribo/make/text.hh b/scribo/make/text.hh
deleted file mode 100644
index 6d10ef3..0000000
--- a/scribo/make/text.hh
+++ /dev/null
@@ -1,180 +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_MAKE_TEXT_HH
-# define SCRIBO_MAKE_TEXT_HH
-
-/// \file
-///
-/// Construct a util::text.
-
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
-# include <mln/core/site_set/box.hh>
-# include <mln/fun/i2v/array.hh>
-# include <mln/labeling/blobs.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/labeling/relabel.hh>
-# include <mln/util/array.hh>
-# include <mln/make/relabelfun.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/util/text.hh>
-
-
-namespace scribo
-{
-
- namespace make
- {
-
-
- /// Construct a util::text
- ///
- /// \param[in] bboxes Text component bounding boxes.
- /// \param[in] lbl Associated label image.
- /// \param[in] nbboxes The number of bounding boxes.
- ///
- /// \return A util::text.
- template <typename L>
- scribo::util::text<L>
- text(const mln::util::array<box<mln_site(L)> >& bboxes,
- const Image<L>& lbl,
- mln_value(L)& nbboxes);
-
- /// Construct a util::text
- ///
- /// \param[in] input_ A binary image.
- /// \param[in] nbh_ A neighborhood to be used with labeling algorithms.
- /// \param[in] nbboxes The number of bounding boxes.
- ///
- /// \return A util::text.
- template <typename I, typename N, typename V>
- scribo::util::text<mln_ch_value(I,V)>
- text(const Image<I>& input_, const Neighborhood<N>& nbh_,
- V& nbboxes);
-
-
- /// Construct a new util::text from another one.
- ///
- /// \param[in] text A text structure.
- /// \param[in] f_ A function v2v or v2b. It will be used to regroup text
- /// components.
- ///
- /// \return a new util::text.
- //
- template <typename L, typename F>
- scribo::util::text<L>
- text(const scribo::util::text<L>& text,
- const Function<F>& f_);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L>
- scribo::util::text<L>
- text(const mln::util::array<box<mln_site(L)> >& bboxes,
- const Image<L>& lbl,
- mln_value(L)& nbboxes)
- {
- trace::entering("scribo::make::text");
-
- mln_precondition(exact(lbl).is_valid());
-
- scribo::util::text<L> result = scribo::util::text<L>(bboxes, lbl,
- nbboxes);
-
- trace::exiting("scribo::make::text");
- return result;
- }
-
-
-
- template <typename I, typename N, typename V>
- scribo::util::text<mln_ch_value(I,V)>
- text(const Image<I>& input_, const Neighborhood<N>& nbh_,
- V& nbboxes)
- {
- trace::entering("scribo::make::text");
-
- const I& input = exact(input_);
- const N& nbh = exact(nbh_);
-
- mln_precondition(input.is_valid());
- mln_precondition(nbh.is_valid());
-
- typedef mln::util::array< box<mln_site(I)> > boxes_t;
-
- mln_ch_value(I,V) lbl = labeling::blobs(input, nbh, nbboxes);
-
- boxes_t cboxes = labeling::compute(accu::meta::shape::bbox(), lbl, nbboxes);
-
- trace::exiting("scribo::make::text");
- return make::text(cboxes, lbl, nbboxes);
- }
-
-
- template <typename L, typename F>
- scribo::util::text<L>
- text(const scribo::util::text<L>& text,
- const Function<F>& f_)
- {
- trace::entering("scribo::make::text");
-
- mln_precondition(text.is_valid());
- const F& f = exact(f_);
-
- mln_value(L) new_nbboxes;
- mln::fun::i2v::array<mln_value(L)> fv2v
- = mln::make::relabelfun(f, text.nbboxes(), new_nbboxes);
-
- L lbl = labeling::relabel(text.label_image(), text.nbboxes(), fv2v);
-
- mln::util::array< accu::shape::bbox<mln_site(L)> > tboxes(new_nbboxes.next());
- mln::util::array< accu::center<mln_site(L)> > tcenters(new_nbboxes.next());
- for_all_comps(i, text.bboxes())
- {
- tboxes[fv2v(i)].take(text.bbox(i));
- tcenters[fv2v(i)].take(text.mass_center(i));
- }
-
- scribo::util::text<L> new_text;
- new_text.nbboxes() = new_nbboxes;
- new_text.label_image() = lbl;
- convert::from_to(tboxes, new_text.bboxes());
- convert::from_to(tcenters, new_text.mass_centers());
-
- trace::exiting("scribo::make::text");
- return new_text;
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::make
-
-} // end of namespace scribo
-
-#endif // ! SCRIBO_MAKE_TEXT_HH
diff --git a/scribo/primitive/internal/update_link_array.hh b/scribo/primitive/internal/update_link_array.hh
deleted file mode 100644
index f7fdf44..0000000
--- a/scribo/primitive/internal/update_link_array.hh
+++ /dev/null
@@ -1,105 +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_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
-# define SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
-
-/// \file
-///
-/// Update a lookup table if a neighbor is found on the right of
-/// the current bbox.
-///
-/// \todo To be deleted.
-
-# include <mln/core/concept/image.hh>
-# include <mln/util/array.hh>
-# include <mln/math/abs.hh>
-
-
-namespace scribo
-{
-
- namespace primitive
- {
-
- namespace internal
- {
-
- 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>
- bool
- 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, float dmax);
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename I>
- inline
- bool
- 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, float 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
- && static_cast<float>((math::abs(p.col() - c.col()))) < dmax // Not too far
- && link_array[lbl(p)] != i) // Not creating a loop
- {
- link_array[i] = lbl(p);
- return true;
- }
-
- return false;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::primitive::internal
-
- } // end of namespace scribo::text
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
diff --git a/scribo/primitive/link/internal/anchors_3.hh b/scribo/primitive/link/internal/anchors_3.hh
deleted file mode 100644
index 3be9658..0000000
--- a/scribo/primitive/link/internal/anchors_3.hh
+++ /dev/null
@@ -1,147 +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_PRIMITIVE_LINK_INTERNAL_ANCHORS_3_HH
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_ANCHORS_3_HH
-
-/// \file
-///
-/// Routine providing 3 anchors for neighbor seeking.
-
-# include <mln/math/min.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_image.hh>
-
-
-namespace scribo
-{
-
- namespace primitive
- {
-
- namespace link
- {
-
- namespace internal
- {
-
- /*! \brief Return the proper anchor used to find a neighbor.
-
- This routine provides up to 3 different anchors.
-
- \param[in] objects An object image.
- \param[in] mass_centers Object mass centers.
- \param[in] current_object An object id.
- \param[in] anchor The expected anchor.
-
- Anchor can take one of the following values:
- - 0, top anchor.
- - 1, center anchor. It is the mass center.
- - 2, bottom anchor.
-
-
- Top and bottom anchors are respectively computed from the
- bbox pmin and the bbox pmax, P.
-
- Then the output anchor coordinates are computed as follows:
-
- out.col = bbox.center.col
-
- if object height, h, is lower than 30.
- out.row = P.row + min(2, (h + 1) / 2 - 1)
- else
- out.row = P.row - min(10, h /10)
-
- */
- template <typename L, typename P>
- mln_site(L)
- anchors_3(const object_image(L)& objects,
- const mln::util::array<P>& mass_centers,
- unsigned current_object, unsigned anchor);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L, typename P>
- mln_site(L)
- anchors_3(const object_image(L)& objects,
- const mln::util::array<P>& mass_centers,
- unsigned current_object, unsigned anchor)
- {
- unsigned h = objects.bbox(current_object).pmax().row()
- - objects.bbox(current_object).pmin().row();
-
- mln_site(L) sp = objects.bbox(current_object).center();
- mln::def::coord r;
-
- switch (anchor)
- {
- // Top
- case 0:
- if (h < 30)
- r = objects.bbox(current_object).pmin().row()
- + mln::math::min(2u, (h + 1) / 2 - 1);
- else
- r = objects.bbox(current_object).pmin().row()
- - mln::math::min(10u, h /10);
- break;
-
-
- // Center
- case 1:
- return mass_centers(current_object);
-
-
- // Bottom
- case 2:
- if (h < 30)
- r = objects.bbox(current_object).pmax().row()
- + mln::math::min(2u, (h + 1) / 2 - 1);
- else
- r = objects.bbox(current_object).pmax().row()
- - mln::math::min(10u, h /10);
- break;
-
- default:
- mln::trace::warning("Non handled anchor");
- mln_assertion(anchor > 2);
- }
-
- sp.row() = r;
- return sp;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::primitive::link::internal
-
- } // end of namespace scribo::primitive::link
-
- } // end of namespace scribo::primitive
-
-} // end of namespace scribo
-
-#endif // ! SCRIBO_PRIMITIVE_LINK_INTERNAL_ANCHORS_3_HH
diff --git a/scribo/primitive/link/internal/link_ms_dmax_base.hh b/scribo/primitive/link/internal/link_ms_dmax_base.hh
deleted file mode 100644
index edb0941..0000000
--- a/scribo/primitive/link/internal/link_ms_dmax_base.hh
+++ /dev/null
@@ -1,164 +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_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_HH_
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_HH_
-
-/// \file
-///
-/// Base class for link functors using mass centers and a given max
-/// distance.
-
-
-# include <mln/accu/center.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/math/abs.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/core/object_links.hh>
-
-# include <scribo/primitive/link/internal/find_link.hh>
-# include <scribo/primitive/link/internal/link_functor_base.hh>
-
-# include <scribo/primitive/link/compute.hh>
-
-
-namespace scribo
-{
-
- namespace primitive
- {
-
- namespace link
- {
-
- namespace internal
- {
-
- /// \brief Base class for link functors using mass centers and
- /// a given max distance.
- //
- template <typename L, typename E>
- class link_ms_dmax_base
- : public link_functor_base<L, E>
- {
- typedef link_functor_base<L,E> super_;
- typedef mln_result(accu::center<mln_psite(L)>) ms_t;
-
- public:
-
- typedef mln_site(L) P;
-
-
- link_ms_dmax_base(const object_image(L)& objects,
- unsigned neighb_max_distance,
- anchor::Direction direction);
-
- bool verify_link_criterion_(unsigned current_object,
- const P& start_point, const P& p) const;
-
- mln_site(L) start_point_(unsigned current_object,
- unsigned anchor);
-
- void start_processing_object_(unsigned current_object);
-
- private:
- float dmax_;
- float neighb_max_distance_;
- anchor::Direction direction_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L, typename E>
- inline
- link_ms_dmax_base<L, E>::link_ms_dmax_base(
- const object_image(L)& objects,
- unsigned neighb_max_distance,
- anchor::Direction direction)
-
- : super_(objects),
- dmax_(0),
- neighb_max_distance_(neighb_max_distance),
- direction_(direction)
- {
- }
-
-
- template <typename L, typename E>
- inline
- bool
- link_ms_dmax_base<L, E>::verify_link_criterion_(unsigned current_object,
- const P& start_point,
- const P& p) const
- {
- (void) current_object;
-
- float dist = math::abs(p[direction_] - start_point[direction_]);
- return dist <= dmax_; // Not too far
- }
-
-
- template <typename L, typename E>
- inline
- mln_site(L)
- link_ms_dmax_base<L, E>::start_point_(unsigned current_object,
- unsigned anchor)
- {
- (void) anchor;
- return this->objects_.mass_center(current_object);
- }
-
-
- template <typename L, typename E>
- inline
- void
- link_ms_dmax_base<L, E>::start_processing_object_(
- unsigned current_object)
- {
- float
- midcol = (this->objects_.bbox(current_object).pmax()[direction_]
- - this->objects_.bbox(current_object).pmin()[direction_]) / 2;
- dmax_ = midcol + neighb_max_distance_;
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::primitive::link::internal
-
- } // end of namespace scribo::primitive::link
-
- } // end of namespace scribo::primitive
-
-} // end of namespace scribo
-
-
-#endif // SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_HH_
diff --git a/scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh b/scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh
deleted file mode 100644
index 915296d..0000000
--- a/scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh
+++ /dev/null
@@ -1,170 +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_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_RATIO_BASE_HH_
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_RATIO_BASE_HH_
-
-/// \file
-///
-/// \brief Base class for link functors using mass centers and a
-/// proportional max distance.
-
-
-# include <mln/accu/center.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/math/abs.hh>
-# include <mln/math/max.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/core/object_links.hh>
-
-# include <scribo/primitive/link/internal/find_link.hh>
-# include <scribo/primitive/link/internal/link_functor_base.hh>
-
-# include <scribo/primitive/link/compute.hh>
-
-
-namespace scribo
-{
-
- namespace primitive
- {
-
- namespace link
- {
-
- namespace internal
- {
-
- /// \brief Base class for link functors using mass centers and
- /// a proportional max distance.
- //
- template <typename L, typename E>
- class link_ms_dmax_ratio_base
- : public link_functor_base<L, E>
- {
- typedef link_functor_base<L,E> super_;
- typedef mln_result(accu::center<mln_psite(L)>) ms_t;
-
- public:
-
- typedef mln_site(L) P;
-
-
- link_ms_dmax_ratio_base(const object_image(L)& objects,
- float dmax_ratio,
- anchor::Direction direction);
-
-
-
- bool verify_link_criterion_(unsigned current_object,
- const P& start_point, const P& p) const;
-
- mln_site(L) start_point_(unsigned current_object,
- unsigned anchor);
-
- void start_processing_object_(unsigned current_object);
-
- private:
- float dmax_ratio_;
- float dmax_;
- anchor::Direction direction_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L, typename E>
- inline
- link_ms_dmax_ratio_base<L, E>::link_ms_dmax_ratio_base(
- const object_image(L)& objects,
- float dmax_ratio,
- anchor::Direction direction)
-
- : super_(objects),
- dmax_ratio_(dmax_ratio),
- dmax_(0),
- direction_(direction)
- {
- }
-
- template <typename L, typename E>
- inline
- bool
- link_ms_dmax_ratio_base<L, E>::verify_link_criterion_(
- unsigned current_object,
- const P& start_point,
- const P& p) const
- {
- mln_assertion(dmax_ != 0);
- (void) current_object;
-
- float dist = math::abs(p[direction_] - start_point[direction_]);
- return dist <= dmax_; // Not too far
- }
-
-
- template <typename L, typename E>
- inline
- mln_site(L)
- link_ms_dmax_ratio_base<L, E>::start_point_(unsigned current_object,
- unsigned anchor)
- {
- (void) anchor;
- return this->objects_.mass_center(current_object);
- }
-
-
- template <typename L, typename E>
- inline
- void
- link_ms_dmax_ratio_base<L, E>::start_processing_object_(
- unsigned current_object)
- {
- float
- w = this->objects_.bbox(current_object).width();
-// h = (this->objects_.bbox(current_object).pmax().row()
-// - this->objects_.bbox(current_object).pmin().row());
-// dmax_ = (w / 2.0f) + (dmax_ratio_ * math::max(w, h));
- dmax_ = (w / 2.0f) + (dmax_ratio_ * w);
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::primitive::link::internal
-
- } // end of namespace scribo::primitive::link
-
- } // end of namespace scribo::primitive
-
-} // end of namespace scribo
-
-
-#endif // SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_RATIO_BASE_HH_
diff --git a/scribo/src/pbm_lines_in_doc.cc b/scribo/src/pbm_lines_in_doc.cc
deleted file mode 100644
index 8363b61..0000000
--- a/scribo/src/pbm_lines_in_doc.cc
+++ /dev/null
@@ -1,299 +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.
-
-
-#include <libgen.h>
-#include <iostream>
-#include <fstream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/logical/not.hh>
-
-#include <mln/labeling/colorize.hh>
-
-#include <mln/io/pbm/all.hh>
-#include <mln/io/ppm/save.hh>
-#include <mln/io/dump/save.hh>
-
-#include <mln/math/min.hh>
-
-#include <mln/literal/colors.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/value/label_16.hh>
-
-#include <mln/draw/box.hh>
-
-#include <mln/extension/adjust.hh>
-
-#include <scribo/table/erase.hh>
-
-#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/extract/lines_h_discontinued.hh>
-#include <scribo/primitive/extract/lines_v_discontinued.hh>
-
-#include <scribo/primitive/link/merge_double_link.hh>
-#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
-#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
-
-#include <scribo/primitive/group/apply.hh>
-#include <scribo/primitive/group/from_double_link.hh>
-#include <scribo/primitive/group/from_single_link.hh>
-
-#include <scribo/filter/object_links_bottom_aligned.hh>
-#include <scribo/filter/object_links_bbox_h_ratio.hh>
-#include <scribo/filter/object_links_bbox_overlap.hh>
-
-#include <scribo/filter/objects_large.hh>
-#include <scribo/filter/objects_small.hh>
-#include <scribo/filter/objects_thin.hh>
-#include <scribo/filter/objects_thick.hh>
-
-#include <scribo/filter/object_groups_small.hh>
-
-#include <scribo/debug/decision_image.hh>
-#include <scribo/debug/save_bboxes_image.hh>
-#include <scribo/debug/save_bboxes_image.hh>
-#include <scribo/debug/save_linked_bboxes_image.hh>
-
-#include <scribo/debug/usage.hh>
-
-#include <scribo/make/debug_filename.hh>
-
-
-const char *args_desc[][2] =
-{
- { "input.pbm", "A binary image. 'False' for objects, 'True'\
-for the background." },
- { "out.ppm", "Show the text found in the input." },
- { "object_label.dump", "Object labeled image." },
- { "line_label.dump", "Text lines labeled image." },
- { "bbox_100p.txt", "Text file containing pmin and pmax of text line bounding boxes." },
- { "bbox_50p.txt", "Text file containing pmin and pmax of text line bounding boxes." },
- { "output_dir", "Output directory for debug image" },
- {0, 0}
-};
-
-
-int main(int argc, char* argv[])
-{
- using namespace scribo;
- using namespace mln;
-
- if (argc != 7 && argc != 8)
- return scribo::debug::usage(argv,
- "Find text lines in a document",
- "input.pbm out.ppm object_label.dump line_label.dump bbox_100p.txt bbox_50p.txt [output_dir]",
- args_desc,
- "Debug outputs. The recognized text is printed in the standard output.");
-
- if (argc == 8)
- scribo::make::internal::debug_filename_prefix = argv[7];
-
- trace::entering("main");
-
-
- bool enable_debug = (argc == 5);
-
- image2d<bool> input;
- io::pbm::load(input, argv[1]);
-
- typedef image2d<value::label_16> L;
-
- /// Finding objects.
- std::cout << "Finding objects..." << std::endl;
- value::label_16 nobjects;
- object_image(L)
- objects = scribo::primitive::extract::objects(input,
- c8(),
- nobjects);
-
-
- /// First filtering.
- std::cout << "Filtering objects..." << std::endl;
- object_image(L) filtered_objects
- = scribo::filter::objects_small(objects, 6);
-
-
- filtered_objects
- = scribo::filter::objects_large(filtered_objects,
- math::min(input.ncols(), input.nrows())
- * math::min(input.ncols(), input.nrows()) / 5);
-
-
-
- /// Linking potential objects
- std::cout << "Linking objects..." << std::endl;
- object_links<L> left_link
- = primitive::link::with_single_left_link_dmax_ratio(filtered_objects);
- object_links<L> right_link
- = primitive::link::with_single_right_link_dmax_ratio(filtered_objects);
-
-
-#ifndef NOUT
- if (enable_debug)
- {
- std::cerr << "BEFORE - nobjects = " << nobjects << std::endl;
- scribo::debug::save_linked_bboxes_image(input,
- filtered_objects,
- left_link, right_link,
- literal::red, literal::cyan,
- literal::yellow,
- literal::green,
- scribo::make::debug_filename("links.ppm"));
- }
-#endif
-
-
- // Validating left and right links.
- object_links<L>
- merged_links = primitive::link::merge_double_link(filtered_objects,
- left_link,
- right_link);
-
-
-
-
- // Remove links if bboxes have too different sizes.
- object_links<L> hratio_filtered_links
- = filter::object_links_bbox_h_ratio(filtered_objects,
- merged_links,
- 2.0f);
-
-
-
-
-#ifndef NOUT
- if (enable_debug)
- {
- image2d<value::rgb8>
- hratio_decision_image = scribo::debug::decision_image(input,
- merged_links,
- hratio_filtered_links);
- io::ppm::save(hratio_decision_image,
- scribo::make::debug_filename("hratio_links_decision_image.ppm"));
- }
-#endif
-
-
-
-
- //Remove links if bboxes overlap too much.
- object_links<L> overlap_filtered_links
- = filter::object_links_bbox_overlap(filtered_objects,
- hratio_filtered_links,
- 0.8f);
-
-
-
-
-#ifndef NOUT
- if (enable_debug)
- {
- image2d<value::rgb8> overlap_decision_image
- = scribo::debug::decision_image(input,
- hratio_filtered_links,
- overlap_filtered_links);
- io::ppm::save(overlap_decision_image,
- scribo::make::debug_filename("overlap_links_decision_image.ppm"));
- }
-#endif
-
-
-
-
- object_groups<L>
- groups = primitive::group::from_single_link(filtered_objects,
- overlap_filtered_links);
-
-
- std::cout << "Grouping objects..." << std::endl;
- object_image(L)
- grouped_objects = primitive::group::apply(filtered_objects, groups);
-
-
-
- std::cout << "Saving line bboxes..." << std::endl;
-
- // 100p bboxes
- {
- std::ofstream out;
- out.open(argv[5], std::ios_base::trunc);
-
- if (! out)
- {
- std::cout << "Can't create output file!" << std::endl;
- return 1;
- }
-
- for_all_ncomponents(i, grouped_objects.nlabels())
- {
- out << grouped_objects.bbox(i).pmin().row() << " "
- << grouped_objects.bbox(i).pmin().col()
- << " "
- << grouped_objects.bbox(i).pmax().row() << " "
- << grouped_objects.bbox(i).pmax().col()
- << std::endl;
- }
- out.close();
-
- }
-
- // 50p bboxes
- {
- std::ofstream out;
- out.open(argv[6], std::ios_base::trunc);
-
- if (! out)
- {
- std::cout << "Can't create output file!" << std::endl;
- return 1;
- }
-
- for_all_ncomponents(i, grouped_objects.nlabels())
- {
- out << grouped_objects.bbox(i).pmin().row() / 2 << " "
- << grouped_objects.bbox(i).pmin().col() / 2
- << " "
- << grouped_objects.bbox(i).pmax().row() / 2 << " "
- << grouped_objects.bbox(i).pmax().col() / 2
- << std::endl;
- }
- out.close();
-
- }
-
- scribo::debug::save_bboxes_image(input, grouped_objects.bboxes(),
- literal::red,
- argv[2]);
-
- io::dump::save(filtered_objects, argv[3]);
- io::dump::save(grouped_objects, argv[4]);
-
- trace::exiting("main");
-}
--
1.5.6.5
1
0
* mln/accu/internal/base.hh,
* mln/accu/math/sum.hh: Aesthetic changes.
* mln/data/paste_without_localization.hh: Add a missing include.
* mln/geom/rotate.hh: Add a new overload taking a box as argument.
---
milena/ChangeLog | 11 +++
milena/mln/accu/internal/base.hh | 4 +-
milena/mln/accu/math/sum.hh | 3 +-
milena/mln/data/paste_without_localization.hh | 1 +
milena/mln/geom/rotate.hh | 93 +++++++++++++++++++++----
5 files changed, 96 insertions(+), 16 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 710cfc9..15a205c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,14 @@
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Small changes in Milena.
+
+ * mln/accu/internal/base.hh,
+ * mln/accu/math/sum.hh: Aesthetic changes.
+
+ * mln/data/paste_without_localization.hh: Add a missing include.
+
+ * mln/geom/rotate.hh: Add a new overload taking a box as argument.
+
2010-08-04 Guillaume Lazzara <z(a)lrde.epita.fr>
Replace deduced type 'point' by 'site'.
diff --git a/milena/mln/accu/internal/base.hh b/milena/mln/accu/internal/base.hh
index 8c03cc3..a554a11 100644
--- a/milena/mln/accu/internal/base.hh
+++ b/milena/mln/accu/internal/base.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -33,7 +34,6 @@
# include <mln/core/concept/accumulator.hh>
-
namespace mln
{
diff --git a/milena/mln/accu/math/sum.hh b/milena/mln/accu/math/sum.hh
index c7e3e47..a77e2a2 100644
--- a/milena/mln/accu/math/sum.hh
+++ b/milena/mln/accu/math/sum.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
diff --git a/milena/mln/data/paste_without_localization.hh b/milena/mln/data/paste_without_localization.hh
index 1aad2fe..667e7f1 100644
--- a/milena/mln/data/paste_without_localization.hh
+++ b/milena/mln/data/paste_without_localization.hh
@@ -35,6 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/box_runstart_piter.hh>
+# include <mln/border/get.hh>
namespace mln
{
diff --git a/milena/mln/geom/rotate.hh b/milena/mln/geom/rotate.hh
index 0d42943..1ba8cb1 100644
--- a/milena/mln/geom/rotate.hh
+++ b/milena/mln/geom/rotate.hh
@@ -72,7 +72,8 @@ namespace mln
/// of the domain before the rotation.
/// \param[in] output_domain The domain of the output image. An
/// invalid domain, causes the routine
- /// to use the rotated input_ domain.
+ /// to use a domain large enough to
+ /// display the whole original image.
///
/// \return An image with the same domain as \p input.
//
@@ -95,6 +96,24 @@ namespace mln
rotate(const Image<I>& input, double angle);
+ /// Rotate a box.
+ ///
+ /// FIXME: the return type may be too generic and may lead to
+ /// invalid covariance.
+ //
+ template <typename B>
+ B
+ rotate(const Box<B>& box_, double angle, const mln_site(B)& ref);
+
+ /// \overload
+ ///
+ /// The rotation center \p ref is set to box.pcenter().
+ //
+ template <typename B>
+ B
+ rotate(const Box<B>& box, double angle);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -112,6 +131,8 @@ namespace mln
// Do not check that output_domain_ is valid. If it is not,
// further in this routine, we define a default domain.
+ typedef mln_site(I) P;
+ mln_precondition(P::dim == 2);
mln_precondition(input.is_valid());
mln_precondition(angle >= -360.0f && angle <= 360.0f);
// mlc_converts_to(mln_exact(Ext), mln_value(I))::check();
@@ -138,26 +159,16 @@ namespace mln
S b = output_domain;
// Automatically adjusting the output domain if needed.
if (!output_domain.is_valid())
- {
- accu::shape::bbox<mln_site(I)> accu;
-
- typedef mln_site(I) P;
- accu.take(P(comp_transf(input.domain().pmin().to_vec())));
- accu.take(P(comp_transf(input.domain().pmax().to_vec())));
-
- b = accu.to_result();
- }
+ b = rotate(input.domain(), angle);
typedef
- typename mln::internal::extension_type<const I, mln_exact(Ext)>::result ext_t;
+ typename mln::internal::extension_type<const I, mln_exact(Ext)>::result ext_t;
typedef
tr_image<mln_box(I), ext_t, comp_transf_t> tr_t;
tr_t tr = transposed_image(b, ext_t(input, extension), comp_transf);
- typedef mln_site(I) P;
- P rpmin = P(rot(input.domain().pmin().to_vec()));
mln_concrete(I) output;
initialize(output, tr);
@@ -189,6 +200,62 @@ namespace mln
}
+ template <typename B>
+ B
+ rotate(const Box<B>& box_, double angle, const mln_site(B)& ref)
+ {
+ trace::entering("geom::rotate");
+
+ const B& box = exact(box_);
+
+ typedef mln_site(B) P;
+ mln_precondition(P::dim == 2);
+ mln_precondition(box.is_valid());
+ mln_precondition(angle >= -360.0f && angle <= 360.0f);
+
+ typedef fun::x2x::translation<2,double> trans_t;
+ trans_t
+ t(-1 * ref.to_vec()),
+ t_1(ref.to_vec());
+
+ typedef fun::x2x::rotation<2,double> rot_t;
+ rot_t rot(math::pi * angle / 180.f, literal::origin);
+
+ typedef
+ fun::x2x::composed<trans_t, fun::x2x::composed<rot_t, trans_t> >
+ comp_transf_t;
+
+ comp_transf_t comp_transf = compose(t_1, compose(rot, t));
+
+ accu::shape::bbox<P> accu;
+
+ P
+ top_right(box.pmin().row(),
+ box.pmax().col()),
+ bot_left(box.pmax().row(),
+ box.pmin().col());
+
+ accu.take(P(comp_transf(box.pmin().to_vec())));
+ accu.take(P(comp_transf(top_right.to_vec())));
+ accu.take(P(comp_transf(bot_left.to_vec())));
+ accu.take(P(comp_transf(box.pmax().to_vec())));
+
+ B output = accu.to_result();
+
+ trace::exiting("geom::rotate");
+ return output;
+ }
+
+
+ template <typename B>
+ B
+ rotate(const Box<B>& box, double angle)
+ {
+ return rotate(box, angle, exact(box).pcenter());
+ }
+
+
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* all.hh,
* binarization/all.hh,
* binarization/internal/first_pass_functor.hh,
* convert/from_qimage.hh,
* core/tag/component.hh,
* core/tag/line.hh,
* debug/links_decision_image.hh,
* debug/mean_and_base_lines_image.hh,
* filter/object_groups_with_holes.hh,
* io/xml/save.hh,
* make/all.hh,
* postprocessing/all.hh,
* postprocessing/fill_object_holes.hh,
* preprocessing/all.hh,
* preprocessing/crop_without_localization.hh,
* preprocessing/denoise_bg.hh,
* preprocessing/denoise_fg.hh,
* preprocessing/deskew.hh,
* preprocessing/deskew_crop.hh,
* preprocessing/split_bg_fg.hh,
* primitive/extract/all.hh,
* primitive/extract/lines_h_single.hh,
* primitive/extract/lines_pattern.hh,
* primitive/extract/lines_v_single.hh,
* primitive/group/all.hh,
* primitive/internal/all.hh,
* primitive/internal/is_link_valid.hh,
* primitive/link/all.hh,
* primitive/link/internal/compute_anchor.hh,
* primitive/link/internal/dmax_functor_base.hh,
* primitive/regroup/from_single_left_link.hh,
* primitive/remove/separators.hh,
* subsampling/bilinear.hh,
* text/merging.hh,
* toolchain/nepomuk/text_extraction.hh,
* upsampling/eagle.hh: Add missing headers in order to fix
unit-tests.
* tests/Makefile.am: Disable "table" directory's tests.
* tests/core/Makefile.am: Remove object_image test.
* tests/core/object_image.cc: Remove. Deprecated.
* tests/filter/objects_with_holes.cc,
* tests/filter/small_and_large_bboxes.cc: Write a real test.
* tests/unit_test/Makefile.am: Add specific flags for unit-tests
using tesseract and image magick.
---
scribo/ChangeLog | 54 +++++++++++++++
scribo/all.hh | 8 ++-
.../{core/def/lbl_type.hh => binarization/all.hh} | 29 +++++---
scribo/binarization/internal/first_pass_functor.hh | 8 ++-
scribo/convert/from_qimage.hh | 1 +
scribo/core/tag/component.hh | 5 +-
scribo/core/tag/line.hh | 5 +-
scribo/debug/links_decision_image.hh | 2 +
scribo/debug/mean_and_base_lines_image.hh | 4 +-
scribo/filter/object_groups_with_holes.hh | 10 ++-
scribo/io/xml/save.hh | 30 +++++----
scribo/make/all.hh | 4 +-
.../def/lbl_type.hh => postprocessing/all.hh} | 22 +++---
scribo/postprocessing/fill_object_holes.hh | 9 ++-
scribo/preprocessing/all.hh | 21 +++++-
scribo/preprocessing/crop_without_localization.hh | 6 +-
scribo/preprocessing/denoise_bg.hh | 5 +-
scribo/preprocessing/denoise_fg.hh | 25 ++-----
scribo/preprocessing/deskew.hh | 2 +
scribo/preprocessing/deskew_crop.hh | 2 +-
scribo/preprocessing/split_bg_fg.hh | 3 +-
scribo/primitive/extract/all.hh | 4 +-
scribo/primitive/extract/lines_h_single.hh | 2 +-
scribo/primitive/extract/lines_pattern.hh | 4 +-
scribo/primitive/extract/lines_v_single.hh | 2 +
scribo/primitive/group/all.hh | 5 +-
scribo/primitive/internal/all.hh | 8 +-
scribo/primitive/internal/is_link_valid.hh | 8 +-
scribo/primitive/link/all.hh | 7 +-
scribo/primitive/link/internal/compute_anchor.hh | 7 ++-
.../primitive/link/internal/dmax_functor_base.hh | 2 +
scribo/primitive/regroup/from_single_left_link.hh | 4 +
scribo/primitive/remove/separators.hh | 2 +
scribo/subsampling/bilinear.hh | 5 ++
scribo/tests/Makefile.am | 5 +-
scribo/tests/core/Makefile.am | 8 +--
scribo/tests/core/object_image.cc | 72 --------------------
scribo/tests/filter/objects_with_holes.cc | 67 +++++++++++-------
scribo/tests/filter/small_and_large_bboxes.cc | 62 +++++------------
scribo/tests/unit_test/Makefile.am | 32 +++++++++
scribo/text/merging.hh | 2 +-
scribo/toolchain/nepomuk/text_extraction.hh | 3 +
scribo/upsampling/eagle.hh | 4 +
43 files changed, 324 insertions(+), 246 deletions(-)
copy scribo/{core/def/lbl_type.hh => binarization/all.hh} (67%)
copy scribo/{core/def/lbl_type.hh => postprocessing/all.hh} (79%)
delete mode 100644 scribo/tests/core/object_image.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 08477d4..cef5ea4 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,57 @@
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix many tests in Scribo.
+
+ * all.hh,
+ * binarization/all.hh,
+ * binarization/internal/first_pass_functor.hh,
+ * convert/from_qimage.hh,
+ * core/tag/component.hh,
+ * core/tag/line.hh,
+ * debug/links_decision_image.hh,
+ * debug/mean_and_base_lines_image.hh,
+ * filter/object_groups_with_holes.hh,
+ * io/xml/save.hh,
+ * make/all.hh,
+ * postprocessing/all.hh,
+ * postprocessing/fill_object_holes.hh,
+ * preprocessing/all.hh,
+ * preprocessing/crop_without_localization.hh,
+ * preprocessing/denoise_bg.hh,
+ * preprocessing/denoise_fg.hh,
+ * preprocessing/deskew.hh,
+ * preprocessing/deskew_crop.hh,
+ * preprocessing/split_bg_fg.hh,
+ * primitive/extract/all.hh,
+ * primitive/extract/lines_h_single.hh,
+ * primitive/extract/lines_pattern.hh,
+ * primitive/extract/lines_v_single.hh,
+ * primitive/group/all.hh,
+ * primitive/internal/all.hh,
+ * primitive/internal/is_link_valid.hh,
+ * primitive/link/all.hh,
+ * primitive/link/internal/compute_anchor.hh,
+ * primitive/link/internal/dmax_functor_base.hh,
+ * primitive/regroup/from_single_left_link.hh,
+ * primitive/remove/separators.hh,
+ * subsampling/bilinear.hh,
+ * text/merging.hh,
+ * toolchain/nepomuk/text_extraction.hh,
+ * upsampling/eagle.hh: Add missing headers in order to fix
+ unit-tests.
+
+ * tests/Makefile.am: Disable "table" directory's tests.
+
+ * tests/core/Makefile.am: Remove object_image test.
+
+ * tests/core/object_image.cc: Remove. Deprecated.
+
+ * tests/filter/objects_with_holes.cc,
+ * tests/filter/small_and_large_bboxes.cc: Write a real test.
+
+ * tests/unit_test/Makefile.am: Add specific flags for unit-tests
+ using tesseract and image magick.
+
2010-07-21 Roland Levillain <roland(a)lrde.epita.fr>
Have Tesseract-related parts of Scribo compile again.
diff --git a/scribo/all.hh b/scribo/all.hh
index 4debad0..c9805d3 100644
--- a/scribo/all.hh
+++ b/scribo/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,15 +38,16 @@ namespace scribo
} // end of namespace scribo
+# include <scribo/binarization/all.hh>
# 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/postprocessing/all.hh>
# include <scribo/preprocessing/all.hh>
# include <scribo/primitive/all.hh>
-# include <scribo/table/all.hh>
+//# include <scribo/table/all.hh>
# include <scribo/text/all.hh>
-# include <scribo/util/all.hh>
#endif // ! SCRIBO_ALL_HH
diff --git a/scribo/core/def/lbl_type.hh b/scribo/binarization/all.hh
similarity index 67%
copy from scribo/core/def/lbl_type.hh
copy to scribo/binarization/all.hh
index 6434bbe..6f40505 100644
--- a/scribo/core/def/lbl_type.hh
+++ b/scribo/binarization/all.hh
@@ -23,26 +23,33 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_CORE_LBL_TYPE_HH
-# define SCRIBO_CORE_LBL_TYPE_HH
+#ifndef SCRIBO_BINARIZATION_ALL_HH
+# define SCRIBO_BINARIZATION_ALL_HH
/// \file
///
-/// Global type definition for labels.
-
-# include <mln/value/label.hh>
-
+/// Include all headers located in scribo/binarization.
namespace scribo
{
- namespace def
+ /// Namespace of binarization routines.
+ namespace binarization
{
- typedef mln::value::label<30u> lbl_type;
-
- } // end of namespace scribo::def
+ } // end of namespace scribo::binarization
} // end of namespace scribo
-#endif // ! SCRIBO_CORE_DEF_HH
+
+# include <scribo/binarization/global_threshold.hh>
+# include <scribo/binarization/global_threshold_auto.hh>
+
+# include <scribo/binarization/local_threshold.hh>
+
+# include <scribo/binarization/sauvola.hh>
+# include <scribo/binarization/sauvola_ms.hh>
+# include <scribo/binarization/sauvola_ms_split.hh>
+# include <scribo/binarization/sauvola_threshold_image.hh>
+
+#endif // ! SCRIBO_BINARIZATION_ALL_HH
diff --git a/scribo/binarization/internal/first_pass_functor.hh b/scribo/binarization/internal/first_pass_functor.hh
index 4d47d94..96c7cfb 100644
--- a/scribo/binarization/internal/first_pass_functor.hh
+++ b/scribo/binarization/internal/first_pass_functor.hh
@@ -26,7 +26,11 @@
#ifndef SCRIBO_BINARIZATION_INTERNAL_FIRST_PASS_FUNCTOR_HH
# define SCRIBO_BINARIZATION_INTERNAL_FIRST_PASS_FUNCTOR_HH
+# include <mln/core/image/image2d.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/extension/fill.hh>
# include <mln/value/int_u8.hh>
+# include <mln/data/fill.hh>
# include <scribo/binarization/sauvola_threshold_image.hh>
@@ -95,7 +99,7 @@ namespace scribo
initialize(debug_k_l, input);
# endif // ! SCRIBO_SAUVOLA_DEBUG
- extension::fill(msk, false);
+ mln::extension::fill(msk, false);
initialize(card, input);
data::fill(card, 1);
@@ -153,8 +157,6 @@ namespace scribo
void finalize()
{
mln_assertion(! pxl.is_valid());
-
-// std::cout << std::endl << " ------- " << std::endl;
}
};
diff --git a/scribo/convert/from_qimage.hh b/scribo/convert/from_qimage.hh
index b297c2f..353e1ba 100644
--- a/scribo/convert/from_qimage.hh
+++ b/scribo/convert/from_qimage.hh
@@ -35,6 +35,7 @@
# include <QtGui/QImage>
+# include <mln/core/image/image2d.hh>
# include <mln/value/qt/rgb32.hh>
# if QT_VERSION < 0x040000
diff --git a/scribo/core/tag/component.hh b/scribo/core/tag/component.hh
index 3c061b3..5ed51fa 100644
--- a/scribo/core/tag/component.hh
+++ b/scribo/core/tag/component.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -26,6 +27,8 @@
#ifndef SCRIBO_CORE_TAG_COMPONENT_HH
# define SCRIBO_CORE_TAG_COMPONENT_HH
+# include <iostream>
+
/// \file
///
/// \brief Component tags.
diff --git a/scribo/core/tag/line.hh b/scribo/core/tag/line.hh
index f571188..ccb8cd1 100644
--- a/scribo/core/tag/line.hh
+++ b/scribo/core/tag/line.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -26,6 +27,8 @@
#ifndef SCRIBO_CORE_TAG_LINE_HH
# define SCRIBO_CORE_TAG_LINE_HH
+# include <iostream>
+
/// \file
///
/// \brief Line tags.
diff --git a/scribo/debug/links_decision_image.hh b/scribo/debug/links_decision_image.hh
index 944d17e..387cd7f 100644
--- a/scribo/debug/links_decision_image.hh
+++ b/scribo/debug/links_decision_image.hh
@@ -35,6 +35,8 @@
# include <mln/data/convert.hh>
# include <mln/value/rgb8.hh>
# include <mln/literal/colors.hh>
+# include <mln/draw/box.hh>
+# include <mln/draw/line.hh>
# include <scribo/core/object_links.hh>
diff --git a/scribo/debug/mean_and_base_lines_image.hh b/scribo/debug/mean_and_base_lines_image.hh
index 16a9aad..56055c9 100644
--- a/scribo/debug/mean_and_base_lines_image.hh
+++ b/scribo/debug/mean_and_base_lines_image.hh
@@ -37,6 +37,7 @@
# include <mln/literal/colors.hh>
# include <mln/draw/box.hh>
+# include <mln/draw/line.hh>
# include <mln/draw/dashed_line.hh>
# include <scribo/core/line_set.hh>
@@ -96,7 +97,8 @@ namespace scribo
trace::entering("scribo::debug::mean_and_base_lines_image");
mln_precondition(exact(input).is_valid());
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
+ mln_ch_value(I, value::rgb8)
+ output = data::convert(value::rgb8(), input);
for_all_lines(l, lines)
{
diff --git a/scribo/filter/object_groups_with_holes.hh b/scribo/filter/object_groups_with_holes.hh
index 28cd928..e833092 100644
--- a/scribo/filter/object_groups_with_holes.hh
+++ b/scribo/filter/object_groups_with_holes.hh
@@ -33,6 +33,7 @@
# include <sstream>
+# include <mln/core/image/image2d.hh>
# include <mln/core/concept/image.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/routine/extend.hh>
@@ -42,6 +43,7 @@
# include <mln/geom/nrows.hh>
# include <mln/extension/duplicate.hh>
+# include <mln/extension/adjust_fill.hh>
# include <mln/draw/box_plain.hh>
# include <mln/util/array.hh>
@@ -50,8 +52,12 @@
# include <mln/fun/i2v/array.hh>
+
# include <scribo/core/macros.hh>
# include <scribo/core/component_set.hh>
+# include <scribo/core/object_groups.hh>
+
+# include <scribo/primitive/group/apply.hh>
namespace scribo
@@ -98,7 +104,7 @@ namespace scribo
typedef mln_dpsite(P) D;
const L& lbl = components.labeled_image();
- extension::adjust_fill(lbl, 1, 0);
+ mln::extension::adjust_fill(lbl, 1, 0);
mln_concrete(L) output;
initialize(output, lbl);
@@ -160,7 +166,7 @@ namespace scribo
neighb2d nbh = c8();
- image2d<unsigned> parent, card;
+ mln_ch_value(L,unsigned) parent, card;
L bboxes_ima;
// Will store the first background component id associated
diff --git a/scribo/io/xml/save.hh b/scribo/io/xml/save.hh
index 1d5cd6c..f13396f 100644
--- a/scribo/io/xml/save.hh
+++ b/scribo/io/xml/save.hh
@@ -30,8 +30,12 @@
///
/// \brief Save text line information as XML.
-#include <fstream>
-#include <sstream>
+# include <fstream>
+# include <sstream>
+
+# include <map>
+
+# include <scribo/core/line_set.hh>
namespace scribo
{
@@ -66,8 +70,8 @@ namespace scribo
namespace internal
{
- std::string&
- html_markups_replace(std::string& input,
+ std::string&
+ html_markups_replace(std::string& input,
std::map<char, std::string>& map)
{
for (unsigned i = 0; i < input.size(); ++i)
@@ -83,7 +87,7 @@ namespace scribo
}
} // end of namespace scribo::io::xml::internal
-
+
template <typename L>
void
save(const std::string& input_name,
@@ -114,7 +118,7 @@ namespace scribo
{
file << "<pcGts xmlns=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16 http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent…" pcGtsId=\"" << input_name << "\">" << std::endl;
}
-
+
file << " <PcMetadata>" << std::endl;
file << " <PcCreator>LRDE</PcCreator>" << std::endl;
file << " <PcCreated/>" << std::endl;
@@ -190,20 +194,20 @@ namespace scribo
<< " <point x=\"" << lines(l).bbox().pmin().col()
<< "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
<< std::endl
- << " </coords>" << std::endl;
-
+ << " </coords>" << std::endl;
+
if (lines(l).has_text())
{
std::string tmp = lines(l).text();
tmp = internal::html_markups_replace(tmp, html_map);
-
+
file << " <line text=\""
<< tmp
<< "\">" << std::endl;
}
else
file << " <line>" << std::endl;
-
+
file << " <coords>" << std::endl
<< " <point x=\"" << lines(l).bbox().pmin().col()
<< "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
@@ -218,12 +222,12 @@ namespace scribo
<< "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
<< std::endl
<< " </coords>" << std::endl;
-
+
file << " </line>" << std::endl;
- file << " </paragraph>" << std::endl;
+ file << " </paragraph>" << std::endl;
}
-
+
file << " </text_region>" << std::endl;
}
}
diff --git a/scribo/make/all.hh b/scribo/make/all.hh
index 8fb3ca0..71888e8 100644
--- a/scribo/make/all.hh
+++ b/scribo/make/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -42,7 +43,6 @@ namespace scribo
} // end of namespace scribo
# include <scribo/make/influence_zone_graph.hh>
-# include <scribo/make/text.hh>
# include <scribo/make/debug_filename.hh>
diff --git a/scribo/core/def/lbl_type.hh b/scribo/postprocessing/all.hh
similarity index 79%
copy from scribo/core/def/lbl_type.hh
copy to scribo/postprocessing/all.hh
index 6434bbe..4a2ca4d 100644
--- a/scribo/core/def/lbl_type.hh
+++ b/scribo/postprocessing/all.hh
@@ -23,26 +23,26 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_CORE_LBL_TYPE_HH
-# define SCRIBO_CORE_LBL_TYPE_HH
+#ifndef SCRIBO_POSTPROCESSING_ALL_HH
+# define SCRIBO_POSTPROCESSING_ALL_HH
/// \file
///
-/// Global type definition for labels.
-
-# include <mln/value/label.hh>
-
+/// Include all headers located in scribo/postprocessing.
namespace scribo
{
- namespace def
+ /// Namespace of postprocessing routines.
+ namespace postprocessing
{
- typedef mln::value::label<30u> lbl_type;
-
- } // end of namespace scribo::def
+ } // end of namespace scribo::postprocessing
} // end of namespace scribo
-#endif // ! SCRIBO_CORE_DEF_HH
+
+# include <scribo/postprocessing/fill_object_holes.hh>
+
+
+#endif // ! SCRIBO_POSTPROCESSING_ALL_HH
diff --git a/scribo/postprocessing/fill_object_holes.hh b/scribo/postprocessing/fill_object_holes.hh
index 7dc53eb..43c02ab 100644
--- a/scribo/postprocessing/fill_object_holes.hh
+++ b/scribo/postprocessing/fill_object_holes.hh
@@ -36,7 +36,7 @@
# include <sstream>
-# include <mln/core/concept/image.hh>
+# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/routine/extend.hh>
# include <mln/core/image/dmorph/extended.hh>
@@ -160,7 +160,7 @@ namespace scribo
inline
object_groups<L>
fill_object_holes(const object_groups<L>& groups,
- unsigned min_size)
+ unsigned min_size)
{
trace::entering("scribo::postprocessing::impl::generic::fill_object_holes");
@@ -178,7 +178,7 @@ namespace scribo
util::array<bool> bg_comps_done(
static_cast<unsigned>(components.nelements()) + 1, false);
- fun::i2v::array<bool>
+ mln::fun::i2v::array<bool>
to_keep(static_cast<unsigned>(components.nelements()) + 1,
false);
@@ -328,10 +328,11 @@ namespace scribo
{
trace::entering("scribo::postprocessing::fill_object_holes");
+ const I& input = exact(input_);
+
mln_precondition(input.is_valid());
mlc_is(mln_value(I), bool)::check();
- const I& input = exact(input_);
mln_concrete(I) output = duplicate(input);
typedef value::int_u16 L;
diff --git a/scribo/preprocessing/all.hh b/scribo/preprocessing/all.hh
index 93974cf..6f13e07 100644
--- a/scribo/preprocessing/all.hh
+++ b/scribo/preprocessing/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -41,6 +42,22 @@ namespace scribo
} // end of namespace scribo
-# include <scribo/preprocessing/unskew.hh>
+
+# include <scribo/preprocessing/crop.hh>
+# include <scribo/preprocessing/crop_without_localization.hh>
+
+# include <scribo/preprocessing/denoise.hh>
+# include <scribo/preprocessing/denoise_fg.hh>
+# include <scribo/preprocessing/denoise_bg.hh>
+
+# include <scribo/preprocessing/homogeneous_contrast.hh>
+
+# include <scribo/preprocessing/rotate_90.hh>
+
+# include <scribo/preprocessing/split_bg_fg.hh>
+
+# include <scribo/preprocessing/deskew.hh>
+# include <scribo/preprocessing/deskew_crop.hh>
+
#endif // ! SCRIBO_PREPROCESSING_ALL_HH
diff --git a/scribo/preprocessing/crop_without_localization.hh b/scribo/preprocessing/crop_without_localization.hh
index 18c5ee7..7346aee 100644
--- a/scribo/preprocessing/crop_without_localization.hh
+++ b/scribo/preprocessing/crop_without_localization.hh
@@ -55,7 +55,8 @@ namespace scribo
*/
template <typename I>
mln_concrete(I)
- crop_without_localization(const Image<I>& input, const mln_box(I)& domain);
+ crop_without_localization(const Image<I>& input,
+ const mln_box(I)& domain);
# ifndef MLN_INCLUDE_ONLY
@@ -63,7 +64,8 @@ namespace scribo
template <typename I>
mln_concrete(I)
- crop_without_localization(const Image<I>& input, const mln_box(I)& domain)
+ crop_without_localization(const Image<I>& input,
+ const mln_box(I)& domain)
{
trace::entering("scribo::preprocessing::crop_without_localization");
mln_assertion(exact(input).is_valid());
diff --git a/scribo/preprocessing/denoise_bg.hh b/scribo/preprocessing/denoise_bg.hh
index 14837bb..8ad2d45 100644
--- a/scribo/preprocessing/denoise_bg.hh
+++ b/scribo/preprocessing/denoise_bg.hh
@@ -30,7 +30,7 @@
///
/// Denoise image background.
-# include <mln/core/concept/image.hh>
+# include <mln/core/image/image2d.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/concept/function.hh>
# include <mln/data/transform.hh>
@@ -113,6 +113,9 @@ namespace scribo
namespace preprocessing
{
+ using namespace mln;
+
+
template <typename I, typename N>
mln_concrete(I)
denoise_bg(const Image<I>& input_, const Neighborhood<N>& nbh_,
diff --git a/scribo/preprocessing/denoise_fg.hh b/scribo/preprocessing/denoise_fg.hh
index 5909164..9701d06 100644
--- a/scribo/preprocessing/denoise_fg.hh
+++ b/scribo/preprocessing/denoise_fg.hh
@@ -30,10 +30,9 @@
///
/// Denoise image foreground.
-# include <mln/core/concept/image.hh>
+# include <mln/core/image/image2d.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/concept/function.hh>
-# include <mln/data/transform.hh>
# include <mln/accu/math/count.hh>
@@ -42,8 +41,10 @@
# include <mln/util/array.hh>
# include <mln/fun/i2v/array.hh>
-# include <mln/labeling/foreground.hh>
+# include <mln/data/transform.hh>
+
# include <mln/labeling/compute.hh>
+# include <mln/labeling/foreground.hh>
# include <scribo/fun/v2b/label_to_bool.hh>
@@ -73,20 +74,9 @@ namespace scribo
unsigned min_card);
- } // end of namespace scribo::preprocessing
-
-} // end of namespace mln
-
-
# ifndef MLN_INCLUDE_ONLY
-namespace scribo
-{
-
- namespace preprocessing
- {
-
template <typename I, typename N>
mln_concrete(I)
denoise_fg(const Image<I>& input_, const Neighborhood<N>& nbh_,
@@ -99,7 +89,6 @@ namespace scribo
mlc_equal(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
- // FIXME:
unsigned nlabels;
image2d<unsigned> lbl = labeling::foreground(input, nbh, nlabels);
@@ -120,12 +109,10 @@ namespace scribo
return output;
}
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::preprocessing
-} // end of namespace mln
-
-
-# endif // ! MLN_INCLUDE_ONLY
+} // end of namespace scribo
# endif // SCRIBO_PREPROCESSING_DENOISE_FG_HH
diff --git a/scribo/preprocessing/deskew.hh b/scribo/preprocessing/deskew.hh
index 27d38a1..81331a7 100644
--- a/scribo/preprocessing/deskew.hh
+++ b/scribo/preprocessing/deskew.hh
@@ -34,9 +34,11 @@
# include <queue>
+
# include <mln/core/image/image2d.hh>
# include <mln/math/pi.hh>
# include <mln/geom/rotate.hh>
+# include <mln/value/int_u8.hh>
# define PI 3.1415926535897932384
diff --git a/scribo/preprocessing/deskew_crop.hh b/scribo/preprocessing/deskew_crop.hh
index 3b15cb1..988e803 100644
--- a/scribo/preprocessing/deskew_crop.hh
+++ b/scribo/preprocessing/deskew_crop.hh
@@ -138,7 +138,7 @@ namespace scribo
// }
-// } // end of namespace scribo::preprocessing::internal
+ } // end of namespace scribo::preprocessing::internal
// Facade
diff --git a/scribo/preprocessing/split_bg_fg.hh b/scribo/preprocessing/split_bg_fg.hh
index 1ad056a..5094f32 100644
--- a/scribo/preprocessing/split_bg_fg.hh
+++ b/scribo/preprocessing/split_bg_fg.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
diff --git a/scribo/primitive/extract/all.hh b/scribo/primitive/extract/all.hh
index 5ccb83b..de759e1 100644
--- a/scribo/primitive/extract/all.hh
+++ b/scribo/primitive/extract/all.hh
@@ -50,7 +50,7 @@ namespace scribo
} // end of namespace scribo
# include <scribo/primitive/extract/lines_pattern.hh>
-# include <scribo/primitive/extract/canvas.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>
@@ -60,7 +60,7 @@ namespace scribo
# include <scribo/primitive/extract/lines_v_discontinued.hh>
# include <scribo/primitive/extract/lines_h_pattern.hh>
# include <scribo/primitive/extract/components.hh>
-# include <scribo/primitive/extract/cells.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>
diff --git a/scribo/primitive/extract/lines_h_single.hh b/scribo/primitive/extract/lines_h_single.hh
index ad6b794..1bff2f4 100644
--- a/scribo/primitive/extract/lines_h_single.hh
+++ b/scribo/primitive/extract/lines_h_single.hh
@@ -33,8 +33,8 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/win/hline2d.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/primitive/extract/components.hh>
diff --git a/scribo/primitive/extract/lines_pattern.hh b/scribo/primitive/extract/lines_pattern.hh
index 5f9950a..bc23012 100644
--- a/scribo/primitive/extract/lines_pattern.hh
+++ b/scribo/primitive/extract/lines_pattern.hh
@@ -34,11 +34,13 @@
/// \todo Make a more generic canvas.
# include <mln/core/concept/image.hh>
-# include <mln/core/alias/window2d.hh>
+# include <mln/core/concept/window.hh>
# include <mln/core/routine/duplicate.hh>
# include <mln/extension/adjust_fill.hh>
+# include <mln/geom/ncols.hh>
+
# include <mln/accu/transform_line.hh>
# include <mln/accu/count_value.hh>
diff --git a/scribo/primitive/extract/lines_v_single.hh b/scribo/primitive/extract/lines_v_single.hh
index c67dfca..67b9f9d 100644
--- a/scribo/primitive/extract/lines_v_single.hh
+++ b/scribo/primitive/extract/lines_v_single.hh
@@ -35,6 +35,8 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/win/hline2d.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/primitive/extract/components.hh>
namespace scribo
{
diff --git a/scribo/primitive/group/all.hh b/scribo/primitive/group/all.hh
index 75f0685..b9ad5d3 100644
--- a/scribo/primitive/group/all.hh
+++ b/scribo/primitive/group/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -50,7 +51,7 @@ namespace scribo
# 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_graph.hh>
# include <scribo/primitive/group/from_single_link.hh>
diff --git a/scribo/primitive/internal/all.hh b/scribo/primitive/internal/all.hh
index 26f5d5b..1e190d0 100644
--- a/scribo/primitive/internal/all.hh
+++ b/scribo/primitive/internal/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -49,9 +50,8 @@ namespace scribo
# 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/update_graph_link.hh>
-# include <scribo/primitive/internal/update_link_array.hh>
+//# include <scribo/primitive/internal/find_graph_link.hh>
+//# include <scribo/primitive/internal/update_graph_link.hh>
#endif // ! SCRIBO_PRIMITIVE_INTERNAL_ALL_HH
diff --git a/scribo/primitive/internal/is_link_valid.hh b/scribo/primitive/internal/is_link_valid.hh
index 5510699..b18e55c 100644
--- a/scribo/primitive/internal/is_link_valid.hh
+++ b/scribo/primitive/internal/is_link_valid.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -29,12 +30,11 @@
/// \file
///
/// Validate a link from two different links.
-///
-/// \todo To be deleted ?.
-# include <mln/util/array.hh>
# include <mln/util/couple.hh>
+# include <scribo/core/object_links.hh>
+
namespace scribo
{
diff --git a/scribo/primitive/link/all.hh b/scribo/primitive/link/all.hh
index 7313adb..dbce148 100644
--- a/scribo/primitive/link/all.hh
+++ b/scribo/primitive/link/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -49,9 +50,9 @@ namespace scribo
-# include <scribo/primitive/link/with_several_graphes.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_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>
diff --git a/scribo/primitive/link/internal/compute_anchor.hh b/scribo/primitive/link/internal/compute_anchor.hh
index b1ca77d..1c52b91 100644
--- a/scribo/primitive/link/internal/compute_anchor.hh
+++ b/scribo/primitive/link/internal/compute_anchor.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -31,7 +32,9 @@
/// Routine providing anchors for neighbor seeking.
# include <mln/math/min.hh>
-# include <mln/util/array.hh>
+
+# include <scribo/core/tag/anchor.hh>
+# include <scribo/core/component_set.hh>
namespace scribo
diff --git a/scribo/primitive/link/internal/dmax_functor_base.hh b/scribo/primitive/link/internal/dmax_functor_base.hh
index 8ff3f10..67a8db4 100644
--- a/scribo/primitive/link/internal/dmax_functor_base.hh
+++ b/scribo/primitive/link/internal/dmax_functor_base.hh
@@ -48,6 +48,8 @@ namespace scribo
namespace internal
{
+ using namespace mln;
+
/// \brief Base class for dmax functors.
template <typename E>
diff --git a/scribo/primitive/regroup/from_single_left_link.hh b/scribo/primitive/regroup/from_single_left_link.hh
index c90e35c..adb5b06 100644
--- a/scribo/primitive/regroup/from_single_left_link.hh
+++ b/scribo/primitive/regroup/from_single_left_link.hh
@@ -45,7 +45,11 @@
# include <scribo/core/macros.hh>
# include <scribo/core/component_set.hh>
# include <scribo/core/object_links.hh>
+# include <scribo/core/object_groups.hh>
+# include <scribo/primitive/group/apply.hh>
+# include <scribo/primitive/group/from_single_link.hh>
+# include <scribo/primitive/link/with_single_left_link.hh>
# include <scribo/primitive/link/internal/find_link.hh>
# include <scribo/primitive/link/internal/link_single_dmax_base.hh>
diff --git a/scribo/primitive/remove/separators.hh b/scribo/primitive/remove/separators.hh
index 11e9fee..23d5fd1 100644
--- a/scribo/primitive/remove/separators.hh
+++ b/scribo/primitive/remove/separators.hh
@@ -39,6 +39,8 @@
# include <mln/data/fill.hh>
+# include <mln/border/resize.hh>
+
namespace scribo
{
diff --git a/scribo/subsampling/bilinear.hh b/scribo/subsampling/bilinear.hh
index 534865a..b3d77ee 100644
--- a/scribo/subsampling/bilinear.hh
+++ b/scribo/subsampling/bilinear.hh
@@ -31,6 +31,10 @@
/// Bilinear subsampling.
# include <mln/core/concept/image.hh>
+# include <mln/core/alias/box2d.hh>
+# include <mln/geom/max_col.hh>
+# include <mln/geom/max_row.hh>
+
# include <mln/opt/at.hh>
@@ -40,6 +44,7 @@ namespace scribo
namespace subsampling
{
+ using namespace mln;
template <typename I>
mln_concrete(I)
diff --git a/scribo/tests/Makefile.am b/scribo/tests/Makefile.am
index 4214e37..a6ed969 100644
--- a/scribo/tests/Makefile.am
+++ b/scribo/tests/Makefile.am
@@ -21,11 +21,14 @@ SUBDIRS = \
core \
filter \
preprocessing \
- table \
text \
toolchain \
unit_test
+# Disabled directories:
+#
+# table
+
# Regen files recursively.
include $(top_srcdir)/build-aux/regen-recursive.mk
REGEN_SUBDIRS += unit_test
diff --git a/scribo/tests/core/Makefile.am b/scribo/tests/core/Makefile.am
index a7773ec..cf1c528 100644
--- a/scribo/tests/core/Makefile.am
+++ b/scribo/tests/core/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+# (LRDE).
#
# This file is part of Olena.
#
@@ -19,9 +20,6 @@
include $(top_srcdir)/scribo/tests/tests.mk
-check_PROGRAMS = \
- object_image
-
-object_image_SOURCES = object_image.cc
+check_PROGRAMS =
TESTS = $(check_PROGRAMS)
diff --git a/scribo/tests/core/object_image.cc b/scribo/tests/core/object_image.cc
deleted file mode 100644
index 9ac6152..0000000
--- a/scribo/tests/core/object_image.cc
+++ /dev/null
@@ -1,72 +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.
-
-#include <iostream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/make/image.hh>
-#include <mln/fun/i2v/array.hh>
-
-#include <scribo/core/object_image.hh>
-
-#include <mln/debug/println.hh>
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- unsigned data[4][4] = { {1, 0, 0, 0},
- {0, 0, 2, 0},
- {3, 0, 0, 0},
- {0, 0, 4, 0} };
-
- typedef image2d<unsigned> I;
- I ima = make::image(data);
-
- object_image(I) lbl(ima, 4);
-
- fun::i2v::array<unsigned> f(5);
- f(0) = 0;
- f(1) = 1;
- f(2) = 4;
- f(3) = 3;
- f(4) = 4;
-
- // { {1, 0, 0, 0},
- // {0, 0, 2, 0},
- // {3, 0, 0, 0},
- // {0, 0, 2, 0} };
- lbl.relabel(f);
-
-
- mln_assertion(lbl.bbox(1) == make::box2d(0, 0, 0,0));
- mln_assertion(lbl.mass_center(1) == point2d(0,0));
-
- mln_assertion(lbl.bbox(2) == make::box2d(1, 2, 3,2));
- mln_assertion(lbl.mass_center(2) == point2d(2,2));
-
- mln_assertion(lbl.bbox(3) == make::box2d(2, 0, 2,0));
- mln_assertion(lbl.mass_center(3) == point2d(2,0));
-}
diff --git a/scribo/tests/filter/objects_with_holes.cc b/scribo/tests/filter/objects_with_holes.cc
index 5396962..ca852a9 100644
--- a/scribo/tests/filter/objects_with_holes.cc
+++ b/scribo/tests/filter/objects_with_holes.cc
@@ -1,49 +1,62 @@
+// Copyright (C) 2009, 2010 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.
+
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/io/pbm/load.hh>
#include <mln/value/label_8.hh>
-
-#include <mln/util/timer.hh>
-#include <mln/labeling/background.hh>
#include <mln/value/label_32.hh>
#include <mln/data/convert.hh>
#include <mln/data/wrap.hh>
-#include <mln/debug/println.hh>
-
-
-
#include <scribo/filter/objects_with_holes.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
+
+#include <scribo/tests/data.hh>
int main(int argc, char *argv[])
{
using namespace mln;
+ using namespace scribo;
- if (argc != 2)
- return 1;
+ std::string img = SCRIBO_IMG_DIR "/text_to_group_and_clean.pbm";
image2d<bool> input;
- io::pbm::load(input, argv[1]);
+ io::pbm::load(input, img.c_str());
value::label_16 nlabels;
- typedef object_image(image2d<value::label_16>) O;
- O objects = scribo::primitive::extract::objects(input, c8(), nlabels);
-
- util::timer timer;
- timer.start();
+ typedef component_set<image2d<value::label_16> > O;
+ O comps = scribo::primitive::extract::components(input, c8(), nlabels);
+ O filtered_comps = scribo::filter::objects_with_holes(comps, 2, 1);
- value::label_16 nbglabels;
- image2d<bool> bin = data::convert(bool(), objects);
- image2d<value::label_16> lbl_bg = labeling::background(bin, c8(), nbglabels);
- float t_ = timer;
- std::cout << t_ << std::endl;
+ unsigned valid_comps = 0;
+ for_all_comps(c, filtered_comps)
+ if (filtered_comps(c).is_valid())
+ ++valid_comps;
- timer.restart();
- O out = scribo::filter::objects_with_holes(objects, 2, 1);
-// debug::println(out);
+ mln_assertion(valid_comps == 8u);
- t_ = timer;
- std::cout << t_ << std::endl;
- io::pgm::save(data::wrap(value::label_8(), out), "out.pgm");
}
diff --git a/scribo/tests/filter/small_and_large_bboxes.cc b/scribo/tests/filter/small_and_large_bboxes.cc
index 0b10cfe..adae46f 100644
--- a/scribo/tests/filter/small_and_large_bboxes.cc
+++ b/scribo/tests/filter/small_and_large_bboxes.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -34,12 +35,11 @@
#include <scribo/core/object_image.hh>
-#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/group/apply.hh>
-#include <scribo/primitive/link/with_graph.hh>
-#include <scribo/primitive/group/from_graph.hh>
+#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/primitive/group/from_single_link.hh>
#include <scribo/filter/objects_small.hh>
-#include <scribo/util/text.hh>
#include <scribo/make/debug_filename.hh>
#include <scribo/debug/save_bboxes_image.hh>
@@ -47,64 +47,40 @@
#include <scribo/tests/data.hh>
-int usage(const char *name)
-{
- std::cout << "Usage: " << name << " <input.pbm> " << std::endl;
- return 1;
-}
-
int main(int argc, char* argv[])
{
using namespace scribo;
using namespace mln;
- std::string img;
- if (argc < 2)
- {
- usage(argv[0]);
- img = SCRIBO_IMG_DIR "/text_to_group_and_clean.pbm";
- }
- else
- img = argv[1];
-
- scribo::make::internal::debug_filename_prefix = argv[0];
+ std::string img = SCRIBO_IMG_DIR "/text_to_group_and_clean.pbm";
image2d<bool> input;
io::pbm::load(input, img.c_str());
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
- typedef object_image(L) text_t;
- text_t text = primitive::extract::objects(input, c8(), nbboxes);
+ component_set<L>
+ text = primitive::extract::components(input, c8(), nbboxes);
- mln::util::graph g = primitive::link::with_graph(text, 30);
+ object_links<L> links = primitive::link::with_single_left_link(text, 30);
mln_assertion(nbboxes == 12u);
-// std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
-// scribo::debug::save_linked_bboxes_image(input,
-// text, g,
-// literal::red, literal::cyan,
-// "test_graph_left_linked.ppm");
- object_groups<L> groups = primitive::group::from_graph(text, g);
+ object_groups<L> groups = primitive::group::from_single_link(links);
- 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");
+ component_set<L> grouped_comps = primitive::group::apply(groups);
- mln_assertion(grouped_text.nlabels() == 6u);
+ mln_assertion(grouped_comps.nelements() == 6u);
- text_t
- filtered_text = scribo::filter::objects_small(grouped_text, 20);
+ component_set<L>
+ filtered_comps = scribo::filter::components_small(grouped_comps, 20);
- mln_assertion(filtered_text.nlabels() == 2u);
+ unsigned valid_comps = 0;
+ for_all_comps(c, filtered_comps)
+ if (filtered_comps(c).is_valid())
+ ++valid_comps;
-// scribo::debug::save_bboxes_image(input, filtered_text.bboxes(),
-// literal::red,
-// "test_graph_filtered_text.ppm");
+ mln_assertion(valid_comps == 2u);
}
diff --git a/scribo/tests/unit_test/Makefile.am b/scribo/tests/unit_test/Makefile.am
index 8b3e47f..255babf 100644
--- a/scribo/tests/unit_test/Makefile.am
+++ b/scribo/tests/unit_test/Makefile.am
@@ -42,6 +42,38 @@ $(srcdir)/unit-tests.mk: build_unit_test.sh disabled_tests
include $(srcdir)/unit-tests.mk
+
+#FIXME: how to handle that automaticaly during the unit test list
+#generation?
+scribo_convert_from_qimage_CPPFLAGS=\
+ $(QT_CPPFLAGS) $(AM_CPPFLAGS) -I$(srcdir)
+scribo_convert_from_qimage_CXXFLAGS=\
+ $(QT_CXXFLAGS) $(AM_CXXFLAGS)
+scribo_convert_from_qimage_LDFLAGS=\
+ $(QT_LDFLAGS) $(LDFLAGS)
+scribo_convert_from_qimage_LDADD=\
+ $(QT_LIBS) $(LDADD)
+
+scribo_toolchain_nepomuk_text_extraction_CPPFLAGS=\
+ $(QT_CPPFLAGS) $(TESSERACT_CPPFLAGS) $(TIFF_CPPFLAGS) \
+ $(AM_CPPFLAGS) -I$(srcdir)
+scribo_toolchain_nepomuk_text_extraction_CXXFLAGS=\
+ $(QT_CXXFLAGS) $(AM_CXXFLAGS)
+scribo_toolchain_nepomuk_text_extraction_LDFLAGS=\
+ $(QT_LDFLAGS) $(TESSERACT_LDFLAGS) $(TIFF_LDFLAGS) \
+ $(LDFLAGS)
+scribo_toolchain_nepomuk_text_extraction_LDADD=\
+ $(QT_LIBS) $(LDADD)
+
+scribo_text_recognition_CPPFLAGS=\
+ $(TESSERACT_CPPFLAGS) $(TIFF_CPPFLAGS) \
+ $(AM_CPPFLAGS) -I$(srcdir)
+scribo_text_recognition_LDFLAGS=\
+ $(TESSERACT_LDFLAGS) $(TIFF_LDFLAGS) \
+ $(LDFLAGS)
+
+
+
MAINTAINERCLEANFILES = $(srcdir)/scribo_*.cc
TESTS = $(check_PROGRAMS)
diff --git a/scribo/text/merging.hh b/scribo/text/merging.hh
index c7ad3b3..36d41c2 100644
--- a/scribo/text/merging.hh
+++ b/scribo/text/merging.hh
@@ -57,7 +57,7 @@
#include <mln/data/wrap.hh>
#include <mln/util/timer.hh>
-#include <text/look_like_text_lines.hh>
+#include <scribo/text/look_like_text_lines.hh>
namespace scribo
diff --git a/scribo/toolchain/nepomuk/text_extraction.hh b/scribo/toolchain/nepomuk/text_extraction.hh
index ed486f5..b3136be 100644
--- a/scribo/toolchain/nepomuk/text_extraction.hh
+++ b/scribo/toolchain/nepomuk/text_extraction.hh
@@ -32,8 +32,11 @@
/// Extract text from a document.
+# include <QtCore/QSet>
# include <QtCore/QString>
# include <QtCore/QStringList>
+# include <QtCore/QTextStream>
+# include <QtCore/QTextCodec>
# include <QtGui/QImage>
# include <mln/core/image/image2d.hh>
diff --git a/scribo/upsampling/eagle.hh b/scribo/upsampling/eagle.hh
index eab1989..6652156 100644
--- a/scribo/upsampling/eagle.hh
+++ b/scribo/upsampling/eagle.hh
@@ -32,6 +32,10 @@
# include <mln/core/concept/image.hh>
# include <mln/core/def/coord.hh>
+# include <mln/geom/min_row.hh>
+# include <mln/geom/min_col.hh>
+# include <mln/geom/max_row.hh>
+# include <mln/geom/max_col.hh>
# include <mln/opt/at.hh>
# include <mln/make/box2d.hh>
--
1.5.6.5
1
0

06 Aug '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/scribo-arthur has been updated
via 50621ae105a7b5c3ac3deeccbfeb443c84109266 (commit)
from d60f47f325bafaf2a006b127885934910c741b88 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
50621ae Open Document bug warning.
-----------------------------------------------------------------------
Summary of changes:
scribo/sandbox/ChangeLog | 8 ++++++++
scribo/sandbox/arthur/xml_transform/README | 24 +++++++++++++-----------
scribo/sandbox/arthur/xml_transform/main.cc | 9 +++++----
3 files changed, 26 insertions(+), 15 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0