last-svn-commit-433-g0877158 Replace the use of object_image with component_set.

* core/erase_objects.hh, * debug/several_links_decision_image.hh, * filter/object_groups_size_ratio.hh, * filter/object_links_bbox_w_ratio.hh, * filter/object_links_center_aligned.hh, * filter/object_links_left_aligned.hh, * filter/object_links_right_aligned.hh, * filter/objects_h_thick.hh, * filter/objects_h_thin.hh, * filter/objects_size_ratio.hh, * filter/objects_v_thick.hh, * filter/objects_v_thin.hh, * primitive/extract/lines_h_thick_and_single.hh, * primitive/extract/lines_v_thick_and_single.hh, * primitive/group/from_graph.hh, * primitive/internal/find_graph_link.hh, * primitive/link/with_graph.hh, * primitive/link/with_rag.hh, * primitive/link/with_several_graphes.hh, * primitive/link/with_several_left_links.hh, * primitive/link/with_several_right_closest_links.hh, * primitive/link/with_several_right_links.hh, * primitive/link/with_single_down_link.hh, * primitive/link/with_single_up_link.hh: Replace the use of object_image with component_set. --- scribo/ChangeLog | 30 ++++++ scribo/core/erase_objects.hh | 18 ++-- scribo/debug/several_links_decision_image.hh | 47 ++++----- scribo/filter/object_groups_size_ratio.hh | 11 +- scribo/filter/object_links_bbox_w_ratio.hh | 19 ++-- scribo/filter/object_links_center_aligned.hh | 10 +-- scribo/filter/object_links_left_aligned.hh | 13 +-- scribo/filter/object_links_right_aligned.hh | 16 ++-- scribo/filter/objects_h_thick.hh | 82 +++++++-------- scribo/filter/objects_h_thin.hh | 106 ++++++++++---------- scribo/filter/objects_size_ratio.hh | 65 +++++++------ scribo/filter/objects_v_thick.hh | 86 ++++++++-------- scribo/filter/objects_v_thin.hh | 105 ++++++++++---------- .../primitive/extract/lines_h_thick_and_single.hh | 16 ++-- .../primitive/extract/lines_v_thick_and_single.hh | 15 ++-- scribo/primitive/group/from_graph.hh | 17 ++-- scribo/primitive/internal/find_graph_link.hh | 33 ++++--- scribo/primitive/link/with_graph.hh | 32 +++--- scribo/primitive/link/with_rag.hh | 24 +++-- scribo/primitive/link/with_several_graphes.hh | 35 ++++--- scribo/primitive/link/with_several_left_links.hh | 83 ++++++---------- .../link/with_several_right_closest_links.hh | 70 ++++++------- scribo/primitive/link/with_several_right_links.hh | 95 +++++++----------- scribo/primitive/link/with_single_down_link.hh | 30 +++--- scribo/primitive/link/with_single_up_link.hh | 33 +++--- 25 files changed, 532 insertions(+), 559 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 2d5510a..a8bffd2 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,35 @@ 2010-08-09 Guillaume Lazzara <z@lrde.epita.fr> + Replace the use of object_image with component_set. + + * core/erase_objects.hh, + * debug/several_links_decision_image.hh, + * filter/object_groups_size_ratio.hh, + * filter/object_links_bbox_w_ratio.hh, + * filter/object_links_center_aligned.hh, + * filter/object_links_left_aligned.hh, + * filter/object_links_right_aligned.hh, + * filter/objects_h_thick.hh, + * filter/objects_h_thin.hh, + * filter/objects_size_ratio.hh, + * filter/objects_v_thick.hh, + * filter/objects_v_thin.hh, + * primitive/extract/lines_h_thick_and_single.hh, + * primitive/extract/lines_v_thick_and_single.hh, + * primitive/group/from_graph.hh, + * primitive/internal/find_graph_link.hh, + * primitive/link/with_graph.hh, + * primitive/link/with_rag.hh, + * primitive/link/with_several_graphes.hh, + * primitive/link/with_several_left_links.hh, + * primitive/link/with_several_right_closest_links.hh, + * primitive/link/with_several_right_links.hh, + * primitive/link/with_single_down_link.hh, + * primitive/link/with_single_up_link.hh: Replace the use of + object_image with component_set. + +2010-08-09 Guillaume Lazzara <z@lrde.epita.fr> + Small fixes in Scribo. * core/component_info.hh (is_valid): Check the bounding box diff --git a/scribo/core/erase_objects.hh b/scribo/core/erase_objects.hh index 3e401f0..931024e 100644 --- a/scribo/core/erase_objects.hh +++ b/scribo/core/erase_objects.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,7 +29,7 @@ /// \file /// -/// Remove the content of bounding boxes from an image. +/// Erase components in an image. # include <mln/core/concept/image.hh> # include <mln/core/site_set/box.hh> @@ -36,6 +37,7 @@ # include <mln/pw/all.hh> # include <mln/util/array.hh> +# include <scribo/core/component_set.hh> # include <scribo/core/macros.hh> namespace scribo @@ -46,13 +48,12 @@ namespace scribo /// Remove labeled components from a binary image. /// /// \param[in,out] input_ A binary image. - /// \param[in] objects An image of objects (object value must be - /// different from 0). + /// \param[in] comps A set of components to be erased. /// // template <typename I, typename L> void - erase_objects(Image<I>& input, const Image<L>& objects); + erase_objects(Image<I>& input, const component_set<L>& comps); # ifndef MLN_INCLUDE_ONLY @@ -61,18 +62,17 @@ namespace scribo template <typename I, typename L> void erase_objects(Image<I>& input_, - const Image<L>& objects_) + const component_set<L>& comps) { trace::entering("scribo::erase_objects"); mlc_equal(mln_value(I),bool)::check(); I& input = exact(input_); - I& objects = exact(objects_); mln_precondition(input.is_valid()); - mln_precondition(objects.is_valid()); - data::fill((input | (pw::value(objects) != pw::cst(literal::zero))).rw(), + data::fill((input | (pw::value(comps.labeled_image()) + != pw::cst(literal::zero))).rw(), false); trace::exiting("scribo::erase_objects"); diff --git a/scribo/debug/several_links_decision_image.hh b/scribo/debug/several_links_decision_image.hh index 3446287..73e66a1 100644 --- a/scribo/debug/several_links_decision_image.hh +++ b/scribo/debug/several_links_decision_image.hh @@ -94,10 +94,9 @@ namespace scribo trace::entering("scribo::debug::several_links_decision_image"); const I& input = exact(input_); - const object_image(L)& objects = links.object_image_(); + const component_set<L>& comps = links.components(); mln_precondition(input.is_valid()); - mln_precondition(objects.is_valid()); mln_precondition(links.is_valid()); mln_precondition(filtered_links.is_valid()); @@ -106,60 +105,56 @@ namespace scribo image2d<value::rgb8> links_decision_image = data::convert(value::rgb8(), input); - for_all_components(i, objects.bboxes()) - mln::draw::box(links_decision_image, objects.bbox(i), literal::blue); + for_all_comps(c, comps) + mln::draw::box(links_decision_image, comps(c).bbox(), literal::blue); - // Computing mass centers. - mln::util::array<mln_result(accu::center<mln_psite(I)>)> - mass_centers = labeling::compute(accu::meta::center(), - objects, objects.nlabels()); - - for (unsigned i = 1; i < links.size(); ++i) + for_all_links(l, links) { - - if (links[i] != i) + if (links(l) != l) { value::rgb8 value = literal::green; - if (links[i] != filtered_links[i]) + if (links(l) != filtered_links(l)) value = literal::red; - mln_site(L) c = objects.bbox(i).center(); + mln_site(L) c = comps(l).bbox().pcenter(); // Right link from the top anchor. mln_site(L) a1 = c; - a1.row() = objects.bbox(i).pmin().row() - + (c.row() - objects.bbox(i).pmin().row()) / 4; + a1.row() = comps(l).bbox().pmin().row() + + (c.row() - comps(l).bbox().pmin().row()) / 4; // Right link from the central site - mln_site(I) p1 = mass_centers[i]; + mln_site(I) p1 = comps(l).mass_center(); // Right link from the bottom anchor. mln_site(L) a2 = c; - a2.row() = objects.bbox(i).pmax().row() - - (c.row() - objects.bbox(i).pmin().row()) / 4; + a2.row() = comps(l).bbox().pmax().row() + - (c.row() - comps(l).bbox().pmin().row()) / 4; mln_site(L) a1_bak = a1, a2_bak = a2; + const L& lbl_ima = comps.labeled_image(); + mln_site(L) tmp; - while(objects.domain().has(a1) - || objects.domain().has(a2) - || objects.domain().has(p1)) + while(lbl_ima.domain().has(a1) + || lbl_ima.domain().has(a2) + || lbl_ima.domain().has(p1)) { - if (internal::draw_line(objects, links_decision_image, links[i], + if (internal::draw_line(lbl_ima, links_decision_image, links(l), a1_bak, a1, value)) break; else ++a1.col(); - if (internal::draw_line(objects, links_decision_image, links[i], - mass_centers[i], p1, value)) + if (internal::draw_line(lbl_ima, links_decision_image, links(l), + comps(l).mass_center(), p1, value)) break; else ++p1.col(); - if (internal::draw_line(objects, links_decision_image, links[i], + if (internal::draw_line(lbl_ima, links_decision_image, links(l), a2_bak, a2, value)) break; else diff --git a/scribo/filter/object_groups_size_ratio.hh b/scribo/filter/object_groups_size_ratio.hh index 1c05560..94d9b1b 100644 --- a/scribo/filter/object_groups_size_ratio.hh +++ b/scribo/filter/object_groups_size_ratio.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -63,7 +64,7 @@ namespace scribo mln_precondition(groups.is_valid()); - const object_image(L)& objects = groups.object_image_(); + const component_set<L>& comps = groups.components(); // FIXME: estimating the group size should be removed once // available in the object_group structure. @@ -73,9 +74,9 @@ namespace scribo group_size(groups.size(), 0), invalid_object_in_group(groups.size(), 0); - for_all_ncomponents(i, objects.nlabels()) + for_all_comps(i, comps) { - if ((objects.bbox(i).nrows() / objects.bbox(i).ncols()) + if ((comps(i).bbox().nrows() / comps(i).bbox().ncols()) >= max_size_ratio) ++invalid_object_in_group[groups[i]]; @@ -86,7 +87,7 @@ namespace scribo output(0) = 0; for (unsigned i = 1; i < output.size(); ++i) if ((invalid_object_in_group[groups[i]] / static_cast<float>(group_size[groups[i]])) >= max_invalid_ratio_per_group - || !components(i).is_valid()) + || !comps(i).is_valid()) output(i) = 0; trace::exiting("scribo::filter::object_groups_size_ratio"); diff --git a/scribo/filter/object_links_bbox_w_ratio.hh b/scribo/filter/object_links_bbox_w_ratio.hh index 7cc99c3..0bb373f 100644 --- a/scribo/filter/object_links_bbox_w_ratio.hh +++ b/scribo/filter/object_links_bbox_w_ratio.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,8 +29,10 @@ /// \file /// -/// Invalidate links between two objects with too different height or -/// width. +/// Invalidate links between two objects with too different width. +/// +/// \todo rename to object_links_bbox_h_ratio (h for horizontal) to be +/// consistent with other routine names. # include <mln/util/array.hh> @@ -50,7 +53,6 @@ namespace scribo /*! \brief Invalidate links between two objects with too different width. - \param[in] objects An object image. \param[in] links Link objects information. \param[in] min_w_ratio The minimum width ratio of two linked bounding boxes. @@ -59,8 +61,7 @@ namespace scribo */ template <typename L> object_links<L> - object_links_bbox_w_ratio(const object_image(L)& objects, - const object_links<L>& links, + object_links_bbox_w_ratio(const object_links<L>& links, float min_w_ratio); @@ -69,17 +70,15 @@ namespace scribo template <typename L> object_links<L> - object_links_bbox_w_ratio(const object_image(L)& objects, - const object_links<L>& links, + object_links_bbox_w_ratio(const object_links<L>& links, float min_w_ratio) { trace::entering("scribo::filter::object_links_bbox_w_ratio"); - mln_precondition(objects.is_valid()); mln_precondition(links.is_valid()); object_links<L> - output = object_links_bbox_ratio(objects, links, 1, min_w_ratio); + output = object_links_bbox_ratio(links, 1, min_w_ratio); trace::exiting("scribo::filter::object_links_bbox_w_ratio"); return output; diff --git a/scribo/filter/object_links_center_aligned.hh b/scribo/filter/object_links_center_aligned.hh index 8d89e73..da18b00 100644 --- a/scribo/filter/object_links_center_aligned.hh +++ b/scribo/filter/object_links_center_aligned.hh @@ -36,7 +36,6 @@ # include <scribo/core/macros.hh> # include <scribo/core/object_links.hh> -# include <scribo/core/object_image.hh> # include <scribo/filter/object_links_non_aligned_simple.hh> @@ -74,8 +73,7 @@ namespace scribo */ template <typename L> object_links<L> - object_links_center_aligned(const object_image(L)& objects, - const object_links<L>& links, + object_links_center_aligned(const object_links<L>& links, float max_alpha); @@ -84,17 +82,15 @@ namespace scribo template <typename L> object_links<L> - object_links_center_aligned(const object_image(L)& objects, - const object_links<L>& links, + object_links_center_aligned(const object_links<L>& links, float max_alpha) { trace::entering("scribo::filter::object_links_center_aligned"); - mln_precondition(objects.is_valid()); mln_precondition(links.is_valid()); object_links<L> - output = object_links_non_aligned_simple(objects, links, + output = object_links_non_aligned_simple(links, anchor::Center, max_alpha); trace::exiting("scribo::filter::object_links_center_aligned"); diff --git a/scribo/filter/object_links_left_aligned.hh b/scribo/filter/object_links_left_aligned.hh index a352d71..059b423 100644 --- a/scribo/filter/object_links_left_aligned.hh +++ b/scribo/filter/object_links_left_aligned.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -52,7 +53,6 @@ namespace scribo /*! \brief Invalidate links between two objects if their left are not aligned. - \param[in] objects An object image. \param[in] links Object links information. \param[in] max_alpha Maximum angle value (degrees). @@ -82,8 +82,7 @@ namespace scribo */ template <typename L> object_links<L> - object_links_left_aligned(const object_image(L)& objects, - const object_links<L>& links, + object_links_left_aligned(const object_links<L>& links, float max_alpha); @@ -92,17 +91,15 @@ namespace scribo template <typename L> object_links<L> - object_links_left_aligned(const object_image(L)& objects, - const object_links<L>& links, + object_links_left_aligned(const object_links<L>& links, float max_alpha) { trace::entering("scribo::filter::object_links_left_aligned"); - mln_precondition(objects.is_valid()); mln_precondition(links.is_valid()); object_links<L> - output = object_links_non_aligned_simple(objects, links, + output = object_links_non_aligned_simple(links, anchor::Left, max_alpha); diff --git a/scribo/filter/object_links_right_aligned.hh b/scribo/filter/object_links_right_aligned.hh index ee964a3..dfb06c7 100644 --- a/scribo/filter/object_links_right_aligned.hh +++ b/scribo/filter/object_links_right_aligned.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -81,9 +82,8 @@ namespace scribo */ template <typename L> object_links<L> - object_links_right_aligned(const object_image(L)& objects, - const object_links<L>& links, - float max_alpha); + object_links_right_aligned(const object_links<L>& links, + float max_alpha); # ifndef MLN_INCLUDE_ONLY @@ -91,17 +91,15 @@ namespace scribo template <typename L> object_links<L> - object_links_right_aligned(const object_image(L)& objects, - const object_links<L>& links, - float max_alpha) + object_links_right_aligned(const object_links<L>& links, + float max_alpha) { trace::entering("scribo::filter::object_links_right_aligned"); - mln_precondition(objects.is_valid()); mln_precondition(links.is_valid()); object_links<L> - output = object_links_non_aligned_simple(objects, links, + output = object_links_non_aligned_simple(links, anchor::Right, max_alpha); diff --git a/scribo/filter/objects_h_thick.hh b/scribo/filter/objects_h_thick.hh index 9709346..9422798 100644 --- a/scribo/filter/objects_h_thick.hh +++ b/scribo/filter/objects_h_thick.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -33,10 +34,7 @@ # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh> -# include <mln/util/array.hh> - -# include <scribo/core/object_image.hh> -# include <scribo/primitive/extract/objects.hh> +# include <scribo/core/component_set.hh> # include <scribo/filter/internal/compute.hh> @@ -48,12 +46,12 @@ namespace scribo using namespace mln; - /// Remove objects horizontaly thicker or equal to \p max_thickness. + /// Remove objects horizontaly thicker or equal to \p min_thickness. /// /// \param[in] input_ A binary image. /// \param[in] nbh_ A neighborhood used in labeling algorithms. /// \param[in] label_type The label type used for labeling. - /// \param[in] max_thickness The maximum thickness value. + /// \param[in] min_thickness The maximum thickness value. /// /// \result A binary image without thick objects. // @@ -63,21 +61,21 @@ namespace scribo objects_h_thick(const Image<I>& input_, const Neighborhood<N>& nbh_, const V& label_type, - unsigned max_thickness); + unsigned min_thickness); - /// Remove objects horizontaly thicker or equal to \p max_thickness. + /// Remove objects horizontaly thicker or equal to \p min_thickness. /// - /// \param[in] objects An object image. - /// \param[in] max_thickness The maximum thickness value. + /// \param[in] comps Component data. + /// \param[in] min_thickness The minimum thickness value. /// - /// \result An object image without too thick objects. + /// \result A component data set without too thick components. // template <typename L> inline - object_image(L) - objects_h_thick(const object_image(L)& objects, - unsigned max_thickness); + component_set<L> + objects_h_thick(const component_set<L>& comps, + unsigned min_thickness); @@ -87,8 +85,8 @@ namespace scribo namespace internal { - /// Filter Functor. Return false for all objects which are too - /// large. + /// Filter Functor. Return false for all components which are + /// thick. template <typename L> struct h_thick_object_filter : Function_v2b< h_thick_object_filter<L> > @@ -96,48 +94,48 @@ namespace scribo /// Constructor /// - /// \param[in] objects An object image. - /// \param[in] max_thickness the maximum thickness allowed. + /// \param[in] comps Component data. + /// \param[in] min_thickness the minimum thickness allowed. // - h_thick_object_filter(const object_image(L)& objects, - unsigned max_thickness) - : objects_(objects), max_thickness_(max_thickness) + h_thick_object_filter(const component_set<L>& comps, + unsigned min_thickness) + : comps_(comps), min_thickness_(min_thickness) { } /// Constructor /// - /// \param[in] max_thickness the maximum thickness allowed. + /// \param[in] min_thickness the minimum thickness allowed. // - h_thick_object_filter(unsigned max_thickness) - : max_thickness_(max_thickness) + h_thick_object_filter(unsigned min_thickness) + : min_thickness_(min_thickness) { } /// Set the underlying object image. // - void update_objects(const object_image(L)& objects) + void update_objects(const component_set<L>& comps) { - objects_ = objects; + comps_ = comps; } - /// Return false if the objects is thicker than - /// \p max_thickness_. + /// Return false if the component is thicker than + /// \p min_thickness_. /// /// \param[in] l An image value. bool operator()(const mln_value(L)& l) const { if (l == literal::zero) return true; - return objects_.bbox(l).nrows() < max_thickness_; + return comps_(l).bbox().height() > min_thickness_; } - /// An object image. - object_image(L) objects_; + /// Components data. + component_set<L> comps_; - /// The maximum thickness. - unsigned max_thickness_; + /// The minimum thickness. + unsigned min_thickness_; }; @@ -150,7 +148,7 @@ namespace scribo objects_thick(const Image<I>& input_, const Neighborhood<N>& nbh_, const V& label_type, - unsigned max_thickness) + unsigned min_thickness) { trace::entering("scribo::filter::objects_h_thick"); @@ -160,7 +158,7 @@ namespace scribo mln_precondition(input.is_valid()); mln_precondition(nbh.is_valid()); - internal::h_thick_object_filter<V> functor(max_thickness); + internal::h_thick_object_filter<V> functor(min_thickness); mln_concrete(I) output = internal::compute(input, nbh, label_type, functor); @@ -171,16 +169,14 @@ namespace scribo template <typename L> inline - object_image(L) - objects_h_thick(const object_image(L)& objects, - unsigned max_thickness) + component_set<L> + objects_h_thick(const component_set<L>& comps, + unsigned min_thickness) { trace::entering("scribo::filter::objects_h_thick"); - mln_precondition(objects.is_valid()); - - internal::h_thick_object_filter<L> functor(objects, max_thickness); - object_image(L) output = internal::compute(objects, functor); + internal::h_thick_object_filter<L> functor(comps, min_thickness); + component_set<L> output = internal::compute(comps, functor); trace::exiting("scribo::filter::objects_h_thick"); return output; diff --git a/scribo/filter/objects_h_thin.hh b/scribo/filter/objects_h_thin.hh index 2b098ac..56c6ab7 100644 --- a/scribo/filter/objects_h_thin.hh +++ b/scribo/filter/objects_h_thin.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,15 +29,13 @@ /// \file /// -/// Remove too thin objects. +/// Remove too thin components. # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh> -# include <mln/util/array.hh> - -# include <scribo/core/object_image.hh> -# include <scribo/primitive/extract/objects.hh> +# include <scribo/core/component_set.hh> +# include <scribo/filter/internal/compute.hh> namespace scribo { @@ -46,14 +45,14 @@ namespace scribo using namespace mln; - /// Remove objects thinner or equal to \p min_thickness. + /// Remove components thinner or equal to \p min_thinness. /// /// \param[in] input_ a binary image. /// \param[in] nbh_ a neighborhood used in labeling algorithms. /// \param[in] label_type the label type used for labeling. - /// \param[in] min_thickness the minimum thickness value. + /// \param[in] min_thinness the minimum thinness value. /// - /// \result A binary image without h_thin objects. + /// \result A binary image without h_thin components. // template <typename I, typename N, typename V> inline @@ -61,20 +60,20 @@ namespace scribo objects_h_thin(const Image<I>& input_, const Neighborhood<N>& nbh_, const V& label_type, - unsigned min_thickness); + unsigned min_thinness); - /// Remove lines of text thinner or equal to \p min_thickness. + /// Remove lines of text thinner or equal to \p min_thinness. /// - /// \param[in] objects An object image. - /// \param[in] min_thickness the minimum thickness value. + /// \param[in] comps A component set. + /// \param[in] min_thinness the minimum thinness value. /// - /// \result An object image without too thin vertical objects. + /// \result An object image without too thin vertical components. // template <typename L> inline - object_image(L) - objects_h_thin(const object_image(L)& text, - unsigned min_thickness); + component_set<L> + objects_h_thin(const component_set<L>& comps, + unsigned min_thinness); # ifndef MLN_INCLUDE_ONLY @@ -84,7 +83,7 @@ namespace scribo /// Filter Functor. - /// Return false for all objects which are too large. + /// Return false for all components which are too large. template <typename L> struct objects_h_thin_filter : Function_v2b< objects_h_thin_filter<L> > @@ -93,19 +92,36 @@ namespace scribo /// Constructor /// - /// \param[in] objects object bounding boxes. - /// \param[in] min_thickness the minimum of vertical thickness + /// \param[in] comps A component set. + /// \param[in] min_thinness the minimum of vertical thinness /// allowed. // - objects_h_thin_filter(const object_image(L)& objects, - unsigned min_thickness) - : objects_(objects), min_thickness_(min_thickness) + objects_h_thin_filter(const component_set<L>& comps, + unsigned min_thinness) + : comps_(comps), min_thinness_(min_thinness) + { + } + + + /// Constructor + /// + /// \param[in] min_thinness the maximum thinness allowed. + // + objects_h_thin_filter(unsigned min_thinness) + : min_thinness_(min_thinness) { } + /// Set the underlying component set. + // + void update_objects(const component_set<L>& comps) + { + comps_ = comps; + } - /// Return false if the objects is thinner than - /// \p min_thickness_. + + /// Return false if the components is thinner than + /// \p min_thinness_. /// /// \param[in] l An image value. // @@ -113,14 +129,14 @@ namespace scribo { if (l == literal::zero) return true; - return objects_.bbox(l).ncols() > min_thickness_; + return comps_(l).bbox().ncols() > min_thinness_; } /// Component bounding boxes. - object_image(L) objects_; + component_set<L> comps_; - /// The minimum vertical thickness. - unsigned min_thickness_; + /// The minimum vertical thinness. + unsigned min_thinness_; }; @@ -133,7 +149,7 @@ namespace scribo objects_h_thin(const Image<I>& input_, const Neighborhood<N>& nbh_, const V& label_type, - unsigned min_thickness) + unsigned min_thinness) { trace::entering("scribo::filter::objects_h_thin"); @@ -143,18 +159,10 @@ namespace scribo mln_precondition(input.is_valid()); mln_precondition(nbh.is_valid()); - V nlabels; - typedef mln_ch_value(I,V) lbl_t; - object_image(lbl_t) objects - = primitive::extract::objects(input, nbh, nlabels); - - typedef internal::objects_h_thin_filter<lbl_t> func_t; - func_t fv2b(objects, min_thickness); - objects.relabel(fv2b); + internal::objects_h_thin_filter<V> functor(min_thinness); + mln_concrete(I) + output = internal::compute(input, nbh, label_type, functor); - mln_concrete(I) output = duplicate(input); - data::fill((output | pw::value(objects) == pw::cst(literal::zero)).rw(), - false); trace::exiting("scribo::filter::objects_h_thin"); return output; @@ -163,20 +171,16 @@ namespace scribo template <typename L> inline - object_image(L) - objects_h_thin(const object_image(L)& objects, - unsigned min_thickness) + component_set<L> + objects_h_thin(const component_set<L>& comps, + unsigned min_thinness) { trace::entering("scribo::filter::objects_h_thin"); - mln_precondition(objects.is_valid()); - - typedef internal::objects_h_thin_filter<L> func_t; - func_t is_not_too_h_thin(objects, min_thickness); + internal::objects_h_thin_filter<L> + is_not_too_h_thin(comps, min_thinness); - object_image(L) output; - output.init_from_(objects); - output.relabel(is_not_too_h_thin); + component_set<L> output = internal::compute(comps, is_not_too_h_thin); trace::exiting("scribo::filter::objects_h_thin"); return output; diff --git a/scribo/filter/objects_size_ratio.hh b/scribo/filter/objects_size_ratio.hh index cd12b2e..55de80d 100644 --- a/scribo/filter/objects_size_ratio.hh +++ b/scribo/filter/objects_size_ratio.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,11 +29,11 @@ /// \file /// -/// +/// \brief Invalidate components with a width/height ratio too low. # include <mln/core/concept/function.hh> -# include <scribo/core/object_image.hh> +# include <scribo/core/component_set.hh> namespace scribo @@ -42,10 +43,18 @@ namespace scribo { using namespace mln; + /// \brief Invalidate components with a height/width ratio too low. + /// + /// Compute the ratio height/width from the component bounding + /// boxes and compare it to \p size_ratio. + /// + /// If the height/width ratio is lower than min_size_ratio then + /// the component is invalidated. + // template <typename L> - object_image(L) - objects_size_ratio(const object_image(L)& objects, - float size_ratio); + component_set<L> + objects_size_ratio(const component_set<L>& comps, + float min_size_ratio); # ifndef MLN_INCLUDE_ONLY @@ -56,16 +65,15 @@ namespace scribo /// Filter Functor. - /// Return false for all objects which have a bad ratio. + /// Return false for all components having a too low size ratio. + // template <typename L> - struct objects_size_ratio_filter - : Function_v2b< objects_size_ratio_filter<L> > + struct components_size_ratio_filter + : Function_v2b< components_size_ratio_filter<L> > { - typedef accu::shape::bbox<mln_psite(L)> box_accu_t; - - objects_size_ratio_filter(const object_image(L)& objects, - float ratio) - : objects_(objects), ratio_(ratio) + components_size_ratio_filter(const component_set<L>& comps, + float min_size_ratio) + : comps_(comps), min_size_ratio_(min_size_ratio) { } @@ -73,14 +81,14 @@ namespace scribo { if (l == literal::zero) return true; - return (objects_.bbox(l).nrows() / static_cast<float>(objects_.bbox(l).ncols())) < ratio_; + return (comps_(l).bbox().height() / static_cast<float>(comps_(l).bbox().width())) >= min_size_ratio_; } - /// Component bounding boxes. - object_image(L) objects_; + /// Components data. + component_set<L> comps_; - /// The maximum size ratio. - float ratio_; + /// The minimum size ratio. + float min_size_ratio_; }; @@ -89,21 +97,18 @@ namespace scribo template <typename L> - object_image(L) - objects_size_ratio(const object_image(L)& objects, - float size_ratio) + component_set<L> + objects_size_ratio(const component_set<L>& comps, + float min_size_ratio) { trace::entering("scribo::primitive::objects_size_ratio"); - mln_precondition(objects.is_valid()); - - typedef internal::objects_size_ratio_filter<L> func_t; - func_t has_bad_ratio(objects, size_ratio); + typedef internal::components_size_ratio_filter<L> func_t; + func_t has_valid_size_ratio(comps, min_size_ratio); - object_image(L) output; - output.init_from_(objects); - output.relabel(has_bad_ratio); + component_set<L> output = comps.duplicate(); + output.update_tags(has_valid_size_ratio, component::Ignored); trace::exiting("scribo::primitive::objects_size_ratio"); return output; @@ -117,4 +122,4 @@ namespace scribo } // end of namespace scribo -#endif // ! SCRIBO_FILTER_OBJECTs_SIZE_RATIO_HH +#endif // ! SCRIBO_FILTER_OBJECTS_SIZE_RATIO_HH diff --git a/scribo/filter/objects_v_thick.hh b/scribo/filter/objects_v_thick.hh index 730e144..7b25d87 100644 --- a/scribo/filter/objects_v_thick.hh +++ b/scribo/filter/objects_v_thick.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,15 +29,12 @@ /// \file /// -/// Remove too verticaly thick objects. +/// Remove too verticaly thick components. # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh> -# include <mln/util/array.hh> - -# include <scribo/core/object_image.hh> -# include <scribo/primitive/extract/objects.hh> +# include <scribo/core/component_set.hh> # include <scribo/filter/internal/compute.hh> @@ -48,14 +46,14 @@ namespace scribo using namespace mln; - /// Remove objects verticaly thicker or equal to \p max_thickness. + /// Remove components verticaly thicker or equal to \p min_thickness. /// /// \param[in] input_ A binary image. /// \param[in] nbh_ A neighborhood used in labeling algorithms. /// \param[in] label_type The label type used for labeling. - /// \param[in] max_thickness The maximum thickness value. + /// \param[in] min_thickness The maximum thickness value. /// - /// \result A binary image without thick objects. + /// \result A binary image without thick components. // template <typename I, typename N, typename V> inline @@ -63,21 +61,21 @@ namespace scribo objects_v_thick(const Image<I>& input_, const Neighborhood<N>& nbh_, const V& label_type, - unsigned max_thickness); + unsigned min_thickness); - /// Remove objects verticaly thicker or equal to \p max_thickness. + /// Remove components verticaly thicker or equal to \p min_thickness. /// - /// \param[in] objects An object image. - /// \param[in] max_thickness The maximum thickness value. + /// \param[in] comps A component set. + /// \param[in] min_thickness The maximum thickness value. /// - /// \result An object image without too thick objects. + /// \result An object image without too thick components. // template <typename L> inline - object_image(L) - objects_v_thick(const object_image(L)& objects, - unsigned max_thickness); + component_set<L> + objects_v_thick(const component_set<L>& comps, + unsigned min_thickness); @@ -87,7 +85,7 @@ namespace scribo namespace internal { - /// Filter Functor. Return false for all objects which are too + /// Filter Functor. Return false for all components which are too /// large. template <typename L> struct v_thick_object_filter @@ -96,48 +94,48 @@ namespace scribo /// Constructor /// - /// \param[in] objects An object image. - /// \param[in] max_thickness the maximum thickness allowed. + /// \param[in] comps A component set. + /// \param[in] min_thickness the maximum thickness allowed. // - v_thick_object_filter(const object_image(L)& objects, - unsigned max_thickness) - : objects_(objects), max_thickness_(max_thickness) + v_thick_object_filter(const component_set<L>& comps, + unsigned min_thickness) + : comps_(comps), min_thickness_(min_thickness) { } /// Constructor /// - /// \param[in] max_thickness the maximum thickness allowed. + /// \param[in] min_thickness the maximum thickness allowed. // - v_thick_object_filter(unsigned max_thickness) - : max_thickness_(max_thickness) + v_thick_object_filter(unsigned min_thickness) + : min_thickness_(min_thickness) { } - /// Set the underlying object image. + /// Set the underlying component set. // - void update_objects(const object_image(L)& objects) + void update_objects(const component_set<L>& comps) { - objects_ = objects; + comps_ = comps; } - /// Return false if the objects is thicker than - /// \p max_thickness_. + /// Return false if the components is thicker than + /// \p min_thickness_. /// /// \param[in] l An image value. bool operator()(const mln_value(L)& l) const { if (l == literal::zero) return true; - return objects_.bbox(l).nrows() < max_thickness_; + return comps_(l).bbox().nrows() > min_thickness_; } - /// An object image. - object_image(L) objects_; + /// A component set. + component_set<L> comps_; - /// The maximum thickness. - unsigned max_thickness_; + /// The min thickness. + unsigned min_thickness_; }; @@ -150,7 +148,7 @@ namespace scribo objects_thick(const Image<I>& input_, const Neighborhood<N>& nbh_, const V& label_type, - unsigned max_thickness) + unsigned min_thickness) { trace::entering("scribo::filter::objects_v_thick"); @@ -160,7 +158,7 @@ namespace scribo mln_precondition(input.is_valid()); mln_precondition(nbh.is_valid()); - internal::v_thick_object_filter<V> functor(max_thickness); + internal::v_thick_object_filter<V> functor(min_thickness); mln_concrete(I) output = internal::compute(input, nbh, label_type, functor); @@ -171,16 +169,14 @@ namespace scribo template <typename L> inline - object_image(L) - objects_v_thick(const object_image(L)& objects, - unsigned max_thickness) + component_set<L> + objects_v_thick(const component_set<L>& comps, + unsigned min_thickness) { trace::entering("scribo::filter::objects_v_thick"); - mln_precondition(objects.is_valid()); - - internal::v_thick_object_filter<L> functor(objects, max_thickness); - object_image(L) output = internal::compute(objects, functor); + internal::v_thick_object_filter<L> functor(comps, min_thickness); + component_set<L> output = internal::compute(comps, functor); trace::exiting("scribo::filter::objects_v_thick"); return output; diff --git a/scribo/filter/objects_v_thin.hh b/scribo/filter/objects_v_thin.hh index 6564d30..52e10af 100644 --- a/scribo/filter/objects_v_thin.hh +++ b/scribo/filter/objects_v_thin.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,15 +29,14 @@ /// \file /// -/// Remove too thin objects. +/// Remove too thin components. # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh> -# include <mln/util/array.hh> +# include <scribo/core/component_set.hh> +# include <scribo/filter/internal/compute.hh> -# include <scribo/core/object_image.hh> -# include <scribo/primitive/extract/objects.hh> namespace scribo { @@ -46,14 +46,14 @@ namespace scribo using namespace mln; - /// Remove objects thinner or equal to \p min_thickness. + /// Remove components thinner or equal to \p min_thinness. /// /// \param[in] input_ a binary image. /// \param[in] nbh_ a neighborhood used in labeling algorithms. /// \param[in] label_type the label type used for labeling. - /// \param[in] min_thickness the minimum thickness value. + /// \param[in] min_thinness the minimum thinness value. /// - /// \result A binary image without v_thin objects. + /// \result A binary image without v_thin components. // template <typename I, typename N, typename V> inline @@ -61,20 +61,20 @@ namespace scribo objects_v_thin(const Image<I>& input_, const Neighborhood<N>& nbh_, const V& label_type, - unsigned min_thickness); + unsigned min_thinness); - /// Remove lines of text thinner or equal to \p min_thickness. + /// Remove lines of text thinner or equal to \p min_thinness. /// - /// \param[in] objects An object image. - /// \param[in] min_thickness the minimum thickness value. + /// \param[in] comps A component set. + /// \param[in] min_thinness the minimum thinness value. /// - /// \result An object image without too thin vertical objects. + /// \result An object image without too thin vertical components. // template <typename L> inline - object_image(L) - objects_v_thin(const object_image(L)& text, - unsigned min_thickness); + component_set<L> + components_v_thin(const component_set<L>& text, + unsigned min_thinness); # ifndef MLN_INCLUDE_ONLY @@ -93,19 +93,36 @@ namespace scribo /// Constructor /// - /// \param[in] objects object bounding boxes. - /// \param[in] min_thickness the minimum of vertical thickness + /// \param[in] comps A component set. + /// \param[in] min_thinness the minimum of vertical thinness /// allowed. // - objects_v_thin_filter(const object_image(L)& objects, - unsigned min_thickness) - : objects_(objects), min_thickness_(min_thickness) + objects_v_thin_filter(const component_set<L>& comps, + unsigned min_thinness) + : comps_(comps), min_thinness_(min_thinness) { } - /// Return false if the objects is thinner than - /// \p min_thickness_. + /// Constructor + /// + /// \param[in] min_thinness the maximum thinness allowed. + // + objects_v_thin_filter(unsigned min_thinness) + : min_thinness_(min_thinness) + { + } + + /// Set the underlying component set. + // + void update_objects(const component_set<L>& comps) + { + comps_ = comps; + } + + + /// Return false if the components is thinner than + /// \p min_thinness_. /// /// \param[in] l An image value. // @@ -113,14 +130,14 @@ namespace scribo { if (l == literal::zero) return true; - return objects_.bbox(l).nrows() > min_thickness_; + return comps_.bbox(l).nrows() > min_thinness_; } /// Component bounding boxes. - object_image(L) objects_; + component_set<L> comps_; - /// The minimum vertical thickness. - unsigned min_thickness_; + /// The minimum vertical thinness. + unsigned min_thinness_; }; @@ -133,7 +150,7 @@ namespace scribo objects_v_thin(const Image<I>& input_, const Neighborhood<N>& nbh_, const V& label_type, - unsigned min_thickness) + unsigned min_thinness) { trace::entering("scribo::filter::objects_v_thin"); @@ -144,18 +161,9 @@ namespace scribo mln_precondition(input.is_valid()); mln_precondition(nbh.is_valid()); - V nlabels; - typedef mln_ch_value(I,V) lbl_t; - object_image(lbl_t) objects - = primitive::extract::objects(input, nbh, nlabels); - - typedef internal::objects_v_thin_filter<lbl_t> func_t; - func_t fv2b(objects, min_thickness); - objects.relabel(fv2b); - - mln_concrete(I) output = duplicate(input); - data::fill((output | (pw::value(objects) == pw::cst(literal::zero))).rw(), - false); + internal::objects_v_thin_filter<V> fv2b(min_thinness); + mln_concrete(I) + output = internal::compute(input, nbh, label_type, fv2b); trace::exiting("scribo::filter::objects_v_thin"); return output; @@ -164,20 +172,15 @@ namespace scribo template <typename L> inline - object_image(L) - objects_v_thin(const object_image(L)& objects, - unsigned min_thickness) + component_set<L> + objects_v_thin(const component_set<L>& comps, + unsigned min_thinness) { trace::entering("scribo::filter::objects_v_thin"); - mln_precondition(objects.is_valid()); - - typedef internal::objects_v_thin_filter<L> func_t; - func_t is_not_too_v_thin(objects, min_thickness); - - object_image(L) output; - output.init_from_(objects); - output.relabel(is_not_too_v_thin); + internal::objects_v_thin_filter<L> + is_not_too_v_thin(comps, min_thinness); + component_set<L> output = internal::compute(comps, is_not_too_v_thin); trace::exiting("scribo::filter::objects_v_thin"); return output; diff --git a/scribo/primitive/extract/lines_h_thick_and_single.hh b/scribo/primitive/extract/lines_h_thick_and_single.hh index 3b3185b..551e5d8 100644 --- a/scribo/primitive/extract/lines_h_thick_and_single.hh +++ b/scribo/primitive/extract/lines_h_thick_and_single.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -39,7 +40,6 @@ # include <scribo/core/object_image.hh> # include <scribo/core/macros.hh> -# include <scribo/primitive/extract/objects.hh> # include <scribo/primitive/extract/lines_h_thick.hh> # include <scribo/primitive/extract/lines_h_single.hh> @@ -59,8 +59,9 @@ namespace scribo /// Extract horizontal thick lines in a binary image. /*! - * Only non discontinued lines are correctly extracted with this routine. - * Only lines matching the given criterions are kept in the result. + * Only non discontinued lines are correctly extracted with this + * routine. Only lines matching the given criterions are kept + * in the result. * * \param[in] input_ A binary image. * \param[in] nbh_ The neighborhood used for labeling image @@ -74,7 +75,7 @@ namespace scribo * \return An image in which lines are labeled. */ template <typename I, typename N, typename V> - object_image(mln_ch_value(I,V)) + component_set<mln_ch_value(I,V)> lines_h_thick_and_single(const Image<I>& input_, const Neighborhood<N>& nbh_, V& nlines, @@ -117,7 +118,7 @@ namespace scribo template <typename I, typename N, typename V> inline - object_image(mln_ch_value(I,V)) + component_set<mln_ch_value(I,V)> lines_h_thick_and_single(const Image<I>& input, const Neighborhood<N>& nbh, V& nlines, @@ -130,8 +131,7 @@ namespace scribo nlines, min_line_length, h_w_ratio); - - object_image(mln_ch_value(I,V)) + component_set<mln_ch_value(I,V)> output = lines_h_thick(input, nbh, nlines, min_line_length); output = lines_h_single(output, min_line_length, h_w_ratio); diff --git a/scribo/primitive/extract/lines_v_thick_and_single.hh b/scribo/primitive/extract/lines_v_thick_and_single.hh index eba25ab..c19ba5a 100644 --- a/scribo/primitive/extract/lines_v_thick_and_single.hh +++ b/scribo/primitive/extract/lines_v_thick_and_single.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -39,7 +40,6 @@ # include <scribo/core/object_image.hh> # include <scribo/core/macros.hh> -# include <scribo/primitive/extract/objects.hh> # include <scribo/primitive/extract/lines_v_thick.hh> # include <scribo/primitive/extract/lines_v_single.hh> @@ -58,8 +58,9 @@ namespace scribo /// Extract vertical thick lines in a binary image. /*! - * Only non discontinued lines are correctly extracted with this routine. - * Only lines matching the given criterions are kept in the result. + * Only non discontinued lines are correctly extracted with this + * routine. Only lines matching the given criterions are kept + * in the result. * * \param[in] input_ A binary image. * \param[in] nbh_ The neighborhood used for labeling image @@ -73,7 +74,7 @@ namespace scribo * \return An image in which lines are labeled. */ template <typename I, typename N, typename V> - object_image(mln_ch_value(I,V)) + component_set<mln_ch_value(I,V)> lines_v_thick_and_single(const Image<I>& input_, const Neighborhood<N>& nbh_, V& nlines, @@ -116,7 +117,7 @@ namespace scribo template <typename I, typename N, typename V> inline - object_image(mln_ch_value(I,V)) + component_set<mln_ch_value(I,V)> lines_v_thick_and_single(const Image<I>& input, const Neighborhood<N>& nbh, V& nlines, @@ -129,7 +130,7 @@ namespace scribo nlines, min_line_length, h_w_ratio); - object_image(mln_ch_value(I,V)) + component_set<mln_ch_value(I,V)> output = lines_v_thick(input, nbh, nlines, min_line_length); output = lines_v_single(output, min_line_length, h_w_ratio); diff --git a/scribo/primitive/group/from_graph.hh b/scribo/primitive/group/from_graph.hh index 602be90..37a5718 100644 --- a/scribo/primitive/group/from_graph.hh +++ b/scribo/primitive/group/from_graph.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -64,14 +65,14 @@ namespace scribo /// Group objects according to a graph of links /// - /// \param[in] objects An object image. + /// \param[in] comps A component set. /// \param[in] g_ The graph of object links. /// /// \return Object groups information. // template <typename L, typename G> object_groups<L> - from_graph(const object_image(L)& objects, + from_graph(const component_set<L>& comps, const Graph<G>& g_); @@ -87,8 +88,8 @@ namespace scribo struct map_vertex_to_representative_id_functor { - map_vertex_to_representative_id_functor(const object_image(L)& objects) - : vertextorep(objects) + map_vertex_to_representative_id_functor(const component_set<L>& comps) + : vertextorep(comps) { } @@ -148,7 +149,7 @@ namespace scribo template <typename L, typename G> inline object_groups<L> - from_graph(const object_image(L)& objects, + from_graph(const component_set<L>& comps, const Graph<G>& g_) { trace::entering("scribo::primitive::group::from_graph"); @@ -157,10 +158,10 @@ namespace scribo mln_assertion(g.is_valid()); - internal::map_vertex_to_representative_id_functor<L> f(objects); + internal::map_vertex_to_representative_id_functor<L> f(comps); canvas::browsing::depth_first_search(g, f); - object_groups<L> groups(objects); + object_groups<L> groups(comps); groups.init_(f.vertextorep); trace::exiting("scribo::primitive::group::from_graph"); diff --git a/scribo/primitive/internal/find_graph_link.hh b/scribo/primitive/internal/find_graph_link.hh index f5a1039..7176153 100644 --- a/scribo/primitive/internal/find_graph_link.hh +++ b/scribo/primitive/internal/find_graph_link.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,19 +29,22 @@ /// \file /// -/// Find the right neighbor of a line of text if exists. +/// Find the right neighbor of a component if exists. # include <mln/core/concept/image.hh> # include <mln/core/concept/graph.hh> +//FIXME: not generic. +# include <mln/core/alias/dpoint2d.hh> + # include <mln/math/abs.hh> # include <mln/util/array.hh> -# include <scribo/primitive/internal/update_graph_link.hh> -//FIXME: not generic. -# include <mln/core/alias/dpoint2d.hh> +# include <scribo/core/component_set.hh> + +# include <scribo/primitive/internal/update_graph_link.hh> namespace scribo @@ -52,10 +56,10 @@ namespace scribo namespace internal { - /// Find a neighbor of a text line in a specific range if it exists. + /// Find a neighbor of a component in a specific range if it exists. /// /// \param g_ The link graph. - /// \param text The lines of text. + /// \param comps A component set. /// \param current_comp The current line being processed. /// \param dmax The maximum lookup distance. /// \param c Start point of the neighbor lookup. @@ -63,7 +67,7 @@ namespace scribo template <typename G, typename L> void find_graph_link(Graph<G>& g_, - const object_image(L)& text, + const component_set<L>& comps, unsigned current_comp, int dmax, const mln_site(L)& c); @@ -73,7 +77,7 @@ namespace scribo template <typename G, typename L> void find_graph_link(Graph<G>& g_, - const object_image(L)& text, + const component_set<L>& comps, unsigned current_comp, int dmax, const mln_site(L)& c) @@ -82,18 +86,19 @@ namespace scribo G& g = exact(g_); mln_precondition(g.is_valid()); - mln_precondition(text.is_valid()); ///FIXME: the following code is not generic... /// First site on the right of the central site mln_site(L) p = c + right; - while (text.domain().has(p) && (text(p) == literal::zero - || text(p) == current_comp) + const L& lbl = comps.labeled_image(); + + while (comps.domain().has(p) && (lbl(p) == literal::zero + || lbl(p) == current_comp) && math::abs(p.col() - c.col()) < dmax) ++p.col(); - update_graph_link(text, g, p, c, current_comp, dmax); + update_graph_link(comps, g, p, c, current_comp, dmax); trace::exiting("scribo::primitive::internal::find_graph_link"); } @@ -102,7 +107,7 @@ namespace scribo } // end of namespace scribo::primitive::internal - } // end of namespace scribo::text + } // end of namespace scribo::primitive } // end of namespace scribo diff --git a/scribo/primitive/link/with_graph.hh b/scribo/primitive/link/with_graph.hh index 2d579aa..efe4721 100644 --- a/scribo/primitive/link/with_graph.hh +++ b/scribo/primitive/link/with_graph.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -42,6 +43,7 @@ # include <mln/util/graph.hh> # include <scribo/core/macros.hh> +# include <scribo/core/component_set.hh> # include <scribo/primitive/internal/find_graph_link.hh> @@ -55,12 +57,14 @@ namespace scribo namespace link { + using namespace mln; + /*! Construct the links between each line of text and store it as a graph. Look up for neighbors on the right of each box. - \param[in] objects An object image. + \param[in] comps A component set. \param[in] neighb_max_distance The maximum distance allowed to look for a neighbor. @@ -68,8 +72,8 @@ namespace scribo */ template <typename L> mln::util::graph - with_graph(const object_image(L)& objects, - unsigned neighb_max_distance); + with_graph(const component_set<L>& comps, + unsigned neighb_max_distance); # ifndef MLN_INCLUDE_ONLY @@ -77,32 +81,26 @@ namespace scribo template <typename L> inline mln::util::graph - with_graph(const object_image(L)& objects, + with_graph(const component_set<L>& comps, unsigned neighb_max_distance) { trace::entering("scribo::primitive::link::with_graph"); - mln_precondition(objects.is_valid()); - - mln::util::graph g(objects.nlabels().next()); + mln::util::graph g(comps.nelements().next()); - for_all_ncomponents(i, objects.nlabels()) + for_all_comps(i, comps) { - unsigned midcol = (objects.bbox(i).pmax().col() - - objects.bbox(i).pmin().col()) / 2; + unsigned midcol = (comps(i).bbox().pmax().col() + - comps(i).bbox().pmin().col()) / 2; int dmax = midcol + neighb_max_distance; - mln::util::array<mln_result(accu::center<mln_psite(L)>)> - mass_center = labeling::compute(accu::meta::center(), - objects, - objects.nlabels()); - // ------- // | | // | X-------> // | | // ------- - internal::find_graph_link(g, objects, i, dmax, mass_center[i]); + internal::find_graph_link(g, comps, i, dmax, + comps(i).mass_center()); } trace::exiting("scribo::primitive::link::with_graph"); diff --git a/scribo/primitive/link/with_rag.hh b/scribo/primitive/link/with_rag.hh index 3638ec7..e66d87e 100644 --- a/scribo/primitive/link/with_rag.hh +++ b/scribo/primitive/link/with_rag.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -29,7 +30,7 @@ /// \file /// -/// Link objects with a region adjacency graph. +/// Link components with a region adjacency graph. # include <mln/core/concept/neighborhood.hh> @@ -42,7 +43,7 @@ # include <scribo/core/macros.hh> -# include <scribo/core/object_image.hh> +# include <scribo/core/component_set.hh> namespace scribo @@ -57,10 +58,12 @@ namespace scribo using namespace mln; + /// \brief Link components with a region adjacency graph. + // template <typename L, typename N> util::couple<mln::util::graph, mln_concrete(L)> - with_rag(const object_image(L)& objects, - const Neighborhood<N>& nbh); + with_rag(const component_set<L>& comps, + const Neighborhood<N>& nbh); # ifndef MLN_INCLUDE_ONLY @@ -68,20 +71,21 @@ namespace scribo template <typename L, typename N> util::couple<mln::util::graph, mln_concrete(L)> - with_rag(const object_image(L)& objects, - const Neighborhood<N>& nbh) + with_rag(const component_set<L>& comps, + const Neighborhood<N>& nbh) { trace::entering("scribo::primitive::link::with_rag"); - mln_precondition(objects.is_valid()); + mln_precondition(comps.is_valid()); mln_concrete(L) - iz = transform::influence_zone_geodesic(objects, nbh); + iz = transform::influence_zone_geodesic(comps.labeled_image(), + nbh); mln::util::graph g = mln::make::influence_zone_adjacency_graph(iz, nbh, - objects.nlabels()); + comps.nelements()); trace::exiting("scribo::primitive::link::with_rag"); return make::couple(g, iz); diff --git a/scribo/primitive/link/with_several_graphes.hh b/scribo/primitive/link/with_several_graphes.hh index 98d631e..acfccbc 100644 --- a/scribo/primitive/link/with_several_graphes.hh +++ b/scribo/primitive/link/with_several_graphes.hh @@ -39,7 +39,9 @@ # include <mln/util/array.hh> # include <mln/util/graph.hh> + # include <scribo/core/macros.hh> +# include <scribo/core/component_set.hh> # include <scribo/primitive/internal/find_graph_link.hh> namespace scribo @@ -51,11 +53,13 @@ namespace scribo namespace link { + using namespace mln; + /// Link character bounding boxes with several graphes. /// Look up for neighbors on the left of each box. template <typename L> mln::util::graph - with_several_graphes(const object_image(L)& objects, + with_several_graphes(const component_set<L>& comps, unsigned neighb_max_distance); # ifndef MLN_INCLUDE_ONLY @@ -63,25 +67,20 @@ namespace scribo template <typename L> inline mln::util::graph - with_several_graphes(const object_image(L)& objects, + with_several_graphes(const component_set<L>& comps, unsigned neighb_max_distance) { trace::entering("scribo::primitive::link::with_several_graphes"); - mln::util::graph g(objects.nlabels().next()); + mln::util::graph g(comps.nelements().next()); - for_all_ncomponents(i, objects.nlabels()) + for_all_comps(i, comps) { - unsigned midcol = (objects.bbox(i).pmax().col() - - objects.bbox(i).pmin().col()) / 2; + unsigned midcol = (comps(i).bbox().pmax().col() + - comps(i).bbox().pmin().col()) / 2; int dmax = midcol + neighb_max_distance; - mln::util::array<mln_result(accu::center<mln_psite(L)>)> - mass_center = labeling::compute(accu::meta::center(), - objects, - objects.nlabels()); - - mln_site(L) c = mass_center(i); + mln_site(L) c = comps(i).mass_center(); // ------- // | X-------> @@ -98,16 +97,18 @@ namespace scribo /// Left link from the top anchor. mln_site(L) a1 = c; - a1.row() = objects.bbox(i).pmin().row() + (c.row() - objects.bbox(i).pmin().row()) / 4; - internal::find_graph_link(g, objects, i, dmax, a1); + a1.row() = comps(i).bbox().pmin().row() + + (c.row() - comps(i).bbox().pmin().row()) / 4; + internal::find_graph_link(g, comps, i, dmax, a1); /// First site on the right of the central site - internal::find_graph_link(g, objects, i, dmax, c); + internal::find_graph_link(g, comps, i, dmax, c); /// Left link from the bottom anchor. mln_site(L) a2 = c; - a2.row() = objects.bbox(i).pmax().row() - (c.row() - objects.bbox(i).pmin().row()) / 4; - internal::find_graph_link(g, objects, i, dmax, a2); + a2.row() = comps(i).bbox().pmax().row() + - (c.row() - comps(i).bbox().pmin().row()) / 4; + internal::find_graph_link(g, comps, i, dmax, a2); } diff --git a/scribo/primitive/link/with_several_left_links.hh b/scribo/primitive/link/with_several_left_links.hh index 5a685a1..3f9a0cd 100644 --- a/scribo/primitive/link/with_several_left_links.hh +++ b/scribo/primitive/link/with_several_left_links.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -35,9 +36,10 @@ # include <mln/util/array.hh> +# include <scribo/primitive/link/with_single_left_link.hh> # include <scribo/core/object_links.hh> +# include <scribo/core/component_set.hh> # include <scribo/core/macros.hh> -# include <scribo/util/text.hh> namespace scribo @@ -53,11 +55,12 @@ namespace scribo /// if possible. /// Iterate to the right but link boxes to the left. /// - /// \return an mln::util::array. Map a bounding box to its left neighbor. + /// \return object links data. + // template <typename L> inline object_links<L> - with_several_left_links(const object_image(L)& objects, + with_several_left_links(const component_set<L>& objects, unsigned neighb_max_distance); @@ -65,7 +68,7 @@ namespace scribo template <typename L> inline object_links<L> - with_several_left_links(const object_image(L)& objects); + with_several_left_links(const component_set<L>& comps); # ifndef MLN_INCLUDE_ONLY @@ -73,29 +76,11 @@ namespace scribo template <typename L> inline object_links<L> - with_several_left_links(const object_image(L)& objects, + with_several_left_links(const component_set<L>& comps, unsigned neighb_max_distance) { trace::entering("scribo::primitive::link::with_several_left_links"); - mln_precondition(objects.is_valid()); - - object_links<L> - link_1(objects, objects.nlabels().next()), - link_2(objects, objects.nlabels().next()), - link_3(objects, objects.nlabels().next()), - final_link(objects, objects.nlabels().next()); - - primitive::internal::init_link_array(link_1); - primitive::internal::init_link_array(link_2); - primitive::internal::init_link_array(link_3); - - mln::util::array<mln_result(accu::center<mln_psite(L)>)> - mass_centers = labeling::compute(accu::meta::center(), - objects, objects.nlabels()); - - for_all_ncomponents(i, objects.nlabels()) - { // ------- // <------X | // | | @@ -105,41 +90,33 @@ namespace scribo // | | // <------X | // ------- - unsigned midcol = (objects.bbox(i).pmax().col() - - objects.bbox(i).pmin().col()) / 2; - int dmax = midcol + neighb_max_distance; - mln_site(L) c = objects.bbox(i).center(); + // FIXME: make it faster. + internal::single_left_functor<L> + functor(comps, neighb_max_distance); + object_links<L> link_center = compute(functor, anchor::Center); + object_links<L> link_top = compute(functor, anchor::Top); + object_links<L> link_bot = compute(functor, anchor::Bottom); - /// Left link from the top anchor. - mln_site(L) a1 = c; - a1.row() = objects.bbox(i).pmin().row() + (c.row() - objects.bbox(i).pmin().row()) / 4; - primitive::internal::find_left_link(objects, link_1, i, dmax, a1); - /// Left link from the central site - primitive::internal::find_left_link(objects, link_2, i, - dmax, mass_centers[i]); + object_links<L> final_link(comps); - /// Left link from the bottom anchor. - mln_site(L) a2 = c; - a2.row() = objects.bbox(i).pmax().row() - (c.row() - objects.bbox(i).pmin().row()) / 4; - primitive::internal::find_left_link(objects, link_3, i, dmax, a2); - } - - for_all_ncomponents(i, objects.nlabels()) + for_all_comps(i, comps) { - if (link_2[i] != i) - final_link[i] = link_2[i]; - else if (link_1[i] == link_3[i]) - final_link[i] = link_1[i]; - else if (link_1[i] != i && link_3[i] == i) - final_link[i] = link_1[i]; - else if (link_3[i] != i && link_1[i] == i) - final_link[i] = link_3[i]; + if (link_center(i) != i) + final_link(i) = link_center(i); + else if (link_top(i) == link_bot(i)) + final_link(i) = link_top(i); + else if (link_top(i) != i && link_bot(i) == i) + final_link(i) = link_top(i); + else if (link_bot(i) != i && link_top(i) == i) + final_link(i) = link_bot(i); else - final_link[i] = i; + final_link(i) = i; } + + trace::exiting("scribo::primitive::link::with_several_left_links"); return final_link; } @@ -148,9 +125,9 @@ namespace scribo template <typename L> inline object_links<L> - with_several_left_links(const object_image(L)& objects) + with_several_left_links(const component_set<L>& comps) { - return with_several_left_links(objects); + return with_several_left_links(comps); } # endif // ! MLN_INCLUDE_ONLY diff --git a/scribo/primitive/link/with_several_right_closest_links.hh b/scribo/primitive/link/with_several_right_closest_links.hh index 629d0b0..da1e75b 100644 --- a/scribo/primitive/link/with_several_right_closest_links.hh +++ b/scribo/primitive/link/with_several_right_closest_links.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -33,20 +34,21 @@ /// Merge code with primitive::link::with_single_right_link.hh /// /// \todo Factor code with primitive::link::with_several_right_links +/// +/// FIXME: rewrite the code with functors -> See with_several_right_links # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh> +# include <mln/math/abs.hh> + # include <mln/extension/fill.hh> # include <mln/util/array.hh> -# include <scribo/core/object_links.hh> -# include <scribo/core/object_image.hh> + # include <scribo/core/macros.hh> -# include <scribo/primitive/internal/init_link_array.hh> -# include <scribo/primitive/internal/find_right_link.hh> -# include <scribo/util/text.hh> +# include <scribo/core/object_links.hh> namespace scribo @@ -71,14 +73,14 @@ namespace scribo template <typename L> inline object_links<L> - with_several_right_closest_links(const object_image(L)& objects, + with_several_right_closest_links(const component_set<L>& comps, unsigned neighb_max_distance); /// \overload template <typename L> inline object_links<L> - with_several_right_closest_links(const object_image(L)& objects); + with_several_right_closest_links(const component_set<L>& comps); # ifndef MLN_INCLUDE_ONLY @@ -114,31 +116,21 @@ namespace scribo template <typename L> inline object_links<L> - with_several_right_closest_links(const object_image(L)& objects, + with_several_right_closest_links(const component_set<L>& comps, unsigned neighb_max_distance) { trace::entering("scribo::primitive::link::with_several_right_closest_links"); - mln_precondition(objects.is_valid()); - - extension::fill(objects, 0); + extension::fill(comps.labeled_image_(), 0); object_links<L> - link_1(objects, objects.nlabels().next()), - link_2(objects, objects.nlabels().next()), - link_3(objects, objects.nlabels().next()), - final_link(objects, objects.nlabels().next()); - - primitive::internal::init_link_array(link_1); - primitive::internal::init_link_array(link_2); - primitive::internal::init_link_array(link_3); - - mln::util::array<mln_result(accu::center<mln_psite(L)>)> - mass_centers = labeling::compute(accu::meta::center(), - objects, objects.nlabels()); + link_1(comps), link_2(comps), link_3(comps), final_link(comps); + link_1.init(); + link_2.init(); + link_3.init(); - for_all_ncomponents(i, objects.nlabels()) + for_all_comps(i, comps) { // ------- // | a1-------> @@ -150,31 +142,31 @@ namespace scribo // | a2-------> // ------- - float midcol = (objects.bbox(i).pmax().col() - - objects.bbox(i).pmin().col()) / 2; + float midcol = (comps(i).bbox().pmax().col() + - comps(i).bbox().pmin().col()) / 2; float dmax = midcol + neighb_max_distance; - mln_site(L) c = objects.bbox(i).center(); + mln_site(L) c = comps(i).bbox().center(); algebra::vec<3, mln::util::couple<bool, mln_site(L)> > res; // Right link from the top anchor. mln_site(L) a1 = c; - a1.row() = objects.bbox(i).pmin().row() - + (c.row() - objects.bbox(i).pmin().row()) / 4; - res[0] = primitive::internal::find_right_link(objects, link_1, + a1.row() = comps(i).bbox().pmin().row() + + (c.row() - comps(i).bbox().pmin().row()) / 4; + res[0] = primitive::internal::find_right_link(comps, link_1, i, dmax, a1); // Right link from the central site - res[1] = primitive::internal::find_right_link(objects, link_2, + res[1] = primitive::internal::find_right_link(comps, link_2, i, dmax, - mass_centers[i]); + comps(i).mass_center()); // Right link from the bottom anchor. mln_site(L) a2 = c; - a2.row() = objects.bbox(i).pmax().row() - - (c.row() - objects.bbox(i).pmin().row()) / 4; - res[2] = primitive::internal::find_right_link(objects, link_3, + a2.row() = comps(i).bbox().pmax().row() + - (c.row() - comps(i).bbox().pmin().row()) / 4; + res[2] = primitive::internal::find_right_link(comps, link_3, i, dmax, a2); // Try to find the closest object. @@ -185,7 +177,7 @@ namespace scribo // If there exists a link and the site is not outside the // image domain. if (res[closest_idx].first()) - final_link[i] = objects(res[closest_idx].second()); + final_link[i] = comps(res[closest_idx].second()); else final_link[i] = i; } @@ -198,9 +190,9 @@ namespace scribo template <typename L> inline object_links<L> - with_several_right_closest_links(const object_image(L)& objects) + with_several_right_closest_links(const component_set<L>& comps) { - return with_several_right_closest_links(objects, mln_max(unsigned)); + return with_several_right_closest_links(comps, mln_max(unsigned)); } diff --git a/scribo/primitive/link/with_several_right_links.hh b/scribo/primitive/link/with_several_right_links.hh index 14d3229..d75ac7b 100644 --- a/scribo/primitive/link/with_several_right_links.hh +++ b/scribo/primitive/link/with_several_right_links.hh @@ -37,9 +37,10 @@ # include <mln/util/array.hh> +# include <scribo/primitive/link/with_single_right_link.hh> # include <scribo/core/object_links.hh> +# include <scribo/core/component_set.hh> # include <scribo/core/macros.hh> -# include <scribo/util/text.hh> namespace scribo @@ -57,88 +58,64 @@ namespace scribo /// if possible. /// Iterate to the right but link boxes to the right. /// - /// \return an mln::util::array. Map a bounding box to its right neighbor. + /// \return Object links. + // template <typename L> inline object_links<L> - with_several_right_links(const object_image(L)& objects, + with_several_right_links(const component_set<L>& comps, unsigned neighb_max_distance); /// \overload template <typename L> inline object_links<L> - with_several_right_links(const object_image(L)& objects); + with_several_right_links(const component_set<L>& comps); # ifndef MLN_INCLUDE_ONLY + template <typename L> inline object_links<L> - with_several_right_links(const object_image(L)& objects, + with_several_right_links(const component_set<L>& comps, unsigned neighb_max_distance) { trace::entering("scribo::primitive::link::with_several_right_links"); - mln_precondition(objects.is_valid()); - - object_links<L> - link_1(objects, objects.nlabels().next()), - link_2(objects, objects.nlabels().next()), - link_3(objects, objects.nlabels().next()), - final_link(objects, objects.nlabels().next()); + // ------- + // | X-------> + // | | + // | | + // | X-------> + // | | + // | | + // | X-------> + // ------- - internal::init_link_array(link_1); - internal::init_link_array(link_2); - internal::init_link_array(link_3); + // FIXME: make it faster. + internal::single_right_functor<L> + functor(comps, neighb_max_distance); + object_links<L> link_center = compute(functor, anchor::Center); + object_links<L> link_top = compute(functor, anchor::Top); + object_links<L> link_bot = compute(functor, anchor::Bottom); - mln::util::array<mln_result(accu::center<mln_psite(L)>)> - mass_centers = labeling::compute(accu::meta::center(), - objects, objects.nlabels()); + object_links<L> final_link(comps); - for_all_ncomponents(i, objects.nlabels()) + for_all_comps(i, comps) { - // ------- - // | X-------> - // | | - // | | - // | X-------> - // | | - // | | - // | X-------> - // ------- - float midcol = (objects.bbox(i).pmax().col() - - objects.bbox(i).pmin().col()) / 2; - float dmax = midcol + neighb_max_distance; - - mln_site(L) c = objects.bbox(i).center(); - - /// Right link from the top anchor. - mln_site(L) a1 = c; - a1.row() = objects.bbox(i).pmin().row() + (c.row() - objects.bbox(i).pmin().row()) / 4; - internal::find_right_link(objects, link_1, i, dmax, a1); - - /// Right link from the central site - internal::find_right_link(objects, link_2, i, dmax, mass_centers[i]); - - /// Right link from the bottom anchor. - mln_site(L) a2 = c; - a2.row() = objects.bbox(i).pmax().row() - (c.row() - objects.bbox(i).pmin().row()) / 4; - internal::find_right_link(objects, link_3, i, dmax, a2); - - - if (link_2[i] != i) - final_link[i] = link_2[i]; - else if (link_1[i] == link_3[i]) - final_link[i] = link_1[i]; - else if (link_1[i] != i && link_3[i] == i) - final_link[i] = link_1[i]; - else if (link_3[i] != i && link_1[i] == i) - final_link[i] = link_3[i]; + if (link_center(i) != i) + final_link(i) = link_center(i); + else if (link_top(i) == link_bot(i)) + final_link(i) = link_top(i); + else if (link_top(i) != i && link_bot(i) == i) + final_link(i) = link_top(i); + else if (link_bot(i) != i && link_top(i) == i) + final_link(i) = link_bot(i); else - final_link[i] = i; + final_link(i) = i; } trace::exiting("scribo::primitive::link::with_several_right_links"); @@ -149,9 +126,9 @@ namespace scribo template <typename L> inline object_links<L> - with_several_right_links(const object_image(L)& objects) + with_several_right_links(const component_set<L>& comps) { - return with_several_right_links(objects, mln_max(unsigned)); + return with_several_right_links(comps, mln_max(unsigned)); } diff --git a/scribo/primitive/link/with_single_down_link.hh b/scribo/primitive/link/with_single_down_link.hh index 7e4e82c..01c6f7e 100644 --- a/scribo/primitive/link/with_single_down_link.hh +++ b/scribo/primitive/link/with_single_down_link.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -43,7 +44,6 @@ # include <scribo/core/macros.hh> -# include <scribo/core/object_image.hh> # include <scribo/core/object_links.hh> # include <scribo/primitive/link/internal/find_link.hh> @@ -63,7 +63,7 @@ namespace scribo /// \brief Link objects with their down neighbor if exists. /// - /// \param[in] objects An object image. + /// \param[in] comps A component set. /// \param[in] neighb_max_distance The maximum distance allowed /// to seach a neighbor object. /// \param[in] anchor The neighborhod lookup start point. @@ -73,7 +73,7 @@ namespace scribo template <typename L> inline object_links<L> - with_single_down_link(const object_image(L)& objects, + with_single_down_link(const component_set<L>& comps, unsigned neighb_max_distance, anchor::Type anchor); @@ -83,7 +83,7 @@ namespace scribo template <typename L> inline object_links<L> - with_single_down_link(const object_image(L)& objects, + with_single_down_link(const component_set<L>& comps, unsigned neighb_max_distance); @@ -92,7 +92,7 @@ namespace scribo template <typename L> inline object_links<L> - with_single_down_link(const object_image(L)& objects); + with_single_down_link(const component_set<L>& comps); # ifndef MLN_INCLUDE_ONLY @@ -113,8 +113,8 @@ namespace scribo public: typedef mln_site(L) P; - single_down_functor(const object_image(L)& objects, unsigned dmax) - : sdowner_(objects, dmax, anchor::Vertical) + single_down_functor(const component_set<L>& comps, unsigned dmax) + : sdowner_(comps, dmax, anchor::Vertical) { } @@ -134,16 +134,14 @@ namespace scribo template <typename L> inline object_links<L> - with_single_down_link(const object_image(L)& objects, + with_single_down_link(const component_set<L>& comps, unsigned neighb_max_distance, anchor::Type anchor) { trace::entering("scribo::primitive::link::with_single_down_link"); - mln_precondition(objects.is_valid()); - internal::single_down_functor<L> - functor(objects, neighb_max_distance); + functor(comps, neighb_max_distance); object_links<L> output = compute(functor, anchor); @@ -155,10 +153,10 @@ namespace scribo template <typename L> inline object_links<L> - with_single_down_link(const object_image(L)& objects, + with_single_down_link(const component_set<L>& comps, unsigned neighb_max_distance) { - return with_single_down_link(objects, neighb_max_distance, + return with_single_down_link(comps, neighb_max_distance, anchor::MassCenter); } @@ -166,9 +164,9 @@ namespace scribo template <typename L> inline object_links<L> - with_single_down_link(const object_image(L)& objects) + with_single_down_link(const component_set<L>& comps) { - return with_single_down_link(objects, mln_max(unsigned)); + return with_single_down_link(comps, mln_max(unsigned)); } diff --git a/scribo/primitive/link/with_single_up_link.hh b/scribo/primitive/link/with_single_up_link.hh index 8781128..4062275 100644 --- a/scribo/primitive/link/with_single_up_link.hh +++ b/scribo/primitive/link/with_single_up_link.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,7 +29,7 @@ /// \file /// -/// Link text objects with their up neighbor. +/// Link components with their up neighbor. # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh> @@ -61,9 +62,9 @@ namespace scribo namespace link { - /// \brief Link objects with their up neighbor if exists. + /// \brief Link components with their up neighbor if exists. /// - /// \param[in] objects An object image. + /// \param[in] comps A component set. /// \param[in] neighb_max_distance The maximum distance allowed /// to seach a neighbor object. /// \param[in] anchor The neighborhod lookup start point. @@ -73,7 +74,7 @@ namespace scribo template <typename L> inline object_links<L> - with_single_up_link(const object_image(L)& objects, + with_single_up_link(const component_set<L>& comps, unsigned neighb_max_distance, anchor::Type anchor); @@ -83,7 +84,7 @@ namespace scribo template <typename L> inline object_links<L> - with_single_up_link(const object_image(L)& objects, + with_single_up_link(const component_set<L>& comps, unsigned neighb_max_distance); @@ -93,7 +94,7 @@ namespace scribo template <typename L> inline object_links<L> - with_single_up_link(const object_image(L)& objects); + with_single_up_link(const component_set<L>& comps); # ifndef MLN_INCLUDE_ONLY @@ -114,8 +115,8 @@ namespace scribo public: typedef mln_site(L) P; - single_up_functor(const object_image(L)& objects, unsigned dmax) - : super_(objects, dmax, anchor::Vertical) + single_up_functor(const component_set<L>& comps, unsigned dmax) + : super_(comps, dmax, anchor::Vertical) { } @@ -135,16 +136,14 @@ namespace scribo template <typename L> inline object_links<L> - with_single_up_link(const object_image(L)& objects, + with_single_up_link(const component_set<L>& comps, unsigned neighb_max_distance, anchor::Type anchor) { trace::entering("scribo::primitive::link::with_single_up_link"); - mln_precondition(objects.is_valid()); - internal::single_up_functor<L> - functor(objects, neighb_max_distance); + functor(comps, neighb_max_distance); object_links<L> output = compute(functor, anchor); @@ -155,10 +154,10 @@ namespace scribo template <typename L> inline object_links<L> - with_single_up_link(const object_image(L)& objects, + with_single_up_link(const component_set<L>& comps, unsigned neighb_max_distance) { - return with_single_up_link(objects, neighb_max_distance, + return with_single_up_link(comps, neighb_max_distance, anchor::MassCenter); } @@ -166,9 +165,9 @@ namespace scribo template <typename L> inline object_links<L> - with_single_up_link(const object_image(L)& objects) + with_single_up_link(const component_set<L>& comps) { - return with_single_up_link(objects, mln_max(unsigned)); + return with_single_up_link(comps, mln_max(unsigned)); } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara