* 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
* 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
* 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
* core/internal/link_functor_base.hh,
* debug/save_object_diff.hh,
* make/text.hh,
* primitive/internal/update_link_array.hh,
* primitive/link/internal/anchors_3.hh,
* primitive/link/internal/link_ms_dmax_base.hh,
* primitive/link/internal/link_ms_dmax_ratio_base.hh,
* src/pbm_lines_in_doc.cc: Remove.
---
scribo/ChangeLog | 13 +
scribo/core/internal/link_functor_base.hh | 119 --------
scribo/debug/save_object_diff.hh | 98 -------
scribo/make/text.hh | 180 ------------
scribo/primitive/internal/update_link_array.hh | 105 -------
scribo/primitive/link/internal/anchors_3.hh | 147 ----------
.../primitive/link/internal/link_ms_dmax_base.hh | 164 -----------
.../link/internal/link_ms_dmax_ratio_base.hh | 170 -----------
scribo/src/pbm_lines_in_doc.cc | 299 --------------------
9 files changed, 13 insertions(+), 1282 deletions(-)
delete mode 100644 scribo/core/internal/link_functor_base.hh
delete mode 100644 scribo/debug/save_object_diff.hh
delete mode 100644 scribo/make/text.hh
delete mode 100644 scribo/primitive/internal/update_link_array.hh
delete mode 100644 scribo/primitive/link/internal/anchors_3.hh
delete mode 100644 scribo/primitive/link/internal/link_ms_dmax_base.hh
delete mode 100644 scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh
delete mode 100644 scribo/src/pbm_lines_in_doc.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index cef5ea4..3b441f7 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,18 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Remove deprecated files.
+
+ * core/internal/link_functor_base.hh,
+ * debug/save_object_diff.hh,
+ * make/text.hh,
+ * primitive/internal/update_link_array.hh,
+ * primitive/link/internal/anchors_3.hh,
+ * primitive/link/internal/link_ms_dmax_base.hh,
+ * primitive/link/internal/link_ms_dmax_ratio_base.hh,
+ * src/pbm_lines_in_doc.cc: Remove.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix many tests in Scribo.
* all.hh,
diff --git a/scribo/core/internal/link_functor_base.hh b/scribo/core/internal/link_functor_base.hh
deleted file mode 100644
index addba06..0000000
--- a/scribo/core/internal/link_functor_base.hh
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_HH
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_HH
-
-/// \file
-///
-/// Base class for link functors.
-
-# include <mln/core/concept/image.hh>
-
-# include <mln/math/abs.hh>
-
-# include <mln/util/array.hh>
-# include <mln/util/couple.hh>
-
-# include <scribo/core/concept/link_functor.hh>
-
-# include <scribo/core/object_image.hh>
-# include <scribo/core/object_links.hh>
-
-# include <scribo/primitive/internal/init_link_array.hh>
-
-
-namespace scribo
-{
-
- namespace internal
- {
-
- /// \brief Base class for link functors.
- template <typename L, typename E>
- class link_functor_base : public Link_Functor<E>
- {
- public:
-
- typedef L support;
-
- link_functor_base(const object_image(L)& objects);
-
- const object_links<L>& links() const;
-
- unsigned link(unsigned object) const;
- const object_image(L)& objects() const;
-
- protected:
- object_links<L> links_;
- const object_image(L) objects_;
- };
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L, typename E>
- inline
- link_functor_base<L,E>::link_functor_base(const object_image(L)& objects)
- : links_(objects, static_cast<unsigned>(objects.nlabels()) + 1),
- objects_(objects)
- {
- primitive::internal::init_link_array(links_);
- }
-
- template <typename L, typename E>
- inline
- const object_links<L>&
- link_functor_base<L,E>::links() const
- {
- return links_;
- }
-
- template <typename L, typename E>
- inline
- unsigned
- link_functor_base<L,E>::link(unsigned object) const
- {
- return links_[object];
- }
-
- template <typename L, typename E>
- inline
- const object_image(L)&
- link_functor_base<L,E>::objects() const
- {
- return objects_;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::internal
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_HH
diff --git a/scribo/debug/save_object_diff.hh b/scribo/debug/save_object_diff.hh
deleted file mode 100644
index e4f49f4..0000000
--- a/scribo/debug/save_object_diff.hh
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_DEBUG_SAVE_OBJECT_DIFF_HH
-# define SCRIBO_DEBUG_SAVE_OBJECT_DIFF_HH
-
-/// \file
-///
-/// Show the difference between two object images.
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/concept/image.hh>
-# include <mln/data/fill.hh>
-# include <mln/labeling/colorize.hh>
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/save.hh>
-# include <mln/literal/black.hh>
-# include <mln/literal/colors.hh>
-# include <mln/pw/all.hh>
-# include <mln/core/image/dmorph/image_if.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
-
-namespace scribo
-{
-
- namespace debug
- {
-
- using namespace mln;
-
- /*! \brief Show the difference between two object images.
-
- \param[in] lbl An object image.
- \param[in] lbl_2 Another object image.
- \param[in] filename The output filename.
-
- */
- template <typename L, typename L2>
- void
- save_object_diff(const object_image(L)& lbl, const object_image(L2)& lbl_2,
- const std::string& filename);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L, typename L2>
- void
- save_object_diff(const object_image(L)& lbl, const object_image(L2)& lbl_2,
- const std::string& filename)
- {
- image2d<value::rgb8> output;
- initialize(output, lbl_2);
-
- data::fill(output, literal::black);
-
- for_all_components(i, lbl.bboxes())
- data::fill(((output | lbl.bbox(i)).rw() | (pw::value(lbl) == i)).rw(), literal::red);
-
- for_all_components(i, lbl_2.bboxes())
- data::fill(((output | lbl_2.bbox(i)).rw() | (pw::value(lbl_2) == i)).rw(), literal::green);
-
- io::ppm::save(output, filename);
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::debug
-
-} // end of namespace scribo
-
-#endif // ! SCRIBO_DEBUG_SAVE_OBJECT_DIFF_HH
diff --git a/scribo/make/text.hh b/scribo/make/text.hh
deleted file mode 100644
index 6d10ef3..0000000
--- a/scribo/make/text.hh
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_MAKE_TEXT_HH
-# define SCRIBO_MAKE_TEXT_HH
-
-/// \file
-///
-/// Construct a util::text.
-
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
-# include <mln/core/site_set/box.hh>
-# include <mln/fun/i2v/array.hh>
-# include <mln/labeling/blobs.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/labeling/relabel.hh>
-# include <mln/util/array.hh>
-# include <mln/make/relabelfun.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/util/text.hh>
-
-
-namespace scribo
-{
-
- namespace make
- {
-
-
- /// Construct a util::text
- ///
- /// \param[in] bboxes Text component bounding boxes.
- /// \param[in] lbl Associated label image.
- /// \param[in] nbboxes The number of bounding boxes.
- ///
- /// \return A util::text.
- template <typename L>
- scribo::util::text<L>
- text(const mln::util::array<box<mln_site(L)> >& bboxes,
- const Image<L>& lbl,
- mln_value(L)& nbboxes);
-
- /// Construct a util::text
- ///
- /// \param[in] input_ A binary image.
- /// \param[in] nbh_ A neighborhood to be used with labeling algorithms.
- /// \param[in] nbboxes The number of bounding boxes.
- ///
- /// \return A util::text.
- template <typename I, typename N, typename V>
- scribo::util::text<mln_ch_value(I,V)>
- text(const Image<I>& input_, const Neighborhood<N>& nbh_,
- V& nbboxes);
-
-
- /// Construct a new util::text from another one.
- ///
- /// \param[in] text A text structure.
- /// \param[in] f_ A function v2v or v2b. It will be used to regroup text
- /// components.
- ///
- /// \return a new util::text.
- //
- template <typename L, typename F>
- scribo::util::text<L>
- text(const scribo::util::text<L>& text,
- const Function<F>& f_);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L>
- scribo::util::text<L>
- text(const mln::util::array<box<mln_site(L)> >& bboxes,
- const Image<L>& lbl,
- mln_value(L)& nbboxes)
- {
- trace::entering("scribo::make::text");
-
- mln_precondition(exact(lbl).is_valid());
-
- scribo::util::text<L> result = scribo::util::text<L>(bboxes, lbl,
- nbboxes);
-
- trace::exiting("scribo::make::text");
- return result;
- }
-
-
-
- template <typename I, typename N, typename V>
- scribo::util::text<mln_ch_value(I,V)>
- text(const Image<I>& input_, const Neighborhood<N>& nbh_,
- V& nbboxes)
- {
- trace::entering("scribo::make::text");
-
- const I& input = exact(input_);
- const N& nbh = exact(nbh_);
-
- mln_precondition(input.is_valid());
- mln_precondition(nbh.is_valid());
-
- typedef mln::util::array< box<mln_site(I)> > boxes_t;
-
- mln_ch_value(I,V) lbl = labeling::blobs(input, nbh, nbboxes);
-
- boxes_t cboxes = labeling::compute(accu::meta::shape::bbox(), lbl, nbboxes);
-
- trace::exiting("scribo::make::text");
- return make::text(cboxes, lbl, nbboxes);
- }
-
-
- template <typename L, typename F>
- scribo::util::text<L>
- text(const scribo::util::text<L>& text,
- const Function<F>& f_)
- {
- trace::entering("scribo::make::text");
-
- mln_precondition(text.is_valid());
- const F& f = exact(f_);
-
- mln_value(L) new_nbboxes;
- mln::fun::i2v::array<mln_value(L)> fv2v
- = mln::make::relabelfun(f, text.nbboxes(), new_nbboxes);
-
- L lbl = labeling::relabel(text.label_image(), text.nbboxes(), fv2v);
-
- mln::util::array< accu::shape::bbox<mln_site(L)> > tboxes(new_nbboxes.next());
- mln::util::array< accu::center<mln_site(L)> > tcenters(new_nbboxes.next());
- for_all_comps(i, text.bboxes())
- {
- tboxes[fv2v(i)].take(text.bbox(i));
- tcenters[fv2v(i)].take(text.mass_center(i));
- }
-
- scribo::util::text<L> new_text;
- new_text.nbboxes() = new_nbboxes;
- new_text.label_image() = lbl;
- convert::from_to(tboxes, new_text.bboxes());
- convert::from_to(tcenters, new_text.mass_centers());
-
- trace::exiting("scribo::make::text");
- return new_text;
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::make
-
-} // end of namespace scribo
-
-#endif // ! SCRIBO_MAKE_TEXT_HH
diff --git a/scribo/primitive/internal/update_link_array.hh b/scribo/primitive/internal/update_link_array.hh
deleted file mode 100644
index f7fdf44..0000000
--- a/scribo/primitive/internal/update_link_array.hh
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
-# define SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
-
-/// \file
-///
-/// Update a lookup table if a neighbor is found on the right of
-/// the current bbox.
-///
-/// \todo To be deleted.
-
-# include <mln/core/concept/image.hh>
-# include <mln/util/array.hh>
-# include <mln/math/abs.hh>
-
-
-namespace scribo
-{
-
- namespace primitive
- {
-
- namespace internal
- {
-
- using namespace mln;
-
-
- /// Update the lookup table \p link_array if a neighbor is found
- /// on the right of the current bbox.
- ///
- /// \param[in] lbl A label image.
- /// \param[in] link_array Links of bounding boxes.
- /// \param[in] p A site of \p lbl.
- /// \param[in] c A site of \p lbl.
- //
- template <typename I>
- bool
- update_link_array(const Image<I>& lbl,
- mln::util::array<unsigned>& link_array,
- const mln_site(I)& p, const mln_site(I)& c,
- unsigned i, float dmax);
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename I>
- inline
- bool
- update_link_array(const Image<I>& lbl_,
- mln::util::array<unsigned>& link_array,
- const mln_site(I)& p, const mln_site(I)& c,
- unsigned i, float dmax)
- {
- const I& lbl = exact(lbl_);
-
- mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
- mln_assertion(lbl.is_valid());
-
- if (lbl.domain().has(p) // Not outside image domain
- && lbl(p) != literal::zero // Not the background
- && lbl(p) != i // Not the current component
- && static_cast<float>((math::abs(p.col() - c.col()))) < dmax // Not too far
- && link_array[lbl(p)] != i) // Not creating a loop
- {
- link_array[i] = lbl(p);
- return true;
- }
-
- return false;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::primitive::internal
-
- } // end of namespace scribo::text
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
diff --git a/scribo/primitive/link/internal/anchors_3.hh b/scribo/primitive/link/internal/anchors_3.hh
deleted file mode 100644
index 3be9658..0000000
--- a/scribo/primitive/link/internal/anchors_3.hh
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_ANCHORS_3_HH
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_ANCHORS_3_HH
-
-/// \file
-///
-/// Routine providing 3 anchors for neighbor seeking.
-
-# include <mln/math/min.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_image.hh>
-
-
-namespace scribo
-{
-
- namespace primitive
- {
-
- namespace link
- {
-
- namespace internal
- {
-
- /*! \brief Return the proper anchor used to find a neighbor.
-
- This routine provides up to 3 different anchors.
-
- \param[in] objects An object image.
- \param[in] mass_centers Object mass centers.
- \param[in] current_object An object id.
- \param[in] anchor The expected anchor.
-
- Anchor can take one of the following values:
- - 0, top anchor.
- - 1, center anchor. It is the mass center.
- - 2, bottom anchor.
-
-
- Top and bottom anchors are respectively computed from the
- bbox pmin and the bbox pmax, P.
-
- Then the output anchor coordinates are computed as follows:
-
- out.col = bbox.center.col
-
- if object height, h, is lower than 30.
- out.row = P.row + min(2, (h + 1) / 2 - 1)
- else
- out.row = P.row - min(10, h /10)
-
- */
- template <typename L, typename P>
- mln_site(L)
- anchors_3(const object_image(L)& objects,
- const mln::util::array<P>& mass_centers,
- unsigned current_object, unsigned anchor);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L, typename P>
- mln_site(L)
- anchors_3(const object_image(L)& objects,
- const mln::util::array<P>& mass_centers,
- unsigned current_object, unsigned anchor)
- {
- unsigned h = objects.bbox(current_object).pmax().row()
- - objects.bbox(current_object).pmin().row();
-
- mln_site(L) sp = objects.bbox(current_object).center();
- mln::def::coord r;
-
- switch (anchor)
- {
- // Top
- case 0:
- if (h < 30)
- r = objects.bbox(current_object).pmin().row()
- + mln::math::min(2u, (h + 1) / 2 - 1);
- else
- r = objects.bbox(current_object).pmin().row()
- - mln::math::min(10u, h /10);
- break;
-
-
- // Center
- case 1:
- return mass_centers(current_object);
-
-
- // Bottom
- case 2:
- if (h < 30)
- r = objects.bbox(current_object).pmax().row()
- + mln::math::min(2u, (h + 1) / 2 - 1);
- else
- r = objects.bbox(current_object).pmax().row()
- - mln::math::min(10u, h /10);
- break;
-
- default:
- mln::trace::warning("Non handled anchor");
- mln_assertion(anchor > 2);
- }
-
- sp.row() = r;
- return sp;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::primitive::link::internal
-
- } // end of namespace scribo::primitive::link
-
- } // end of namespace scribo::primitive
-
-} // end of namespace scribo
-
-#endif // ! SCRIBO_PRIMITIVE_LINK_INTERNAL_ANCHORS_3_HH
diff --git a/scribo/primitive/link/internal/link_ms_dmax_base.hh b/scribo/primitive/link/internal/link_ms_dmax_base.hh
deleted file mode 100644
index edb0941..0000000
--- a/scribo/primitive/link/internal/link_ms_dmax_base.hh
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_HH_
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_HH_
-
-/// \file
-///
-/// Base class for link functors using mass centers and a given max
-/// distance.
-
-
-# include <mln/accu/center.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/math/abs.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/core/object_links.hh>
-
-# include <scribo/primitive/link/internal/find_link.hh>
-# include <scribo/primitive/link/internal/link_functor_base.hh>
-
-# include <scribo/primitive/link/compute.hh>
-
-
-namespace scribo
-{
-
- namespace primitive
- {
-
- namespace link
- {
-
- namespace internal
- {
-
- /// \brief Base class for link functors using mass centers and
- /// a given max distance.
- //
- template <typename L, typename E>
- class link_ms_dmax_base
- : public link_functor_base<L, E>
- {
- typedef link_functor_base<L,E> super_;
- typedef mln_result(accu::center<mln_psite(L)>) ms_t;
-
- public:
-
- typedef mln_site(L) P;
-
-
- link_ms_dmax_base(const object_image(L)& objects,
- unsigned neighb_max_distance,
- anchor::Direction direction);
-
- bool verify_link_criterion_(unsigned current_object,
- const P& start_point, const P& p) const;
-
- mln_site(L) start_point_(unsigned current_object,
- unsigned anchor);
-
- void start_processing_object_(unsigned current_object);
-
- private:
- float dmax_;
- float neighb_max_distance_;
- anchor::Direction direction_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L, typename E>
- inline
- link_ms_dmax_base<L, E>::link_ms_dmax_base(
- const object_image(L)& objects,
- unsigned neighb_max_distance,
- anchor::Direction direction)
-
- : super_(objects),
- dmax_(0),
- neighb_max_distance_(neighb_max_distance),
- direction_(direction)
- {
- }
-
-
- template <typename L, typename E>
- inline
- bool
- link_ms_dmax_base<L, E>::verify_link_criterion_(unsigned current_object,
- const P& start_point,
- const P& p) const
- {
- (void) current_object;
-
- float dist = math::abs(p[direction_] - start_point[direction_]);
- return dist <= dmax_; // Not too far
- }
-
-
- template <typename L, typename E>
- inline
- mln_site(L)
- link_ms_dmax_base<L, E>::start_point_(unsigned current_object,
- unsigned anchor)
- {
- (void) anchor;
- return this->objects_.mass_center(current_object);
- }
-
-
- template <typename L, typename E>
- inline
- void
- link_ms_dmax_base<L, E>::start_processing_object_(
- unsigned current_object)
- {
- float
- midcol = (this->objects_.bbox(current_object).pmax()[direction_]
- - this->objects_.bbox(current_object).pmin()[direction_]) / 2;
- dmax_ = midcol + neighb_max_distance_;
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::primitive::link::internal
-
- } // end of namespace scribo::primitive::link
-
- } // end of namespace scribo::primitive
-
-} // end of namespace scribo
-
-
-#endif // SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_HH_
diff --git a/scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh b/scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh
deleted file mode 100644
index 915296d..0000000
--- a/scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_RATIO_BASE_HH_
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_RATIO_BASE_HH_
-
-/// \file
-///
-/// \brief Base class for link functors using mass centers and a
-/// proportional max distance.
-
-
-# include <mln/accu/center.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/math/abs.hh>
-# include <mln/math/max.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/core/object_links.hh>
-
-# include <scribo/primitive/link/internal/find_link.hh>
-# include <scribo/primitive/link/internal/link_functor_base.hh>
-
-# include <scribo/primitive/link/compute.hh>
-
-
-namespace scribo
-{
-
- namespace primitive
- {
-
- namespace link
- {
-
- namespace internal
- {
-
- /// \brief Base class for link functors using mass centers and
- /// a proportional max distance.
- //
- template <typename L, typename E>
- class link_ms_dmax_ratio_base
- : public link_functor_base<L, E>
- {
- typedef link_functor_base<L,E> super_;
- typedef mln_result(accu::center<mln_psite(L)>) ms_t;
-
- public:
-
- typedef mln_site(L) P;
-
-
- link_ms_dmax_ratio_base(const object_image(L)& objects,
- float dmax_ratio,
- anchor::Direction direction);
-
-
-
- bool verify_link_criterion_(unsigned current_object,
- const P& start_point, const P& p) const;
-
- mln_site(L) start_point_(unsigned current_object,
- unsigned anchor);
-
- void start_processing_object_(unsigned current_object);
-
- private:
- float dmax_ratio_;
- float dmax_;
- anchor::Direction direction_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L, typename E>
- inline
- link_ms_dmax_ratio_base<L, E>::link_ms_dmax_ratio_base(
- const object_image(L)& objects,
- float dmax_ratio,
- anchor::Direction direction)
-
- : super_(objects),
- dmax_ratio_(dmax_ratio),
- dmax_(0),
- direction_(direction)
- {
- }
-
- template <typename L, typename E>
- inline
- bool
- link_ms_dmax_ratio_base<L, E>::verify_link_criterion_(
- unsigned current_object,
- const P& start_point,
- const P& p) const
- {
- mln_assertion(dmax_ != 0);
- (void) current_object;
-
- float dist = math::abs(p[direction_] - start_point[direction_]);
- return dist <= dmax_; // Not too far
- }
-
-
- template <typename L, typename E>
- inline
- mln_site(L)
- link_ms_dmax_ratio_base<L, E>::start_point_(unsigned current_object,
- unsigned anchor)
- {
- (void) anchor;
- return this->objects_.mass_center(current_object);
- }
-
-
- template <typename L, typename E>
- inline
- void
- link_ms_dmax_ratio_base<L, E>::start_processing_object_(
- unsigned current_object)
- {
- float
- w = this->objects_.bbox(current_object).width();
-// h = (this->objects_.bbox(current_object).pmax().row()
-// - this->objects_.bbox(current_object).pmin().row());
-// dmax_ = (w / 2.0f) + (dmax_ratio_ * math::max(w, h));
- dmax_ = (w / 2.0f) + (dmax_ratio_ * w);
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::primitive::link::internal
-
- } // end of namespace scribo::primitive::link
-
- } // end of namespace scribo::primitive
-
-} // end of namespace scribo
-
-
-#endif // SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_MS_DMAX_RATIO_BASE_HH_
diff --git a/scribo/src/pbm_lines_in_doc.cc b/scribo/src/pbm_lines_in_doc.cc
deleted file mode 100644
index 8363b61..0000000
--- a/scribo/src/pbm_lines_in_doc.cc
+++ /dev/null
@@ -1,299 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-
-#include <libgen.h>
-#include <iostream>
-#include <fstream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/logical/not.hh>
-
-#include <mln/labeling/colorize.hh>
-
-#include <mln/io/pbm/all.hh>
-#include <mln/io/ppm/save.hh>
-#include <mln/io/dump/save.hh>
-
-#include <mln/math/min.hh>
-
-#include <mln/literal/colors.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/value/label_16.hh>
-
-#include <mln/draw/box.hh>
-
-#include <mln/extension/adjust.hh>
-
-#include <scribo/table/erase.hh>
-
-#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/extract/lines_h_discontinued.hh>
-#include <scribo/primitive/extract/lines_v_discontinued.hh>
-
-#include <scribo/primitive/link/merge_double_link.hh>
-#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
-#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
-
-#include <scribo/primitive/group/apply.hh>
-#include <scribo/primitive/group/from_double_link.hh>
-#include <scribo/primitive/group/from_single_link.hh>
-
-#include <scribo/filter/object_links_bottom_aligned.hh>
-#include <scribo/filter/object_links_bbox_h_ratio.hh>
-#include <scribo/filter/object_links_bbox_overlap.hh>
-
-#include <scribo/filter/objects_large.hh>
-#include <scribo/filter/objects_small.hh>
-#include <scribo/filter/objects_thin.hh>
-#include <scribo/filter/objects_thick.hh>
-
-#include <scribo/filter/object_groups_small.hh>
-
-#include <scribo/debug/decision_image.hh>
-#include <scribo/debug/save_bboxes_image.hh>
-#include <scribo/debug/save_bboxes_image.hh>
-#include <scribo/debug/save_linked_bboxes_image.hh>
-
-#include <scribo/debug/usage.hh>
-
-#include <scribo/make/debug_filename.hh>
-
-
-const char *args_desc[][2] =
-{
- { "input.pbm", "A binary image. 'False' for objects, 'True'\
-for the background." },
- { "out.ppm", "Show the text found in the input." },
- { "object_label.dump", "Object labeled image." },
- { "line_label.dump", "Text lines labeled image." },
- { "bbox_100p.txt", "Text file containing pmin and pmax of text line bounding boxes." },
- { "bbox_50p.txt", "Text file containing pmin and pmax of text line bounding boxes." },
- { "output_dir", "Output directory for debug image" },
- {0, 0}
-};
-
-
-int main(int argc, char* argv[])
-{
- using namespace scribo;
- using namespace mln;
-
- if (argc != 7 && argc != 8)
- return scribo::debug::usage(argv,
- "Find text lines in a document",
- "input.pbm out.ppm object_label.dump line_label.dump bbox_100p.txt bbox_50p.txt [output_dir]",
- args_desc,
- "Debug outputs. The recognized text is printed in the standard output.");
-
- if (argc == 8)
- scribo::make::internal::debug_filename_prefix = argv[7];
-
- trace::entering("main");
-
-
- bool enable_debug = (argc == 5);
-
- image2d<bool> input;
- io::pbm::load(input, argv[1]);
-
- typedef image2d<value::label_16> L;
-
- /// Finding objects.
- std::cout << "Finding objects..." << std::endl;
- value::label_16 nobjects;
- object_image(L)
- objects = scribo::primitive::extract::objects(input,
- c8(),
- nobjects);
-
-
- /// First filtering.
- std::cout << "Filtering objects..." << std::endl;
- object_image(L) filtered_objects
- = scribo::filter::objects_small(objects, 6);
-
-
- filtered_objects
- = scribo::filter::objects_large(filtered_objects,
- math::min(input.ncols(), input.nrows())
- * math::min(input.ncols(), input.nrows()) / 5);
-
-
-
- /// Linking potential objects
- std::cout << "Linking objects..." << std::endl;
- object_links<L> left_link
- = primitive::link::with_single_left_link_dmax_ratio(filtered_objects);
- object_links<L> right_link
- = primitive::link::with_single_right_link_dmax_ratio(filtered_objects);
-
-
-#ifndef NOUT
- if (enable_debug)
- {
- std::cerr << "BEFORE - nobjects = " << nobjects << std::endl;
- scribo::debug::save_linked_bboxes_image(input,
- filtered_objects,
- left_link, right_link,
- literal::red, literal::cyan,
- literal::yellow,
- literal::green,
- scribo::make::debug_filename("links.ppm"));
- }
-#endif
-
-
- // Validating left and right links.
- object_links<L>
- merged_links = primitive::link::merge_double_link(filtered_objects,
- left_link,
- right_link);
-
-
-
-
- // Remove links if bboxes have too different sizes.
- object_links<L> hratio_filtered_links
- = filter::object_links_bbox_h_ratio(filtered_objects,
- merged_links,
- 2.0f);
-
-
-
-
-#ifndef NOUT
- if (enable_debug)
- {
- image2d<value::rgb8>
- hratio_decision_image = scribo::debug::decision_image(input,
- merged_links,
- hratio_filtered_links);
- io::ppm::save(hratio_decision_image,
- scribo::make::debug_filename("hratio_links_decision_image.ppm"));
- }
-#endif
-
-
-
-
- //Remove links if bboxes overlap too much.
- object_links<L> overlap_filtered_links
- = filter::object_links_bbox_overlap(filtered_objects,
- hratio_filtered_links,
- 0.8f);
-
-
-
-
-#ifndef NOUT
- if (enable_debug)
- {
- image2d<value::rgb8> overlap_decision_image
- = scribo::debug::decision_image(input,
- hratio_filtered_links,
- overlap_filtered_links);
- io::ppm::save(overlap_decision_image,
- scribo::make::debug_filename("overlap_links_decision_image.ppm"));
- }
-#endif
-
-
-
-
- object_groups<L>
- groups = primitive::group::from_single_link(filtered_objects,
- overlap_filtered_links);
-
-
- std::cout << "Grouping objects..." << std::endl;
- object_image(L)
- grouped_objects = primitive::group::apply(filtered_objects, groups);
-
-
-
- std::cout << "Saving line bboxes..." << std::endl;
-
- // 100p bboxes
- {
- std::ofstream out;
- out.open(argv[5], std::ios_base::trunc);
-
- if (! out)
- {
- std::cout << "Can't create output file!" << std::endl;
- return 1;
- }
-
- for_all_ncomponents(i, grouped_objects.nlabels())
- {
- out << grouped_objects.bbox(i).pmin().row() << " "
- << grouped_objects.bbox(i).pmin().col()
- << " "
- << grouped_objects.bbox(i).pmax().row() << " "
- << grouped_objects.bbox(i).pmax().col()
- << std::endl;
- }
- out.close();
-
- }
-
- // 50p bboxes
- {
- std::ofstream out;
- out.open(argv[6], std::ios_base::trunc);
-
- if (! out)
- {
- std::cout << "Can't create output file!" << std::endl;
- return 1;
- }
-
- for_all_ncomponents(i, grouped_objects.nlabels())
- {
- out << grouped_objects.bbox(i).pmin().row() / 2 << " "
- << grouped_objects.bbox(i).pmin().col() / 2
- << " "
- << grouped_objects.bbox(i).pmax().row() / 2 << " "
- << grouped_objects.bbox(i).pmax().col() / 2
- << std::endl;
- }
- out.close();
-
- }
-
- scribo::debug::save_bboxes_image(input, grouped_objects.bboxes(),
- literal::red,
- argv[2]);
-
- io::dump::save(filtered_objects, argv[3]);
- io::dump::save(grouped_objects, argv[4]);
-
- trace::exiting("main");
-}
--
1.5.6.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/scribo-arthur has been updated
via 50621ae105a7b5c3ac3deeccbfeb443c84109266 (commit)
from d60f47f325bafaf2a006b127885934910c741b88 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
50621ae Open Document bug warning.
-----------------------------------------------------------------------
Summary of changes:
scribo/sandbox/ChangeLog | 8 ++++++++
scribo/sandbox/arthur/xml_transform/README | 24 +++++++++++++-----------
scribo/sandbox/arthur/xml_transform/main.cc | 9 +++++----
3 files changed, 26 insertions(+), 15 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform