URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-05 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Dispatch by speed traits (was Fastest_Image).
* mln/arith/min.hh,
* mln/arith/minus.hh,
* mln/arith/plus.hh,
* mln/arith/revert.hh,
* mln/border/duplicate.hh,
* mln/border/fill.hh,
* mln/border/get.hh,
* mln/border/mirror.hh,
* mln/border/resize.hh,
* mln/debug/iota.hh,
* mln/debug/println_with_border.hh,
* mln/histo/compute.hh,
* mln/io/internal/pnm/save.hh,
* mln/labeling/level.hh,
* mln/level/apply.hh,
* mln/level/assign.hh,
* mln/level/fill.hh,
* mln/level/memset_.hh,
* mln/level/take.hh,
* mln/linear/convolve.hh,
* mln/linear/local/convolve.hh,
* mln/logical/and.hh,
* mln/logical/and_not.hh,
* mln/logical/not.hh,
* mln/logical/or.hh,
* mln/test/predicate.hh,
* tests/labeling_level_fast.cc: New dispatch system.
Fix (was identical as hline2d)
* mln/core/win/vline2d.hh: Fix.
---
mln/arith/min.hh | 38 +++++++++++++++++-------------
mln/arith/minus.hh | 38 +++++++++++++++++-------------
mln/arith/plus.hh | 48 +++++++++++++++++++++++----------------
mln/arith/revert.hh | 18 ++++++++------
mln/border/duplicate.hh | 15 +++++-------
mln/border/fill.hh | 21 ++++++++---------
mln/border/get.hh | 10 ++++----
mln/border/mirror.hh | 7 ++++-
mln/border/resize.hh | 1
mln/core/win/vline2d.hh | 4 +--
mln/debug/iota.hh | 8 ++----
mln/debug/println_with_border.hh | 19 +++++++--------
mln/histo/compute.hh | 8 ++----
mln/io/internal/pnm/save.hh | 31 +++++++++++++++++--------
mln/labeling/level.hh | 34 +++++++++------------------
mln/level/apply.hh | 9 +++----
mln/level/assign.hh | 13 ++++------
mln/level/fill.hh | 11 ++++----
mln/level/memset_.hh | 7 +++--
mln/level/take.hh | 9 +++----
mln/linear/convolve.hh | 18 +++++++-------
mln/linear/local/convolve.hh | 9 +++----
mln/logical/and.hh | 25 ++++++++++++--------
mln/logical/and_not.hh | 25 ++++++++++++--------
mln/logical/not.hh | 18 ++++++++------
mln/logical/or.hh | 25 ++++++++++++--------
mln/test/predicate.hh | 7 +++--
tests/labeling_level_fast.cc | 2 -
28 files changed, 256 insertions(+), 222 deletions(-)
Index: trunk/milena/tests/labeling_level_fast.cc
===================================================================
--- trunk/milena/tests/labeling_level_fast.cc (revision 1253)
+++ trunk/milena/tests/labeling_level_fast.cc (revision 1254)
@@ -56,7 +56,7 @@
unsigned n;
image2d_b<value::int_u8> out(i1.domain(), border);
- labeling::level_fast(i1, 2, c4(), out, n);
+ labeling::level(i1, 2, c4(), out, n);
std::cout << "n = " << n << std::endl;
debug::println(out);
Index: trunk/milena/mln/histo/compute.hh
===================================================================
--- trunk/milena/mln/histo/compute.hh (revision 1253)
+++ trunk/milena/mln/histo/compute.hh (revision 1254)
@@ -54,9 +54,8 @@
{
template <typename I>
- data<mln_vset(I)> compute(const Image<I>& input_)
+ data<mln_vset(I)> compute(mln::trait::speed::any, const I& input)
{
- const I& input = exact(input_);
data<mln_vset(I)> h(input.values());
mln_piter(I) p(input.domain());
for_all(p)
@@ -65,9 +64,8 @@
}
template <typename I>
- data<mln_vset(I)> compute(const Fastest_Image<I>& input_)
+ data<mln_vset(I)> compute(mln::trait::speed::fastest, const I& input)
{
- const I& input = exact(input_);
data<mln_vset(I)> h(input.values());
mln_pixter(const I) p(input);
for_all(p)
@@ -82,7 +80,7 @@
data<mln_vset(I)> compute(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- return impl::compute(exact(input));
+ return impl::compute(mln_trait_image_speed(I)(), exact(input));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/debug/iota.hh
===================================================================
--- trunk/milena/mln/debug/iota.hh (revision 1253)
+++ trunk/milena/mln/debug/iota.hh (revision 1254)
@@ -53,20 +53,18 @@
{
template <typename I>
- void iota(Image<I>& input_)
+ void iota(mln::trait::speed::any, I& input)
{
unsigned i = 0;
- I& input = exact(input_);
mln_piter(I) p(input.domain());
for_all(p)
input(p) = ++i;
}
template <typename I>
- void iota(Fastest_Image<I>& input_)
+ void iota(mln::trait::speed::fastest, I& input)
{
unsigned i = 0;
- I& input = exact(input_);
mln_pixter(I) p(input);
for_all(p)
p.val() = ++i;
@@ -79,7 +77,7 @@
void iota(Image<I>& input)
{
mln_precondition(exact(input).has_data());
- impl::iota(exact(input));
+ impl::iota(mln_trait_image_speed(I)(), exact(input));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/debug/println_with_border.hh
===================================================================
--- trunk/milena/mln/debug/println_with_border.hh (revision 1253)
+++ trunk/milena/mln/debug/println_with_border.hh (revision 1254)
@@ -48,7 +48,7 @@
/// Print the image \p input on the standard output.
template <typename I>
- void println_with_border(const Fastest_Image<I>& input);
+ void println_with_border(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
@@ -58,9 +58,8 @@
// generic version
template <typename S, typename I>
- void println_with_border(const S&, const Fastest_Image<I>& input_)
+ void println_with_border(const S&, const I& input)
{
- const I& input = exact(input_);
for (size_t i = 0; i < input.ncells(); i++)
std::cout << format( input.buffer()[i] ) << ' ';
std::cout << std::endl;
@@ -68,9 +67,8 @@
// 2D version
template <typename I>
- void println_with_border(const box2d& b, const Fastest_Image<I>&
input_)
+ void println_with_border(const box2d& b, const I& input)
{
- const I& input = exact(input_);
const std::size_t ncols = b.ncols() + 2 * input.border();
for (size_t i = 0; i < input.ncells(); i++)
{
@@ -83,15 +81,14 @@
// 3D version
template <typename I>
- void println_with_border(const box3d& b, const Fastest_Image<I>&
input_)
+ void println_with_border(const box3d& b, const I& input)
{
- const I& ima = exact(input_);
typedef mln_point(I) P;
std::size_t len_s = b.len(P::dim - 3);
std::size_t len_r = b.len(P::dim - 2);
std::size_t len_c = b.len(P::dim - 1);
- std::size_t border = ima.border ();
+ std::size_t border = input.border ();
std::size_t real_len_s = len_s + 2 * border;
std::size_t real_len_r = len_r + 2 * border;
std::size_t real_len_c = len_c + 2 * border;
@@ -101,7 +98,7 @@
for (std::size_t j = 0; j < real_len_r; ++j)
{
for (std::size_t i = 0; i < real_len_c; ++i)
- std::cout << format(ima[k * (real_len_r * real_len_c) + j * real_len_c + i])
+ std::cout << format(input[k * (real_len_r * real_len_c) + j * real_len_c + i])
<< ' ';
std::cout << std::endl;
}
@@ -115,8 +112,10 @@
// facade
template <typename I>
- void println_with_border(const Fastest_Image<I>& input)
+ void println_with_border(const Image<I>& input)
{
+ mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
+
impl::println_with_border(exact(input).bbox(), exact(input));
}
Index: trunk/milena/mln/core/win/vline2d.hh
===================================================================
--- trunk/milena/mln/core/win/vline2d.hh (revision 1253)
+++ trunk/milena/mln/core/win/vline2d.hh (revision 1254)
@@ -52,9 +52,9 @@
* o \n
* x \n
* o \n
- * is defined with length = 5.
+ * is defined with length = 3.
*/
- typedef line<grid::square, 1, int> vline2d;
+ typedef line<grid::square, 0, int> vline2d;
} // end of namespace mln::win
Index: trunk/milena/mln/arith/min.hh
===================================================================
--- trunk/milena/mln/arith/min.hh (revision 1253)
+++ trunk/milena/mln/arith/min.hh (revision 1254)
@@ -76,31 +76,31 @@
{
template <typename L, typename R, typename O>
- void min_(const Image<L>& lhs_, const Image<R>& rhs_,
Image<O>& output_)
+ void min_(mln::trait::speed::any, const L& lhs,
+ mln::trait::speed::any, const R& rhs,
+ mln::trait::speed::any, O& output)
{
- const L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
- O& output = exact(output_);
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) < rhs(p) ? lhs(p) : rhs(p);
}
template <typename L, typename R, typename O>
- void min_(const Fastest_Image<L>& lhs, const Fastest_Image<R>&
rhs, Fastest_Image<O>& output)
- {
- mln_pixter(const L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
- mln_pixter(O) op(exact(output));
+ void min_(mln::trait::speed::fastest, const L& lhs,
+ mln::trait::speed::fastest, const R& rhs,
+ mln::trait::speed::fastest, O& output)
+ {
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
for_all_3(lp, rp, op)
op.val() = lp.val() < rp.val() ? lp.val() : rp.val();
}
template <typename L, typename R>
- void min_inplace_(Image<L>& lhs_, const Image<R>& rhs_)
+ void min_inplace_(mln::trait::speed::any, L& lhs,
+ mln::trait::speed::any, const R& rhs)
{
- L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
mln_piter(R) p(rhs.domain());
for_all(p)
if (rhs(p) < lhs(p))
@@ -108,10 +108,11 @@
}
template <typename L, typename R>
- void min_inplace_(Fastest_Image<L>& lhs, const
Fastest_Image<R>& rhs)
+ void min_inplace_(mln::trait::speed::fastest, L& lhs,
+ mln::trait::speed::fastest, const R& rhs)
{
- mln_pixter(L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
+ mln_pixter(L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
for_all_2(rp, lp)
if (rp.val() < lp.val())
lp.val() = rp.val();
@@ -127,14 +128,17 @@
{
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_precondition(exact(output).domain() == exact(lhs).domain());
- impl::min_(exact(lhs), exact(rhs), exact(output));
+ impl::min_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(O)(), exact(output));
}
template <typename L, typename R>
void min_inplace(Image<L>& lhs, const Image<R>& rhs)
{
mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
- impl::min_inplace_(exact(lhs), exact(rhs));
+ impl::min_inplace_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/arith/plus.hh
===================================================================
--- trunk/milena/mln/arith/plus.hh (revision 1253)
+++ trunk/milena/mln/arith/plus.hh (revision 1254)
@@ -107,41 +107,42 @@
{
template <typename L, typename R, typename O>
- void plus_(const Image<L>& lhs_, const Image<R>& rhs_,
Image<O>& output_)
+ void plus_(mln::trait::speed::any, const L& lhs,
+ mln::trait::speed::any, const R& rhs,
+ mln::trait::speed::any, O& output)
{
- const L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
- O& output = exact(output_);
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) + rhs(p);
}
template <typename L, typename R, typename O>
- void plus_(const Fastest_Image<L>& lhs, const Fastest_Image<R>&
rhs, Fastest_Image<O>& output)
- {
- mln_pixter(const L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
- mln_pixter(O) op(exact(output));
+ void plus_(mln::trait::speed::fastest, const L& lhs,
+ mln::trait::speed::fastest, const R& rhs,
+ mln::trait::speed::fastest, O& output)
+ {
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
for_all_3(lp, rp, op)
op.val() = lp.val() + rp.val();
}
template <typename L, typename R>
- void plus_inplace_(Image<L>& lhs_, const Image<R>& rhs_)
+ void plus_inplace_(mln::trait::speed::any, L& lhs,
+ mln::trait::speed::any, const R& rhs)
{
- L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
mln_piter(R) p(rhs.domain());
for_all(p)
lhs(p) += rhs(p);
}
template <typename L, typename R>
- void plus_inplace_(Fastest_Image<L>& lhs, const
Fastest_Image<R>& rhs)
+ void plus_inplace_(mln::trait::speed::fastest, L& lhs,
+ mln::trait::speed::fastest, const R& rhs)
{
- mln_pixter(L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
+ mln_pixter(L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
for_all_2(rp, lp)
lp.val() += rp.val();
}
@@ -157,7 +158,9 @@
{
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_precondition(exact(output).domain() == exact(lhs).domain());
- impl::plus_(exact(lhs), exact(rhs), exact(output));
+ impl::plus_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(O)(), exact(output));
}
@@ -175,21 +178,28 @@
void plus_cst(const Image<I>& input, const V& val, Image<O>&
output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- plus(input, pw::cst(val) | exact(input).domain(), output); // Calls the previous
version.
+ trait::speed::any any;
+ impl::plus_(mln_trait_image_speed(I)(), exact(input),
+ any, pw::cst(val) | exact(input).domain(),
+ mln_trait_image_speed(O)(), exact(output)); // Calls the previous version.
}
template <typename L, typename R>
void plus_inplace(Image<L>& lhs, const Image<R>& rhs)
{
mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
- impl::plus_inplace_(exact(lhs), exact(rhs));
+ impl::plus_inplace_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs));
}
template <typename I, typename V>
void plus_cst_inplace(Image<I>& input, const V& val)
{
mln_precondition(exact(input).has_data());
- plus_inplace(input, pw::cst(val) | exact(input).domain()); // Calls the previous
version.
+ trait::speed::any any;
+ plus_inplace(mln_trait_image_speed(I)(), exact(input),
+ any, pw::cst(val) | exact(input).domain());
+ // Calls the previous version.
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/arith/revert.hh
===================================================================
--- trunk/milena/mln/arith/revert.hh (revision 1253)
+++ trunk/milena/mln/arith/revert.hh (revision 1254)
@@ -78,10 +78,9 @@
{
template <typename I, typename O>
- void revert_(const Image<I>& input_, Image<O>& output_)
+ void revert_(mln::trait::speed::any, const I& input,
+ mln::trait::speed::any, O& output)
{
- const I& input = exact(input_);
- O& output = exact(output_);
typedef mln_value(I) V;
mln_piter(I) p(input.domain());
for_all(p)
@@ -89,11 +88,12 @@
}
template <typename I, typename O>
- void revert_(const Fastest_Image<I>& input, Fastest_Image<O>&
output)
+ void revert_(mln::trait::speed::fastest, const I& input,
+ mln::trait::speed::fastest, O& output)
{
typedef mln_value(I) V;
- mln_pixter(const I) ip(exact(input));
- mln_pixter(O) op(exact(output));
+ mln_pixter(const I) ip(input);
+ mln_pixter(O) op(output);
for_all_2(ip, op)
op.val() = mln_min(V) + (mln_max(V) - ip.val());
}
@@ -107,14 +107,16 @@
void revert(const Image<I>& input, Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- impl::revert_(exact(input), exact(output));
+ impl::revert_(mln_trait_image_speed(I)(), exact(input),
+ mln_trait_image_speed(O)(), exact(output));
}
template <typename I>
void revert_inplace(Image<I>& input)
{
mln_precondition(exact(input).has_data());
- impl::revert_(exact(input), exact(input));
+ impl::revert_(mln_trait_image_speed(I)(), exact(input),
+ mln_trait_image_speed(I)(), exact(input));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/arith/minus.hh
===================================================================
--- trunk/milena/mln/arith/minus.hh (revision 1253)
+++ trunk/milena/mln/arith/minus.hh (revision 1254)
@@ -75,41 +75,42 @@
{
template <typename L, typename R, typename O>
- void minus_(const Image<L>& lhs_, const Image<R>& rhs_,
Image<O>& output_)
+ void minus_(mln::trait::speed::any, const L& lhs,
+ mln::trait::speed::any, const R& rhs,
+ mln::trait::speed::any, O& output)
{
- const L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
- O& output = exact(output_);
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) - rhs(p);
}
template <typename L, typename R, typename O>
- void minus_(const Fastest_Image<L>& lhs, const
Fastest_Image<R>& rhs, Fastest_Image<O>& output)
- {
- mln_pixter(const L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
- mln_pixter(O) op(exact(output));
+ void minus_(mln::trait::speed::fastest, const L& lhs,
+ mln::trait::speed::fastest, const R& rhs,
+ mln::trait::speed::fastest, O& output)
+ {
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
for_all_3(lp, rp, op)
op.val() = lp.val() - rp.val();
}
template <typename L, typename R>
- void minus_inplace_(Image<L>& lhs_, const Image<R>& rhs_)
+ void minus_inplace_(mln::trait::speed::any, L& lhs,
+ mln::trait::speed::any, const R& rhs)
{
- L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
mln_piter(R) p(rhs.domain());
for_all(p)
lhs(p) -= rhs(p);
}
template <typename L, typename R>
- void minus_inplace_(Fastest_Image<L>& lhs, const
Fastest_Image<R>& rhs)
+ void minus_inplace_(mln::trait::speed::fastest, L& lhs,
+ mln::trait::speed::fastest, const R& rhs)
{
- mln_pixter(L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
+ mln_pixter(L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
for_all_2(rp, lp)
lp.val() -= rp.val();
}
@@ -124,14 +125,17 @@
{
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_precondition(exact(output).domain() == exact(lhs).domain());
- impl::minus_(exact(lhs), exact(rhs), exact(output));
+ impl::minus_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(O)(), exact(output));
}
template <typename L, typename R>
void minus_inplace(Image<L>& lhs, const Image<R>& rhs)
{
mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
- impl::minus_inplace_(exact(lhs), exact(rhs));
+ impl::minus_inplace_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/take.hh
===================================================================
--- trunk/milena/mln/level/take.hh (revision 1253)
+++ trunk/milena/mln/level/take.hh (revision 1254)
@@ -63,18 +63,16 @@
{
template <typename A, typename I>
- void take(const Image<I>& input_, A& a)
+ void take(mln::trait::speed::any, const I& input, A& a)
{
- const I& input = exact(input_);
mln_piter(I) p(input.domain());
for_all(p)
a.take(input(p));
}
template <typename A, typename I>
- void take(const Fastest_Image<I>& input_, A& a)
+ void take(mln::trait::speed::fastest, const I& input, A& a)
{
- const I& input = exact(input_);
mln_pixter(const I) pxl(input);
for_all(pxl)
a.take(pxl.val());
@@ -89,7 +87,8 @@
void take(const Image<I>& input, Accumulator<A>& a)
{
mln_precondition(exact(input).has_data());
- impl::take(exact(input), exact(a));
+ impl::take(mln_trait_image_speed(I)(), exact(input),
+ exact(a));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/assign.hh
===================================================================
--- trunk/milena/mln/level/assign.hh (revision 1253)
+++ trunk/milena/mln/level/assign.hh (revision 1254)
@@ -65,20 +65,18 @@
{
template <typename L, typename R>
- void assign(Image<L>& target_, const Image<R>& data_)
+ void assign(mln::trait::speed::any, L& target,
+ mln::trait::speed::any, const R& data)
{
- L& target = exact(target_);
- const R& data = exact(data_);
mln_piter(L) p(target.domain());
for_all(p)
target(p) = data(p);
}
template <typename L, typename R>
- void assign(Fastest_Image<L>& target_, const Fastest_Image<R>&
data_)
+ void assign(mln::trait::speed::fastest, L& target,
+ mln::trait::speed::fastest, const R& data)
{
- L& target = exact(target_);
- const R& data = exact(data_);
mln_pixter(L) lhs(target);
mln_pixter(const R) rhs(data);
for_all_2(lhs, rhs)
@@ -92,7 +90,8 @@
void assign(Image<L>& target, const Image<R>& data)
{
mln_precondition(exact(data).domain() == exact(target).domain());
- impl::assign(exact(target), exact(data));
+ impl::assign(mln_trait_image_speed(L)(), exact(target),
+ mln_trait_image_speed(R)(), exact(data));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/apply.hh
===================================================================
--- trunk/milena/mln/level/apply.hh (revision 1253)
+++ trunk/milena/mln/level/apply.hh (revision 1254)
@@ -67,18 +67,16 @@
{
template <typename I, typename F>
- void apply_(Image<I>& input_, const F& f)
+ void apply_(mln::trait::speed::any, I& input, const F& f)
{
- I& input = exact(input_);
mln_piter(I) p(input.domain());
for_all(p)
input(p) = f(input(p));
}
template <typename I, typename F>
- void apply_(Fastest_Image<I>& input_, const F& f)
+ void apply_(mln::trait::speed::fastest, I& input, const F& f)
{
- I& input = exact(input_);
mln_pixter(I) pxl(input);
for_all(pxl)
pxl.val() = f(pxl.val());
@@ -93,7 +91,8 @@
void apply(Image<I>& input, const Function_v2v<F>& f)
{
mln_precondition(exact(input).has_data());
- impl::apply_(exact(input), exact(f));
+ impl::apply_(mln_trait_image_speed(I)(), exact(input),
+ exact(f));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/fill.hh
===================================================================
--- trunk/milena/mln/level/fill.hh (revision 1253)
+++ trunk/milena/mln/level/fill.hh (revision 1254)
@@ -132,18 +132,18 @@
// fill_with_value
template <typename I>
- void fill_with_value(Image<I>& ima_, const mln_value(I)& value)
+ void fill_with_value(mln::trait::speed::any, I& ima,
+ const mln_value(I)& value)
{
- I& ima = exact(ima_);
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = value;
}
template <typename I>
- void fill_with_value(Fastest_Image<I>& ima_, const mln_value(I)&
value)
+ void fill_with_value(mln::trait::speed::fastest, I& ima,
+ const mln_value(I)& value)
{
- I& ima = exact(ima_);
level::memset_(ima, ima.point_at_offset(0), value, ima.ncells());
}
@@ -159,7 +159,8 @@
{
mlc_is(mln_trait_image_io(I), trait::io::write)::check(); // FIXME: Only the
upcoming general facade!!!
mln_precondition(exact(ima).has_data());
- impl::fill_with_value(exact(ima), value);
+ impl::fill_with_value(mln_trait_image_speed(I)(), exact(ima),
+ value);
}
Index: trunk/milena/mln/level/memset_.hh
===================================================================
--- trunk/milena/mln/level/memset_.hh (revision 1253)
+++ trunk/milena/mln/level/memset_.hh (revision 1254)
@@ -66,7 +66,7 @@
* \pre \p input has to be initialized. FIXME: More.
*/
template <typename I>
- void memset_(Fastest_Image<I>& input, const mln_point(I)& p,
+ void memset_(I& input, const mln_point(I)& p,
const mln_value(I)& v, std::size_t n);
@@ -111,10 +111,11 @@
}
template <typename I>
- void memset_(Fastest_Image<I>& input_, const mln_point(I)& p,
+ void memset_(I& input, const mln_point(I)& p,
const mln_value(I)& v, std::size_t n)
{
- I& input = exact(input_);
+ mlc_is(mln_trait_image_speed(I), trait::speed::fastest)::check();
+
mln_precondition(input.has_data());
mln_precondition(input.owns_(p));
mln_precondition(input.offset_at(p) + n <= input.ncells());
Index: trunk/milena/mln/linear/convolve.hh
===================================================================
--- trunk/milena/mln/linear/convolve.hh (revision 1253)
+++ trunk/milena/mln/linear/convolve.hh (revision 1254)
@@ -67,12 +67,11 @@
{
template <typename I, typename W, typename O>
- void convolve_(const Image<I>& input_, const
Weighted_Window<W>& w_win_,
- Image<O>& output_)
+ void convolve_(mln::trait::speed::any, const I& input,
+ const Weighted_Window<W>& w_win_,
+ mln::trait::speed::any, O& output)
{
- const I& input = exact(input_);
const W& w_win = exact(w_win_);
- O& output = exact(output_);
mln_piter(I) p(input.domain());
mln_qiter(W) q(w_win, p);
@@ -87,12 +86,11 @@
}
template <typename I, typename W, typename O>
- void convolve_(const Fastest_Image<I>& input_, const
Weighted_Window<W>& w_win_,
- Fastest_Image<O>& output_)
+ void convolve_(mln::trait::speed::fastest, const I& input,
+ const Weighted_Window<W>& w_win_,
+ mln::trait::speed::fastest, O& output)
{
- const I& input = exact(input_);
const W& w_win = exact(w_win_);
- O& output = exact(output_);
border::resize(input, w_win.delta());
border::duplicate(input);
@@ -122,7 +120,9 @@
Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- impl::convolve_(exact(input), exact(w_win), exact(output));
+ impl::convolve_(mln_trait_image_speed(I)(), exact(input),
+ exact(w_win),
+ mln_trait_image_speed(O)(), exact(output));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/linear/local/convolve.hh
===================================================================
--- trunk/milena/mln/linear/local/convolve.hh (revision 1253)
+++ trunk/milena/mln/linear/local/convolve.hh (revision 1254)
@@ -87,12 +87,11 @@
{
template <typename I, typename P, typename W, typename R>
- void convolve(const Image<I>& input_,
+ void convolve(mln::trait::speed::any, const I& input,
const Generalized_Point<P>& p_,
const W& w_win,
R& result)
{
- const I& input = exact(input_);
const P& p = internal::force_exact<P>(p_);
R tmp = 0; // FIXME: zero?
@@ -103,12 +102,11 @@
}
template <typename I, typename P, typename W, typename R>
- void convolve(const Fastest_Image<I>& input_,
+ void convolve(mln::trait::speed::fastest, const I& input,
const Generalized_Point<P>& p_,
const W& w_win,
R& result)
{
- const I& input = exact(input_);
const P& p = internal::force_exact<P>(p_);
mln_precondition(input.border() >= w_win.delta());
@@ -151,7 +149,8 @@
R& result)
{
mln_precondition(exact(input).has_data());
- impl::convolve(exact(input), p, exact(w_win), result);
+ impl::convolve(mln_trait_image_speed(I)(), exact(input),
+ p, exact(w_win), result);
}
template <typename P, typename W, typename R>
Index: trunk/milena/mln/border/resize.hh
===================================================================
--- trunk/milena/mln/border/resize.hh (revision 1253)
+++ trunk/milena/mln/border/resize.hh (revision 1254)
@@ -67,6 +67,7 @@
{
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
+ mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
if (ima.border() >= thickness)
return;
mln::internal::fixme();
Index: trunk/milena/mln/border/fill.hh
===================================================================
--- trunk/milena/mln/border/fill.hh (revision 1253)
+++ trunk/milena/mln/border/fill.hh (revision 1254)
@@ -53,7 +53,7 @@
* \todo Implement it + optimize with memset if possible.
*/
template <typename I>
- void fill(const Fastest_Image<I>& ima, const mln_value(I)& v);
+ void fill(const Image<I>& ima, const mln_value(I)& v);
# ifndef MLN_INCLUDE_ONLY
@@ -61,13 +61,12 @@
{
template <typename I>
- void fill_size_1_(const Fastest_Image<I>& ima_, const mln_value(I)&
v)
+ void fill_size_1_(const I& ima, const mln_value(I)& v)
{
typedef mln_point(I) P;
- const I& ima = exact(ima_);
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
- std::size_t len_r = exact(ima).bbox().len(P::dim - 1);
+ std::size_t len_r = ima.bbox().len(P::dim - 1);
std::size_t st = 0;
for_all (pl)
@@ -84,13 +83,11 @@
}
template <typename I>
- void fill_size_n_(const Fastest_Image<I>& ima_, const mln_value(I)&
v)
+ void fill_size_n_(const I& ima, const mln_value(I)& v)
{
typedef mln_point(I) P;
- const I& ima = exact(ima_);
- typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
- std::size_t len_r = exact(ima).bbox().len(P::dim - 1);
+ std::size_t len_r = ima.bbox().len(P::dim - 1);
std::size_t st = 0;
for_all (pl)
@@ -108,18 +105,20 @@
// Facade.
template <typename I>
- void fill(const Fastest_Image<I>& ima_, const mln_value(I)& v)
+ void fill(const Image<I>& ima_, const mln_value(I)& v)
{
trace::entering("border::fill");
typedef mln_point(I) P;
const I& ima = exact(ima_);
+
+ mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
mln_precondition(ima.has_data());
if (!ima.border ())
return;
if (sizeof(mln_value(I)) == 1)
- impl::fill_size_1_(ima_, v);
+ impl::fill_size_1_(ima, v);
else
- impl::fill_size_n_(ima_, v);
+ impl::fill_size_n_(ima, v);
trace::exiting("border::fill");
}
Index: trunk/milena/mln/border/duplicate.hh
===================================================================
--- trunk/milena/mln/border/duplicate.hh (revision 1253)
+++ trunk/milena/mln/border/duplicate.hh (revision 1254)
@@ -55,7 +55,7 @@
* \todo Implement it + optimize with memcpy if possible.
*/
template <typename I>
- void duplicate(const Fastest_Image<I>& ima);
+ void duplicate(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
@@ -64,9 +64,8 @@
{
template <typename I>
- void duplicate_1d_(const Fastest_Image<I>& ima_)
+ void duplicate_1d_(const I& ima)
{
- const I& ima = exact(ima_);
mln_precondition(ima.has_data());
typedef mln_point(I) P;
@@ -83,9 +82,8 @@
}
template <typename I>
- void duplicate_2d_(const Fastest_Image<I>& ima_)
+ void duplicate_2d_(const I& ima)
{
- const I& ima = exact(ima_);
mln_precondition(ima.has_data());
typedef mln_point(I) P;
@@ -196,15 +194,16 @@
typedef mln_point(I) P;
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
+ mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
if (!ima.border ())
return;
if (P::dim == 1)
- impl::duplicate_1d_(ima_);
+ impl::duplicate_1d_(ima);
if (P::dim == 2)
- impl::duplicate_2d_(ima_);
+ impl::duplicate_2d_(ima);
if (P::dim == 3)
- impl::duplicate_3d_(ima_);
+ impl::duplicate_3d_(ima);
trace::exiting("border::duplicate");
}
Index: trunk/milena/mln/border/mirror.hh
===================================================================
--- trunk/milena/mln/border/mirror.hh (revision 1253)
+++ trunk/milena/mln/border/mirror.hh (revision 1254)
@@ -53,15 +53,18 @@
* \todo Implement it + optimize with memset if possible.
*/
template <typename I>
- void mirror(const Fastest_Image<I>& ima);
+ void mirror(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
- void mirror(const Fastest_Image<I>& ima_)
+ void mirror(const Image<I>& ima_)
{
const I& ima = exact(ima_);
+
+ mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
+
mln_precondition(ima.has_data());
mln::internal::fixme();
}
Index: trunk/milena/mln/border/get.hh
===================================================================
--- trunk/milena/mln/border/get.hh (revision 1253)
+++ trunk/milena/mln/border/get.hh (revision 1254)
@@ -69,15 +69,15 @@
}
template <typename I>
- unsigned get_(const Image<I>& ima)
+ unsigned get_(mln::trait::speed::any, const I& ima)
{
- return border::impl::get__(exact(ima));
+ return border::impl::get__(ima);
}
template <typename I>
- unsigned get_(const Fastest_Image<I>& ima)
+ unsigned get_(mln::trait::speed::fastest, const I& ima)
{
- return exact(ima).border();
+ return ima.border();
}
} // end of namespace mln::border::impl
@@ -89,7 +89,7 @@
unsigned get(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return border::impl::get_(exact(ima));
+ return border::impl::get_(mln_trait_image_speed(I)(), exact(ima));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/test/predicate.hh
===================================================================
--- trunk/milena/mln/test/predicate.hh (revision 1253)
+++ trunk/milena/mln/test/predicate.hh (revision 1254)
@@ -69,7 +69,7 @@
{
template <typename I, typename F>
- bool predicate_(const Image<I>& ima_, const F& f)
+ bool predicate_(mln::trait::speed::any, const I& ima_, const F& f)
{
const I& ima = exact(ima_);
mln_piter(I) p(ima.domain());
@@ -80,7 +80,7 @@
}
template <typename I, typename F>
- bool predicate_(const Fastest_Image<I>& ima_, const F& f)
+ bool predicate_(mln::trait::speed::fastest, const I& ima_, const F& f)
{
const I& ima = exact(ima_);
mln_pixter(const I) pxl(ima);
@@ -109,7 +109,8 @@
bool predicate(const Image<I>& ima, const Function_v2b<F>& f)
{
mln_precondition(exact(ima).has_data());
- return impl::predicate_(exact(ima), exact(f));
+ return impl::predicate_(mln_trait_image_speed(I)(), exact(ima),
+ exact(f));
}
template <typename S, typename F>
Index: trunk/milena/mln/io/internal/pnm/save.hh
===================================================================
--- trunk/milena/mln/io/internal/pnm/save.hh (revision 1253)
+++ trunk/milena/mln/io/internal/pnm/save.hh (revision 1254)
@@ -65,8 +65,16 @@
namespace pnm
{
+ // FIXME: Doc.
+ template <typename I>
+ void save(const int type, const Image<I>& ima_, const std::string&
filename);
+
+
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
// write a rgb value into for uncontiguous datas
template <unsigned int n>
void write_value(std::ofstream& file,
@@ -96,10 +104,8 @@
// save data for (sizeof(int_u8) != 1) and non fastest images
template <typename I>
void save_data_uncontiguous(std::ofstream& file,
- const Image< I >& ima_)
+ const I& ima)
{
- const I& ima = exact(ima_);
-
const int
min_row = geom::min_row(ima),
max_row = geom::max_row(ima),
@@ -116,7 +122,7 @@
// (faster)
template <typename I>
void save_data_contiguous(std::ofstream& file,
- const Fastest_Image<I>& ima_)
+ const I& ima_)
{
const I& ima = exact(ima_);
const int
@@ -132,8 +138,8 @@
// caller for fastest images
template <typename I>
- void save_data(std::ofstream& file,
- const Fastest_Image<I>& ima)
+ void save_data_(std::ofstream& file,
+ mln::trait::speed::fastest, const I& ima)
{
if (sizeof(value::int_u8) == 1)
save_data_contiguous(file, ima);
@@ -143,13 +149,17 @@
// caller for non fastest images
template <typename I>
- void save_data(std::ofstream& file,
- const Image<I>& ima)
+ void save_data_(std::ofstream& file,
+ mln::trait::speed::any, const I& ima)
{
save_data_uncontiguous(file, ima);
}
- // main function : save header and data
+ } // end of namespace mln::io::internal::pnm::impl
+
+
+ // Facades.
+
template <typename I>
void save(const int type, const Image<I>& ima_, const std::string&
filename)
{
@@ -157,7 +167,8 @@
std::ofstream file(filename.c_str());
io::internal::pnm::save_header(type, ima, filename, file);
- save_data(file, ima);
+ impl::save_data_(file,
+ mln_trait_image_speed(I)(), ima);
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/logical/and.hh
===================================================================
--- trunk/milena/mln/logical/and.hh (revision 1253)
+++ trunk/milena/mln/logical/and.hh (revision 1254)
@@ -77,22 +77,23 @@
{
template <typename L, typename R, typename O>
- void and__(const Image<L>& lhs_, const Image<R>& rhs_,
Image<O>& output_)
+ void and__(mln::trait::speed::any, const L& lhs,
+ mln::trait::speed::any, const R& rhs,
+ mln::trait::speed::any, O& output)
{
- const L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
- O& output = exact(output_);
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) && rhs(p);
}
template <typename L, typename R, typename O>
- void and__(const Fastest_Image<L>& lhs, const Fastest_Image<R>&
rhs, Fastest_Image<O>& output)
+ void and__(mln::trait::speed::fastest, const L& lhs,
+ mln::trait::speed::fastest, const R& rhs,
+ mln::trait::speed::fastest, O& output)
{
- mln_pixter(const L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
- mln_pixter(O) op(exact(output));
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
for_all_3(lp, rp, op)
op.val() = lp.val() && rp.val();
}
@@ -107,14 +108,18 @@
{
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_precondition(exact(output).domain() == exact(lhs).domain());
- impl::and__(exact(lhs), exact(rhs), exact(output));
+ impl::and__(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(O)(), exact(output));
}
template <typename L, typename R>
void and_inplace(Image<L>& lhs, const Image<R>& rhs)
{
mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
- impl::and__(exact(lhs), exact(rhs), exact(lhs));
+ impl::and__(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(L)(), exact(lhs));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/logical/and_not.hh
===================================================================
--- trunk/milena/mln/logical/and_not.hh (revision 1253)
+++ trunk/milena/mln/logical/and_not.hh (revision 1254)
@@ -77,22 +77,23 @@
{
template <typename L, typename R, typename O>
- void and_not_(const Image<L>& lhs_, const Image<R>& rhs_,
Image<O>& output_)
+ void and_not_(mln::trait::speed::any, const L& lhs,
+ mln::trait::speed::any, const R& rhs,
+ mln::trait::speed::any, O& output)
{
- const L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
- O& output = exact(output_);
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) && ! rhs(p);
}
template <typename L, typename R, typename O>
- void and_not_(const Fastest_Image<L>& lhs, const
Fastest_Image<R>& rhs, Fastest_Image<O>& output)
+ void and_not_(mln::trait::speed::fastest, const L& lhs,
+ mln::trait::speed::fastest, const R& rhs,
+ mln::trait::speed::fastest, O& output)
{
- mln_pixter(const L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
- mln_pixter(O) op(exact(output));
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
for_all_3(lp, rp, op)
op.val() = lp.val() && ! rp.val();
}
@@ -107,14 +108,18 @@
{
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_precondition(exact(output).domain() == exact(lhs).domain());
- impl::and_not_(exact(lhs), exact(rhs), exact(output));
+ impl::and_not_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(O)(), exact(output));
}
template <typename L, typename R>
void and_not_inplace(Image<L>& lhs, const Image<R>& rhs)
{
mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
- impl::and_not_(exact(lhs), exact(rhs), exact(lhs));
+ impl::and_not_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(L)(), exact(lhs));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/logical/or.hh
===================================================================
--- trunk/milena/mln/logical/or.hh (revision 1253)
+++ trunk/milena/mln/logical/or.hh (revision 1254)
@@ -77,22 +77,23 @@
{
template <typename L, typename R, typename O>
- void or__(const Image<L>& lhs_, const Image<R>& rhs_,
Image<O>& output_)
+ void or__(mln::trait::speed::any, const L& lhs,
+ mln::trait::speed::any, const R& rhs,
+ mln::trait::speed::any, O& output)
{
- const L& lhs = exact(lhs_);
- const R& rhs = exact(rhs_);
- O& output = exact(output_);
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) || rhs(p);
}
template <typename L, typename R, typename O>
- void or__(const Fastest_Image<L>& lhs, const Fastest_Image<R>&
rhs, Fastest_Image<O>& output)
+ void or__(mln::trait::speed::fastest, const L& lhs,
+ mln::trait::speed::fastest, const R& rhs,
+ mln::trait::speed::fastest, O& output)
{
- mln_pixter(const L) lp(exact(lhs));
- mln_pixter(const R) rp(exact(rhs));
- mln_pixter(O) op(exact(output));
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
for_all_3(lp, rp, op)
op.val() = lp.val() || rp.val();
}
@@ -107,14 +108,18 @@
{
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_precondition(exact(output).domain() == exact(lhs).domain());
- impl::or__(exact(lhs), exact(rhs), exact(output));
+ impl::or__(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(O)(), exact(output));
}
template <typename L, typename R>
void or_inplace(Image<L>& lhs, const Image<R>& rhs)
{
mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
- impl::or__(exact(lhs), exact(rhs), exact(lhs));
+ impl::or__(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(L)(), exact(lhs));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/logical/not.hh
===================================================================
--- trunk/milena/mln/logical/not.hh (revision 1253)
+++ trunk/milena/mln/logical/not.hh (revision 1254)
@@ -73,20 +73,20 @@
{
template <typename I, typename O>
- void not__(const Image<I>& input_, Image<O>& output_)
+ void not__(mln::trait::speed::any, const I& input,
+ mln::trait::speed::any, O& output)
{
- const I& input = exact(input_);
- O& output = exact(output_);
mln_piter(I) p(input.domain());
for_all(p)
output(p) = ! input(p);
}
template <typename I, typename O>
- void not__(const Fastest_Image<I>& input, Fastest_Image<O>&
output)
+ void not__(mln::trait::speed::fastest, const I& input,
+ mln::trait::speed::fastest, O& output)
{
- mln_pixter(const I) ip(exact(input));
- mln_pixter(O) op(exact(output));
+ mln_pixter(const I) ip(input);
+ mln_pixter(O) op(output);
for_all_2(ip, op)
op.val() = ! ip.val();
}
@@ -100,14 +100,16 @@
void not_(const Image<I>& input, Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- impl::not__(exact(input), exact(output));
+ impl::not__(mln_trait_image_speed(I)(), exact(input),
+ mln_trait_image_speed(O)(), exact(output));
}
template <typename I>
void not_inplace(Image<I>& input)
{
mln_precondition(exact(input).has_data());
- impl::not__(exact(input), exact(input));
+ impl::not__(mln_trait_image_speed(I)(), exact(input),
+ mln_trait_image_speed(I)(), exact(input));
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/labeling/level.hh
===================================================================
--- trunk/milena/mln/labeling/level.hh (revision 1253)
+++ trunk/milena/mln/labeling/level.hh (revision 1254)
@@ -61,11 +61,6 @@
bool level(const Image<I>& input, const mln_value(I)& val, const
Neighborhood<N>& nbh,
Image<O>& output, unsigned& nlabels);
- template <typename I, typename N, typename O>
- bool level_fast(const Fastest_Image<I>& input, const mln_value(I)& val,
const Neighborhood<N>& nbh,
- Fastest_Image<O>& output, unsigned& nlabels);
-
-
# ifndef MLN_INCLUDE_ONLY
namespace impl
@@ -101,11 +96,12 @@
// 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)
+ bool level_(mln::trait::speed::any, const I& input,
+ const mln_value(I)& val, const Neighborhood<N>& nbh,
+ mln::trait::speed::any, O& output, unsigned& nlabels)
{
typedef impl::level_t<I,N,O> F;
- F f(exact(input), val, exact(nbh), exact(output));
+ F f(input, val, exact(nbh), output);
canvas::labeling<F> run(f);
nlabels = f.nlabels;
return f.status;
@@ -136,20 +132,19 @@
template <typename I, typename N, typename O>
- bool level_fast_(const Fastest_Image<I>& input, const mln_value(I)&
val, const Neighborhood<N>& nbh,
- Fastest_Image<O>& output, unsigned& nlabels)
+ bool level_(mln::trait::speed::fastest, const I& input,
+ const mln_value(I)& val, const Neighborhood<N>& nbh,
+ mln::trait::speed::fastest, O& output, unsigned& nlabels)
{
typedef level_fast_t<I,N,O> F;
- F f(exact(input), val, exact(nbh), exact(output));
+ F f(input, val, exact(nbh), output);
canvas::labeling_fast<F> run(f);
nlabels = f.nlabels;
return f.status;
}
-
} // end of namespace mln::labeling::impl
-
// Facade.
template <typename I, typename N, typename O>
@@ -157,15 +152,10 @@
Image<O>& output, unsigned& nlabels)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- return impl::level_(exact(input), val, nbh, output, nlabels);
- }
-
- template <typename I, typename N, typename O>
- bool level_fast(const Fastest_Image<I>& input, const mln_value(I)& val,
const Neighborhood<N>& nbh,
- Fastest_Image<O>& output, unsigned& nlabels)
- {
- mln_precondition(exact(output).domain() == exact(input).domain());
- return impl::level_fast_(exact(input), val, nbh, output, nlabels);
+ return impl::level_(mln_trait_image_speed(I)(), exact(input),
+ val, nbh,
+ mln_trait_image_speed(O)(), exact(output),
+ nlabels);
}
# endif // ! MLN_INCLUDE_ONLY