Commit 82d645ec authored by Thierry Geraud's avatar Thierry Geraud
Browse files

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.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1075 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent e19933d7
2007-09-06 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.
2007-09-06 Simon Nivault <simon.nivault@lrde.epita.fr> 2007-09-06 Simon Nivault <simon.nivault@lrde.epita.fr>
Median specialized for fast image Median specialized for fast image
......
...@@ -44,6 +44,8 @@ namespace mln ...@@ -44,6 +44,8 @@ namespace mln
namespace canvas namespace canvas
{ {
// General version.
template <typename F> template <typename F>
struct labeling struct labeling
{ {
...@@ -149,6 +151,10 @@ namespace mln ...@@ -149,6 +151,10 @@ namespace mln
}; };
// FIXME: Fast version.
} // end of namespace mln::canvas } // end of namespace mln::canvas
} // end of namespace mln } // end of namespace mln
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
* \brief Conversions to mln::Image. * \brief Conversions to mln::Image.
*/ */
# include <mln/core/image1d_b.hh>
# include <mln/core/image2d_b.hh> # include <mln/core/image2d_b.hh>
# include <mln/core/concept/point_set.hh> # include <mln/core/concept/point_set.hh>
...@@ -132,7 +133,7 @@ namespace mln ...@@ -132,7 +133,7 @@ namespace mln
mln_precondition(! win.is_empty()); mln_precondition(! win.is_empty());
typedef mln_point(W) P; typedef mln_point(W) P;
box2d b = geom::bbox(win); box_<P> b = geom::bbox(win);
mln_image_from(W, bool) ima(b); mln_image_from(W, bool) ima(b);
level::fill(ima, false); level::fill(ima, false);
mln_qiter(W) q(win, P::zero); mln_qiter(W) q(win, P::zero);
......
...@@ -66,6 +66,7 @@ namespace mln ...@@ -66,6 +66,7 @@ namespace mln
Image<O>& output, Image<O>& output,
unsigned& nlabels) unsigned& nlabels)
{ {
mln_precondition(exact(output).domain() == exact(input).domain());
return labeling::level(input, false, nbh, output, nlabels); return labeling::level(input, false, nbh, output, nlabels);
} }
......
...@@ -94,6 +94,7 @@ namespace mln ...@@ -94,6 +94,7 @@ namespace mln
Image<O>& output, Image<O>& output,
unsigned& nlabels) unsigned& nlabels)
{ {
mln_precondition(exact(output).domain() == exact(input).domain());
typedef impl::flat_zones_<I,N,O> F; typedef impl::flat_zones_<I,N,O> F;
F f(exact(input), exact(nbh), exact(output)); F f(exact(input), exact(nbh), exact(output));
canvas::labeling<F> run(f); canvas::labeling<F> run(f);
......
...@@ -66,6 +66,7 @@ namespace mln ...@@ -66,6 +66,7 @@ namespace mln
Image<O>& output, Image<O>& output,
unsigned& nlabels) unsigned& nlabels)
{ {
mln_precondition(exact(output).domain() == exact(input).domain());
return labeling::level(input, true, nbh, output, nlabels); return labeling::level(input, true, nbh, output, nlabels);
} }
......
...@@ -66,8 +66,10 @@ namespace mln ...@@ -66,8 +66,10 @@ namespace mln
namespace impl namespace impl
{ {
// Functors.
template <typename I_, typename N_, typename O_> 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; typedef mln_point(I_) P;
...@@ -84,13 +86,28 @@ namespace mln ...@@ -84,13 +86,28 @@ namespace mln
const mln_value(I_)& val; 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), : base_<I_,N_,O_>(input, nbh, output),
s(input.domain()), s(input.domain()),
val(val) 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 } // end of namespace mln::labeling::impl
...@@ -101,11 +118,7 @@ namespace mln ...@@ -101,11 +118,7 @@ namespace mln
Image<O>& output, unsigned& nlabels) Image<O>& output, unsigned& nlabels)
{ {
mln_precondition(exact(output).domain() == exact(input).domain()); mln_precondition(exact(output).domain() == exact(input).domain());
typedef impl::level_<I,N,O> F; return impl::level_(exact(input), val, nbh, output, nlabels);
F f(exact(input), val, exact(nbh), exact(output));
canvas::labeling<F> run(f);
nlabels = f.nlabels;
return f.status;
} }
# endif // ! MLN_INCLUDE_ONLY # endif // ! MLN_INCLUDE_ONLY
......
...@@ -103,6 +103,7 @@ namespace mln ...@@ -103,6 +103,7 @@ namespace mln
bool regional_maxima(const Image<I>& input, const Neighborhood<N>& nbh, bool regional_maxima(const Image<I>& input, const Neighborhood<N>& nbh,
Image<O>& output, unsigned& nlabels) Image<O>& output, unsigned& nlabels)
{ {
mln_precondition(exact(output).domain() == exact(input).domain());
typedef impl::regional_maxima_<I,N,O> F; typedef impl::regional_maxima_<I,N,O> F;
F f(exact(input), exact(nbh), exact(output)); F f(exact(input), exact(nbh), exact(output));
canvas::labeling<F> run(f); canvas::labeling<F> run(f);
......
...@@ -103,6 +103,7 @@ namespace mln ...@@ -103,6 +103,7 @@ namespace mln
bool regional_minima(const Image<I>& input, const Neighborhood<N>& nbh, bool regional_minima(const Image<I>& input, const Neighborhood<N>& nbh,
Image<O>& output, unsigned& nlabels) Image<O>& output, unsigned& nlabels)
{ {
mln_precondition(exact(output).domain() == exact(input).domain());
typedef impl::regional_minima_<I,N,O> F; typedef impl::regional_minima_<I,N,O> F;
F f(exact(input), exact(nbh), exact(output)); F f(exact(input), exact(nbh), exact(output));
canvas::labeling<F> run(f); canvas::labeling<F> run(f);
......
...@@ -54,6 +54,8 @@ namespace mln ...@@ -54,6 +54,8 @@ namespace mln
* its symmetrization is handled by the client. * its symmetrization is handled by the client.
* *
* \pre output.domain = input.domain * \pre output.domain = input.domain
*
* \todo Optimize.
*/ */
template <typename I, typename W, unsigned N, typename O> template <typename I, typename W, unsigned N, typename O>
void line_convolve(const Image<I>& input, W (&weights)[N], void line_convolve(const Image<I>& input, W (&weights)[N],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment