Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
* src/Makefile.am: Disable tests and remove deprecated ones.
* src/preprocessing/Makefile.am: Use MAGICKXX_* flags.
---
scribo/ChangeLog | 12 +++++++++-
scribo/src/Makefile.am | 9 +++----
scribo/src/preprocessing/Makefile.am | 42 ++++++++++++++++++---------------
3 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 1ce0459..7197f41 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,8 +1,18 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
- Cleanup and improve text recognition.
+ Cleanup Makefiles.
+
+ * src/Makefile.am: Disable tests and remove deprecated ones.
+ * src/preprocessing/Makefile.am: Use MAGICKXX_* flags.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Cleanup and improve text recognition.
+
+ * src/text_recognition_in_picture.cc: Use new routines. Cleanup
+ useless comments. Use a height ratio filter to improve OCR
+ results.
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am
index a7dd7bc..b1a29e8 100644
--- a/scribo/src/Makefile.am
+++ b/scribo/src/Makefile.am
@@ -26,14 +26,13 @@ SUBDIRS = \
misc \
postprocessing \
preprocessing \
- table \
text
-bin_PROGRAMS = \
- pbm_lines_in_doc
+# Disabled for the moment:
+# table
-pbm_lines_in_doc_SOURCES = pbm_lines_in_doc.cc
+bin_PROGRAMS =
if HAVE_TESSERACT
@@ -46,7 +45,7 @@ if HAVE_TESSERACT
$(TESSERACT_LDFLAGS) \
$(TIFF_LDFLAGS) \
-lpthread
-# -lhpdf
+
pbm_text_in_doc_SOURCES = pbm_text_in_doc.cc
endif HAVE_TESSERACT
diff --git a/scribo/src/preprocessing/Makefile.am b/scribo/src/preprocessing/Makefile.am
index 8b99bf2..5dabcac 100644
--- a/scribo/src/preprocessing/Makefile.am
+++ b/scribo/src/preprocessing/Makefile.am
@@ -22,46 +22,50 @@ bin_PROGRAMS = \
denoise_fg \
homogeneous_contrast \
preprocess \
- split_bg_fg \
unskew
denoise_bg_SOURCES = denoise_bg.cc
denoise_fg_SOURCES = denoise_fg.cc
homogeneous_contrast_SOURCES = homogeneous_contrast.cc
preprocess_SOURCES = preprocess.cc
-split_bg_fg_SOURCES = split_bg_fg.cc
unskew_SOURCES = unskew.cc
if HAVE_MAGICKXX
+ bin_PROGRAMS += split_bg_fg
+ split_bg_fg_SOURCES = split_bg_fg.cc
+ split_bg_fg_CPPFLAGS = $(AM_CPPFLAGS) \
+ $(MAGICKXX_CPPFLAGS)
+
+ split_bg_fg_LDFLAGS = $(AM_LDFLAGS) \
+ $(MAGICKXX_LDFLAGS) \
+ -lpthread
+
bin_PROGRAMS += rotate_90
rotate_90_SOURCES = rotate_90.cc
rotate_90_CPPFLAGS = $(AM_CPPFLAGS) \
- $(TESSERACT_CPPFLAGS) \
- `Magick++-config --cppflags`
+ $(MAGICKXX_CPPFLAGS)
- rotate_90_LDFLAGS = $(AM_LDFLAGS) \
- $(TESSERACT_LDFLAGS) \
- -lpthread `Magick++-config --libs`
+ rotate_90_LDFLAGS = $(AM_LDFLAGS) \
+ $(MAGICKXX_LDFLAGS) \
+ -lpthread
- bin_PROGRAMS += to_pgm
+ bin_PROGRAMS += to_pgm
to_pgm_SOURCES = to_pgm.cc
to_pgm_CPPFLAGS = $(AM_CPPFLAGS) \
- $(TESSERACT_CPPFLAGS) \
- `Magick++-config --cppflags`
+ $(MAGICKXX_CPPFLAGS)
- to_pgm_LDFLAGS = $(AM_LDFLAGS) \
- $(TESSERACT_LDFLAGS) \
- -lpthread `Magick++-config --libs`
+ to_pgm_LDFLAGS = $(AM_LDFLAGS) \
+ $(MAGICKXX_LDFLAGS) \
+ -lpthread
- bin_PROGRAMS += subsample
+ bin_PROGRAMS += subsample
subsample_SOURCES = subsample.cc
subsample_CPPFLAGS = $(AM_CPPFLAGS) \
- $(TESSERACT_CPPFLAGS) \
- `Magick++-config --cppflags`
+ $(MAGICKXX_CPPFLAGS)
- subsample_LDFLAGS = $(AM_LDFLAGS) \
- $(TESSERACT_LDFLAGS) \
- -lpthread `Magick++-config --libs`
+ subsample_LDFLAGS = $(AM_LDFLAGS) \
+ $(MAGICKXX_LDFLAGS) \
+ -lpthread
endif HAVE_MAGICKXX
--
1.5.6.5
1
0
09 Aug '10
* src/text_recognition_in_picture.cc: Use new routines. Cleanup
useless comments. Use a height ratio filter to improve OCR
results.
---
scribo/ChangeLog | 6 ++
scribo/src/text_recognition_in_picture.cc | 129 ++++++++++++++---------------
2 files changed, 68 insertions(+), 67 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 54a9d1c..1ce0459 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,11 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Cleanup and improve text recognition.
+
+
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Cleanup and make use of the new routines.
* src/text_in_picture.cc: Here.
diff --git a/scribo/src/text_recognition_in_picture.cc b/scribo/src/text_recognition_in_picture.cc
index 119f757..b69411e 100644
--- a/scribo/src/text_recognition_in_picture.cc
+++ b/scribo/src/text_recognition_in_picture.cc
@@ -74,8 +74,10 @@
#include <scribo/primitive/group/from_single_link.hh>
#include <scribo/primitive/regroup/from_single_left_link.hh>
+#include <scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh>
+
+#include <scribo/filter/objects_size_ratio.hh>
-//#include <scribo/filter/objects_with_holes.hh>
#include <scribo/filter/object_groups_with_holes.hh>
#include <scribo/filter/object_links_bbox_h_ratio.hh>
@@ -95,6 +97,7 @@
#include <scribo/debug/usage.hh>
#include <scribo/preprocessing/split_bg_fg.hh>
+#include <scribo/preprocessing/rotate_90.hh>
#include <scribo/make/debug_filename.hh>
@@ -104,7 +107,6 @@
#include <scribo/src/afp/components.hh>
#include <scribo/src/afp/link.hh>
-#include <scribo/src/afp/regroup.hh>
#include <scribo/core/line_set.hh>
#include <scribo/text/recognition.hh>
@@ -116,11 +118,15 @@
const char *args_desc[][2] =
{
- { "input.ppm", "A color image." },
+ { "input.*", "An image." },
{ "ouput.ppm", "A color image where the text is highlighted." },
{ "out.txt", "Text recognized text with its position." },
- { "max_dim_size", "The highest dimension size of the image used for computation. It is used to find a resize factor and impacts on the performance. (1024 by default)" },
- { "lbl.ppm", "A color image with the labeled text components. (Considered as optional debug)" },
+ { "max_dim_size", "The highest dimension size of the image used for "
+ "computation. It is used to find a resize factor and impacts on the"
+ " performance. (1024 by default)" },
+ { "lambda", "Lambda value used for foreground extraction." },
+ { "lbl.ppm", "A color image with the labeled text components. (Considered"
+ " as optional debug)" },
{0, 0}
};
@@ -132,6 +138,7 @@ namespace mln
{
config()
{
+ min_size_ratio = 0.2f;
max_dim_size = 1024;
sauvola_s = 2u; // 3?
@@ -146,6 +153,9 @@ namespace mln
group_min_holes = 3;
}
+ // Component filtering
+ double min_size_ratio;
+
// Image resizing factor
unsigned max_dim_size;
@@ -173,51 +183,6 @@ mln::config conf;
namespace mln
{
- template <typename I, typename L>
- mln_concrete(I)
- compute_text_image(const I& input_rgb,
- const scribo::component_set<L>& grouped_objects)
- {
- unsigned shift = 5;
- float height = 1, width = 0;
- for_all_comps(i, grouped_objects)
- if (grouped_objects(i).is_valid())
- {
- height += grouped_objects(i).bbox().nrows() + shift;
- width = math::max(static_cast<float>(grouped_objects(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, grouped_objects)
- if (grouped_objects(i).is_valid())
- {
- mln_VAR(tmp, duplicate(input_rgb | grouped_objects(i).bbox()));
-
- typedef fun::x2x::translation<mln_site_(I)::dim, float> trans_t;
- trans_t trans(dv - grouped_objects(i).bbox().pmin().to_vec());
-
- mln_domain(I)
- tr_box(grouped_objects(i).bbox().pmin().to_vec() + trans.t(),
- grouped_objects(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] += grouped_objects(i).bbox().nrows() + shift;
- }
-
- return output;
- }
-
-
template <typename I>
unsigned get_factor(const I& ima)
{
@@ -238,13 +203,17 @@ namespace mln
int main(int argc, char* argv[])
{
using namespace scribo;
+ using namespace scribo::primitive;
using namespace mln;
- if (argc < 4 || argc > 6)
+ if (argc < 4 || argc > 7)
return scribo::debug::usage(argv,
- "Find text in a photo.\n\n\
-Common usage: ./text_in_photo_fast input.ppm output.ppm out.txt [max_dim_size] [lbl.ppm]",
- "input.ppm output.ppm out.txt [max_dim_size] [lbl.ppm]",
+ "Find text in a photo.\n\n"
+ "Common usage: ./text_recognition_in_picture"
+ " input.* output.ppm out.txt [max_dim_size]"
+ " [lambda] [lbl.ppm]",
+ "input.* output.ppm out.txt [max_dim_size]"
+ " [lambda] [lbl.ppm]",
args_desc);
@@ -266,7 +235,12 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm out.txt [max_dim_size] [
unsigned lambda;
- lambda = 1.2 * (input_rgb.nrows() + input_rgb.ncols());
+ if (argc >= 6)
+ lambda = atoi(argv[5]);
+ else
+ lambda = 1.2 * (input_rgb.nrows() + input_rgb.ncols());
+
+ std::cout << "Using lambda = " << lambda << std::endl;
image2d<value::int_u8> intensity_ima;
@@ -275,6 +249,24 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm out.txt [max_dim_size] [
fg = preprocessing::split_bg_fg(input_rgb, lambda, 32).second();
intensity_ima = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>());
+// // Perform an initial rotation if needed.
+// // input_rgb = geom::rotate(input_rgb, -45, literal::black);
+// intensity_ima = geom::rotate(intensity_ima, -45);
+
+// // Make sure the domain origin is set to (0,0).
+// box2d rb = intensity_ima.domain();
+// box2d b(geom::nrows(intensity_ima), geom::ncols(intensity_ima));
+// // {
+// // image2d<value::rgb8> tmp(b);
+// // data::paste_without_localization(input_rgb, tmp);
+// // input_rgb = tmp;
+// // }
+// {
+// image2d<value::int_u8> tmp(b);
+// data::paste_without_localization(intensity_ima, tmp);
+// intensity_ima = tmp;
+// }
+
// Binarize foreground to use it in the processing chain.
@@ -292,18 +284,19 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm out.txt [max_dim_size] [
typedef image2d<value::label_16> L;
/// Finding components.
- typedef component_set<L> Obj;
- Obj filtered_components;
-
+ component_set<L> filtered_components;
{
mln::util::array<std::pair<box2d, std::pair<point2d, unsigned> > > attribs;
value::label_16 ncomponents;
L components = extract_components(input, ncomponents, attribs);
- filtered_components = Obj(components, ncomponents, attribs);
+ filtered_components = component_set<L>(components, ncomponents, attribs);
}
+ filtered_components = filter::objects_size_ratio(filtered_components,
+ conf.min_size_ratio);
+
/// linking potential components
mln::util::couple<object_links<L>, object_links<L> >
links = primitive::link::left_right(filtered_components);
@@ -325,8 +318,6 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm out.txt [max_dim_size] [
-
-
//Remove links if bboxes overlap too much.
object_links<L> overlap_filtered_links
= filter::object_links_bbox_overlap(hratio_filtered_links,
@@ -353,22 +344,26 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm out.txt [max_dim_size] [
// Grouping groups together if possible.
- groups = primitive::regroup::from_single_left_link(filtered_thin_groups,
- conf.regroup_dmax);
+ groups = regroup::from_single_left_link_wrt_h_ratio(filtered_thin_groups,
+ conf.regroup_dmax,
+ conf.bbox_h_ratio);
/// Filter grouped objects not having enough background components.
groups = scribo::filter::object_groups_with_holes(groups,
- conf.group_min_holes);
+ conf.group_min_holes);
component_set<L> comps = primitive::group::apply(groups);
- if (argc > 5)
+ if (argc > 6)
mln::io::ppm::save(mln::labeling::colorize(value::rgb8(),
comps.labeled_image(),
comps.nelements()),
- argv[5]);
+ argv[6]);
+// mln::io::ppm::save(scribo::debug::highlight_text_area_rotated(input_rgb,
+// comps, -45, rb),
+// argv[2]);
mln::io::ppm::save(scribo::debug::highlight_text_area(input_rgb, comps),
- argv[2]);
+ argv[2]);
scribo::line_set<L> lines = scribo::make::line_set(groups);
--
1.5.6.5
1
0
last-svn-commit-437-g5a13b71 Cleanup and make use of the new routines.
by Guillaume Lazzara 09 Aug '10
by Guillaume Lazzara 09 Aug '10
09 Aug '10
* src/text_in_picture.cc: Here.
---
scribo/ChangeLog | 6 ++
scribo/src/text_in_picture.cc | 122 ++++++++++++++++-------------------------
2 files changed, 53 insertions(+), 75 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 780a185..54a9d1c 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,11 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Cleanup and make use of the new routines.
+
+ * src/text_in_picture.cc: Here.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Make use of the new component_set interface.
* filter/internal/compute.hh,
diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture.cc
index a7cf8d2..e7b8328 100644
--- a/scribo/src/text_in_picture.cc
+++ b/scribo/src/text_in_picture.cc
@@ -74,8 +74,8 @@
#include <scribo/primitive/group/from_single_link.hh>
#include <scribo/primitive/regroup/from_single_left_link.hh>
+// #include <scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh>
-//#include <scribo/filter/objects_with_holes.hh>
#include <scribo/filter/object_groups_with_holes.hh>
#include <scribo/filter/object_links_bbox_h_ratio.hh>
@@ -87,6 +87,7 @@
#include <scribo/filter/object_groups_v_thickness.hh>
#include <scribo/debug/highlight_text_area.hh>
+#include <scribo/debug/text_areas_image.hh>
#include <scribo/debug/decision_image.hh>
#include <scribo/debug/save_bboxes_image.hh>
@@ -106,13 +107,9 @@
#include <scribo/src/afp/link.hh>
#include <scribo/src/afp/regroup.hh>
-// #include <scribo/core/line_set.hh>
-// #include <scribo/text/recognition.hh>
-// #include <scribo/text/merging.hh>
-
const char *args_desc[][2] =
{
- { "input.ppm", "A color image." },
+ { "input.*", "A color image." },
{ "ouput.ppm", "A color image where the text is highlighted." },
{ "debug_output_dir", "Directory were debug images will be saved" },
{ "lambda", "Lambda value used for foreground extraction" },
@@ -128,6 +125,8 @@ namespace mln
{
config()
{
+ max_dim_size = 1024;
+
sauvola_s = 2u; // 3?
sauvola_min_w = 51u;
@@ -140,6 +139,8 @@ namespace mln
group_min_holes = 3;
}
+ // Image resizing factor
+ unsigned max_dim_size;
// Sauvola ms
unsigned sauvola_s;
@@ -155,51 +156,16 @@ namespace mln
};
+} // end of namespace mln
+
+
+// Global config variable.
+mln::config conf;
+
- template <typename I, typename L>
- mln_concrete(I)
- compute_text_image(const I& input_rgb,
- const scribo::component_set<L>& grouped_objects)
- {
- unsigned shift = 5;
- float height = 1, width = 0;
- for_all_comps(i, grouped_objects)
- if (grouped_objects(i).is_valid())
- {
- height += grouped_objects(i).bbox().nrows() + shift;
- width = math::max(static_cast<float>(grouped_objects(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, grouped_objects)
- if (grouped_objects(i).is_valid())
- {
- mln_VAR(tmp, duplicate(input_rgb | grouped_objects(i).bbox()));
-
- typedef fun::x2x::translation<mln_site_(I)::dim, float> trans_t;
- trans_t trans(dv - grouped_objects(i).bbox().pmin().to_vec());
-
- mln_domain(I)
- tr_box(grouped_objects(i).bbox().pmin().to_vec() + trans.t(),
- grouped_objects(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] += grouped_objects(i).bbox().nrows() + shift;
- }
-
- return output;
- }
+namespace mln
+{
template <typename I>
unsigned get_factor(const I& ima)
@@ -208,7 +174,7 @@ namespace mln
nrows = ima.nrows(),
ncols = ima.ncols(),
max_dim = std::max(nrows, ncols),
- factor = max_dim / 512;
+ factor = max_dim / conf.max_dim_size;
return factor ? factor : 1;
}
@@ -219,13 +185,20 @@ namespace mln
int main(int argc, char* argv[])
{
using namespace scribo;
+ using namespace scribo::primitive;
using namespace mln;
- if (argc < 3 || argc > 10)
+ if (argc < 3 || argc > 11)
return scribo::debug::usage(argv,
- "Find text in a photo.\n\n\
-Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
- "input.ppm output.ppm <bg/fg enabled> <sauvola_ms enabled> <Bg comp filter enabled> <small group filter enabled> <thin group filter enabled> [debug_output_dir] [lambda]",
+ "Find text in a photo.\n\n"
+ "Common usage: ./text_in_photo_fast input.*"
+ " output.ppm 1 1 1 1 1",
+ "input.ppm output.ppm <bg/fg enabled>"
+ " <sauvola_ms enabled> "
+ "<holes in group filter enabled> "
+ "<small group filter enabled> "
+ "<thin group filter enabled> "
+ "[debug_output_dir] [max_dim_size] [lambda]",
args_desc);
std::string out_base_dir;
@@ -239,11 +212,12 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
trace::entering("main");
- config conf;
-
image2d<value::rgb8> input_rgb;
io::magick::load(input_rgb, argv[1]);
+ if (argc >= 10)
+ conf.max_dim_size = atoi(argv[9]);
+
unsigned factor = get_factor(input_rgb);
std::cout << "Reduction Factor : " << factor << std::endl;
@@ -255,8 +229,8 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
std::cout << "Resized domain: " << input_rgb.domain() << std::endl;
unsigned lambda;
- if (argc == 10)
- lambda = atoi(argv[9]);
+ if (argc == 11)
+ lambda = atoi(argv[10]);
else
lambda = 1.2 * (input_rgb.nrows() + input_rgb.ncols());
@@ -360,7 +334,7 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
/// linking potential components
timer_.restart();
mln::util::couple<object_links<L>, object_links<L> >
- links = primitive::link::left_right(filtered_components);
+ links = link::left_right(filtered_components);
object_links<L>& left_link = links.first();
object_links<L>& right_link = links.second();
@@ -383,11 +357,11 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
{
std::cerr << "BEFORE - ncomponents = " << filtered_components.nelements() << std::endl;
scribo::debug::save_linked_bboxes_image(input,
- filtered_components,
left_link, right_link,
literal::red, literal::cyan,
literal::yellow,
literal::green,
+ anchor::MassCenter,
scribo::make::debug_filename("links.ppm"));
}
#endif
@@ -397,7 +371,7 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
// Validating left and right links.
timer_.restart();
object_links<L>
- merged_links = primitive::link::merge_double_link(left_link, right_link);
+ merged_links = link::merge_double_link(left_link, right_link);
t_ = timer_;
std::cout << "Right/Left Validation. " << t_ << std::endl;
@@ -454,14 +428,14 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
timer_.restart();
object_groups<L>
- groups = primitive::group::from_single_link(overlap_filtered_links);
+ groups = group::from_single_link(overlap_filtered_links);
// Apply grouping in a temporary image (for debug purpose).
#ifndef NOUT
component_set<L>
- raw_group_image = primitive::group::apply(groups);
+ raw_group_image = group::apply(groups);
#endif // !NOUT
t_ = timer_;
@@ -569,12 +543,15 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
g_timer.restart();
// Grouping groups together if possible.
- groups = primitive::regroup::from_single_left_link(filtered_thin_groups,
- conf.regroup_dmax);
+// filtered_thin_groups = regroup::from_single_left_link_wrt_h_ratio(filtered_thin_groups,
+// conf.regroup_dmax,
+// 1.60f);
+ filtered_thin_groups = regroup::from_single_left_link(filtered_thin_groups,
+ conf.regroup_dmax);
// component_set<L>
-// grouped_components = primitive::group::apply(groups);
+// grouped_components = group::apply(groups);
t_ = g_timer;
@@ -599,12 +576,14 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
{
std::cout << "** Using objects_with_two_holes" << std::endl;
- groups = scribo::filter::object_groups_with_holes(groups,
+ groups = scribo::filter::object_groups_with_holes(filtered_thin_groups,
conf.group_min_holes);
t_ = g_timer;
std::cout << "Objects_with_holes " << t_ << std::endl;
}
+ else
+ groups = filtered_thin_groups;
t_ = timer_;
@@ -639,7 +618,7 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
io::ppm::save(scribo::debug::highlight_text_area(input_rgb, comps),
out_base_dir + "_input_with_bboxes.ppm");
- io::ppm::save(compute_text_image(input_rgb, comps),
+ io::ppm::save(scribo::debug::text_areas_image(input_rgb, comps),
out_base_dir + "_out_text.ppm");
t_ = timer_;
@@ -647,13 +626,6 @@ Common usage: ./text_in_photo_fast input.ppm output.ppm 1 1 1 1 1",
std::cout << "# objects = " << comps.nelements() << std::endl;
-
-
-// scribo::line_set<L>
-// lines = scribo::make::line_set(groups);
-// lines = scribo::text::merging(lines);
-// text::recognition(lines, "fra", "out.txt");
-
trace::exiting("main");
return comps.nelements() != 0;
}
--
1.5.6.5
1
0
last-svn-commit-436-g8bd9126 Make use of the new component_set interface.
by Guillaume Lazzara 09 Aug '10
by Guillaume Lazzara 09 Aug '10
09 Aug '10
* filter/internal/compute.hh,
* filter/objects_small.hh,
* filter/objects_thick.hh,
* filter/objects_thin.hh,
* primitive/group/from_double_link.hh,
* primitive/link/compute_several.hh,
* table/align_lines_horizontaly.hh,
* table/erase.hh,
* table/extract.hh: Here.
---
scribo/ChangeLog | 14 ++++++++++++++
scribo/debug/decision_image.hh | 2 +-
scribo/filter/internal/compute.hh | 10 +++++-----
scribo/filter/objects_small.hh | 20 +++++---------------
scribo/filter/objects_thick.hh | 12 ++++++------
scribo/filter/objects_thin.hh | 23 ++++++++++++-----------
scribo/primitive/group/from_double_link.hh | 22 ++++++++++------------
scribo/primitive/link/compute_several.hh | 2 +-
scribo/table/align_lines_horizontaly.hh | 25 +++++++++++++++----------
scribo/table/erase.hh | 14 ++++++--------
scribo/table/extract.hh | 14 ++++++++------
11 files changed, 83 insertions(+), 75 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 4865134..780a185 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,19 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Make use of the new component_set interface.
+
+ * filter/internal/compute.hh,
+ * filter/objects_small.hh,
+ * filter/objects_thick.hh,
+ * filter/objects_thin.hh,
+ * primitive/group/from_double_link.hh,
+ * primitive/link/compute_several.hh,
+ * table/align_lines_horizontaly.hh,
+ * table/erase.hh,
+ * table/extract.hh: Here.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix compilation of Scribo tools.
* src/debug/show_links_bbox_overlap.cc,
diff --git a/scribo/debug/decision_image.hh b/scribo/debug/decision_image.hh
index 1bf2643..aa1a188 100644
--- a/scribo/debug/decision_image.hh
+++ b/scribo/debug/decision_image.hh
@@ -104,7 +104,7 @@ namespace scribo
trace::entering("scribo::debug::decision_image");
const I& input = exact(input_);
- const component_set<L>& components = groups.object_image_();
+ const component_set<L>& components = groups.components();
mln_precondition(input.is_valid());
mln_precondition(groups.is_valid());
diff --git a/scribo/filter/internal/compute.hh b/scribo/filter/internal/compute.hh
index bd00eb6..7c87c5f 100644
--- a/scribo/filter/internal/compute.hh
+++ b/scribo/filter/internal/compute.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.
//
@@ -106,7 +107,7 @@ namespace scribo
component_set<lbl_t> components
= primitive::extract::components(input, nbh, nlabels);
- filter.update_components(components);
+ filter.update_objects(components);
components.relabel(filter);
mln_concrete(I) output = duplicate(input);
@@ -127,9 +128,8 @@ namespace scribo
mln_precondition(components.is_valid());
- component_set<L> output;
- output.init_from_(components);
- output.relabel(filter);
+ component_set<L> output = components.duplicate();
+ output.update_tags(filter, component::Ignored);
trace::exiting("scribo::filter::internal::compute");
return output;
diff --git a/scribo/filter/objects_small.hh b/scribo/filter/objects_small.hh
index f97a79e..ba9a50c 100644
--- a/scribo/filter/objects_small.hh
+++ b/scribo/filter/objects_small.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.
//
@@ -36,20 +37,12 @@
# include <mln/core/concept/function.hh>
# include <mln/core/image/dmorph/image_if.hh>
-# include <mln/labeling/blobs.hh>
-# include <mln/labeling/relabel.hh>
-
-# include <mln/make/relabelfun.hh>
+# include <mln/data/transform.hh>
# include <mln/util/array.hh>
# include <mln/pw/all.hh>
-# include <mln/accu/math/count.hh>
-
-# include <mln/set/compute.hh>
-
-
# include <scribo/core/component_set.hh>
# include <scribo/fun/v2b/objects_small_filter.hh>
# include <scribo/primitive/extract/components.hh>
@@ -120,11 +113,8 @@ namespace scribo
typedef fun::v2b::components_small_filter<mln_ch_value(I,V)> func_t;
func_t fv2b(lbl, min_size);
- lbl.relabel(fv2b);
-
- mln_concrete(I) output = duplicate(input);
- data::fill((output | (pw::value(lbl) == pw::cst(literal::zero))).rw(),
- false);
+ mln_concrete(I)
+ output = mln::data::transform(lbl.labeled_image(), fv2b);
trace::exiting("scribo::filter::components_small");
return output;
diff --git a/scribo/filter/objects_thick.hh b/scribo/filter/objects_thick.hh
index c933532..485092a 100644
--- a/scribo/filter/objects_thick.hh
+++ b/scribo/filter/objects_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.
//
@@ -111,8 +112,8 @@ namespace scribo
{
if (l == literal::zero)
return true;
- return components_.bbox(l).nrows() < max_thickness_
- && components_.bbox(l).ncols() < max_thickness_;
+ return components_(l).bbox().nrows() < max_thickness_
+ && components_(l).bbox().ncols() < max_thickness_;
}
@@ -173,9 +174,8 @@ namespace scribo
typedef internal::thick_object_filter<L> func_t;
func_t is_not_too_thick(components, max_thickness);
- component_set<L> output;
- output.init_from_(components);
- output.relabel(is_not_too_thick);
+ component_set<L> output = components.duplicate();
+ output.update_tags(is_not_too_thick, component::Ignored);
trace::exiting("scribo::filter::objects_thick");
return output;
diff --git a/scribo/filter/objects_thin.hh b/scribo/filter/objects_thin.hh
index c821b74..e8591d9 100644
--- a/scribo/filter/objects_thin.hh
+++ b/scribo/filter/objects_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.
//
@@ -37,6 +38,8 @@
# include <mln/util/array.hh>
+# include <mln/data/transform.hh>
+
# include <scribo/core/component_set.hh>
# include <scribo/primitive/extract/components.hh>
# include <scribo/filter/internal/compute.hh>
@@ -111,8 +114,8 @@ namespace scribo
{
if (l == literal::zero)
return true;
- return components_.bbox(l).nrows() > min_thickness_
- && components_.bbox(l).ncols() > min_thickness_;
+ return components_(l).bbox().nrows() > min_thickness_
+ && components_(l).bbox().ncols() > min_thickness_;
}
/// Component bounding boxes.
@@ -145,16 +148,13 @@ namespace scribo
V nlabels;
typedef mln_ch_value(I,V) lbl_t;
- component_set<lbl_t> components
+ component_set<lbl_t> comps
= primitive::extract::components(input, nbh, nlabels);
typedef internal::components_thin_filter<lbl_t> func_t;
- func_t fv2b(components, min_thickness);
- components.relabel(fv2b);
-
- mln_concrete(I) output = duplicate(input);
- data::fill((output | (pw::value(components) == pw::cst(literal::zero))).rw(),
- false);
+ func_t fv2b(comps, min_thickness);
+ mln_concrete(I)
+ output = mln::data::transform(comps.labeled_image(), fv2b);
trace::exiting("scribo::filter::components_thin");
return output;
@@ -174,7 +174,8 @@ namespace scribo
typedef internal::components_thin_filter<L> func_t;
func_t is_not_too_thin(components, min_thickness);
- component_set<L> output = internal::compute(components, is_not_too_thin);
+ component_set<L> output = components.duplicate();
+ output.update_tags(is_not_too_thin, component::Ignored);
trace::exiting("scribo::filter::components_thin");
return output;
diff --git a/scribo/primitive/group/from_double_link.hh b/scribo/primitive/group/from_double_link.hh
index 9367cfa..3af395d 100644
--- a/scribo/primitive/group/from_double_link.hh
+++ b/scribo/primitive/group/from_double_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.
//
@@ -69,8 +70,7 @@ namespace scribo
*/
template <typename L>
object_groups<L>
- from_double_link(const component_set<L>& components,
- const object_links<L>& left_link,
+ from_double_link(const object_links<L>& left_link,
const object_links<L>& right_link);
@@ -81,19 +81,17 @@ namespace scribo
template <typename L>
inline
object_groups<L>
- from_double_link(const component_set<L>& components,
- const object_links<L>& left_link,
+ from_double_link(const object_links<L>& left_link,
const object_links<L>& right_link)
{
trace::entering("scribo::primitive::group::from_double_link");
mln_precondition(left_link.nelements() == right_link.nelements());
- mln_precondition(left_link.components_id_() == components.id_());
- mln_precondition(right_link.components_id_() == components.id_());
- object_groups<L> parent(components, left_link.nelements());
+
+ object_groups<L> parent(left_link);
parent.init();
- for_all_ncomponents(i, components.nlabels())
+ for_all_comps(i, left_link.components())
{
mln::util::couple<bool, unsigned>
nbh = internal::is_link_valid(left_link, right_link, i);
@@ -101,14 +99,14 @@ namespace scribo
{
unsigned par = internal::find_root(parent, nbh.second());
if (par < i)
- parent[par] = i;
+ parent(par) = i;
else
- parent[i] = par;
+ parent(i) = par;
}
}
for (unsigned i = parent.nelements() - 1; i < parent.nelements(); --i)
- parent[i] = parent[parent[i]];
+ parent(i) = parent(parent(i));
trace::exiting("scribo::primitive::group::from_double_link");
return parent;
diff --git a/scribo/primitive/link/compute_several.hh b/scribo/primitive/link/compute_several.hh
index 929a7cb..551b16c 100644
--- a/scribo/primitive/link/compute_several.hh
+++ b/scribo/primitive/link/compute_several.hh
@@ -95,7 +95,7 @@ namespace scribo
F& functor = exact(functor_);
- for_all_ncomponents(current_object, functor.objects().nlabels())
+ for_all_comps(current_object, functor.components())
{
functor.start_processing_object(current_object); //<-- start_processing_object
internal::find_several_links(functor, current_object);
diff --git a/scribo/table/align_lines_horizontaly.hh b/scribo/table/align_lines_horizontaly.hh
index cf776ae..25e4036 100644
--- a/scribo/table/align_lines_horizontaly.hh
+++ b/scribo/table/align_lines_horizontaly.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.
//
@@ -61,30 +62,34 @@ namespace scribo
///
/// \return A list of the resulting aligned rows. Each integer is actually
/// a row number.
- template <typename I>
+ template <typename I, typename L>
mln::util::array<int>
align_lines_horizontaly(const Image<I>& input,
- mln::util::array<box<mln_site(I)> >& line_bboxes,
+ const component_set<L>& lines,
+ component_set<L>& aligned_lines,
unsigned max_alignment_diff);
# ifndef MLN_INCLUDE_ONLY
- template <typename I>
+ template <typename I, typename L>
mln::util::array<int>
align_lines_horizontaly(const Image<I>& input,
- mln::util::array<box<mln_site(I)> >& line_bboxes,
+ const component_set<L>& lines,
+ component_set<L>& aligned_lines,
unsigned max_alignment_diff)
{
trace::entering("scribo::table::align_lines_horizontaly");
mln_precondition(exact(input).is_valid());
- mln::util::array<int> res = internal::align_lines(geom::nrows(input),
- geom::min_row(input),
- geom::max_row(input),
- line_bboxes, 0,
- max_alignment_diff);
+ mln::util::array<int>
+ res = internal::align_lines(geom::nrows(input),
+ geom::min_row(input),
+ geom::max_row(input),
+ lines,
+ aligned_lines, 0,
+ max_alignment_diff);
trace::exiting("scribo::table::align_lines_horizontaly");
return res;
diff --git a/scribo/table/erase.hh b/scribo/table/erase.hh
index a34e5a0..8cdf834 100644
--- a/scribo/table/erase.hh
+++ b/scribo/table/erase.hh
@@ -54,16 +54,16 @@ namespace scribo
///
/// \param[in] input A binary image from which the table lines
/// are extracted.
- /// \param[in] hlines An object image with horizontal lines.
- /// \param[in] vlines An object image with vertical lines.
+ /// \param[in] hlines A component set with horizontal lines.
+ /// \param[in] vlines A component set with vertical lines.
///
/// \return A copy of \p in where the table lines are removed.
//
template <typename I, typename L>
mln_concrete(I)
erase(const Image<I>& input,
- const Image<L>& hlines,
- const Image<L>& vlines);
+ const component_set<L>& hlines,
+ const component_set<L>& vlines);
# ifndef MLN_INCLUDE_ONLY
@@ -73,14 +73,12 @@ namespace scribo
inline
mln_concrete(I)
erase(const Image<I>& input,
- const Image<L>& hlines,
- const Image<L>& vlines)
+ const component_set<L>& hlines,
+ const component_set<L>& vlines)
{
trace::entering("scribo::internal::erase");
mlc_equal(mln_value(I),bool)::check();
mln_precondition(exact(input).is_valid());
- mln_precondition(exact(hlines).is_valid());
- mln_precondition(exact(vlines).is_valid());
I output = duplicate(input);
diff --git a/scribo/table/extract.hh b/scribo/table/extract.hh
index aca2321..49a7d50 100644
--- a/scribo/table/extract.hh
+++ b/scribo/table/extract.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.
//
@@ -90,9 +91,11 @@ namespace scribo
bvlines = scribo::primitive::extract::lines_v_pattern(input, 51, 3);
V nhlines, nvlines;
- object_image(mln_ch_value(I,V))
- hlines = scribo::primitive::extract::objects(bhlines, c8(), nhlines),
- vlines = scribo::primitive::extract::objects(bvlines, c8(), nvlines);
+ component_set<mln_ch_value(I,V)>
+ hlines = scribo::primitive::extract::components(bhlines, c8(),
+ nhlines),
+ vlines = scribo::primitive::extract::components(bvlines, c8(),
+ nvlines);
typedef mln::util::couple<mln_ch_value(I,V),
mln::util::couple<mln::util::array<box<mln_site(I)> >,
@@ -100,8 +103,7 @@ namespace scribo
tables_t;
tables_t tables
= scribo::table::rebuild(input,
- mln::make::couple(vlines.bboxes(), hlines.bboxes()),
- 30, ncells);
+ vlines, hlines, 30, ncells);
trace::exiting("scribo::table::extract");
return tables;
--
1.5.6.5
1
0
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