last-svn-commit-544-g6668394 Change return value for background in filtering functions.

* scribo/filter/objects_h_thick.hh, * scribo/filter/objects_h_thin.hh, * scribo/filter/objects_size_ratio.hh, * scribo/filter/objects_small.hh, * scribo/filter/objects_thick.hh, * scribo/filter/objects_thin.hh, * scribo/filter/objects_v_thick.hh, * scribo/filter/objects_v_thin.hh: Here. * scribo/fun/v2b/objects_large_filter.hh, * scribo/fun/v2b/objects_small_filter.hh: Here. Count the non filtered objects. --- scribo/ChangeLog | 17 +++++++++++++++++ scribo/scribo/filter/objects_h_thick.hh | 2 +- scribo/scribo/filter/objects_h_thin.hh | 2 +- scribo/scribo/filter/objects_size_ratio.hh | 2 +- scribo/scribo/filter/objects_small.hh | 3 ++- scribo/scribo/filter/objects_thick.hh | 2 +- scribo/scribo/filter/objects_thin.hh | 2 +- scribo/scribo/filter/objects_v_thick.hh | 2 +- scribo/scribo/filter/objects_v_thin.hh | 2 +- scribo/scribo/fun/v2b/objects_large_filter.hh | 10 +++++++++- scribo/scribo/fun/v2b/objects_small_filter.hh | 15 ++++++++++++--- 11 files changed, 47 insertions(+), 12 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index bb3b4aa..5660dc5 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,22 @@ 2010-08-31 Guillaume Lazzara <z@lrde.epita.fr> + Change return value for background in filtering functions. + + * scribo/filter/objects_h_thick.hh, + * scribo/filter/objects_h_thin.hh, + * scribo/filter/objects_size_ratio.hh, + * scribo/filter/objects_small.hh, + * scribo/filter/objects_thick.hh, + * scribo/filter/objects_thin.hh, + * scribo/filter/objects_v_thick.hh, + * scribo/filter/objects_v_thin.hh: Here. + + * scribo/fun/v2b/objects_large_filter.hh, + * scribo/fun/v2b/objects_small_filter.hh: Here. Count the non + filtered objects. + +2010-08-31 Guillaume Lazzara <z@lrde.epita.fr> + * scribo/toolchain/text_in_doc_preprocess.hh: Add a new overload. 2010-08-26 Guillaume Lazzara <z@lrde.epita.fr> diff --git a/scribo/scribo/filter/objects_h_thick.hh b/scribo/scribo/filter/objects_h_thick.hh index 9422798..86dc8dc 100644 --- a/scribo/scribo/filter/objects_h_thick.hh +++ b/scribo/scribo/filter/objects_h_thick.hh @@ -126,7 +126,7 @@ namespace scribo bool operator()(const mln_value(L)& l) const { if (l == literal::zero) - return true; + return false; return comps_(l).bbox().height() > min_thickness_; } diff --git a/scribo/scribo/filter/objects_h_thin.hh b/scribo/scribo/filter/objects_h_thin.hh index 56c6ab7..43bcdfc 100644 --- a/scribo/scribo/filter/objects_h_thin.hh +++ b/scribo/scribo/filter/objects_h_thin.hh @@ -128,7 +128,7 @@ namespace scribo bool operator()(const mln_value(L)& l) const { if (l == literal::zero) - return true; + return false; return comps_(l).bbox().ncols() > min_thinness_; } diff --git a/scribo/scribo/filter/objects_size_ratio.hh b/scribo/scribo/filter/objects_size_ratio.hh index 55de80d..6edb35f 100644 --- a/scribo/scribo/filter/objects_size_ratio.hh +++ b/scribo/scribo/filter/objects_size_ratio.hh @@ -80,7 +80,7 @@ namespace scribo bool operator()(const mln_value(L)& l) const { if (l == literal::zero) - return true; + return false; return (comps_(l).bbox().height() / static_cast<float>(comps_(l).bbox().width())) >= min_size_ratio_; } diff --git a/scribo/scribo/filter/objects_small.hh b/scribo/scribo/filter/objects_small.hh index ba9a50c..1520f7d 100644 --- a/scribo/scribo/filter/objects_small.hh +++ b/scribo/scribo/filter/objects_small.hh @@ -94,7 +94,7 @@ namespace scribo mln_concrete(I) components_small(const Image<I>& input_, const Neighborhood<N>& nbh_, - const V& label_type, + V& nlabels, unsigned min_size) { trace::entering("scribo::filter::components_small"); @@ -115,6 +115,7 @@ namespace scribo func_t fv2b(lbl, min_size); mln_concrete(I) output = mln::data::transform(lbl.labeled_image(), fv2b); + nlabels = fv2b.nlabels_; trace::exiting("scribo::filter::components_small"); return output; diff --git a/scribo/scribo/filter/objects_thick.hh b/scribo/scribo/filter/objects_thick.hh index 485092a..faf13e7 100644 --- a/scribo/scribo/filter/objects_thick.hh +++ b/scribo/scribo/filter/objects_thick.hh @@ -111,7 +111,7 @@ namespace scribo bool operator()(const mln_value(L)& l) const { if (l == literal::zero) - return true; + return false; return components_(l).bbox().nrows() < max_thickness_ && components_(l).bbox().ncols() < max_thickness_; } diff --git a/scribo/scribo/filter/objects_thin.hh b/scribo/scribo/filter/objects_thin.hh index e8591d9..f58d0db 100644 --- a/scribo/scribo/filter/objects_thin.hh +++ b/scribo/scribo/filter/objects_thin.hh @@ -113,7 +113,7 @@ namespace scribo bool operator()(const mln_value(L)& l) const { if (l == literal::zero) - return true; + return false; return components_(l).bbox().nrows() > min_thickness_ && components_(l).bbox().ncols() > min_thickness_; } diff --git a/scribo/scribo/filter/objects_v_thick.hh b/scribo/scribo/filter/objects_v_thick.hh index 7b25d87..1db00cb 100644 --- a/scribo/scribo/filter/objects_v_thick.hh +++ b/scribo/scribo/filter/objects_v_thick.hh @@ -126,7 +126,7 @@ namespace scribo bool operator()(const mln_value(L)& l) const { if (l == literal::zero) - return true; + return false; return comps_(l).bbox().nrows() > min_thickness_; } diff --git a/scribo/scribo/filter/objects_v_thin.hh b/scribo/scribo/filter/objects_v_thin.hh index 52e10af..de11cec 100644 --- a/scribo/scribo/filter/objects_v_thin.hh +++ b/scribo/scribo/filter/objects_v_thin.hh @@ -129,7 +129,7 @@ namespace scribo bool operator()(const mln_value(L)& l) const { if (l == literal::zero) - return true; + return false; return comps_.bbox(l).nrows() > min_thinness_; } diff --git a/scribo/scribo/fun/v2b/objects_large_filter.hh b/scribo/scribo/fun/v2b/objects_large_filter.hh index 1707c9c..91da10d 100644 --- a/scribo/scribo/fun/v2b/objects_large_filter.hh +++ b/scribo/scribo/fun/v2b/objects_large_filter.hh @@ -86,6 +86,9 @@ namespace scribo /// The component set to filter. const component_set<L> components_; + + /// The number of labels remaining after filtering. + mln_value(L) nlabels_; }; @@ -111,8 +114,13 @@ namespace scribo components_large_filter<L>::operator()(const mln_value(L)& l) const { if (l == literal::zero) + return false; + if (components_.info(l).card() <= max_size_) + { + ++nlabels_; return true; - return components_.info(l).card() <= max_size_; + } + return false; } diff --git a/scribo/scribo/fun/v2b/objects_small_filter.hh b/scribo/scribo/fun/v2b/objects_small_filter.hh index 8e0ae8a..86d9287 100644 --- a/scribo/scribo/fun/v2b/objects_small_filter.hh +++ b/scribo/scribo/fun/v2b/objects_small_filter.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. // @@ -86,6 +87,9 @@ namespace scribo /// The component set to filter. const component_set<L> components_; + + /// The number of labels remaining after filtering. + mln_value(L) nlabels_; }; @@ -99,7 +103,7 @@ namespace scribo components_small_filter<L>::components_small_filter( const component_set<L>& components, unsigned min_size) - : min_size_(min_size), components_(components) + : min_size_(min_size), components_(components), nlabels_(0) { } @@ -111,8 +115,13 @@ namespace scribo components_small_filter<L>::operator()(const mln_value(L)& l) const { if (l == literal::zero) + return false; + if (components_.info(l).card() >= min_size_) + { + ++nlabels_; return true; - return components_.info(l).card() >= min_size_; + } + return false; } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara