last-svn-commit-780-gb37a853 mln/labeling/fill_holes.hh: Improve speed.

--- milena/ChangeLog | 4 ++++ milena/mln/labeling/fill_holes.hh | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index edefc8e..2eed916 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,9 @@ 2011-03-01 Guillaume Lazzara <z@lrde.epita.fr> + * mln/labeling/fill_holes.hh: Improve speed. + +2011-03-01 Guillaume Lazzara <z@lrde.epita.fr> + * mln/fun/v2v/rgb_to_luma.hh: New function for grayscale conversion. diff --git a/milena/mln/labeling/fill_holes.hh b/milena/mln/labeling/fill_holes.hh index e76c489..5e487d9 100644 --- a/milena/mln/labeling/fill_holes.hh +++ b/milena/mln/labeling/fill_holes.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -33,6 +34,8 @@ # include <mln/labeling/background.hh> # include <mln/labeling/compute.hh> +# include <mln/data/transform.hh> + # include <mln/core/image/dmorph/image_if.hh> # include <mln/accu/math/count.hh> @@ -57,7 +60,7 @@ namespace mln /// \see mln::labeling::background /// template <typename I, typename N, typename L> - I + mln_concrete(I) fill_holes(const Image<I>& input, const Neighborhood<N>& nbh, L& nlabels); @@ -66,7 +69,7 @@ namespace mln template <typename I, typename N, typename L> inline - I + mln_concrete(I) fill_holes(const Image<I>& input, const Neighborhood<N>& nbh, L& nlabels) { @@ -77,10 +80,6 @@ namespace mln mln_precondition(exact(input).is_valid()); mln_precondition(exact(nbh).is_valid()); - mln_ch_value(I, bool) output; - initialize(output, input); - data::fill(output, false); - mln_ch_value(I, L) lbls = labeling::background(input, nbh, nlabels); accu::math::count<mln_value(I)> a_; @@ -99,7 +98,9 @@ namespace mln } } - data::fill((output | (pw::value(lbls) != bg_lbl)).rw(), true); + util::array<bool> bg_relbl(arr.nelements(), true); + bg_relbl(bg_lbl) = false; + mln_ch_value(I, bool) output = data::transform(lbls, bg_relbl); trace::exiting("labeling::fill_holes"); return output; -- 1.5.6.5
participants (1)
-
Guillaume Lazzara