* core/object_links.hh: New init() member.
* filter/object_groups_v_thickness.hh,
* filter/object_groups_with_holes.hh,
* primitive/group/from_double_link.hh,
* primitive/link/internal/link_functor_base.hh,
* primitive/link/merge_double_link.hh,
* src/afp/link.hh,
* src/afp/regroup.hh: Call init() on object_links instances.
* primitive/internal/init_link_array.hh: Remove.
---
scribo/ChangeLog | 78 ++++++++++++--------
scribo/core/object_links.hh | 35 +++++++++-
scribo/filter/object_groups_v_thickness.hh | 5 +-
scribo/filter/object_groups_with_holes.hh | 24 +-----
scribo/primitive/group/from_double_link.hh | 3 +-
scribo/primitive/internal/init_link_array.hh | 78 --------------------
.../primitive/link/internal/link_functor_base.hh | 5 +-
scribo/primitive/link/merge_double_link.hh | 1 -
scribo/src/afp/link.hh | 13 +--
scribo/src/afp/regroup.hh | 1 -
10 files changed, 95 insertions(+), 148 deletions(-)
delete mode 100644 scribo/primitive/internal/init_link_array.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index ffd4a39..a7134fa 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,41 +1,57 @@
2010-04-13 Guillaume Lazzara <z(a)lrde.epita.fr>
- * scribo/src/text_in_photo_fast.cc: Group routine parameters in a
- global structure.
+ Add init() member to object_links structure.
+
+ * core/object_links.hh: New init() member.
+
+ * filter/object_groups_v_thickness.hh,
+ * filter/object_groups_with_holes.hh,
+ * primitive/group/from_double_link.hh,
+ * primitive/link/internal/link_functor_base.hh,
+ * primitive/link/merge_double_link.hh,
+ * src/afp/link.hh,
+ * src/afp/regroup.hh: Call init() on object_links instances.
+
+ * primitive/internal/init_link_array.hh: Remove.
+
+2010-04-13 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * src/text_in_photo_fast.cc: Group routine parameters in a global
+ structure.
2010-04-13 Guillaume Lazzara <z(a)lrde.epita.fr>
Add new Sauvola overloads and update examples.
- * scribo/binarization/internal/first_pass_functor.hh,
- * scribo/binarization/local_threshold.hh,
- * scribo/binarization/sauvola.hh,
- * scribo/binarization/sauvola_ms.hh,
- * scribo/binarization/sauvola_ms_split.hh,
- * scribo/binarization/sauvola_threshold_image.hh,
- * scribo/canvas/integral_browsing.hh: Add more parameters to
- Sauvola routines.
-
- * scribo/binarization/sauvola_threshold_image_debug.hh: New. New
- overload providing debug outputs.
-
- * scribo/debug/usage.hh: Remove a parameter.
-
- * scribo/src/binarization/Makefile.am,
- * scribo/src/binarization/pgm_global_threshold_auto.cc,
- * scribo/src/binarization/pgm_sauvola.cc,
- * scribo/src/binarization/pgm_sauvola_ms.cc,
- * scribo/src/binarization/ppm_fg_sauvola_ms.cc,
- * scribo/src/binarization/ppm_sauvola.cc,
- * scribo/src/binarization/ppm_sauvola_ms.cc,
- * scribo/src/binarization/ppm_sauvola_ms_split.cc: Add new
- program arguments.
-
- * scribo/src/binarization/fg_sauvola_ms.cc,
- * scribo/src/binarization/sauvola.cc,
- * scribo/src/binarization/sauvola_ms.cc,
- * scribo/src/binarization/sauvola_ms_split.cc,
- * scribo/src/binarization/sauvola_debug.cc: New.
+ * binarization/internal/first_pass_functor.hh,
+ * binarization/local_threshold.hh,
+ * binarization/sauvola.hh,
+ * binarization/sauvola_ms.hh,
+ * binarization/sauvola_ms_split.hh,
+ * binarization/sauvola_threshold_image.hh,
+ * canvas/integral_browsing.hh: Add more parameters to Sauvola
+ routines.
+
+ * binarization/sauvola_threshold_image_debug.hh: New. New overload
+ providing debug outputs.
+
+ * debug/usage.hh: Remove a parameter.
+
+ * src/binarization/Makefile.am,
+ * src/binarization/pgm_global_threshold_auto.cc,
+ * src/binarization/pgm_sauvola.cc,
+ * src/binarization/pgm_sauvola_ms.cc,
+ * src/binarization/ppm_fg_sauvola_ms.cc,
+ * src/binarization/ppm_sauvola.cc,
+ * src/binarization/ppm_sauvola_ms.cc,
+ * src/binarization/ppm_sauvola_ms_split.cc: Add new program
+ arguments.
+
+ * src/binarization/fg_sauvola_ms.cc,
+ * src/binarization/sauvola.cc,
+ * src/binarization/sauvola_ms.cc,
+ * src/binarization/sauvola_ms_split.cc,
+ * src/binarization/sauvola_debug.cc: New.
2010-03-29 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/core/object_links.hh b/scribo/core/object_links.hh
index 654cb75..c10cae6 100644
--- a/scribo/core/object_links.hh
+++ b/scribo/core/object_links.hh
@@ -90,12 +90,18 @@ namespace scribo
const mln::util::array<unsigned>& comp_to_link() const;
+ void init();
private:
mln::util::tracked_ptr<data_t> data_;
};
+ template <typename L>
+ std::ostream&
+ operator<<(std::ostream& ostr, const object_links<L>& links);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -174,7 +180,7 @@ namespace scribo
unsigned
object_links<L>::nelements() const
{
- return data_->comp_to_link_.nelements() ;
+ return data_->comp_to_link_.nelements();
}
@@ -202,6 +208,33 @@ namespace scribo
}
+ template <typename L>
+ void
+ object_links<L>::init()
+ {
+ for (unsigned i = 0; i < nelements(); ++i)
+ if (data_->components_(i).tag() == component::Ignored)
+ data_->comp_to_link_(i) = 0;
+ else
+ data_->comp_to_link_(i) = i;
+ }
+
+
+ template <typename L>
+ std::ostream&
+ operator<<(std::ostream& ostr, const object_links<L>& links)
+ {
+ ostr << "object_links[";
+
+ for_all_links(l, links)
+ ostr << l << "->" << links.comp_to_link()[l]
<< ", ";
+
+ ostr << "]";
+
+ return ostr;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/filter/object_groups_v_thickness.hh
b/scribo/filter/object_groups_v_thickness.hh
index caac765..717b372 100644
--- a/scribo/filter/object_groups_v_thickness.hh
+++ b/scribo/filter/object_groups_v_thickness.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.
//
@@ -75,7 +76,7 @@ namespace scribo
mln::util::array<float>
group_thickness = estim::object_groups_v_thickness(groups);
- object_groups<L> output(groups);
+ object_groups<L> output = groups.duplicate();
output(0) = 0;
for (unsigned i = 1; i < output.nelements(); ++i)
if (groups.components()(i).is_valid()
diff --git a/scribo/filter/object_groups_with_holes.hh
b/scribo/filter/object_groups_with_holes.hh
index 1f31c01..570ae6a 100644
--- a/scribo/filter/object_groups_with_holes.hh
+++ b/scribo/filter/object_groups_with_holes.hh
@@ -42,33 +42,13 @@
# include <mln/draw/box_plain.hh>
# include <mln/util/array.hh>
-# include <mln/labeling/blobs_and_compute.hh>
-
# include <mln/accu/math/count.hh>
# include <mln/fun/i2v/array.hh>
-# include <mln/io/pbm/save.hh>
-# include <mln/io/pgm/save.hh>
-
-# include <mln/data/convert.hh>
-
-# include <mln/labeling/background.hh>
-
# include <scribo/core/macros.hh>
# include <scribo/core/component_set.hh>
-# include <scribo/filter/internal/compute.hh>
-
-# include <mln/data/fill.hh>
-# include <mln/data/paste.hh>
-
-# include <mln/util/timer.hh>
-
-# include <mln/value/label_16.hh>
-# include <mln/core/var.hh>
-
-#include <mln/debug/filename.hh>
namespace scribo
{
@@ -195,6 +175,9 @@ namespace scribo
data::fill(card, 1);
border::fill(card, 1);
+ // We want to label background components only in the
+ // group bounding boxes. Thus, this image is a labeling
+ // constraint.
bboxes_ima = internal::compute_bboxes_image(components);
to_keep(0) = true;
@@ -285,7 +268,6 @@ namespace scribo
if (! to_keep(groups(c)))
output(c) = 0;
-// output.update_tags(to_keep, component::Ignored);
trace::exiting("scribo::filter::impl::generic::object_groups_with_holes");
return output;
diff --git a/scribo/primitive/group/from_double_link.hh
b/scribo/primitive/group/from_double_link.hh
index a1e8479..14c5972 100644
--- a/scribo/primitive/group/from_double_link.hh
+++ b/scribo/primitive/group/from_double_link.hh
@@ -46,7 +46,6 @@
# include <scribo/core/component_set.hh>
# include <scribo/primitive/internal/find_root.hh>
# include <scribo/primitive/internal/is_link_valid.hh>
-# include <scribo/primitive/internal/init_link_array.hh>
namespace scribo
@@ -94,7 +93,7 @@ namespace scribo
mln_precondition(right_link.components_id_() == components.id_());
object_groups<L> parent(components, left_link.nelements());
- internal::init_link_array(parent);
+ parent.init();
for_all_ncomponents(i, components.nlabels())
{
mln::util::couple<bool, unsigned>
diff --git a/scribo/primitive/internal/init_link_array.hh
b/scribo/primitive/internal/init_link_array.hh
deleted file mode 100644
index 2b46ad5..0000000
--- a/scribo/primitive/internal/init_link_array.hh
+++ /dev/null
@@ -1,78 +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_INIT_LINK_ARRAY_HH
-# define SCRIBO_PRIMITIVE_INTERNAL_INIT_LINK_ARRAY_HH
-
-/// \file
-///
-/// Initialize a link array.
-
-
-# include <scribo/core/object_links.hh>
-# include <scribo/core/component_set.hh>
-
-
-namespace scribo
-{
-
- using namespace mln;
-
- namespace primitive
- {
-
- namespace internal
- {
-
- /// Initialize a link array.
- template <typename L>
- void
- init_link_array(object_links<L>& link_array);
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename L>
- inline
- void
- init_link_array(object_links<L>& link_array)
- {
- const component_set<L>& comp_set = link_array.components();
- for (unsigned i = 0; i < link_array.nelements(); ++i)
- if (comp_set(i).tag() == component::Ignored)
- link_array(i) = 0;
- else
- link_array(i) = i;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::primitive::internal
-
- } // end of namespace scribo::primitive
-
-} // end of namespace scribo
-
-
-#endif // ! SCRIBO_PRIMITIVE_INTERNAL_INIT_LINK_ARRAY_HH
diff --git a/scribo/primitive/link/internal/link_functor_base.hh
b/scribo/primitive/link/internal/link_functor_base.hh
index 5e4af46..f2641ad 100644
--- a/scribo/primitive/link/internal/link_functor_base.hh
+++ b/scribo/primitive/link/internal/link_functor_base.hh
@@ -45,7 +45,6 @@
# include <scribo/core/object_links.hh>
# include <scribo/core/concept/link_functor.hh>
# include <scribo/primitive/link/internal/compute_anchor.hh>
-# include <scribo/primitive/internal/init_link_array.hh>
# define scribo_support(T) typename T::support
# define scribo_support_(T) T::support
@@ -194,7 +193,7 @@ namespace scribo
labeled_image_(this->components_.labeled_image()),
nanchors_(nanchors)
{
- primitive::internal::init_link_array(links_);
+ links_.init();
}
@@ -207,7 +206,7 @@ namespace scribo
labeled_image_(this->components_.labeled_image()),
nanchors_(1)
{
- primitive::internal::init_link_array(links_);
+ links_.init();
}
diff --git a/scribo/primitive/link/merge_double_link.hh
b/scribo/primitive/link/merge_double_link.hh
index 704c103..94a44ef 100644
--- a/scribo/primitive/link/merge_double_link.hh
+++ b/scribo/primitive/link/merge_double_link.hh
@@ -48,7 +48,6 @@
# include <scribo/core/component_set.hh>
# include <scribo/primitive/internal/find_root.hh>
# include <scribo/primitive/internal/is_link_valid.hh>
-# include <scribo/primitive/internal/init_link_array.hh>
namespace scribo
diff --git a/scribo/src/afp/link.hh b/scribo/src/afp/link.hh
index b6ef1f9..fc23991 100644
--- a/scribo/src/afp/link.hh
+++ b/scribo/src/afp/link.hh
@@ -3,7 +3,6 @@
#include <mln/util/couple.hh>
#include <scribo/core/component_set.hh>
#include <scribo/core/macros.hh>
-#include <scribo/primitive/internal/init_link_array.hh>
namespace scribo
{
@@ -21,21 +20,19 @@ namespace scribo
{
object_links<L>
right(components, static_cast<unsigned>(components.nelements()) + 1);
- primitive::internal::init_link_array(right);
+ right.init();
object_links<L>
left(components, static_cast<unsigned>(components.nelements()) + 1);
- primitive::internal::init_link_array(left);
+ left.init();
const L& lbl_ima = components.labeled_image();
for_all_comps(i, components)
{
float
- w = (components(i).bbox().pmax().col()
- - components(i).bbox().pmin().col()),
- h = (components(i).bbox().pmax().row()
- - components(i).bbox().pmin().row());
+ w = components(i).bbox().width(),
+ h = components(i).bbox().height();
unsigned dmax = (w / 2.0f) + (3 * math::max(w, h));
@@ -98,7 +95,7 @@ namespace scribo
{
object_links<L>
left(components, static_cast<unsigned>(components.nelements()) + 1);
- primitive::internal::init_link_array(left);
+ left.init();
const L& lbl_ima = components.labeled_image();
diff --git a/scribo/src/afp/regroup.hh b/scribo/src/afp/regroup.hh
index 3fcfcaa..44b5438 100644
--- a/scribo/src/afp/regroup.hh
+++ b/scribo/src/afp/regroup.hh
@@ -3,7 +3,6 @@
#include <mln/util/couple.hh>
#include <scribo/core/component_set.hh>
#include <scribo/core/macros.hh>
-#include <scribo/primitive/internal/init_link_array.hh>
namespace scribo
{
--
1.5.6.5