
* filter/internal/compute.hh, * filter/objects_small.hh, * filter/objects_thick.hh, * filter/objects_thin.hh, * primitive/group/from_double_link.hh, * primitive/link/compute_several.hh, * table/align_lines_horizontaly.hh, * table/erase.hh, * table/extract.hh: Here. --- scribo/ChangeLog | 14 ++++++++++++++ scribo/debug/decision_image.hh | 2 +- scribo/filter/internal/compute.hh | 10 +++++----- scribo/filter/objects_small.hh | 20 +++++--------------- scribo/filter/objects_thick.hh | 12 ++++++------ scribo/filter/objects_thin.hh | 23 ++++++++++++----------- scribo/primitive/group/from_double_link.hh | 22 ++++++++++------------ scribo/primitive/link/compute_several.hh | 2 +- scribo/table/align_lines_horizontaly.hh | 25 +++++++++++++++---------- scribo/table/erase.hh | 14 ++++++-------- scribo/table/extract.hh | 14 ++++++++------ 11 files changed, 83 insertions(+), 75 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 4865134..780a185 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,19 @@ 2010-08-09 Guillaume Lazzara <z@lrde.epita.fr> + Make use of the new component_set interface. + + * filter/internal/compute.hh, + * filter/objects_small.hh, + * filter/objects_thick.hh, + * filter/objects_thin.hh, + * primitive/group/from_double_link.hh, + * primitive/link/compute_several.hh, + * table/align_lines_horizontaly.hh, + * table/erase.hh, + * table/extract.hh: Here. + +2010-08-09 Guillaume Lazzara <z@lrde.epita.fr> + Fix compilation of Scribo tools. * src/debug/show_links_bbox_overlap.cc, diff --git a/scribo/debug/decision_image.hh b/scribo/debug/decision_image.hh index 1bf2643..aa1a188 100644 --- a/scribo/debug/decision_image.hh +++ b/scribo/debug/decision_image.hh @@ -104,7 +104,7 @@ namespace scribo trace::entering("scribo::debug::decision_image"); const I& input = exact(input_); - const component_set<L>& components = groups.object_image_(); + const component_set<L>& components = groups.components(); mln_precondition(input.is_valid()); mln_precondition(groups.is_valid()); diff --git a/scribo/filter/internal/compute.hh b/scribo/filter/internal/compute.hh index bd00eb6..7c87c5f 100644 --- a/scribo/filter/internal/compute.hh +++ b/scribo/filter/internal/compute.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. // @@ -106,7 +107,7 @@ namespace scribo component_set<lbl_t> components = primitive::extract::components(input, nbh, nlabels); - filter.update_components(components); + filter.update_objects(components); components.relabel(filter); mln_concrete(I) output = duplicate(input); @@ -127,9 +128,8 @@ namespace scribo mln_precondition(components.is_valid()); - component_set<L> output; - output.init_from_(components); - output.relabel(filter); + component_set<L> output = components.duplicate(); + output.update_tags(filter, component::Ignored); trace::exiting("scribo::filter::internal::compute"); return output; diff --git a/scribo/filter/objects_small.hh b/scribo/filter/objects_small.hh index f97a79e..ba9a50c 100644 --- a/scribo/filter/objects_small.hh +++ b/scribo/filter/objects_small.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. // @@ -36,20 +37,12 @@ # include <mln/core/concept/function.hh> # include <mln/core/image/dmorph/image_if.hh> -# include <mln/labeling/blobs.hh> -# include <mln/labeling/relabel.hh> - -# include <mln/make/relabelfun.hh> +# include <mln/data/transform.hh> # include <mln/util/array.hh> # include <mln/pw/all.hh> -# include <mln/accu/math/count.hh> - -# include <mln/set/compute.hh> - - # include <scribo/core/component_set.hh> # include <scribo/fun/v2b/objects_small_filter.hh> # include <scribo/primitive/extract/components.hh> @@ -120,11 +113,8 @@ namespace scribo typedef fun::v2b::components_small_filter<mln_ch_value(I,V)> func_t; func_t fv2b(lbl, min_size); - lbl.relabel(fv2b); - - mln_concrete(I) output = duplicate(input); - data::fill((output | (pw::value(lbl) == pw::cst(literal::zero))).rw(), - false); + mln_concrete(I) + output = mln::data::transform(lbl.labeled_image(), fv2b); trace::exiting("scribo::filter::components_small"); return output; diff --git a/scribo/filter/objects_thick.hh b/scribo/filter/objects_thick.hh index c933532..485092a 100644 --- a/scribo/filter/objects_thick.hh +++ b/scribo/filter/objects_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. // @@ -111,8 +112,8 @@ namespace scribo { if (l == literal::zero) return true; - return components_.bbox(l).nrows() < max_thickness_ - && components_.bbox(l).ncols() < max_thickness_; + return components_(l).bbox().nrows() < max_thickness_ + && components_(l).bbox().ncols() < max_thickness_; } @@ -173,9 +174,8 @@ namespace scribo typedef internal::thick_object_filter<L> func_t; func_t is_not_too_thick(components, max_thickness); - component_set<L> output; - output.init_from_(components); - output.relabel(is_not_too_thick); + component_set<L> output = components.duplicate(); + output.update_tags(is_not_too_thick, component::Ignored); trace::exiting("scribo::filter::objects_thick"); return output; diff --git a/scribo/filter/objects_thin.hh b/scribo/filter/objects_thin.hh index c821b74..e8591d9 100644 --- a/scribo/filter/objects_thin.hh +++ b/scribo/filter/objects_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. // @@ -37,6 +38,8 @@ # include <mln/util/array.hh> +# include <mln/data/transform.hh> + # include <scribo/core/component_set.hh> # include <scribo/primitive/extract/components.hh> # include <scribo/filter/internal/compute.hh> @@ -111,8 +114,8 @@ namespace scribo { if (l == literal::zero) return true; - return components_.bbox(l).nrows() > min_thickness_ - && components_.bbox(l).ncols() > min_thickness_; + return components_(l).bbox().nrows() > min_thickness_ + && components_(l).bbox().ncols() > min_thickness_; } /// Component bounding boxes. @@ -145,16 +148,13 @@ namespace scribo V nlabels; typedef mln_ch_value(I,V) lbl_t; - component_set<lbl_t> components + component_set<lbl_t> comps = primitive::extract::components(input, nbh, nlabels); typedef internal::components_thin_filter<lbl_t> func_t; - func_t fv2b(components, min_thickness); - components.relabel(fv2b); - - mln_concrete(I) output = duplicate(input); - data::fill((output | (pw::value(components) == pw::cst(literal::zero))).rw(), - false); + func_t fv2b(comps, min_thickness); + mln_concrete(I) + output = mln::data::transform(comps.labeled_image(), fv2b); trace::exiting("scribo::filter::components_thin"); return output; @@ -174,7 +174,8 @@ namespace scribo typedef internal::components_thin_filter<L> func_t; func_t is_not_too_thin(components, min_thickness); - component_set<L> output = internal::compute(components, is_not_too_thin); + component_set<L> output = components.duplicate(); + output.update_tags(is_not_too_thin, component::Ignored); trace::exiting("scribo::filter::components_thin"); return output; diff --git a/scribo/primitive/group/from_double_link.hh b/scribo/primitive/group/from_double_link.hh index 9367cfa..3af395d 100644 --- a/scribo/primitive/group/from_double_link.hh +++ b/scribo/primitive/group/from_double_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. // @@ -69,8 +70,7 @@ namespace scribo */ template <typename L> object_groups<L> - from_double_link(const component_set<L>& components, - const object_links<L>& left_link, + from_double_link(const object_links<L>& left_link, const object_links<L>& right_link); @@ -81,19 +81,17 @@ namespace scribo template <typename L> inline object_groups<L> - from_double_link(const component_set<L>& components, - const object_links<L>& left_link, + from_double_link(const object_links<L>& left_link, const object_links<L>& right_link) { trace::entering("scribo::primitive::group::from_double_link"); mln_precondition(left_link.nelements() == right_link.nelements()); - mln_precondition(left_link.components_id_() == components.id_()); - mln_precondition(right_link.components_id_() == components.id_()); - object_groups<L> parent(components, left_link.nelements()); + + object_groups<L> parent(left_link); parent.init(); - for_all_ncomponents(i, components.nlabels()) + for_all_comps(i, left_link.components()) { mln::util::couple<bool, unsigned> nbh = internal::is_link_valid(left_link, right_link, i); @@ -101,14 +99,14 @@ namespace scribo { unsigned par = internal::find_root(parent, nbh.second()); if (par < i) - parent[par] = i; + parent(par) = i; else - parent[i] = par; + parent(i) = par; } } for (unsigned i = parent.nelements() - 1; i < parent.nelements(); --i) - parent[i] = parent[parent[i]]; + parent(i) = parent(parent(i)); trace::exiting("scribo::primitive::group::from_double_link"); return parent; diff --git a/scribo/primitive/link/compute_several.hh b/scribo/primitive/link/compute_several.hh index 929a7cb..551b16c 100644 --- a/scribo/primitive/link/compute_several.hh +++ b/scribo/primitive/link/compute_several.hh @@ -95,7 +95,7 @@ namespace scribo F& functor = exact(functor_); - for_all_ncomponents(current_object, functor.objects().nlabels()) + for_all_comps(current_object, functor.components()) { functor.start_processing_object(current_object); //<-- start_processing_object internal::find_several_links(functor, current_object); diff --git a/scribo/table/align_lines_horizontaly.hh b/scribo/table/align_lines_horizontaly.hh index cf776ae..25e4036 100644 --- a/scribo/table/align_lines_horizontaly.hh +++ b/scribo/table/align_lines_horizontaly.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. // @@ -61,30 +62,34 @@ namespace scribo /// /// \return A list of the resulting aligned rows. Each integer is actually /// a row number. - template <typename I> + template <typename I, typename L> mln::util::array<int> align_lines_horizontaly(const Image<I>& input, - mln::util::array<box<mln_site(I)> >& line_bboxes, + const component_set<L>& lines, + component_set<L>& aligned_lines, unsigned max_alignment_diff); # ifndef MLN_INCLUDE_ONLY - template <typename I> + template <typename I, typename L> mln::util::array<int> align_lines_horizontaly(const Image<I>& input, - mln::util::array<box<mln_site(I)> >& line_bboxes, + const component_set<L>& lines, + component_set<L>& aligned_lines, unsigned max_alignment_diff) { trace::entering("scribo::table::align_lines_horizontaly"); mln_precondition(exact(input).is_valid()); - mln::util::array<int> res = internal::align_lines(geom::nrows(input), - geom::min_row(input), - geom::max_row(input), - line_bboxes, 0, - max_alignment_diff); + mln::util::array<int> + res = internal::align_lines(geom::nrows(input), + geom::min_row(input), + geom::max_row(input), + lines, + aligned_lines, 0, + max_alignment_diff); trace::exiting("scribo::table::align_lines_horizontaly"); return res; diff --git a/scribo/table/erase.hh b/scribo/table/erase.hh index a34e5a0..8cdf834 100644 --- a/scribo/table/erase.hh +++ b/scribo/table/erase.hh @@ -54,16 +54,16 @@ namespace scribo /// /// \param[in] input A binary image from which the table lines /// are extracted. - /// \param[in] hlines An object image with horizontal lines. - /// \param[in] vlines An object image with vertical lines. + /// \param[in] hlines A component set with horizontal lines. + /// \param[in] vlines A component set with vertical lines. /// /// \return A copy of \p in where the table lines are removed. // template <typename I, typename L> mln_concrete(I) erase(const Image<I>& input, - const Image<L>& hlines, - const Image<L>& vlines); + const component_set<L>& hlines, + const component_set<L>& vlines); # ifndef MLN_INCLUDE_ONLY @@ -73,14 +73,12 @@ namespace scribo inline mln_concrete(I) erase(const Image<I>& input, - const Image<L>& hlines, - const Image<L>& vlines) + const component_set<L>& hlines, + const component_set<L>& vlines) { trace::entering("scribo::internal::erase"); mlc_equal(mln_value(I),bool)::check(); mln_precondition(exact(input).is_valid()); - mln_precondition(exact(hlines).is_valid()); - mln_precondition(exact(vlines).is_valid()); I output = duplicate(input); diff --git a/scribo/table/extract.hh b/scribo/table/extract.hh index aca2321..49a7d50 100644 --- a/scribo/table/extract.hh +++ b/scribo/table/extract.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. // @@ -90,9 +91,11 @@ namespace scribo bvlines = scribo::primitive::extract::lines_v_pattern(input, 51, 3); V nhlines, nvlines; - object_image(mln_ch_value(I,V)) - hlines = scribo::primitive::extract::objects(bhlines, c8(), nhlines), - vlines = scribo::primitive::extract::objects(bvlines, c8(), nvlines); + component_set<mln_ch_value(I,V)> + hlines = scribo::primitive::extract::components(bhlines, c8(), + nhlines), + vlines = scribo::primitive::extract::components(bvlines, c8(), + nvlines); typedef mln::util::couple<mln_ch_value(I,V), mln::util::couple<mln::util::array<box<mln_site(I)> >, @@ -100,8 +103,7 @@ namespace scribo tables_t; tables_t tables = scribo::table::rebuild(input, - mln::make::couple(vlines.bboxes(), hlines.bboxes()), - 30, ncells); + vlines, hlines, 30, ncells); trace::exiting("scribo::table::extract"); return tables; -- 1.5.6.5