
https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Tiny fix and add some preconditions. * mln/convert/to_image.hh: Fix. * mln/linear/line_convolve.hh: Add todo. * mln/canvas/labeling.hh: Add comments. * mln/labeling/flat_zones.hh, * mln/labeling/foreground.hh, * mln/labeling/regional_minima.hh, * mln/labeling/regional_maxima.hh: Add precondition. * mln/labeling/background.hh: . * mln/labeling/level.hh (level_): Rename as... (level_t): ...this. (level_): New. canvas/labeling.hh | 6 ++++++ convert/to_image.hh | 3 ++- labeling/background.hh | 1 + labeling/flat_zones.hh | 1 + labeling/foreground.hh | 1 + labeling/level.hh | 27 ++++++++++++++++++++------- labeling/regional_maxima.hh | 1 + labeling/regional_minima.hh | 1 + linear/line_convolve.hh | 2 ++ 9 files changed, 35 insertions(+), 8 deletions(-) Index: mln/convert/to_image.hh --- mln/convert/to_image.hh (revision 1074) +++ mln/convert/to_image.hh (working copy) @@ -33,6 +33,7 @@ * \brief Conversions to mln::Image. */ +# include <mln/core/image1d_b.hh> # include <mln/core/image2d_b.hh> # include <mln/core/concept/point_set.hh> @@ -132,7 +133,7 @@ mln_precondition(! win.is_empty()); typedef mln_point(W) P; - box2d b = geom::bbox(win); + box_<P> b = geom::bbox(win); mln_image_from(W, bool) ima(b); level::fill(ima, false); mln_qiter(W) q(win, P::zero); Index: mln/linear/line_convolve.hh --- mln/linear/line_convolve.hh (revision 1074) +++ mln/linear/line_convolve.hh (working copy) @@ -54,6 +54,8 @@ * its symmetrization is handled by the client. * * \pre output.domain = input.domain + * + * \todo Optimize. */ template <typename I, typename W, unsigned N, typename O> void line_convolve(const Image<I>& input, W (&weights)[N], Index: mln/canvas/labeling.hh --- mln/canvas/labeling.hh (revision 1074) +++ mln/canvas/labeling.hh (working copy) @@ -44,6 +44,8 @@ namespace canvas { + // General version. + template <typename F> struct labeling { @@ -149,6 +151,10 @@ }; + + // FIXME: Fast version. + + } // end of namespace mln::canvas } // end of namespace mln Index: mln/labeling/flat_zones.hh --- mln/labeling/flat_zones.hh (revision 1074) +++ mln/labeling/flat_zones.hh (working copy) @@ -94,6 +94,7 @@ Image<O>& output, unsigned& nlabels) { + mln_precondition(exact(output).domain() = exact(input).domain()); typedef impl::flat_zones_<I,N,O> F; F f(exact(input), exact(nbh), exact(output)); canvas::labeling<F> run(f); Index: mln/labeling/level.hh --- mln/labeling/level.hh (revision 1074) +++ mln/labeling/level.hh (working copy) @@ -66,8 +66,10 @@ namespace impl { + // Functors. + template <typename I_, typename N_, typename O_> - struct level_ : base_<I_,N_,O_> + struct level_t : base_<I_,N_,O_> { typedef mln_point(I_) P; @@ -84,13 +86,28 @@ const mln_value(I_)& val; - level_(const I_& input, const mln_value(I_)& val, const N_& nbh, O_& output) + level_t(const I_& input, const mln_value(I_)& val, const N_& nbh, O_& output) : base_<I_,N_,O_>(input, nbh, output), s(input.domain()), val(val) {} }; + // Routines. + + template <typename I, typename N, typename O> + bool level_(const Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh, + Image<O>& output, unsigned& nlabels) + { + typedef impl::level_t<I,N,O> F; + F f(exact(input), val, exact(nbh), exact(output)); + canvas::labeling<F> run(f); + nlabels = f.nlabels; + return f.status; + } + + // FIXME: Add fast versions. + } // end of namespace mln::labeling::impl @@ -101,11 +118,7 @@ Image<O>& output, unsigned& nlabels) { mln_precondition(exact(output).domain() = exact(input).domain()); - typedef impl::level_<I,N,O> F; - F f(exact(input), val, exact(nbh), exact(output)); - canvas::labeling<F> run(f); - nlabels = f.nlabels; - return f.status; + return impl::level_(exact(input), val, nbh, output, nlabels); } # endif // ! MLN_INCLUDE_ONLY Index: mln/labeling/foreground.hh --- mln/labeling/foreground.hh (revision 1074) +++ mln/labeling/foreground.hh (working copy) @@ -66,6 +66,7 @@ Image<O>& output, unsigned& nlabels) { + mln_precondition(exact(output).domain() = exact(input).domain()); return labeling::level(input, true, nbh, output, nlabels); } Index: mln/labeling/regional_minima.hh --- mln/labeling/regional_minima.hh (revision 1074) +++ mln/labeling/regional_minima.hh (working copy) @@ -103,6 +103,7 @@ bool regional_minima(const Image<I>& input, const Neighborhood<N>& nbh, Image<O>& output, unsigned& nlabels) { + mln_precondition(exact(output).domain() = exact(input).domain()); typedef impl::regional_minima_<I,N,O> F; F f(exact(input), exact(nbh), exact(output)); canvas::labeling<F> run(f); Index: mln/labeling/regional_maxima.hh --- mln/labeling/regional_maxima.hh (revision 1074) +++ mln/labeling/regional_maxima.hh (working copy) @@ -103,6 +103,7 @@ bool regional_maxima(const Image<I>& input, const Neighborhood<N>& nbh, Image<O>& output, unsigned& nlabels) { + mln_precondition(exact(output).domain() = exact(input).domain()); typedef impl::regional_maxima_<I,N,O> F; F f(exact(input), exact(nbh), exact(output)); canvas::labeling<F> run(f); Index: mln/labeling/background.hh --- mln/labeling/background.hh (revision 1074) +++ mln/labeling/background.hh (working copy) @@ -66,6 +66,7 @@ Image<O>& output, unsigned& nlabels) { + mln_precondition(exact(output).domain() = exact(input).domain()); return labeling::level(input, false, nbh, output, nlabels); }