* binarization/sauvola_ms.hh,
* binarization/sauvola_threshold_image_debug.hh: Update prototypes.
* primitive/internal/rd.hh,
* primitive/group/apply.hh,
* debug/save_bboxes_image.hh: Add missing mln:: namespace prefix.
* filter/objects_large.hh: Split into a routine and a functor.
* fun/v2b/objects_large_filter.hh: New.
* io/xml/save_text_lines.hh: Save line type.
* table/internal/repair_lines.hh,
* table/internal/align_lines.hh,
* make/text.hh: Update macro name.
* core/erase_objects.hh,
* primitive/extract/lines_discontinued.hh,
* primitive/extract/lines_h_discontinued.hh,
* primitive/extract/lines_h_pattern.hh,
* primitive/extract/lines_h_single.hh,
* primitive/extract/lines_h_thick.hh,
* primitive/extract/lines_thick.hh,
* primitive/extract/lines_v_discontinued.hh,
* primitive/extract/lines_v_single.hh,
* primitive/extract/lines_v_thick.hh,
* primitive/group/from_graph.hh,
* primitive/internal/find_graph_link.hh,
* primitive/link/with_graph.hh,
* primitive/link/with_several_graphes.hh,
* primitive/link/with_several_left_links.hh,
* primitive/link/with_several_right_links.hh,
* table/erase.hh,
* table/extract.hh: Remove any references to object_image.
* table/internal/connect_lines.hh: use
influence_zone_geodesic_saturated
* filter/objects_small.hh: Duplicate component set.
* primitive/internal/all.hh,
* primitive/extract/all.hh,
* filter/all.hh,
* core/all.hh: Remove non existing includes.
* core/macros.hh: New macro.
* core/line_info.hh: Fix stats.
* filter/object_links_non_aligned.hh,
* filter/object_links_non_h_aligned.hh,
* filter/object_links_non_v_aligned.hh: Removed.
---
scribo/ChangeLog | 58 ++++++++
scribo/binarization/sauvola_ms.hh | 6 +-
.../binarization/sauvola_threshold_image_debug.hh | 44 +++---
scribo/core/all.hh | 4 +-
scribo/core/erase_objects.hh | 13 +-
scribo/core/line_info.hh | 2 +-
scribo/core/macros.hh | 3 +
scribo/debug/save_bboxes_image.hh | 6 +-
scribo/filter/all.hh | 3 -
scribo/filter/object_links_non_aligned.hh | 138 --------------------
scribo/filter/object_links_non_h_aligned.hh | 109 ---------------
scribo/filter/object_links_non_v_aligned.hh | 122 -----------------
scribo/filter/objects_large.hh | 130 +++----------------
scribo/filter/objects_small.hh | 2 +-
...cts_small_filter.hh => objects_large_filter.hh} | 36 +++---
scribo/io/xml/save_text_lines.hh | 1 +
scribo/make/text.hh | 2 +-
scribo/primitive/extract/all.hh | 5 +-
scribo/primitive/extract/lines_discontinued.hh | 14 +-
scribo/primitive/extract/lines_h_discontinued.hh | 10 +-
scribo/primitive/extract/lines_h_pattern.hh | 39 +++---
scribo/primitive/extract/lines_h_single.hh | 47 ++++----
scribo/primitive/extract/lines_h_thick.hh | 8 +-
scribo/primitive/extract/lines_thick.hh | 11 +-
scribo/primitive/extract/lines_v_discontinued.hh | 10 +-
scribo/primitive/extract/lines_v_single.hh | 47 +++----
scribo/primitive/extract/lines_v_thick.hh | 14 +-
scribo/primitive/group/apply.hh | 4 +-
scribo/primitive/group/from_graph.hh | 1 -
scribo/primitive/internal/all.hh | 3 -
scribo/primitive/internal/find_graph_link.hh | 1 -
scribo/primitive/internal/rd.hh | 2 +-
scribo/primitive/link/with_graph.hh | 2 -
scribo/primitive/link/with_several_graphes.hh | 6 +-
scribo/primitive/link/with_several_left_links.hh | 2 -
scribo/primitive/link/with_several_right_links.hh | 3 -
scribo/table/erase.hh | 10 +-
scribo/table/extract.hh | 3 +-
scribo/table/internal/align_lines.hh | 2 +-
scribo/table/internal/connect_lines.hh | 7 +-
scribo/table/internal/repair_lines.hh | 2 +-
41 files changed, 255 insertions(+), 677 deletions(-)
delete mode 100644 scribo/filter/object_links_non_aligned.hh
delete mode 100644 scribo/filter/object_links_non_h_aligned.hh
delete mode 100644 scribo/filter/object_links_non_v_aligned.hh
copy scribo/fun/v2b/{objects_small_filter.hh => objects_large_filter.hh} (74%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index a36b5e1..0408bf3 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,61 @@
+2010-04-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Small fixes in Scribo.
+
+ * binarization/sauvola_ms.hh,
+ * binarization/sauvola_threshold_image_debug.hh: Update prototypes.
+
+ * primitive/internal/rd.hh,
+ * primitive/group/apply.hh,
+ * debug/save_bboxes_image.hh: Add missing mln:: namespace prefix.
+
+ * filter/objects_large.hh: Split into a routine and a functor.
+
+ * fun/v2b/objects_large_filter.hh: New.
+
+ * io/xml/save_text_lines.hh: Save line type.
+
+ * table/internal/repair_lines.hh,
+ * table/internal/align_lines.hh,
+ * make/text.hh: Update macro name.
+
+ * core/erase_objects.hh,
+ * primitive/extract/lines_discontinued.hh,
+ * primitive/extract/lines_h_discontinued.hh,
+ * primitive/extract/lines_h_pattern.hh,
+ * primitive/extract/lines_h_single.hh,
+ * primitive/extract/lines_h_thick.hh,
+ * primitive/extract/lines_thick.hh,
+ * primitive/extract/lines_v_discontinued.hh,
+ * primitive/extract/lines_v_single.hh,
+ * primitive/extract/lines_v_thick.hh,
+ * primitive/group/from_graph.hh,
+ * primitive/internal/find_graph_link.hh,
+ * primitive/link/with_graph.hh,
+ * primitive/link/with_several_graphes.hh,
+ * primitive/link/with_several_left_links.hh,
+ * primitive/link/with_several_right_links.hh,
+ * table/erase.hh,
+ * table/extract.hh: Remove any references to object_image.
+
+ * table/internal/connect_lines.hh: use
+ influence_zone_geodesic_saturated
+
+ * filter/objects_small.hh: Duplicate component set.
+
+ * primitive/internal/all.hh,
+ * primitive/extract/all.hh,
+ * filter/all.hh,
+ * core/all.hh: Remove non existing includes.
+
+ * core/macros.hh: New macro.
+
+ * core/line_info.hh: Fix stats.
+
+ * filter/object_links_non_aligned.hh,
+ * filter/object_links_non_h_aligned.hh,
+ * filter/object_links_non_v_aligned.hh: Removed.
+
2010-03-19 Guillaume Lazzara <z(a)lrde.epita.fr>
Improve dematerialization wizard.
diff --git a/scribo/binarization/sauvola_ms.hh b/scribo/binarization/sauvola_ms.hh
index 6e70e04..621c638 100644
--- a/scribo/binarization/sauvola_ms.hh
+++ b/scribo/binarization/sauvola_ms.hh
@@ -94,16 +94,14 @@ namespace scribo
*/
template <typename I>
mln_ch_value(I,bool)
- sauvola_ms(const Image<I>& input_1_, unsigned w_1,
- unsigned s, unsigned lambda_min_1, double K);
+ sauvola_ms(const Image<I>& input_1_, unsigned w_1, unsigned s, double K);
/// \overload
/// K is set to 0.34.
//
template <typename I>
mln_ch_value(I,bool)
- sauvola_ms(const Image<I>& input_1, unsigned w_1,
- unsigned s, unsigned lambda_min_1);
+ sauvola_ms(const Image<I>& input_1, unsigned w_1, unsigned s);
diff --git a/scribo/binarization/sauvola_threshold_image_debug.hh
b/scribo/binarization/sauvola_threshold_image_debug.hh
index 18216a6..359bb57 100644
--- a/scribo/binarization/sauvola_threshold_image_debug.hh
+++ b/scribo/binarization/sauvola_threshold_image_debug.hh
@@ -123,10 +123,10 @@ namespace scribo
\return A threshold.
*/
- template <typename P, typename I, typename J>
+ template <typename P, typename M, typename J>
double
compute_sauvola_threshold(const P& p,
- I& mean, I& stddev,
+ M& mean, M& stddev,
const J& simple,
const J& squared,
int win_width, double K, double R)
@@ -156,7 +156,7 @@ namespace scribo
double m_x_y = m_x_y_tmp / wh;
- mean(p) = m_x_y * mean_debug_factor;
+ mean(p) = m_x_y;// * mean_debug_factor;
// Standard deviation.
double s_x_y_tmp = (squared.at_(row_max, col_max)
@@ -166,7 +166,7 @@ namespace scribo
double s_x_y = std::sqrt((s_x_y_tmp - (m_x_y_tmp * m_x_y_tmp) / wh) / (wh - 1.f));
- stddev(p) = s_x_y * stddev_debug_factor;
+ stddev(p) = s_x_y;// * stddev_debug_factor;
// Thresholding.
double t_x_y = sauvola_threshold_formula(m_x_y, s_x_y, K, R);
@@ -198,21 +198,21 @@ namespace scribo
namespace generic
{
- template <typename I, typename J>
+ template <typename I, typename M, typename J>
inline
mln_concrete(I)
sauvola_threshold_image_debug(const Image<I>& input_,
unsigned window_size,
double K,
- Image<I>& mean_, Image<I>& stddev_,
+ Image<M>& mean_, Image<M>& stddev_,
Image<J>& simple_,
Image<J>& squared_)
{
trace::entering("scribo::binarization::impl::generic::sauvola_threshold_image_debug");
const I& input = exact(input_);
- I& mean = exact(mean_);
- I& stddev = exact(stddev_);
+ M& mean = exact(mean_);
+ M& stddev = exact(stddev_);
J& simple = exact(simple_);
J& squared = exact(squared_);
@@ -248,13 +248,13 @@ namespace scribo
- template <typename I, typename J>
+ template <typename I, typename M, typename J>
inline
mln_concrete(I)
sauvola_threshold_image_debug_gl(const Image<I>& input,
unsigned window_size,
double K,
- Image<I>& mean, Image<I>& stddev,
+ Image<M>& mean, Image<M>& stddev,
Image<J>& simple,
Image<J>& squared)
{
@@ -265,13 +265,13 @@ namespace scribo
}
- template <typename I, typename J>
+ template <typename I, typename M, typename J>
inline
mln_ch_value(I, value::int_u8)
sauvola_threshold_image_debug_rgb8(const Image<I>& input,
unsigned window_size,
double K,
- Image<I>& mean, Image<I>& stddev,
+ Image<M>& mean, Image<M>& stddev,
Image<J>& simple,
Image<J>& squared)
{
@@ -302,14 +302,14 @@ namespace scribo
namespace internal
{
- template <unsigned n, typename I, typename J>
+ template <unsigned n, typename I, typename M, typename J>
inline
mln_ch_value(I, value::int_u<n>)
sauvola_threshold_image_debug_dispatch(const value::int_u<n>&,
const I& input,
unsigned window_size,
double K,
- I& mean, I& stddev,
+ M& mean, M& stddev,
J& simple,
J& squared)
{
@@ -318,13 +318,13 @@ namespace scribo
simple, squared);
}
- template <typename I, typename J>
+ template <typename I, typename M, typename J>
inline
mln_ch_value(I, value::int_u8)
sauvola_threshold_image_debug_dispatch(const value::rgb8&, const I& input,
unsigned window_size,
double K,
- I& mean, I& stddev,
+ M& mean, M& stddev,
J& simple,
J& squared)
{
@@ -333,11 +333,11 @@ namespace scribo
simple, squared);
}
- template <typename I, typename J>
+ template <typename I, typename M, typename J>
inline
mln_ch_value(I, value::int_u8)
sauvola_threshold_image_debug_dispatch(const mln_value(I)&, const I&
input,
- I& mean, I& stddev,
+ M& mean, M& stddev,
unsigned window_size,
double K,
J& simple,
@@ -355,11 +355,11 @@ namespace scribo
- template <typename I, typename J>
+ template <typename I, typename M, typename J>
mln_ch_value(I, value::int_u8)
sauvola_threshold_image_debug(const Image<I>& input, unsigned window_size,
double K,
- Image<I>& mean, Image<I>& stddev,
+ Image<M>& mean, Image<M>& stddev,
Image<J>& simple,
Image<J>& squared)
{
@@ -384,12 +384,12 @@ namespace scribo
}
- template <typename I>
+ template <typename I, typename M>
inline
mln_ch_value(I, value::int_u8)
sauvola_threshold_image_debug(const Image<I>& input, unsigned window_size,
double K,
- Image<I>& mean, Image<I>& stddev)
+ Image<M>& mean, Image<M>& stddev)
{
mln_ch_value(I, double)
simple = init_integral_image(input, scribo::internal::identity_),
diff --git a/scribo/core/all.hh b/scribo/core/all.hh
index b98bf04..d00ccf8 100644
--- a/scribo/core/all.hh
+++ b/scribo/core/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -44,6 +45,5 @@ namespace scribo
#include <scribo/core/central_sites.hh>
#include <scribo/core/erase_objects.hh>
#include <scribo/core/macros.hh>
-#include <scribo/core/object_image.hh>
#endif // ! SCRIBO_CORE_ALL_HH
diff --git a/scribo/core/erase_objects.hh b/scribo/core/erase_objects.hh
index 59a1346..3e401f0 100644
--- a/scribo/core/erase_objects.hh
+++ b/scribo/core/erase_objects.hh
@@ -32,12 +32,11 @@
# include <mln/core/concept/image.hh>
# include <mln/core/site_set/box.hh>
-# include <mln/data/paste.hh>
+# include <mln/data/fill.hh>
# include <mln/pw/all.hh>
# include <mln/util/array.hh>
# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
namespace scribo
{
@@ -47,14 +46,13 @@ namespace scribo
/// Remove labeled components from a binary image.
///
/// \param[in,out] input_ A binary image.
- /// \param[in] objects An object image. Objects will be set to
- /// false in \p input_.
+ /// \param[in] objects An image of objects (object value must be
+ /// different from 0).
///
//
template <typename I, typename L>
void
- erase_objects(Image<I>& input_,
- const object_image(L)& objects);
+ erase_objects(Image<I>& input, const Image<L>& objects);
# ifndef MLN_INCLUDE_ONLY
@@ -63,13 +61,14 @@ namespace scribo
template <typename I, typename L>
void
erase_objects(Image<I>& input_,
- const object_image(L)& objects)
+ const Image<L>& objects_)
{
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());
diff --git a/scribo/core/line_info.hh b/scribo/core/line_info.hh
index 0445f85..9ecf600 100644
--- a/scribo/core/line_info.hh
+++ b/scribo/core/line_info.hh
@@ -795,7 +795,7 @@ namespace scribo
// Space between characters.
int space = bb.pmin().col()
- - comp_set(holder_.links()(c)).bbox().pmax().col();
+ - comp_set(holder_.links()(c)).bbox().pmax().col() + 1;
// -- Ignore overlapped characters.
if (space > 0)
diff --git a/scribo/core/macros.hh b/scribo/core/macros.hh
index f644db3..040220c 100644
--- a/scribo/core/macros.hh
+++ b/scribo/core/macros.hh
@@ -52,6 +52,9 @@
# define for_all_lines(E, S) \
for_all_comps(E, S)
+# define for_all_line_comps(E, S) \
+ for_all_elements(E, S)
+
# define for_all_lines_info(E, S) \
for_all_comp_data(E, S)
diff --git a/scribo/debug/save_bboxes_image.hh b/scribo/debug/save_bboxes_image.hh
index f2c34e8..356ea6e 100644
--- a/scribo/debug/save_bboxes_image.hh
+++ b/scribo/debug/save_bboxes_image.hh
@@ -35,6 +35,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/line_set.hh>
# include <scribo/draw/bounding_boxes.hh>
@@ -108,13 +109,14 @@ namespace scribo
trace::entering("scribo::debug::save_bboxes_image");
mln_precondition(exact(input).is_valid());
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
+ mln_ch_value(I, value::rgb8)
+ output = data::convert(value::rgb8(), input);
for_all_lines(l, lines)
if (! lines(l).hidden())
mln::draw::box(output, lines(l).bbox(), value);
- io::ppm::save(output, filename);
+ mln::io::ppm::save(output, filename);
trace::exiting("scribo::debug::save_bboxes_image");
}
diff --git a/scribo/filter/all.hh b/scribo/filter/all.hh
index f9ef9ce..0b5bc11 100644
--- a/scribo/filter/all.hh
+++ b/scribo/filter/all.hh
@@ -42,9 +42,6 @@ namespace scribo
} // end of namespace scribo
# include <scribo/filter/object_groups_small.hh>
-# include <scribo/filter/object_links_non_aligned.hh>
-# include <scribo/filter/object_links_non_h_aligned.hh>
-# include <scribo/filter/object_links_non_v_aligned.hh>
# include <scribo/filter/objects_large.hh>
# include <scribo/filter/objects_small.hh>
# include <scribo/filter/objects_thick.hh>
diff --git a/scribo/filter/object_links_non_aligned.hh
b/scribo/filter/object_links_non_aligned.hh
deleted file mode 100644
index b81a0ab..0000000
--- a/scribo/filter/object_links_non_aligned.hh
+++ /dev/null
@@ -1,138 +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_FILTER_OBJECT_LINKS_NON_ALIGNED_HH
-# define SCRIBO_FILTER_OBJECT_LINKS_NON_ALIGNED_HH
-
-/// \file
-///
-/// Invalidate links between two non aligned objects.
-
-
-# include <mln/math/abs.hh>
-# include <mln/util/array.hh>
-
-# include <scribo/core/macros.hh>
-# include <scribo/core/object_links.hh>
-# include <scribo/core/object_image.hh>
-
-namespace scribo
-{
-
- namespace filter
- {
-
- using namespace mln;
-
- /*! \brief Invalidate links between two non aligned objects.
- Alignment is based on object bounding boxes.
-
- \param[in] objects An object image.
- \param[in] links Object links information.
- \param[in] dim Choose the dimension on which applying the
- filter.
- \param[in] max_delta Maximum delta.
-
-
- Exemple with dim == 1 (horizontal filter):
-
- \verbatim
- v
- ------ ~ ~ ~
- | | |\
- ------ ~ ~ ~ |~ ~ | ~ ~ ~ \
- | | | | ^ \
- | x------------x | => delta, must be < to max_delta
- | | | | v /
- ------ ~ ~ ~ |~ ~ | ~ ~ ~ /
- object1 | | |/
- ------ ~ ~ ~
- object2 ^
-
- \endverbatim
-
- */
- template <typename L>
- object_links<L>
- object_links_non_aligned(const object_image(L)& objects,
- const object_links<L>& links,
- unsigned dim,
- unsigned max_delta);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L>
- object_links<L>
- object_links_non_aligned(const object_image(L)& objects,
- const object_links<L>& links,
- unsigned dim,
- unsigned max_delta)
- {
- trace::entering("scribo::filter::object_links_non_aligned");
-
- mln_precondition(objects.is_valid());
-
-
- typedef typename object_image(L)::bbox_t bbox_t;
- const mln::util::array<bbox_t>& bboxes = objects.bboxes();
- object_links<L> output(links);
-
- for_all_components(i, objects.bboxes())
- if (links[i] != i)
- {
- unsigned
- lnbh = bboxes(links[i]).pmax()[dim] - bboxes(links[i]).pmin()[dim],
- lcurrent = bboxes(i).pmax()[dim] - bboxes(i).pmin()[dim],
- hmin = i,
- hmax = links[i];
-
- if (lnbh < lcurrent)
- {
- hmin = links[i];
- hmax = i;
- }
-
- if (static_cast<unsigned>(math::abs((bboxes[hmin].pmin()[dim] -
bboxes[hmax].pmin()[dim]))) > max_delta
- || static_cast<unsigned>(math::abs((bboxes[hmin].pmax()[dim] -
bboxes[hmax].pmax()[dim]))) > max_delta)
- output[i] = i;
-
- }
-
- trace::exiting("scribo::filter::object_links_non_aligned");
- return output;
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::filter
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_FILTER_OBJECT_LINKS_NON_ALIGNED_HH
diff --git a/scribo/filter/object_links_non_h_aligned.hh
b/scribo/filter/object_links_non_h_aligned.hh
deleted file mode 100644
index 8216316..0000000
--- a/scribo/filter/object_links_non_h_aligned.hh
+++ /dev/null
@@ -1,109 +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_FILTER_OBJECT_LINKS_NON_H_ALIGNED_HH
-# define SCRIBO_FILTER_OBJECT_LINKS_NON_H_ALIGNED_HH
-
-/// \file
-///
-/// Invalidate links between two non horizontaly aligned objects.
-
-
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_links.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/filter/object_links_non_aligned.hh>
-
-namespace scribo
-{
-
- namespace filter
- {
-
- using namespace mln;
-
-
- /*! \brief Invalidate links between two non horizontaly aligned objects.
- Alignment is based on object bounding boxes.
-
- \param[in] objects An object image.
- \param[in] links Object links information.
- \param[in] max_delta Maximum delta.
-
- \result Filtered object links data.
-
- \verbatim
- v
- ------ ~ ~ ~
- | | |\
- ------ ~ ~ ~ |~ ~ | ~ ~ ~ \
- | | | | ^ \
- | x- - - - - --x | => delta, must be < to max_delta
- | | | | v /
- ------ ~ ~ ~ |~ ~ | ~ ~ ~ /
- object1 | | |/
- ------ ~ ~ ~
- object2 ^
-
- \endverbatim
-
-
- */
- template <typename L>
- object_links<L>
- object_links_non_h_aligned(const object_image(L)& objects,
- const object_links<L>& links,
- float max_delta);
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L>
- object_links<L>
- object_links_non_h_aligned(const object_image(L)& objects,
- const object_links<L>& links,
- float max_delta)
- {
- trace::entering("scribo::filter::object_links_non_h_aligned");
-
- mln_precondition(objects.is_valid());
-
- object_links<L>
- output = object_links_non_aligned(objects, links, 0, max_delta);
-
- trace::exiting("scribo::filter::object_links_non_h_aligned");
- return output;
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::filter
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_FILTER_OBJECT_LINKS_NON_H_ALIGNED_HH
diff --git a/scribo/filter/object_links_non_v_aligned.hh
b/scribo/filter/object_links_non_v_aligned.hh
deleted file mode 100644
index bd2aeee..0000000
--- a/scribo/filter/object_links_non_v_aligned.hh
+++ /dev/null
@@ -1,122 +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_FILTER_OBJECT_LINKS_NON_V_ALIGNED_HH
-# define SCRIBO_FILTER_OBJECT_LINKS_NON_V_ALIGNED_HH
-
-/// \file
-///
-/// Invalidate links between two non verticaly aligned objects.
-
-
-# include <mln/util/array.hh>
-
-# include <scribo/core/object_links.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/filter/object_links_non_aligned.hh>
-
-namespace scribo
-{
-
- namespace filter
- {
-
- using namespace mln;
-
- /*! \brief Invalidate links between two non verticaly aligned objects.
- Alignment is based on object bounding boxes.
-
- \param[in] objects An object image.
- \param[in] links Object links information.
- \param[in] max_delta Maximum delta.
-
-
- \verbatim
-
- delta (must be < to max_delta)
- /\
- / \
- / \
- >:-:<>:-:<
- : :
- : :
- : ---:--
- | |
- : | x: | object1
- | | |
- : --|:--
-
- : |:
-
- : |:
- -- ---
- | ||
- | |
- | ||
- | x| object2
- | |
- | |
- | |
- ------
-
- \endverbatim
-
- */
- template <typename L>
- object_links<L>
- object_links_non_v_aligned(const object_image(L)& objects,
- const object_links<L>& links,
- float ratio);
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L>
- object_links<L>
- object_links_non_v_aligned(const object_image(L)& objects,
- const object_links<L>& links,
- float ratio)
- {
- trace::entering("scribo::object_links::object_links_non_v_aligned");
-
- mln_precondition(objects.is_valid());
-
- object_links<L>
- output = object_links_non_aligned(objects, links, 0, ratio);
-
- trace::exiting("scribo::filter::object_links_non_v_aligned");
- return output;
- }
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace scribo::filter
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_FILTER_OBJECT_LINKS_NON_V_ALIGNED_HH
diff --git a/scribo/filter/objects_large.hh b/scribo/filter/objects_large.hh
index dfef95c..81986e4 100644
--- a/scribo/filter/objects_large.hh
+++ b/scribo/filter/objects_large.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.
//
@@ -23,8 +24,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_FILTER_OBJECTS_LARGE_HH
-# define SCRIBO_FILTER_OBJECTS_LARGE_HH
+#ifndef SCRIBO_FILTER_COMPONENTS_LARGE_HH
+# define SCRIBO_FILTER_COMPONENTS_LARGE_HH
/// \file
///
@@ -42,8 +43,9 @@
# include <mln/pw/all.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/primitive/extract/objects.hh>
+# include <scribo/core/component_set.hh>
+# include <scribo/primitive/extract/components.hh>
+# include <scribo/fun/v2b/objects_large_filter.hh>
namespace scribo
{
@@ -65,134 +67,40 @@ namespace scribo
/// \return A binary image without large objects.
template <typename I, typename N, typename V>
mln_concrete(I)
- objects_large(const Image<I>& input_,
+ components_large(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
unsigned max_size);
- /// Remove too large text objects.
- ///
- /// \param[in] objects An object image.
- /// \param[in] max_size The minimum cardinality of an object.
- ///
- /// \return updated text data.
- template <typename L>
- object_image(L)
- objects_large(const object_image(L)& objects,
- unsigned max_size);
-
-
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
-
- /// Filter Functor.
- /// Return false for all objects which are too large.
- template <typename L>
- struct objects_large_filter
- : Function_v2b< objects_large_filter<L> >
- {
-
- typedef accu::math::count<mln_psite(L)> card_t;
-
- /// Constructor
- ///
- /// \param[in] compbboxes Component bounding boxes.
- /// \param[in] max_size Maximum object size.
- objects_large_filter(const object_image(L)& objects,
- unsigned max_size)
- {
- card_ = labeling::compute(card_t(), objects, objects.nlabels());
- max_size_ = max_size;
- }
-
-
- /// Check if the object is large enough.
- ///
- /// \param l A label.
- ///
- /// \return false if the object area is strictly inferior to
- /// \p max_size_.
- bool operator()(const mln_value(L)& l) const
- {
- if (l == literal::zero)
- return true;
- return card_[l] <= max_size_;
- }
-
-
- /// The object bounding boxes.
- mln::util::array<mln_result(card_t)> card_;
- /// The maximum area.
- unsigned max_size_;
- };
-
-
- } // end of namespace scribo::filter::internal
-
-
-
- template <typename I, typename N, typename V>
- inline
- mln_concrete(I)
- objects_large(const Image<I>& input_,
- const Neighborhood<N>& nbh_,
- const V& label_type,
- unsigned max_size)
- {
- trace::entering("scribo::filter::objects_large");
-
- const I& input = exact(input_);
- const N& nbh = exact(nbh_);
-
- mln_precondition(input.is_valid());
- mln_precondition(nbh.is_valid());
-
- V nlabels;
- typedef object_image(mln_ch_value(I,V)) lbl_t;
- lbl_t lbl = primitive::extract::objects(input, nbh, nlabels);
-
- typedef internal::objects_large_filter<lbl_t> func_t;
- func_t fv2b(lbl, max_size);
- labeling::relabel_inplace(lbl, nlabels, fv2b);
-
- mln_concrete(I) output = duplicate(input);
- data::fill((output | pw::value(lbl) == literal::zero).rw(), false);
-
- trace::exiting("scribo::filter::objects_large");
- return output;
- }
-
-
template <typename L>
inline
- object_image(L)
- objects_large(const object_image(L)& objects,
- unsigned max_size)
+ component_set<L>
+ components_large(const component_set<L>& components,
+ unsigned max_size)
{
- trace::entering("scribo::filter::objects_large");
+ trace::entering("scribo::filter::components_large");
- mln_precondition(objects.is_valid());
+ mln_precondition(components.is_valid());
- internal::objects_large_filter<L> f(objects, max_size);
+ fun::v2b::components_large_filter<L> f(components, max_size);
- object_image(L) output;
- output.init_from_(objects);
- output.relabel(f);
+ component_set<L> output = components.duplicate();
+ output.update_tags(f, component::Ignored);
- trace::exiting("scribo::filter::objects_large");
+ trace::exiting("scribo::filter::components_large");
return output;
}
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::filter
} // end of namespace scribo
-#endif // ! SCRIBO_FILTER_OBJECTS_LARGE_HH
+#endif // ! SCRIBO_FILTER_COMPONENTS_LARGE_HH
diff --git a/scribo/filter/objects_small.hh b/scribo/filter/objects_small.hh
index 31112c9..f97a79e 100644
--- a/scribo/filter/objects_small.hh
+++ b/scribo/filter/objects_small.hh
@@ -143,7 +143,7 @@ namespace scribo
fun::v2b::components_small_filter<L> f(components, min_size);
- component_set<L> output = components;
+ component_set<L> output = components.duplicate();
output.update_tags(f, component::Ignored);
trace::exiting("scribo::filter::components_small");
diff --git a/scribo/fun/v2b/objects_small_filter.hh
b/scribo/fun/v2b/objects_large_filter.hh
similarity index 74%
copy from scribo/fun/v2b/objects_small_filter.hh
copy to scribo/fun/v2b/objects_large_filter.hh
index 8e0ae8a..1707c9c 100644
--- a/scribo/fun/v2b/objects_small_filter.hh
+++ b/scribo/fun/v2b/objects_large_filter.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,12 +23,12 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_FUN_V2B_COMPONENTS_SMALL_FILTER_HH
-# define SCRIBO_FUN_V2B_COMPONENTS_SMALL_FILTER_HH
+#ifndef SCRIBO_FUN_V2B_COMPONENTS_LARGE_FILTER_HH
+# define SCRIBO_FUN_V2B_COMPONENTS_LARGE_FILTER_HH
/// \file
///
-/// Remove small components in a binary image.
+/// Remove large components in a binary image.
@@ -56,20 +56,20 @@ namespace scribo
/// Filter Functor.
- /// Return false for all components which are too small.
+ /// Return false for all components which are too large.
template <typename L>
- struct components_small_filter
- : Function_v2b< components_small_filter<L> >
+ struct components_large_filter
+ : Function_v2b< components_large_filter<L> >
{
typedef accu::math::count<mln_psite(L)> card_t;
/// Constructor
///
/// \param[in] components Component bounding boxes.
- /// \param[in] min_size Minimum component size.
+ /// \param[in] max_size Maximum component size.
//
- components_small_filter(const component_set<L>& components,
- unsigned min_size);
+ components_large_filter(const component_set<L>& components,
+ unsigned max_size);
/// Check if the component is large enough.
@@ -77,12 +77,12 @@ namespace scribo
/// \param l A label.
///
/// \return false if the component area is strictly inferion to
- /// \p min_size_.
+ /// \p max_size_.
//
bool operator()(const mln_value(L)& l) const;
/// The minimum area.
- unsigned min_size_;
+ unsigned max_size_;
/// The component set to filter.
const component_set<L> components_;
@@ -96,10 +96,10 @@ namespace scribo
template <typename L>
inline
- components_small_filter<L>::components_small_filter(
+ components_large_filter<L>::components_large_filter(
const component_set<L>& components,
- unsigned min_size)
- : min_size_(min_size), components_(components)
+ unsigned max_size)
+ : max_size_(max_size), components_(components)
{
}
@@ -108,11 +108,11 @@ namespace scribo
template <typename L>
inline
bool
- components_small_filter<L>::operator()(const mln_value(L)& l) const
+ components_large_filter<L>::operator()(const mln_value(L)& l) const
{
if (l == literal::zero)
return true;
- return components_.info(l).card() >= min_size_;
+ return components_.info(l).card() <= max_size_;
}
@@ -125,4 +125,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_FUN_V2B_COMPONENTS_SMALL_FILTER_HH
+#endif // ! SCRIBO_FUN_V2B_COMPONENTS_LARGE_FILTER_HH
diff --git a/scribo/io/xml/save_text_lines.hh b/scribo/io/xml/save_text_lines.hh
index 7f0fdf4..06caf58 100644
--- a/scribo/io/xml/save_text_lines.hh
+++ b/scribo/io/xml/save_text_lines.hh
@@ -104,6 +104,7 @@ namespace scribo
<< "\" txt_orientation=\"" << lines(l).orientation()
<< "\" txt_reading_orientation=\"" <<
lines(l).reading_orientation()
<< "\" txt_reading_direction=\"" <<
lines(l).reading_direction()
+ << "\" txt_text_type=\"" << lines(l).type()
<< "\" txt_reverse_video=\"" <<
(lines(l).reverse_video() ? "true" : "false")
<< "\" txt_indented=\"" << (lines(l).indented() ?
"true" : "false")
<< "\" kerning=\"" << lines(l).char_space()
diff --git a/scribo/make/text.hh b/scribo/make/text.hh
index 7a8456b..6d10ef3 100644
--- a/scribo/make/text.hh
+++ b/scribo/make/text.hh
@@ -154,7 +154,7 @@ namespace scribo
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_components(i, text.bboxes())
+ for_all_comps(i, text.bboxes())
{
tboxes[fv2v(i)].take(text.bbox(i));
tcenters[fv2v(i)].take(text.mass_center(i));
diff --git a/scribo/primitive/extract/all.hh b/scribo/primitive/extract/all.hh
index de1688e..5ccb83b 100644
--- a/scribo/primitive/extract/all.hh
+++ b/scribo/primitive/extract/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -58,7 +59,7 @@ namespace scribo
# include <scribo/primitive/extract/lines_v_thick.hh>
# include <scribo/primitive/extract/lines_v_discontinued.hh>
# include <scribo/primitive/extract/lines_h_pattern.hh>
-# include <scribo/primitive/extract/objects.hh>
+# include <scribo/primitive/extract/components.hh>
# include <scribo/primitive/extract/cells.hh>
# include <scribo/primitive/extract/lines_thick.hh>
# include <scribo/primitive/extract/lines_h_discontinued.hh>
diff --git a/scribo/primitive/extract/lines_discontinued.hh
b/scribo/primitive/extract/lines_discontinued.hh
index 2ea7de6..63953ac 100644
--- a/scribo/primitive/extract/lines_discontinued.hh
+++ b/scribo/primitive/extract/lines_discontinued.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,8 +42,7 @@
# include <mln/morpho/dilation.hh>
# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/primitive/extract/objects.hh>
+# include <scribo/primitive/extract/components.hh>
namespace scribo
{
@@ -70,7 +70,7 @@ namespace scribo
* \return An image in which lines are labeled.
*/
template <typename I, typename N, typename V, typename W>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_discontinued(const Image<I>& input_,
const Neighborhood<N>& nbh_, V& nlines,
const Window<W>& win_, unsigned rank_k);
@@ -111,7 +111,7 @@ namespace scribo
template <typename I, typename N, typename V, typename W>
inline
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_discontinued(const Image<I>& input_,
const Neighborhood<N>& nbh_, V& nlines,
const Window<W>& win_, unsigned rank_k)
@@ -132,8 +132,8 @@ namespace scribo
mln_ch_value(I,bool) filter
= morpho::dilation(morpho::rank_filter(input, win, rank_k), W(dil));
- object_image(mln_ch_value(I,V)) output
- = primitive::extract::objects(filter, nbh, nlines);
+ component_set<mln_ch_value(I,V)> output
+ = primitive::extract::components(filter, nbh, nlines);
trace::exiting("scribo::primitive::extract::lines_discontinued");
return output;
diff --git a/scribo/primitive/extract/lines_h_discontinued.hh
b/scribo/primitive/extract/lines_h_discontinued.hh
index 48ba12a..f1deb98 100644
--- a/scribo/primitive/extract/lines_h_discontinued.hh
+++ b/scribo/primitive/extract/lines_h_discontinued.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.
//
@@ -34,7 +35,6 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/win/hline2d.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/primitive/extract/lines_discontinued.hh>
@@ -63,7 +63,7 @@ namespace scribo
* from 0.
*/
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_h_discontinued(const Image<I>& input,
const Neighborhood<N>& nbh, V& nlines,
unsigned line_length, unsigned rank_k);
@@ -101,7 +101,7 @@ namespace scribo
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_h_discontinued(const Image<I>& input,
const Neighborhood<N>& nbh, V& nlines,
unsigned line_length, unsigned rank_k)
@@ -113,7 +113,7 @@ namespace scribo
win::hline2d win(line_length);
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
output = lines_discontinued(input, nbh, nlines, win, rank_k);
trace::exiting("scribo::primitive::lines_h_discontinued");
diff --git a/scribo/primitive/extract/lines_h_pattern.hh
b/scribo/primitive/extract/lines_h_pattern.hh
index fa1823d..08025a1 100644
--- a/scribo/primitive/extract/lines_h_pattern.hh
+++ b/scribo/primitive/extract/lines_h_pattern.hh
@@ -30,15 +30,18 @@
///
/// Extract horizontal lines matching a specific pattern.
-#include <mln/core/concept/image.hh>
-#include <mln/core/alias/window2d.hh>
-
-# include <mln/win/hline2d.hh>
-
+# include <mln/core/concept/image.hh>
+# include <mln/core/alias/window2d.hh>
+# include <mln/win/rectangle2d.hh>
# include <mln/morpho/dilation.hh>
+# include <mln/arith/times.hh>
+
# include <scribo/primitive/extract/lines_pattern.hh>
+# include <scribo/primitive/internal/rd.hh>
+
+
namespace scribo
{
@@ -74,17 +77,6 @@ namespace scribo
mln_precondition(exact(input).is_valid());
mln_precondition(length % 2 == 1);
-// bool win_def[7][1] = { {1},
-// {0},
-// {0},
-// {0},
-// {0},
-// {0},
-// {1} };
-
-// window2d win;
-// convert::from_to(win_def, win);
-
// FIXME: not generic.
window2d win;
mln_deduce(I, site, dpsite)
@@ -93,11 +85,16 @@ namespace scribo
win.insert(dp1);
win.insert(dp2);
- //FIXME: Add reconstruction instead of this arbitrary dilation.
- win::hline2d hwin(length/2 + 2);
-// win::hline2d hwin(length);
- return morpho::dilation(lines_pattern(input, length, 1, win), hwin);
-// return lines_pattern(input, length, 1, win);
+ mln_concrete(I) output = lines_pattern(input, length, 1, win);
+
+ mln_concrete(I)
+ output_dil = morpho::dilation(output,
+ win::rectangle2d(3, length / 2 + delta));
+
+ output = scribo::primitive::internal::rd(output, input * output_dil);
+
+ trace::exiting("scribo::primitive::extract::lines_h_pattern");
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/primitive/extract/lines_h_single.hh
b/scribo/primitive/extract/lines_h_single.hh
index 4e9cb74..ad6b794 100644
--- a/scribo/primitive/extract/lines_h_single.hh
+++ b/scribo/primitive/extract/lines_h_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.
//
@@ -34,7 +35,7 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/win/hline2d.hh>
-# include <scribo/core/object_image.hh>
+# include <scribo/primitive/extract/components.hh>
namespace scribo
@@ -67,9 +68,9 @@ namespace scribo
* labeled.
*/
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_v_single(const Image<I>& input,
- const Neighborhood<N>& nbh, V& nlines,
+ const Neighborhood<N>& nbh, const V& nlines,
unsigned min_line_length,
float w_h_ratio);
@@ -79,7 +80,7 @@ namespace scribo
* Only single non discontinued lines are correctly extracted
* with this routine.
*
- * \param[in] objects A labeled image.
+ * \param[in] components A labeled image.
* \param[in] line_length The minimum line length.
* \param[in] w_h_ratio The minimum ratio width/height object
* bounding boxes to consider an
@@ -89,8 +90,8 @@ namespace scribo
* labeled.
*/
template <typename L>
- object_image(L)
- lines_h_single(const object_image(L)& objects,
+ component_set<L>
+ lines_h_single(const component_set<L>& components,
unsigned min_line_length,
float w_h_ratio);
@@ -106,17 +107,17 @@ namespace scribo
{
typedef bool result;
- is_line_h_single(const object_image(L)& objects,
+ is_line_h_single(const component_set<L>& components,
float w_h_ratio, unsigned min_line_length)
: w_h_ratio_(w_h_ratio), min_line_length_(min_line_length),
- objects_(objects)
+ components_(components)
{
}
bool operator()(const mln_value(L)& label) const
{
- mln_domain(L) box = objects_.bbox(label);
+ const mln_domain(L)& box = components_(label).bbox();
unsigned
height = box.pmax().row() - box.pmin().row() + 1,
@@ -129,7 +130,7 @@ namespace scribo
float w_h_ratio_;
unsigned min_line_length_;
- object_image(L) objects_;
+ component_set<L> components_;
};
@@ -139,9 +140,9 @@ namespace scribo
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_h_single(const Image<I>& input_,
- const Neighborhood<N>& nbh_, V& nlines,
+ const Neighborhood<N>& nbh_, const V& nlines,
unsigned min_line_length,
float w_h_ratio)
{
@@ -153,14 +154,13 @@ namespace scribo
mln_precondition(nbh.is_valid());
typedef mln_ch_value(I,V) L;
- object_image(L)
- output = objects(input, nbh, nlines);
+ component_set<L>
+ output = primitive::extract::components(input, nbh, nlines);
internal::is_line_h_single<L>
is_line(output, w_h_ratio, min_line_length);
- output.relabel(is_line);
- nlines = output.nlabels();
+ output.update_tags(is_line, component::Ignored);
trace::exiting("scribo::primitive::lines_h_single");
return output;
@@ -170,21 +170,20 @@ namespace scribo
template <typename L>
- object_image(L)
- lines_h_single(const object_image(L)& objects,
+ component_set<L>
+ lines_h_single(const component_set<L>& components,
unsigned min_line_length,
float w_h_ratio)
{
trace::entering("scribo::primitive::lines_h_single");
- mln_precondition(objects.is_valid());
+ mln_precondition(components.is_valid());
internal::is_line_h_single<L>
- is_line(objects, w_h_ratio, min_line_length);
+ is_line(components, w_h_ratio, min_line_length);
- object_image(L) output;
- output.init_from_(objects);
- output.relabel(is_line);
+ component_set<L> output = components.duplicate();
+ output.update_tags(is_line, component::Ignored);
trace::exiting("scribo::primitive::lines_h_single");
return output;
diff --git a/scribo/primitive/extract/lines_h_thick.hh
b/scribo/primitive/extract/lines_h_thick.hh
index 817f47d..b1dfcfd 100644
--- a/scribo/primitive/extract/lines_h_thick.hh
+++ b/scribo/primitive/extract/lines_h_thick.hh
@@ -34,7 +34,7 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/win/hline2d.hh>
-# include <scribo/core/object_image.hh>
+# include <scribo/core/component_set.hh>
# include <scribo/primitive/extract/lines_thick.hh>
namespace scribo
@@ -61,7 +61,7 @@ namespace scribo
* \return An image in which lines are labeled.
*/
template <typename I, typename N, typename V, typename W>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_thick(const Image<I>& input_,
const Neighborhood<N>& nbh_, V& nlines,
unsigned line_length);
@@ -99,7 +99,7 @@ namespace scribo
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_h_thick(const Image<I>& input,
const Neighborhood<N>& nbh, V& nlines,
unsigned line_length)
@@ -111,7 +111,7 @@ namespace scribo
win::hline2d win(line_length);
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
output = lines_thick(input, nbh, nlines, win);
trace::exiting("scribo::primitive::lines_h_thick");
diff --git a/scribo/primitive/extract/lines_thick.hh
b/scribo/primitive/extract/lines_thick.hh
index 230b63c..726dab4 100644
--- a/scribo/primitive/extract/lines_thick.hh
+++ b/scribo/primitive/extract/lines_thick.hh
@@ -37,9 +37,8 @@
# include <mln/morpho/opening/structural.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
-# include <scribo/primitive/extract/objects.hh>
+# include <scribo/primitive/extract/components.hh>
namespace scribo
{
@@ -66,7 +65,7 @@ namespace scribo
* \return An image in which lines are labeled.
*/
template <typename I, typename N, typename V, typename W>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_thick(const Image<I>& input_,
const Neighborhood<N>& nbh_, V& nlines,
const Window<W>& win_);
@@ -105,7 +104,7 @@ namespace scribo
template <typename I, typename N, typename V, typename W>
inline
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_thick(const Image<I>& input_,
const Neighborhood<N>& nbh_, V& nlines,
const Window<W>& win_)
@@ -119,8 +118,8 @@ namespace scribo
const W& win = exact(win_);
mln_ch_value(I,bool) filter = morpho::opening::structural(input, win);
- object_image(mln_ch_value(I,V)) output
- = primitive::extract::objects(filter, nbh, nlines);
+ component_set<mln_ch_value(I,V)> output
+ = primitive::extract::components(filter, nbh, nlines);
trace::exiting("scribo::primitive::lines_thick");
return output;
diff --git a/scribo/primitive/extract/lines_v_discontinued.hh
b/scribo/primitive/extract/lines_v_discontinued.hh
index 8f64472..c0e8b92 100644
--- a/scribo/primitive/extract/lines_v_discontinued.hh
+++ b/scribo/primitive/extract/lines_v_discontinued.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,7 +34,6 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/primitive/extract/lines_discontinued.hh>
@@ -61,7 +61,7 @@ namespace scribo
* from 0.
*/
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_v_discontinued(const Image<I>& input,
const Neighborhood<N>& nbh, V& nlines,
unsigned line_length, unsigned rank_k);
@@ -99,7 +99,7 @@ namespace scribo
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_v_discontinued(const Image<I>& input,
const Neighborhood<N>& nbh, V& nlines,
unsigned line_length, unsigned rank_k)
@@ -111,7 +111,7 @@ namespace scribo
win::vline2d win(line_length);
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
output = lines_discontinued(input, nbh, nlines, win, rank_k);
trace::exiting("scribo::primitive::lines_v_discontinued");
diff --git a/scribo/primitive/extract/lines_v_single.hh
b/scribo/primitive/extract/lines_v_single.hh
index 74391f6..c67dfca 100644
--- a/scribo/primitive/extract/lines_v_single.hh
+++ b/scribo/primitive/extract/lines_v_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.
//
@@ -34,8 +35,6 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/win/hline2d.hh>
-# include <scribo/core/object_image.hh>
-
namespace scribo
{
@@ -66,9 +65,9 @@ namespace scribo
* labeled.
*/
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_v_single(const Image<I>& input,
- const Neighborhood<N>& nbh, V& nlines,
+ const Neighborhood<N>& nbh, const V& nlines,
unsigned min_line_length,
float h_w_ratio);
@@ -78,7 +77,7 @@ namespace scribo
* Only single non discontinued lines are correctly extracted
* with this routine.
*
- * \param[in] objects A labeled image.
+ * \param[in] components A labeled image.
* \param[in] line_length The minimum line length.
* \param[in] h_w_ratio The minimum ratio height/width object
* bounding boxes to consider an
@@ -88,8 +87,8 @@ namespace scribo
* labeled.
*/
template <typename L>
- object_image(L)
- lines_v_single(const object_image(L)& objects,
+ component_set<L>
+ lines_v_single(const component_set<L>& components,
unsigned min_line_length,
float h_w_ratio);
@@ -105,17 +104,17 @@ namespace scribo
{
typedef bool result;
- is_line_v_single(const object_image(L)& objects,
+ is_line_v_single(const component_set<L>& components,
float h_w_ratio, unsigned min_line_length)
: h_w_ratio_(h_w_ratio), min_line_length_(min_line_length),
- objects_(objects)
+ components_(components)
{
}
bool operator()(const mln_value(L)& label) const
{
- mln_domain(L) box = objects_.bbox(label);
+ const mln_domain(L)& box = components_(label).bbox();
unsigned
height = box.pmax().row() - box.pmin().row() + 1,
width = box.pmax().col() - box.pmin().col() + 1;
@@ -127,7 +126,7 @@ namespace scribo
float h_w_ratio_;
unsigned min_line_length_;
- object_image(L) objects_;
+ component_set<L> components_;
};
@@ -136,9 +135,9 @@ namespace scribo
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_v_single(const Image<I>& input_,
- const Neighborhood<N>& nbh_, V& nlines,
+ const Neighborhood<N>& nbh_, const V& nlines,
unsigned min_line_length,
float h_w_ratio)
{
@@ -150,14 +149,13 @@ namespace scribo
mln_precondition(nbh.is_valid());
typedef mln_ch_value(I,V) L;
- object_image(L)
- output = objects(input, nbh, nlines);
+ component_set<L>
+ output = primitive::extract::components(input, nbh, nlines);
internal::is_line_v_single<L>
is_line(output, h_w_ratio, min_line_length);
- output.relabel(is_line);
- nlines = output.nlabels();
+ output.update_tags(is_line, component::Ignored);
trace::exiting("scribo::primitive::lines_v_single");
return output;
@@ -166,21 +164,20 @@ namespace scribo
template <typename L>
- object_image(L)
- lines_v_single(const object_image(L)& objects,
+ component_set<L>
+ lines_v_single(const component_set<L>& components,
unsigned min_line_length,
float h_w_ratio)
{
trace::entering("scribo::primitive::lines_v_single");
- mln_precondition(objects.is_valid());
+ mln_precondition(components.is_valid());
internal::is_line_v_single<L>
- is_line(objects, h_w_ratio, min_line_length);
+ is_line(components, h_w_ratio, min_line_length);
- object_image(L) output;
- output.init_from_(objects);
- output.relabel(is_line);
+ component_set<L> output = components.duplicate();
+ output.update_tags(is_line, component::Ignored);
trace::exiting("scribo::primitive::lines_v_single");
return output;
diff --git a/scribo/primitive/extract/lines_v_thick.hh
b/scribo/primitive/extract/lines_v_thick.hh
index 2ee09dd..8b8a656 100644
--- a/scribo/primitive/extract/lines_v_thick.hh
+++ b/scribo/primitive/extract/lines_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.
//
@@ -34,7 +35,6 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/win/vline2d.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/primitive/extract/lines_thick.hh>
namespace scribo
@@ -61,7 +61,7 @@ namespace scribo
* \return An image in which lines are labeled.
*/
template <typename I, typename N, typename V, typename W>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_thick(const Image<I>& input_,
const Neighborhood<N>& nbh_, V& nlines,
unsigned line_length);
@@ -99,10 +99,10 @@ namespace scribo
template <typename I, typename N, typename V>
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
lines_v_thick(const Image<I>& input,
- const Neighborhood<N>& nbh, V& nlines,
- unsigned line_length)
+ const Neighborhood<N>& nbh, V& nlines,
+ unsigned line_length)
{
trace::entering("scribo::primitive::extract::lines_v_thick");
@@ -111,7 +111,7 @@ namespace scribo
win::vline2d win(line_length);
- object_image(mln_ch_value(I,V))
+ component_set<mln_ch_value(I,V)>
output = lines_thick(input, nbh, nlines, win);
trace::exiting("scribo::primitive::extract::lines_v_thick");
diff --git a/scribo/primitive/group/apply.hh b/scribo/primitive/group/apply.hh
index 026171d..3370104 100644
--- a/scribo/primitive/group/apply.hh
+++ b/scribo/primitive/group/apply.hh
@@ -75,7 +75,7 @@ namespace scribo
template <typename L>
component_set<L>
apply(const object_groups<L>& groups,
- fun::i2v::array<mln_value(L)>& relabel_fun)
+ mln::fun::i2v::array<mln_value(L)>& relabel_fun)
{
trace::entering("scribo::primitive::group::apply");
@@ -105,7 +105,7 @@ namespace scribo
component_set<L>
apply(const object_groups<L>& groups)
{
- fun::i2v::array<mln_value(L)> relabel_fun;
+ mln::fun::i2v::array<mln_value(L)> relabel_fun;
return apply(groups, relabel_fun);
}
diff --git a/scribo/primitive/group/from_graph.hh b/scribo/primitive/group/from_graph.hh
index 55cb56d..602be90 100644
--- a/scribo/primitive/group/from_graph.hh
+++ b/scribo/primitive/group/from_graph.hh
@@ -48,7 +48,6 @@
# include <scribo/core/object_links.hh>
# include <scribo/core/object_groups.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
diff --git a/scribo/primitive/internal/all.hh b/scribo/primitive/internal/all.hh
index 86aa62a..26f5d5b 100644
--- a/scribo/primitive/internal/all.hh
+++ b/scribo/primitive/internal/all.hh
@@ -47,14 +47,11 @@ namespace scribo
} // end of namespace scribo
-# include <scribo/primitive/internal/init_link_array.hh>
# include <scribo/primitive/internal/is_link_valid.hh>
# include <scribo/primitive/internal/find_root.hh>
# include <scribo/primitive/internal/find_graph_link.hh>
-# include <scribo/primitive/internal/find_right_link.hh>
# include <scribo/primitive/internal/update_graph_link.hh>
# include <scribo/primitive/internal/update_link_array.hh>
-# include <scribo/primitive/internal/find_left_link.hh>
#endif // ! SCRIBO_PRIMITIVE_INTERNAL_ALL_HH
diff --git a/scribo/primitive/internal/find_graph_link.hh
b/scribo/primitive/internal/find_graph_link.hh
index b2f6549..f5a1039 100644
--- a/scribo/primitive/internal/find_graph_link.hh
+++ b/scribo/primitive/internal/find_graph_link.hh
@@ -37,7 +37,6 @@
# include <mln/util/array.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/primitive/internal/update_graph_link.hh>
//FIXME: not generic.
diff --git a/scribo/primitive/internal/rd.hh b/scribo/primitive/internal/rd.hh
index 7b8f069..49b6abb 100644
--- a/scribo/primitive/internal/rd.hh
+++ b/scribo/primitive/internal/rd.hh
@@ -100,7 +100,7 @@ namespace scribo
initialize(parent, f);
}
- util::array<int> dp = negative_offsets_wrt(f, nbh);
+ mln::util::array<int> dp = negative_offsets_wrt(f, nbh);
const unsigned n_nbhs = dp.nelements();
// First pass.
diff --git a/scribo/primitive/link/with_graph.hh b/scribo/primitive/link/with_graph.hh
index 5f16ec8..2d579aa 100644
--- a/scribo/primitive/link/with_graph.hh
+++ b/scribo/primitive/link/with_graph.hh
@@ -42,8 +42,6 @@
# include <mln/util/graph.hh>
# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
-# include <scribo/primitive/internal/init_link_array.hh>
# include <scribo/primitive/internal/find_graph_link.hh>
diff --git a/scribo/primitive/link/with_several_graphes.hh
b/scribo/primitive/link/with_several_graphes.hh
index 148d3cc..98d631e 100644
--- a/scribo/primitive/link/with_several_graphes.hh
+++ b/scribo/primitive/link/with_several_graphes.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,10 +39,7 @@
# include <mln/util/array.hh>
# include <mln/util/graph.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_graph_link.hh>
namespace scribo
diff --git a/scribo/primitive/link/with_several_left_links.hh
b/scribo/primitive/link/with_several_left_links.hh
index 2de4cee..5a685a1 100644
--- a/scribo/primitive/link/with_several_left_links.hh
+++ b/scribo/primitive/link/with_several_left_links.hh
@@ -37,8 +37,6 @@
# include <scribo/core/object_links.hh>
# include <scribo/core/macros.hh>
-# include <scribo/primitive/internal/init_link_array.hh>
-# include <scribo/primitive/internal/find_left_link.hh>
# include <scribo/util/text.hh>
diff --git a/scribo/primitive/link/with_several_right_links.hh
b/scribo/primitive/link/with_several_right_links.hh
index b302dcb..14d3229 100644
--- a/scribo/primitive/link/with_several_right_links.hh
+++ b/scribo/primitive/link/with_several_right_links.hh
@@ -38,10 +38,7 @@
# 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>
diff --git a/scribo/table/erase.hh b/scribo/table/erase.hh
index 7cc9461..a34e5a0 100644
--- a/scribo/table/erase.hh
+++ b/scribo/table/erase.hh
@@ -62,8 +62,8 @@ namespace scribo
template <typename I, typename L>
mln_concrete(I)
erase(const Image<I>& input,
- const object_image(L)& hlines,
- const object_image(L)& vlines);
+ const Image<L>& hlines,
+ const Image<L>& vlines);
# ifndef MLN_INCLUDE_ONLY
@@ -73,12 +73,14 @@ namespace scribo
inline
mln_concrete(I)
erase(const Image<I>& input,
- const object_image(L)& hlines,
- const object_image(L)& vlines)
+ const Image<L>& hlines,
+ const Image<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 efd030c..aca2321 100644
--- a/scribo/table/extract.hh
+++ b/scribo/table/extract.hh
@@ -38,12 +38,11 @@
# include <mln/io/ppm/all.hh>
# include <mln/labeling/colorize.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/table/rebuild.hh>
# include <scribo/table/erase.hh>
# include <scribo/primitive/extract/lines_h_pattern.hh>
# include <scribo/primitive/extract/lines_v_pattern.hh>
-# include <scribo/primitive/extract/objects.hh>
+# include <scribo/primitive/extract/components.hh>
# include <scribo/debug/save_bboxes_image.hh>
diff --git a/scribo/table/internal/align_lines.hh b/scribo/table/internal/align_lines.hh
index bd72af8..9af00fc 100644
--- a/scribo/table/internal/align_lines.hh
+++ b/scribo/table/internal/align_lines.hh
@@ -124,7 +124,7 @@ namespace scribo
lines.resize(nsites);
// Map components with actual lines.
- for_all_components(i, line_bboxes)
+ for_all_comps(i, line_bboxes)
{
int minline = line_bboxes[i].pmin()[dim] - max_alignment_diff;
minline = (minline < min_coord ? min_coord : minline);
diff --git a/scribo/table/internal/connect_lines.hh
b/scribo/table/internal/connect_lines.hh
index b2f9273..667060a 100644
--- a/scribo/table/internal/connect_lines.hh
+++ b/scribo/table/internal/connect_lines.hh
@@ -43,7 +43,7 @@
# include <mln/opt/at.hh>
-# include <mln/transform/influence_zone_geodesic.hh>
+# include <mln/transform/influence_zone_geodesic_saturated.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/central_sites.hh>
@@ -96,9 +96,10 @@ namespace scribo
for_all_elements(i, aligned_lines)
opt::at(l, aligned_lines[i]) = aligned_lines[i];
- l = transform::influence_zone_geodesic(l, c2(), max_distance, -1);
+ l = transform::influence_zone_geodesic_saturated(l, c2(),
+ max_distance, -1);
- for_all_components(i, boxes)
+ for_all_comps(i, boxes)
{
mln::util::couple<P,P> cp = central_sites(boxes[i], dim);
if (opt::at(l, cp.first()[dim]) != -1
diff --git a/scribo/table/internal/repair_lines.hh
b/scribo/table/internal/repair_lines.hh
index f197979..481728c 100644
--- a/scribo/table/internal/repair_lines.hh
+++ b/scribo/table/internal/repair_lines.hh
@@ -112,7 +112,7 @@ namespace scribo
typedef mln_ch_value(I,value::label_16) L;
L l(input.domain());
data::fill(l, literal::zero);
- for_all_components(i, tableboxes)
+ for_all_comps(i, tableboxes)
{
mln::util::couple<P,P> cp = central_sites(tableboxes[i], axis);
l(cp.first()) = i;
--
1.5.6.5