Commit 2c6947d7 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

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.
parent 4dad6c9a
2010-04-13 Guillaume Lazzara <z@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@lrde.epita.fr>
* src/text_in_photo_fast.cc: Group routine parameters in a global
structure.
2010-04-13 Guillaume Lazzara <z@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@lrde.epita.fr>
......
......@@ -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
......
// 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()
......
......@@ -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;
......
......@@ -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>
......
// 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
......@@ -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();
}
......
......@@ -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
......
......@@ -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();
......
......@@ -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
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment