* tests/level/fill_with_image.cc,
* tests/level/transform.cc,
* tests/level/paste.cc: Add tests.
* mln/core/image/cast_image.hh: Update properties.
* mln/level/transform.spe.hh,
* mln/level/paste.spe.hh,
* mln/level/fill_with_image.spe.hh: Update dispatch, fix bugs.
* mln/level/transform.hh,
* mln/level/paste.hh: Rename routines.
---
milena/ChangeLog | 14 ++
milena/mln/core/image/cast_image.hh | 12 ++
milena/mln/level/fill_with_image.spe.hh | 113 ++++++++++++----
milena/mln/level/paste.hh | 2 +-
milena/mln/level/paste.spe.hh | 117 ++++++++++++-----
milena/mln/level/transform.hh | 2 +-
milena/mln/level/transform.spe.hh | 225 +++++++++++++++++++------------
milena/tests/level/fill_with_image.cc | 139 ++++++++++++++++++-
milena/tests/level/paste.cc | 122 ++++++++++++++++-
milena/tests/level/transform.cc | 62 +++++++++-
10 files changed, 652 insertions(+), 156 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 35f360b..2c1de6a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,17 @@
+2008-10-27 Nicolas Ballas <ballas(a)lrde.epita.fr>
+
+ Fix bugs in low level routines.
+
+ * tests/level/fill_with_image.cc,
+ * tests/level/transform.cc,
+ * tests/level/paste.cc: Add tests.
+ * mln/core/image/cast_image.hh: Update properties.
+ * mln/level/transform.spe.hh,
+ * mln/level/paste.spe.hh,
+ * mln/level/fill_with_image.spe.hh: Update dispatch, fix bugs.
+ * mln/level/transform.hh,
+ * mln/level/paste.hh: Rename routines.
+
2008-10-24 Roland Levillain <roland(a)lrde.epita.fr>
Fix mln::level::stretch w.r.t. the initialization.
diff --git a/milena/mln/core/image/cast_image.hh b/milena/mln/core/image/cast_image.hh
index 6de5892..d5baa8d 100644
--- a/milena/mln/core/image/cast_image.hh
+++ b/milena/mln/core/image/cast_image.hh
@@ -91,8 +91,20 @@ namespace mln
struct image_< cast_image_<T,I> > :
cast_image_trait_selector<T, I, mln_trait_image_vw_io(I)>
{
+ private:
+ typedef mlc_equal(mln_trait_value_quant(T),
+ trait::value::quant::high) is_high_quant_;
+ public:
+ typedef mlc_if(is_high_quant_,
+ trait::image::quant::high,
+ trait::image::quant::low) quant;
+
typedef trait::image::value_io::read_only value_io;
typedef trait::image::pw_io::read pw_io;
+ typedef trait::image::value_access::indirect value_access;
+
+ /// FIXME is the following property correct?
+ typedef trait::image::ext_domain::none ext_domain;
};
} // end of namespace mln::trait
diff --git a/milena/mln/level/fill_with_image.spe.hh
b/milena/mln/level/fill_with_image.spe.hh
index 846da96..6084e72 100644
--- a/milena/mln/level/fill_with_image.spe.hh
+++ b/milena/mln/level/fill_with_image.spe.hh
@@ -86,9 +86,31 @@ namespace mln
for_all(pi)
{
pi.val() = d.val();
+ d.next();
}
trace::entering("level::impl::fill_with_image_fast");
}
+
+
+ template <typename I, typename J>
+ void fill_with_image_fast_singleton(Image<I>& ima_,
+ const Image<J>& data_)
+ {
+ trace::entering("level::impl::fill_with_image_fast_singleton");
+
+ I& ima = exact(ima_);
+ const J& data = exact(data_);
+
+ level::internal::fill_with_image_tests(ima, data);
+
+ mln_pixter(I) pi(ima);
+
+ for_all(pi)
+ pi.val() = data.val();
+
+ trace::entering("level::impl::fill_with_image_fast_singleton");
+ }
+
} // end of namespace mln::level::impl
@@ -99,6 +121,49 @@ namespace mln
template <typename I, typename J>
inline
+ void fill_with_image_(mln::trait::image::value_access::direct,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_domain::some,
+ Image<I>& ima_,
+ const Image<J>& data_)
+ {
+ I& ima = exact(ima_);
+ const J& data = exact(data_);
+
+ if (ima.domain() == data.domain())
+ impl::fill_with_image_fast(ima, data);
+ else
+ impl::generic::fill_with_image(ima, data);
+ }
+
+ template <typename I, typename J>
+ inline
+ void fill_with_image_(mln::trait::image::value_access::direct,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::ext_domain::none,
+ mln::trait::image::ext_domain::none,
+ Image<I>& ima,
+ const Image<J>& data)
+ {
+ impl::fill_with_image_fast(ima, data);
+ }
+
+
+ template <typename I, typename J>
+ inline
+ void fill_with_image_(mln::trait::image::value_access::any,
+ mln::trait::image::value_access::any,
+ mln::trait::image::ext_domain::any,
+ mln::trait::image::ext_domain::any,
+ Image<I>& ima,
+ const Image<J>& data)
+ {
+ impl::generic::fill_with_image(ima, data);
+ }
+
+ template <typename I, typename J>
+ inline
void fill_with_image_(trait::image::value_storage::any,
trait::image::value_storage::any,
Image<I>& ima,
@@ -110,49 +175,41 @@ namespace mln
template <typename I, typename J>
inline
void fill_with_image_(trait::image::value_storage::one_block,
- trait::image::value_storage::one_block,
+ trait::image::value_storage::singleton,
+ Image<I>& ima,
+ const Image<J>& data)
+ {
+ impl::generic::fill_with_image(ima, data);
+ }
+
+ template <typename I, typename J>
+ inline
+ void fill_with_image_(mln::trait::image::value_storage::one_block,
+ mln::trait::image::value_storage::one_block,
Image<I>& ima_,
const Image<J>& data_)
{
I& ima = exact(ima_);
const J& data = exact(data_);
+
/// Check basic properties
- if (mlc_is(mln_trait_image_value_access(J),
- trait::image::value_access::direct)::value &&
- mlc_is(mln_trait_image_value_access(I),
- trait::image::value_access::direct)::value &&
- mlc_is(mln_trait_image_value_alignement(I),
+ if (mlc_is(mln_trait_image_value_alignement(I),
trait::image::value_alignement::with_grid)::value &&
mlc_is(mln_trait_image_value_alignement(J),
trait::image::value_alignement::with_grid)::value)
{
- /// Check ext_domain
- if (
- ((mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::fixed)::value ||
- mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::extendable)::value) &&
- (mlc_is(mln_trait_image_ext_domain(J),
- trait::image::ext_domain::fixed)::value ||
- mlc_is(mln_trait_image_ext_domain(J),
- trait::image::ext_domain::extendable)::value) &&
- data.border() == data.border()) ||
- (mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::none)::value &&
- mlc_is(mln_trait_image_ext_domain(J),
- trait::image::ext_domain::none)::value))
- {
- /// Check domain
- if (data.domain() == data.domain())
- impl::fill_with_image_fast(ima, data);
- }
+ fill_with_image_(mln_trait_image_value_access(I)(),
+ mln_trait_image_value_access(J)(),
+ mln_trait_image_ext_domain(I)(),
+ mln_trait_image_ext_domain(J)(),
+ ima, data);
}
- impl::generic::fill_with_image(ima, data);
+ else
+ impl::generic::fill_with_image(ima, data);
}
-
template <typename I, typename J>
inline
void fill_with_image_(Image<I>& ima, const Image<J>& data)
diff --git a/milena/mln/level/paste.hh b/milena/mln/level/paste.hh
index c3b8fcc..6bbac4a 100644
--- a/milena/mln/level/paste.hh
+++ b/milena/mln/level/paste.hh
@@ -102,7 +102,7 @@ namespace mln
template <typename I, typename J>
inline
- void paste_(const Image<I>& input_, Image<J>& output_)
+ void paste(const Image<I>& input_, Image<J>& output_)
{
trace::entering("level::impl::generic::paste");
diff --git a/milena/mln/level/paste.spe.hh b/milena/mln/level/paste.spe.hh
index 028ced8..e7c7390 100644
--- a/milena/mln/level/paste.spe.hh
+++ b/milena/mln/level/paste.spe.hh
@@ -66,11 +66,9 @@ namespace mln
namespace generic
{
template <typename I, typename J>
- void paste_(const Image<I>& input, Image<J>& output);
+ void paste(const Image<I>& input, Image<J>& output);
}
-
-
// template <typename I, typename J>
// inline
// void paste_lines_(const I& data, J& destination)
@@ -111,10 +109,30 @@ namespace mln
for_all(pi)
{
po.val() = pi.val();
+ po.next();
}
trace::entering("level::impl::paste_fast");
}
+
+ template <typename I, typename J>
+ void paste_fast_singleton(const Image<I>& input_, Image<J>&
output_)
+ {
+ trace::entering("level::impl::paste_fast_singleton");
+
+ const I& input = exact(input_);
+ J& output = exact(output_);
+
+ level::internal::paste_tests(input, output);
+
+ mln_pixter(J) po(output);
+
+ for_all(po)
+ po.val() = input.val();
+
+ trace::entering("level::impl::paste_fast_singleton");
+ }
+
} // end of namespace impl.
@@ -122,6 +140,48 @@ namespace mln
namespace internal
{
+ template <typename I, typename J>
+ inline
+ void paste_(mln::trait::image::value_access::direct,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_domain::some,
+ const Image<I>& input_,
+ Image<J>& output_)
+ {
+ const I& input = exact(input_);
+ J& output = exact(output_);
+
+ if (input.domain() == output.domain())
+ impl::paste_fast(input, output);
+ else
+ impl::generic::paste(input, output);
+ }
+
+ template <typename I, typename J>
+ inline
+ void paste_(mln::trait::image::value_access::direct,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::ext_domain::none,
+ mln::trait::image::ext_domain::none,
+ const Image<I>& input,
+ Image<J>& output)
+ {
+ impl::paste_fast(input, output);
+ }
+
+
+ template <typename I, typename J>
+ inline
+ void paste_(mln::trait::image::value_access::any,
+ mln::trait::image::value_access::any,
+ mln::trait::image::ext_domain::any,
+ mln::trait::image::ext_domain::any,
+ const Image<I>& input,
+ Image<J>& output)
+ {
+ impl::generic::paste(input, output);
+ }
template <typename I, typename J>
inline
@@ -130,51 +190,45 @@ namespace mln
const Image<I>& input,
Image<J>& output)
{
- impl::generic::paste_(input, output);
+ impl::generic::paste(input, output);
}
template <typename I, typename J>
inline
- void paste_(trait::image::value_storage::one_block,
+ void paste_(trait::image::value_storage::singleton,
trait::image::value_storage::one_block,
+ const Image<I>& input,
+ Image<J>& output)
+ {
+ impl::paste_fast_singleton(input, output);
+ }
+
+
+ template <typename I, typename J>
+ inline
+ void paste_(mln::trait::image::value_storage::one_block,
+ mln::trait::image::value_storage::one_block,
const Image<I>& input_,
Image<J>& output_)
{
const I& input = exact(input_);
J& output = exact(output_);
+
/// Check basic properties
- if (mlc_is(mln_trait_image_value_access(J),
- trait::image::value_access::direct)::value &&
- mlc_is(mln_trait_image_value_access(I),
- trait::image::value_access::direct)::value &&
- mlc_is(mln_trait_image_value_alignement(I),
+ if (mlc_is(mln_trait_image_value_alignement(I),
trait::image::value_alignement::with_grid)::value &&
mlc_is(mln_trait_image_value_alignement(J),
trait::image::value_alignement::with_grid)::value)
{
- /// Check ext_domain
- if (
- ((mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::fixed)::value ||
- mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::extendable)::value) &&
- (mlc_is(mln_trait_image_ext_domain(J),
- trait::image::ext_domain::fixed)::value ||
- mlc_is(mln_trait_image_ext_domain(J),
- trait::image::ext_domain::extendable)::value) &&
- input.border() == output.border()) ||
- (mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::none)::value &&
- mlc_is(mln_trait_image_ext_domain(J),
- trait::image::ext_domain::none)::value))
- {
- /// Check domain
- if (input.domain() == output.domain())
- impl::paste_fast(input, output);
- }
+ paste_(mln_trait_image_value_access(I)(),
+ mln_trait_image_value_access(J)(),
+ mln_trait_image_ext_domain(I)(),
+ mln_trait_image_ext_domain(J)(),
+ input, output);
}
- impl::generic::paste_(input, output);
+ else
+ impl::generic::paste(input, output);
}
@@ -182,6 +236,7 @@ namespace mln
inline
void paste_(const Image<I>& input, Image<J>& output)
{
+
paste_(mln_trait_image_value_storage(I)(),
mln_trait_image_value_storage(J)(),
input, output);
diff --git a/milena/mln/level/transform.hh b/milena/mln/level/transform.hh
index adece40..255751e 100644
--- a/milena/mln/level/transform.hh
+++ b/milena/mln/level/transform.hh
@@ -159,7 +159,7 @@ namespace mln
trace::entering("level::transform");
mln_precondition(exact(output).domain() >= exact(input).domain());
- transform_dispatch(exact(input), exact(f), exact(output));
+ transform_dispatch_(exact(input), exact(f), exact(output));
trace::exiting("level::transform");
}
diff --git a/milena/mln/level/transform.spe.hh b/milena/mln/level/transform.spe.hh
index 0f044d2..e498997 100644
--- a/milena/mln/level/transform.spe.hh
+++ b/milena/mln/level/transform.spe.hh
@@ -175,6 +175,7 @@ namespace mln
for_all(pi)
{
po.val() = f(pi.val());
+ po.next();
}
trace::exiting("level::impl::transform_fast");
@@ -195,8 +196,8 @@ namespace mln
level::internal::transform_tests(input, f, output);
- value::lut_vec<mln_vset(I), mln_result(F)>
- lut(input.values_eligible(), f);
+ value::lut_vec<mln_vset(I), mln_result(F)>
+ lut(input.values_eligible(), f);
mln_pixter(const I) pi(input);
mln_pixter(O) po(output);
@@ -204,8 +205,8 @@ namespace mln
po.start();
for_all(pi)
{
- //po.val() = lut(pi.val);
- po.val() = f(pi.val());
+ po.val() = lut(pi.val());
+ po.next();
}
trace::exiting("level::impl::transform_fast_lowq");
@@ -221,33 +222,33 @@ namespace mln
/// Deal with image not updated
template <typename I, typename F, typename O>
inline
- void transform_dispatch(mln::trait::undef,
- mln::trait::image::quant::any,
- const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(mln::trait::undef,
+ mln::trait::image::quant::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
impl::generic::transform(input, f, output);
}
template <typename I, typename F, typename O>
inline
- void transform_dispatch(mln::trait::image::vw_set::any,
- mln::trait::image::quant::any,
- const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(mln::trait::image::vw_set::any,
+ mln::trait::image::quant::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
impl::generic::transform(input, f, output);
}
template <typename I, typename F, typename O>
inline
- void transform_dispatch(mln::trait::image::vw_set::uni,
- mln::trait::image::quant::any,
- const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(mln::trait::image::vw_set::uni,
+ mln::trait::image::quant::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
impl::transform_taken(input, f, output);
}
@@ -255,31 +256,84 @@ namespace mln
template <typename I, typename F, typename O>
inline
- void transform_dispatch(mln::trait::image::vw_set::none,
- mln::trait::image::quant::low,
- const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(mln::trait::image::vw_set::none,
+ mln::trait::image::quant::low,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
impl::transform_lowq(input, f, output);
}
template <typename I, typename F, typename O>
inline
- void transform_dispatch_oneblock(mln::trait::image::quant::any,
- const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(mln::trait::image::quant::any,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_domain::some,
+ const Image<I>& input_,
+ const Function_v2v<F>& f,
+ Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ O& output = exact(output_);
+
+
+ if (input.domain() == output.domain())
+ transform_fast(input, f, output);
+ else
+ transform_dispatch_(mln_trait_image_vw_set(I)(),
+ mln_trait_image_quant(I)(),
+ input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ inline
+ void transform_dispatch_(mln::trait::image::quant::any,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::ext_domain::none,
+ mln::trait::image::ext_domain::none,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
transform_fast(input, f, output);
}
template <typename I, typename F, typename O>
inline
- void transform_dispatch_oneblock(mln::trait::image::quant::low,
- const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(mln::trait::image::quant::low,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_domain::some,
+ const Image<I>& input_,
+ const Function_v2v<F>& f,
+ Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ O& output = exact(output_);
+
+ if (input.domain() == output.domain())
+ transform_fast_lowq(input, f, output);
+ else
+ transform_dispatch_(mln_trait_image_vw_set(I)(),
+ mln_trait_image_quant(I)(),
+ input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ inline
+ void transform_dispatch_(mln::trait::image::quant::low,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::value_access::direct,
+ mln::trait::image::ext_domain::none,
+ mln::trait::image::ext_domain::none,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
transform_fast_lowq(input, f, output);
}
@@ -287,88 +341,87 @@ namespace mln
template <typename I, typename F, typename O>
inline
- void transform_dispatch(mln::trait::image::value_storage::any,
- mln::trait::image::value_storage::any,
- const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(mln::trait::image::quant::any,
+ mln::trait::image::value_access::any,
+ mln::trait::image::value_access::any,
+ mln::trait::image::ext_domain::any,
+ mln::trait::image::ext_domain::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
- transform_dispatch(mln_trait_image_vw_set(I)(),
- mln_trait_image_quant(I)(),
- input, f, output);
+ transform_dispatch_(mln_trait_image_vw_set(I)(),
+ mln_trait_image_quant(I)(),
+ input, f, output);
}
+
template <typename I, typename F, typename O>
inline
- void transform_dispatch(mln::trait::image::value_storage::singleton,
- mln::trait::image::value_storage::any,
- const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(mln::trait::image::value_storage::any,
+ mln::trait::image::value_storage::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ transform_dispatch_(mln_trait_image_vw_set(I)(),
+ mln_trait_image_quant(I)(),
+ input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ inline
+ void transform_dispatch_(mln::trait::image::value_storage::singleton,
+ mln::trait::image::value_storage::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
transform_singleton(input, f, output);
}
template <typename I, typename F, typename O>
inline
- void transform_dispatch(mln::trait::image::value_storage::one_block,
- mln::trait::image::value_storage::one_block,
- const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ void transform_dispatch_(mln::trait::image::value_storage::one_block,
+ mln::trait::image::value_storage::one_block,
+ const Image<I>& input_,
+ const Function_v2v<F>& f_,
+ Image<O>& output_)
{
const I& input = exact(input_);
O& output = exact(output_);
+
/// Check basic properties
- if (mlc_is(mln_trait_image_value_access(O),
- trait::image::value_access::direct)::value &&
- mlc_is(mln_trait_image_value_access(I),
- trait::image::value_access::direct)::value &&
- mlc_is(mln_trait_image_value_alignement(I),
+ if (mlc_is(mln_trait_image_value_alignement(I),
trait::image::value_alignement::with_grid)::value &&
mlc_is(mln_trait_image_value_alignement(O),
trait::image::value_alignement::with_grid)::value)
{
- /// Check ext_domain
- if (
- ((mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::fixed)::value ||
- mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::extendable)::value) &&
- (mlc_is(mln_trait_image_ext_domain(O),
- trait::image::ext_domain::fixed)::value ||
- mlc_is(mln_trait_image_ext_domain(O),
- trait::image::ext_domain::extendable)::value) &&
- input.border() == output.border()) ||
- (mlc_is(mln_trait_image_ext_domain(I),
- trait::image::ext_domain::none)::value &&
- mlc_is(mln_trait_image_ext_domain(O),
- trait::image::ext_domain::none)::value))
- {
-
- /// Check domain
- if (input.domain() == output.domain())
- transform_dispatch_oneblock(mln_trait_image_quant(I)(),
- input, f_, output);
- }
+ transform_dispatch_(mln_trait_image_quant(I)(),
+ mln_trait_image_value_access(I)(),
+ mln_trait_image_value_access(O)(),
+ mln_trait_image_ext_domain(I)(),
+ mln_trait_image_ext_domain(O)(),
+ input, f_, output);
}
- transform_dispatch(mln_trait_image_vw_set(I)(),
- mln_trait_image_quant(I)(),
- input, f_, output);
+ else
+ transform_dispatch_(mln_trait_image_vw_set(I)(),
+ mln_trait_image_quant(I)(),
+ input, f_, output);
}
template <typename I, typename F, typename O>
inline
- void transform_dispatch(const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ void transform_dispatch_(const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
{
- transform_dispatch(mln_trait_image_value_storage(I)(),
- mln_trait_image_value_storage(O)(),
- input, f, output);
+ transform_dispatch_(mln_trait_image_value_storage(I)(),
+ mln_trait_image_value_storage(O)(),
+ input, f, output);
}
}
diff --git a/milena/tests/level/fill_with_image.cc
b/milena/tests/level/fill_with_image.cc
index a9bd8cf..303dad8 100644
--- a/milena/tests/level/fill_with_image.cc
+++ b/milena/tests/level/fill_with_image.cc
@@ -32,17 +32,24 @@
#include <mln/level/fill_with_value.hh>
#include <mln/level/fill_with_image.hh>
+#include <mln/level/compare.hh>
+#include <mln/core/image/image1d.hh>
#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/pw/image.hh>
#include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/image_if.hh>
#include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
-#include <mln/core/image/image_if.hh>
-#include <mln/level/compare.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/fun/p2v/iota.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/fun/p2b/chess.hh>
+#include <mln/trace/all.hh>
int main()
@@ -50,6 +57,7 @@ int main()
using namespace mln;
const unsigned size = 100;
+ // 2d tests
{
image2d<unsigned int> ima(size, size);
image2d<unsigned int> ima2(size, size);
@@ -68,7 +76,7 @@ int main()
debug::iota(ima2);
level::fill_with_image(ima, ima2);
- assert(ima == (ima2 | b));
+ mln_assertion(ima == (ima2 | b));
}
{
@@ -88,4 +96,127 @@ int main()
mln_assertion(ima_if(p) == 42);
}
+
+ // tests in three dimension
+ {
+ box3d b(point3d(1,2,1), point3d(2,4,3));
+ image3d<int> ima(b, 2);
+ debug::iota(ima);
+
+ box3d b2(point3d(-1,-2,-1), point3d(3,6,3));
+ image3d<int> ima2(b2, 2);
+ debug::iota(ima2);
+
+ image3d<int> ima3(b, 2);
+
+ level::fill_with_image(ima, ima2); // Not so fast version...
+ mln_assertion(ima == (ima2 | b));
+
+ level::fill_with_image(ima3, ima); // Fast version...
+ mln_assertion(ima == ima3);
+ }
+
+ // image 1d test
+ {
+ image1d<unsigned short> ima(size);
+ image1d<unsigned short> out(size);
+
+ debug::iota(ima);
+ level::fill_with_image(out, ima);
+
+ mln_assertion(ima == out);
+ }
+
+
+ // pw image test
+ {
+ const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota,
+ make::box2d(-2,-2, 15,15));
+ image2d<short unsigned int> out(8, 8);
+
+ level::fill(out, 0);
+ level::fill_with_image(out, ima);
+ }
+
+ // flat image test
+ {
+ flat_image<short, box2d> ima(5, make::box2d(size, size));
+ image2d<unsigned short> out(size, size);
+
+ level::fill_with_value(ima, 51);
+ level::fill_with_image(out, ima);
+
+ mln_assertion(ima == out);
+ }
+
+ // image if test
+ {
+ typedef image2d<unsigned short> I;
+ typedef image_if<I, fun::p2b::chess_t> II;
+
+ I ima(size, size);
+ I out(size, size);
+ II ima_if = ima | fun::p2b::chess;
+
+ level::fill_with_value(ima, 42);
+ level::fill_with_value(out, 0);
+ level::fill_with_image(ima_if, ima);
+
+ mln_piter_(II) p(ima_if.domain());
+ for_all(p)
+ mln_assertion(ima_if(p) == ima(p));
+ }
+
+ // cast image test
+ {
+ typedef image2d<unsigned short> I;
+ typedef cast_image_<int, I> II;
+
+ I in(size, size);
+ II cast(in);
+ I out(size, size);
+
+ level::fill(in, 51);
+ level::fill(out, 42);
+
+ level::fill_with_image(out, cast);
+
+ mln_assertion(cast == out);
+ }
+
+ // sub_image test
+ {
+ typedef image2d<int> I;
+ typedef sub_image< image2d<int>, box2d > II;
+
+ I ima(size, size);
+ I out(size, size);
+ II sub_ima(ima, make::box2d(4,4, 10,10));
+
+
+ level::fill(ima, 51);
+ level::fill(out, 0);
+ level::fill_with_image(sub_ima, ima);
+
+ II::piter p(sub_ima.domain());
+ for_all(p)
+ mln_assertion(sub_ima(p) == ima(p));
+ }
+
+ // extended image test
+ {
+ typedef image2d<int> I;
+ typedef extension_val< image2d<int> > II;
+ typedef image2d<unsigned short> III;
+
+ I ima(size, size);
+ II extend_ima(ima, 5);
+ III out(size, size);
+
+ level::fill(ima, 51);
+ level::fill_with_image(out, extend_ima);
+
+ mln_assertion(out == extend_ima);
+ }
+
}
diff --git a/milena/tests/level/paste.cc b/milena/tests/level/paste.cc
index cd97898..e748602 100644
--- a/milena/tests/level/paste.cc
+++ b/milena/tests/level/paste.cc
@@ -30,21 +30,32 @@
* \brief Tests on mln::level::paste.
*/
+#include <mln/core/image/image1d.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/image/image3d.hh>
+#include <mln/pw/image.hh>
+#include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/image_if.hh>
#include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
#include <mln/level/fill.hh>
#include <mln/level/paste.hh>
#include <mln/level/compare.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/fun/p2v/iota.hh>
+
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
+#include <mln/trace/all.hh>
int main()
{
using namespace mln;
+ const unsigned size = 50;
// tests in two dimension
{
@@ -59,10 +70,10 @@ int main()
image2d<int> ima3(b, 2);
level::paste(ima, ima2); // Not so fast version...
- assert(ima == (ima2 | b));
+ mln_assertion(ima == (ima2 | b));
level::paste(ima, ima3); // Fast version...
- assert(ima == ima3);
+ mln_assertion(ima == ima3);
}
// tests in three dimension
@@ -78,9 +89,112 @@ int main()
image3d<int> ima3(b, 2);
level::paste(ima, ima2); // Not so fast version...
- assert(ima == (ima2 | b));
+ mln_assertion(ima == (ima2 | b));
level::paste(ima, ima3); // Fast version...
- assert(ima == ima3);
+ mln_assertion(ima == ima3);
+ }
+
+ /// image 1d test
+ {
+ image1d<unsigned short> ima(size);
+ image1d<unsigned short> out(size);
+
+ debug::iota(ima);
+ level::paste(ima, out);
+
+ mln_assertion(ima == out);
+ }
+
+
+ /// pw image test
+ {
+ const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota,
+ make::box2d(2,2, 5,5));
+ image2d<short unsigned int> out(8, 8);
+
+ level::fill(out, 0);
+ level::paste(ima, out);
+ }
+
+ // flat image test
+ {
+ flat_image<short, box2d> ima(5, make::box2d(size, size));
+ image2d<unsigned short> out(size, size);
+
+ level::fill_with_value(ima, 51);
+ level::paste(ima, out);
+
+ mln_assertion(ima == out);
+ }
+
+ // image if test
+ {
+ typedef image2d<unsigned short> I;
+ typedef image_if<I, fun::p2b::chess_t> II;
+
+ I ima(size, size);
+ I out(size, size);
+ II ima_if = ima | fun::p2b::chess;
+
+ level::fill_with_value(ima, 0);
+ debug::iota(ima);
+ level::paste(ima_if, out);
+
+ mln_assertion(ima_if == out);
+ }
+
+ // cast image test
+ {
+ typedef image2d<unsigned short> I;
+ typedef cast_image_<int, I> II;
+ typedef image2d<unsigned short> III;
+
+ I in(size, size);
+ II cast(in);
+ III out(size, size);
+
+ level::fill(in, 51);
+ level::fill(out, 42);
+
+ level::paste(cast, out);
+
+ mln_assertion(cast == out);
+ }
+
+ // sub_image test
+ {
+ typedef image2d<int> I;
+ typedef sub_image< image2d<int>, box2d > II;
+ typedef image2d<unsigned short> III;
+
+ I ima(size, size);
+ II sub_ima(ima, make::box2d(4,4, 10,10));
+ III out(size, size);
+
+ level::fill(ima, 51);
+ level::paste(sub_ima, out);
+
+ II::piter p(sub_ima.domain());
+ for_all(p)
+ mln_assertion(sub_ima(p) == out(p));
+ }
+
+ // extended image test
+ {
+ typedef image2d<int> I;
+ typedef extension_val< image2d<int> > II;
+ typedef image2d<unsigned short> III;
+
+ I ima(size, size);
+ II extend_ima(ima, 5);
+ III out(size, size);
+
+ level::fill(ima, 51);
+ level::paste(extend_ima, out);
+
+ II::piter p(extend_ima.domain());
+ for_all(p)
+ mln_assertion(extend_ima(p) == out(p));
}
}
diff --git a/milena/tests/level/transform.cc b/milena/tests/level/transform.cc
index f177446..e0b8ec9 100644
--- a/milena/tests/level/transform.cc
+++ b/milena/tests/level/transform.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -37,7 +37,11 @@
#include <mln/core/image/image3d.hh>
#include <mln/pw/image.hh>
#include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
#include <mln/core/image/image_if.hh>
+#include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
+
#include <mln/level/fill.hh>
#include <mln/level/transform.hh>
@@ -140,6 +144,7 @@ int main()
mln_assertion((unsigned short)std::sqrt(ima(p)) == out(p));
}
+ // image if test
{
typedef image2d<unsigned short> I;
typedef image_if<I, fun::p2b::chess_t> II;
@@ -157,4 +162,59 @@ int main()
mln_assertion((unsigned short)std::sqrt(ima_if(p)) == out(p));
}
+ // cast image test
+ {
+ typedef image2d<unsigned short> I;
+ typedef cast_image_<int, I> II;
+ typedef image2d<unsigned short> III;
+
+ I in(size, size);
+ II cast(in);
+ III out(size, size);
+
+ level::fill(in, 51);
+ level::fill(out, 42);
+
+ out = level::transform(cast, mysqrt());
+
+ II::piter p(cast.domain());
+ for_all(p)
+ mln_assertion((unsigned short)std::sqrt(cast(p)) == out(p));
+ }
+
+ // sub_image test
+ {
+ typedef image2d<int> I;
+ typedef sub_image< image2d<int>, box2d > II;
+ typedef image2d<unsigned short> III;
+
+ I ima(size, size);
+ II sub_ima(ima, make::box2d(4,4, 10,10));
+ III out(size, size);
+
+ level::fill(ima, 51);
+ out = level::transform(sub_ima, mysqrt());
+
+ II::piter p(sub_ima.domain());
+ for_all(p)
+ mln_assertion((unsigned short)std::sqrt(sub_ima(p)) == out(p));
+ }
+
+ // extended image test
+ {
+ typedef image2d<int> I;
+ typedef extension_val< image2d<int> > II;
+ typedef image2d<unsigned short> III;
+
+ I ima(size, size);
+ II extend_ima(ima, 5);
+ III out(size, size);
+
+ level::fill(ima, 51);
+ out = level::transform(extend_ima, mysqrt());
+
+ II::piter p(extend_ima.domain());
+ for_all(p)
+ mln_assertion((unsigned short)std::sqrt(extend_ima(p)) == out(p));
+ }
}
--
1.5.6.5