Starting revamping world inter-pixel.
* mln/world/inter_pixel/image2full.hh: Rename as...
* mln/world/inter_pixel/immerse.hh: ...this new file.
(image2full): Rename as...
(immerse): ...this.
Revamp.
* mln/world/inter_pixel/separator_to_pixels.hh: New.
* mln/world/inter_pixel/is_separator.hh: New.
* mln/world/inter_pixel/is_pixel.hh: New.
* mln/world/inter_pixel/compute.hh: New.
* mln/world/inter_pixel/make: New directory.
* mln/world/inter_pixel/neighb2d.hh: Fix ending guard.
* mln/world/inter_pixel/display_edge.hh: Likewise.
* mln/core/macros.hh (mln_unmorph, mln_unmorph_): New.
* mln/core/point.hh (point): Fix warning.
Add static check.
* mln/core/internal/image_morpher.hh (unmorph): New typedef.
* mln/core/internal/pixel_impl.hh
(pixel_impl_): Fix compile errors with g++-3.4.
* mln/core/concept/gpoint.hh (operator*): New overload with scalar.
(trait): New corresponding trait.
* tests/world/inter_pixel/compute.cc: New.
* tests/world/inter_pixel/immerse.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
Fix missing code for operator less with builtins.
* mln/value/builtin/ops.hh:
(mln_internal_decl_op_less_): New.
(mln_internal_def_op_less_): New.
(mln_internal_builtins_op_less_): New.
Misc.
* mln/accu/stat/all.hh: New.
* mln/accu/all.hh: Update.
* mln/convert/to_fun.hh: Upgrade doc style.
* mln/data/paste_without_localization.hh: New.
* mln/data/paste.hh: New static check.
* mln/fun/c.hh: Likewise.
Fix ending guard.
Augmenting accumulators.
* mln/accu/stat/var.hh (mean_t): New typedef.
(to_result, mean): Fix null_ construction.
* tests/accu/stat: New directory.
* tests/accu/stat/Makefile.am: New.
* tests/accu/stat/var.cc: New.
* tests/accu/Makefile.am: Update.
Augmenting fun :-)
* mln/fun/access: New directory.
* mln/fun/access/all.hh: New.
* mln/fun/access/mean.hh: New.
* mln/fun/all.hh: Update.
* mln/fun/stat: New.
* mln/fun/stat/all.hh: New.
* mln/fun/stat/mahalanobis.hh: New.
* tests/fun/stat: New.
* tests/fun/stat/mahalanobis.cc: New.
* tests/fun/stat/Makefile.am: New.
* tests/fun/Makefile.am: Update.
---
milena/ChangeLog | 70 +++++++++++
milena/mln/accu/all.hh | 1 +
milena/mln/{fun => accu/stat}/all.hh | 42 +++-----
milena/mln/accu/stat/var.hh | 16 ++-
milena/mln/convert/to_fun.hh | 10 +-
milena/mln/core/concept/gpoint.hh | 32 +++++-
milena/mln/core/internal/image_morpher.hh | 4 +
milena/mln/core/internal/pixel_impl.hh | 14 +-
milena/mln/core/macros.hh | 10 ++
milena/mln/core/point.hh | 11 +-
milena/mln/data/paste.hh | 6 +-
.../paste_without_localization.hh} | 88 +++++++-------
milena/mln/fun/{ => access}/all.hh | 39 ++-----
.../mln/{convert/to_fun.hh => fun/access/mean.hh} | 80 ++++++++------
milena/mln/fun/all.hh | 18 ++--
milena/mln/fun/c.hh | 14 +-
milena/mln/fun/{ => stat}/all.hh | 39 ++----
.../{convert/to_fun.hh => fun/stat/mahalanobis.hh} | 80 ++++++++-----
milena/mln/value/builtin/ops.hh | 76 +++++++++++-
.../inter_pixel/{image2full.hh => compute.hh} | 74 +++++++------
milena/mln/world/inter_pixel/display_edge.hh | 2 +-
.../inter_pixel/{image2full.hh => immerse.hh} | 63 +++++-----
.../inter_pixel/{image2full.hh => is_pixel.hh} | 76 ++++++------
.../inter_pixel/{image2full.hh => is_separator.hh} | 72 ++++++------
milena/mln/world/inter_pixel/neighb2d.hh | 2 +-
.../mln/world/inter_pixel/separator_to_pixels.hh | 123 ++++++++++++++++++++
milena/tests/accu/Makefile.am | 3 +-
milena/tests/{fun => accu/stat}/Makefile.am | 7 +-
milena/{mln/fun/all.hh => tests/accu/stat/var.cc} | 66 ++++++-----
milena/tests/fun/Makefile.am | 10 ++-
.../{world/inter_pixel => fun/stat}/Makefile.am | 9 +-
.../fun/all.hh => tests/fun/stat/mahalanobis.cc} | 67 ++++++-----
milena/tests/world/inter_pixel/Makefile.am | 6 +-
.../world/inter_pixel/compute.cc} | 78 +++++++------
.../all.hh => tests/world/inter_pixel/immerse.cc} | 59 +++++-----
35 files changed, 850 insertions(+), 517 deletions(-)
copy milena/mln/{fun => accu/stat}/all.hh (63%)
copy milena/mln/{world/inter_pixel/image2full.hh =>
data/paste_without_localization.hh} (50%)
copy milena/mln/fun/{ => access}/all.hh (64%)
copy milena/mln/{convert/to_fun.hh => fun/access/mean.hh} (56%)
copy milena/mln/fun/{ => stat}/all.hh (64%)
copy milena/mln/{convert/to_fun.hh => fun/stat/mahalanobis.hh} (52%)
copy milena/mln/world/inter_pixel/{image2full.hh => compute.hh} (56%)
copy milena/mln/world/inter_pixel/{image2full.hh => immerse.hh} (59%)
copy milena/mln/world/inter_pixel/{image2full.hh => is_pixel.hh} (56%)
rename milena/mln/world/inter_pixel/{image2full.hh => is_separator.hh} (56%)
create mode 100644 milena/mln/world/inter_pixel/separator_to_pixels.hh
copy milena/tests/{fun => accu/stat}/Makefile.am (61%)
copy milena/{mln/fun/all.hh => tests/accu/stat/var.cc} (57%)
copy milena/tests/{world/inter_pixel => fun/stat}/Makefile.am (61%)
copy milena/{mln/fun/all.hh => tests/fun/stat/mahalanobis.cc} (55%)
copy milena/{mln/convert/to_fun.hh => tests/world/inter_pixel/compute.cc} (52%)
copy milena/{mln/fun/all.hh => tests/world/inter_pixel/immerse.cc} (61%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2583428..c69383e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,73 @@
+2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+
+ Several fixes and new stuff.
+
+ Starting revamping world inter-pixel.
+
+ * mln/world/inter_pixel/image2full.hh: Rename as...
+ * mln/world/inter_pixel/immerse.hh: ...this new file.
+ (image2full): Rename as...
+ (immerse): ...this.
+ Revamp.
+ * mln/world/inter_pixel/separator_to_pixels.hh: New.
+ * mln/world/inter_pixel/is_separator.hh: New.
+ * mln/world/inter_pixel/is_pixel.hh: New.
+ * mln/world/inter_pixel/compute.hh: New.
+ * mln/world/inter_pixel/make: New directory.
+ * mln/world/inter_pixel/neighb2d.hh: Fix ending guard.
+ * mln/world/inter_pixel/display_edge.hh: Likewise.
+ * mln/core/macros.hh (mln_unmorph, mln_unmorph_): New.
+ * mln/core/point.hh (point): Fix warning.
+ Add static check.
+ * mln/core/internal/image_morpher.hh (unmorph): New typedef.
+ * mln/core/internal/pixel_impl.hh
+ (pixel_impl_): Fix compile errors with g++-3.4.
+ * mln/core/concept/gpoint.hh (operator*): New overload with scalar.
+ (trait): New corresponding trait.
+ * tests/world/inter_pixel/compute.cc: New.
+ * tests/world/inter_pixel/immerse.cc: New.
+ * tests/world/inter_pixel/Makefile.am: Update.
+
+ Fix missing code for operator less with builtins.
+
+ * mln/value/builtin/ops.hh:
+ (mln_internal_decl_op_less_): New.
+ (mln_internal_def_op_less_): New.
+ (mln_internal_builtins_op_less_): New.
+
+ Misc.
+
+ * mln/accu/stat/all.hh: New.
+ * mln/accu/all.hh: Update.
+ * mln/convert/to_fun.hh: Upgrade doc style.
+ * mln/data/paste_without_localization.hh: New.
+ * mln/data/paste.hh: New static check.
+ * mln/fun/c.hh: Likewise.
+ Fix ending guard.
+
+ Augmenting accumulators.
+
+ * mln/accu/stat/var.hh (mean_t): New typedef.
+ (to_result, mean): Fix null_ construction.
+ * tests/accu/stat: New directory.
+ * tests/accu/stat/Makefile.am: New.
+ * tests/accu/stat/var.cc: New.
+ * tests/accu/Makefile.am: Update.
+
+ Augmenting fun :-)
+
+ * mln/fun/access: New directory.
+ * mln/fun/access/all.hh: New.
+ * mln/fun/access/mean.hh: New.
+ * mln/fun/all.hh: Update.
+ * mln/fun/stat: New.
+ * mln/fun/stat/all.hh: New.
+ * mln/fun/stat/mahalanobis.hh: New.
+ * tests/fun/stat: New.
+ * tests/fun/stat/mahalanobis.cc: New.
+ * tests/fun/stat/Makefile.am: New.
+ * tests/fun/Makefile.am: Update.
+
2009-05-07 Guillaume Sadegh <sadegh(a)lrde.epita.fr>
Add couple to couple conversion.
diff --git a/milena/mln/accu/all.hh b/milena/mln/accu/all.hh
index 5dfe51e..1bf7cf8 100644
--- a/milena/mln/accu/all.hh
+++ b/milena/mln/accu/all.hh
@@ -99,6 +99,7 @@ namespace mln
# include <mln/accu/image/all.hh>
# include <mln/accu/site_set/all.hh>
+# include <mln/accu/stat/all.hh>
#endif // ! MLN_ACCU_ALL_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/accu/stat/all.hh
similarity index 63%
copy from milena/mln/fun/all.hh
copy to milena/mln/accu/stat/all.hh
index 8e9ddad..1c9f8ef 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/accu/stat/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,29 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_ACCU_STAT_ALL_HH
+# define MLN_ACCU_STAT_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/accu/stat/all.hh
+///
+/// File that includes all statistical accumulator types.
namespace mln
{
-
- /// Namespace of image processing routines related to functions.
- namespace fun
+ namespace accu
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// Namespace of statistical accumulators.
+ namespace stat {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/accu/stat/deviation.hh>
+# include <mln/accu/stat/var.hh>
+# include <mln/accu/stat/variance.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_ACCU_STAT_ALL_HH
diff --git a/milena/mln/accu/stat/var.hh b/milena/mln/accu/stat/var.hh
index c871e7d..3dece0b 100644
--- a/milena/mln/accu/stat/var.hh
+++ b/milena/mln/accu/stat/var.hh
@@ -40,6 +40,7 @@
# include <mln/fun/i2v/all_to.hh>
# include <mln/util/pix.hh>
+
namespace mln
{
@@ -84,8 +85,13 @@ namespace mln
/// Get the number of items.
unsigned n_items() const;
+
+ /// Type equipment.
+ typedef algebra::vec<dim,float> mean_t;
+ // ...
+
/// Get the mean vector.
- algebra::vec<dim,float> mean() const;
+ mean_t mean() const;
/// Check whether this accu returns a valid result.
bool is_valid() const;
@@ -115,7 +121,7 @@ namespace mln
{
n_ = 0;
sum_.set_all(0);
- cov_ .set_all(0);
+ cov_.set_all(0);
}
template <typename T>
@@ -163,7 +169,7 @@ namespace mln
mln_result(var<T>)
var<T>::to_result() const
{
- static result null_(fun::i2v::all_to(0));
+ static result null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
@@ -192,10 +198,10 @@ namespace mln
template <typename T>
inline
- algebra::vec<dim,float>
+ typename var<T>::mean_t
var<T>::mean() const
{
- static algebra::vec<dim,float> null_(fun::i2v::all_to(0));
+ static algebra::vec<dim,float> null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/convert/to_fun.hh
index 86a1ddc..6484c42 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/convert/to_fun.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_CONVERT_TO_FUN_HH
# define MLN_CONVERT_TO_FUN_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+/// \file mln/convert/to_fun.hh
+///
+/// Conversions towards some mln::Function.
# include <mln/pw/value.hh>
# include <mln/fun/c.hh>
diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh
index 9311535..504e2ac 100644
--- a/milena/mln/core/concept/gpoint.hh
+++ b/milena/mln/core/concept/gpoint.hh
@@ -36,7 +36,7 @@
# include <mln/core/concept/site.hh>
# include <mln/core/concept/gdpoint.hh>
-# include <mln/value/concept/scalar.hh>
+# include <mln/value/scalar.hh>
# include <mln/algebra/vec.hh>
# include <mln/util/ord.hh>
# include <mln/debug/format.hh>
@@ -74,6 +74,14 @@ namespace mln
typedef mln_delta(L) ret;
};
+ template < typename L, typename R >
+ struct set_binary_< op::times,
+ mln::Gpoint, L,
+ mln::Object, mln::value::scalar_<R> >
+ {
+ typedef L ret;
+ };
+
template <typename P>
struct set_unary_< op::ord, mln::Gpoint, P >
@@ -200,7 +208,7 @@ namespace mln
- /// Substract a delta-point \p rhs to a grid point \p lhs.
+ /// Substract a delta-point \p dp to a grid point \p p.
///
/*! \param[in] p A grid point.
* \param[in] dp A delta-point.
@@ -217,6 +225,13 @@ namespace mln
operator-(const Gpoint<P>& p, const Gdpoint<D>& dp);
+ /// Multiply a point \p p by a scalar \p s.
+ //
+ template <typename P, typename S>
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s);
+
+
/// Print a grid point \p p into the output stream \p ostr.
/*! \param[in,out] ostr An output stream.
* \param[in] p A grid point.
@@ -380,6 +395,19 @@ namespace mln
return tmp;
}
+ template <typename P, typename S>
+ inline
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s)
+ {
+ int s_ = s.to_equiv();
+ const unsigned n = P::dim;
+ P tmp = exact(p);
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] *= s_;
+ return tmp;
+ }
+
template <typename P>
inline
std::ostream& operator<<(std::ostream& ostr, const Gpoint<P>&
p)
diff --git a/milena/mln/core/internal/image_morpher.hh
b/milena/mln/core/internal/image_morpher.hh
index fd170ea..0969acc 100644
--- a/milena/mln/core/internal/image_morpher.hh
+++ b/milena/mln/core/internal/image_morpher.hh
@@ -64,6 +64,10 @@ namespace mln
I* delegatee_();
+
+ /// Unmorph image associated type.
+ typedef I unmorph;
+
/// Give the morphed image (mutable version).
I& unmorph_();
diff --git a/milena/mln/core/internal/pixel_impl.hh
b/milena/mln/core/internal/pixel_impl.hh
index f3162e5..eb956cf 100644
--- a/milena/mln/core/internal/pixel_impl.hh
+++ b/milena/mln/core/internal/pixel_impl.hh
@@ -233,7 +233,7 @@ namespace mln
bool
pixel_impl_<I, E>::is_valid_() const
{
- return value_ptr_ != 0 &&
internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 &&
internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -249,7 +249,7 @@ namespace mln
pixel_impl_<I, E>::val()
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -258,7 +258,7 @@ namespace mln
pixel_impl_<I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -267,7 +267,7 @@ namespace mln
pixel_impl_<I, E>::ima() const
{
// a const pixel, yet a mutable image
- return const_cast<I&>(image_);
+ return const_cast<I&>(this->image_);
}
template <typename I, typename E>
@@ -286,7 +286,7 @@ namespace mln
bool
pixel_impl_<const I, E>::is_valid_() const
{
- return value_ptr_ != 0 &&
internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 &&
internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -302,7 +302,7 @@ namespace mln
pixel_impl_<const I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -310,7 +310,7 @@ namespace mln
const I&
pixel_impl_<const I, E>::ima() const
{
- return image_;
+ return this->image_;
}
template <typename I, typename E>
diff --git a/milena/mln/core/macros.hh b/milena/mln/core/macros.hh
index 8aa59ad..75ab5f0 100644
--- a/milena/mln/core/macros.hh
+++ b/milena/mln/core/macros.hh
@@ -372,6 +372,16 @@
+// u
+
+/// Shortcuts to access the unmorph type associated to T.
+/// \{
+# define mln_unmorph(T) typename T::unmorph
+# define mln_unmorph_(T) T::unmorph
+/// \}
+
+
+
// v
/// Shortcuts to access the value type associated to T.
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index 54289fa..ca15b4c 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -294,16 +294,17 @@ namespace mln
inline
point<G,C>::point(const algebra::vec<dim,C2>& v)
{
+ mlc_converts_to(C2, C)::check();
unsigned j = 0;
- //FIXME: to be improved.
+ //FIXME: to be improved while adding a conversion routine.
if (dim < 3)
coord_ = v;
else
{
for (unsigned i = dim - 2; i < dim; ++i)
- coord_[i] = v[j++];
+ coord_[i] = static_cast<C>(v[j++]);
for (unsigned i = 2; i < dim; ++i, ++j)
- coord_[i-j] = v[j];
+ coord_[i-j] = static_cast<C>(v[j]);
}
}
diff --git a/milena/mln/data/paste.hh b/milena/mln/data/paste.hh
index 6457411..ef3911d 100644
--- a/milena/mln/data/paste.hh
+++ b/milena/mln/data/paste.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -129,6 +129,8 @@ namespace mln
{
trace::entering("data::paste");
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
internal::paste_tests(input, output);
internal::paste_dispatch(input, output);
diff --git a/milena/mln/world/inter_pixel/image2full.hh
b/milena/mln/data/paste_without_localization.hh
similarity index 50%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/data/paste_without_localization.hh
index 03102f7..8b10bee 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/data/paste_without_localization.hh
@@ -25,69 +25,69 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
+# define MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/data/paste_without_localization.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// Paste the contents of an image into another one without taking
+/// into account the localization of sites.
+
+# include <mln/core/concept/image.hh>
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
namespace mln
{
- namespace world
+ namespace data
{
- namespace inter_pixel
- {
+ /// \brief Paste the contents of image \p input into the image \p
+ /// output without taking into account the localization of sites.
+ ///
+ /// \param[in] input The input image providing pixels values.
+ /// \param[in,out] output The image in which values are
+ /// assigned.
+ //
+ template <typename I, typename J>
+ void paste_without_localization(const Image<I>& input, Image<J>&
output);
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
# ifndef MLN_INCLUDE_ONLY
-
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
-
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
-
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
-
+ template <typename I, typename J>
+ inline
+ void paste_without_localization(const Image<I>& input_, Image<J>&
output_)
+ {
+ trace::entering("data::paste_without_localization");
+
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
+ const I& input = exact(input_);
+ J& output = exact(output_);
+
+ mln_fwd_piter(I) pi(input.domain());
+ pi.start();
+ mln_fwd_piter(J) po(output.domain());
+ po.start();
+ while (pi.is_valid() && po.is_valid())
+ {
+ output(po) = input(pi);
+ pi.next();
+ po.next();
+ }
+
+ trace::exiting("data::paste_without_localization");
+ }
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::data
- } // end of namespace mln::world::inter_pixel
+} // end of namespace mln
- } // end of namespace mln::world
-} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/access/all.hh
similarity index 64%
copy from milena/mln/fun/all.hh
copy to milena/mln/fun/access/all.hh
index 8e9ddad..ecae22d 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/access/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,28 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_FUN_ACCESS_ALL_HH
+# define MLN_FUN_ACCESS_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/access/all.hh
+///
+/// File that includes all access functions.
namespace mln
{
-
- /// Namespace of image processing routines related to functions.
namespace fun
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// Namespace for access functions.
+ namespace access
+ {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/fun/access/mean.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_FUN_ACCESS_ALL_HH
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/fun/access/mean.hh
similarity index 56%
copy from milena/mln/convert/to_fun.hh
copy to milena/mln/fun/access/mean.hh
index 86a1ddc..e287882 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/fun/access/mean.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -7,7 +7,7 @@
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
@@ -25,55 +25,67 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CONVERT_TO_FUN_HH
-# define MLN_CONVERT_TO_FUN_HH
+#ifndef MLN_FUN_ACCESS_MEAN_HH
+# define MLN_FUN_ACCESS_MEAN_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
-
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
namespace mln
{
- namespace convert
+ namespace fun
{
- /// Convert a C unary function into an mln::fun::C.
- template <typename R, typename A>
- fun::C<R(*)(A)> to_fun(R (*f)(A));
+ namespace access
+ {
- /// Convert an image into a function.
- template <typename I>
- pw::value_<I> to_fun(const Image<I>& ima);
+ struct mean : unary<mean>
+ {
+ };
+ namespace internal
+ {
-# ifndef MLN_INCLUDE_ONLY
+ template <typename T>
+ struct method_mean
+ {
+ typedef method_mean ret;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ typedef typename T::mean_t result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return x.mean();
+ }
+ };
+
+ }
+
+ } // end of namespace mln::access
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
+ } // end of namespace mln
+
+
+ namespace trait
+ {
+
+ namespace next
{
- return pw::value(ima);
- }
-# endif // ! MLN_INCLUDE_ONLY
+ template <typename A>
+ struct set_unary_< fun::access::mean,
+ Accumulator, A > : fun::access::internal::method_mean<A>
+ {
+ };
+
+ } // end of namespace mln::trait::next
- } // end of namespace mln::convert
+ } // end of namespace mln::trait
} // end of namespace mln
-#endif // ! MLN_CONVERT_TO_FUN_HH
+#endif // ! MLN_FUN_ACCESS_MEAN_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/all.hh
index 8e9ddad..96a347a 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_FUN_ALL_HH
# define MLN_FUN_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/all.hh
+///
+/// File that includes all fun-related routines.
namespace mln
@@ -43,25 +43,25 @@ namespace mln
/// Internal namespace of functions.
namespace internal
- {
- }
- }
+ {}
+ }
}
# include <mln/fun/c.hh>
# include <mln/fun/ops.hh>
# include <mln/fun/i2v/all.hh>
+# include <mln/fun/meta/all.hh>
# include <mln/fun/p2b/all.hh>
# include <mln/fun/p2v/all.hh>
+# include <mln/fun/stat/all.hh>
# include <mln/fun/v2b/all.hh>
# include <mln/fun/v2v/all.hh>
# include <mln/fun/vv2v/all.hh>
# include <mln/fun/x2p/all.hh>
# include <mln/fun/x2v/all.hh>
# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
#endif // ! MLN_FUN_ALL_HH
diff --git a/milena/mln/fun/c.hh b/milena/mln/fun/c.hh
index 8ee9c24..400c781 100644
--- a/milena/mln/fun/c.hh
+++ b/milena/mln/fun/c.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
#ifndef MLN_FUN_C_HH
# define MLN_FUN_C_HH
-/*! \file mln/fun/c.hh
- *
- * \brief Encapsulate a plain (C language-like) pointer to function
- * into a functor.
- */
+/// \file mln/fun/c.hh
+///
+/// Encapsulate a plain (C language-like) pointer to function
+/// into a functor.
# include <mln/fun/internal/selector.hh>
# include <mln/metal/unqualif.hh>
@@ -137,4 +137,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_P2B_C_HH
+#endif // ! MLN_FUN_C_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/stat/all.hh
similarity index 64%
copy from milena/mln/fun/all.hh
copy to milena/mln/fun/stat/all.hh
index 8e9ddad..8ad5257 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/stat/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,30 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_FUN_STAT_ALL_HH
+# define MLN_FUN_STAT_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/stat/all.hh
+///
+/// File that includes all statistical functions.
namespace mln
{
- /// Namespace of image processing routines related to functions.
namespace fun
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// \brief Namespace of statistical functions.
+ ///
+ /// \ingroup modfun
+ namespace stat {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/fun/stat/mahalanobis.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_FUN_STAT_ALL_HH
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/fun/stat/mahalanobis.hh
similarity index 52%
copy from milena/mln/convert/to_fun.hh
copy to milena/mln/fun/stat/mahalanobis.hh
index 86a1ddc..79eea0e 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/fun/stat/mahalanobis.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,55 +25,71 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CONVERT_TO_FUN_HH
-# define MLN_CONVERT_TO_FUN_HH
+#ifndef MLN_FUN_STAT_MAHALANOBIS_HH
+# define MLN_FUN_STAT_MAHALANOBIS_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+/// \file mln/fun/stat/mahalanobis.hh
+///
+/// Define the FIXME
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
namespace mln
{
- namespace convert
+ namespace fun
{
- /// Convert a C unary function into an mln::fun::C.
- template <typename R, typename A>
- fun::C<R(*)(A)> to_fun(R (*f)(A));
+ namespace stat
+ {
- /// Convert an image into a function.
- template <typename I>
- pw::value_<I> to_fun(const Image<I>& ima);
+ template <typename V>
+ struct mahalanobis
+ : public Function_v2v< mahalanobis<V> >,
+ private metal::equal< V, algebra::vec<V::dim,float> >::check_t
+ {
+ enum { n = V::dim };
+ typedef float result;
+ mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean);
-# ifndef MLN_INCLUDE_ONLY
+ float operator()(const V& v) const;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ algebra::mat<n,n,float> var_1;
+ algebra::vec<n,float> mean;
+ };
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
- {
- return pw::value(ima);
- }
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ mahalanobis<V>::mahalanobis(const
algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean)
+ {
+ var_1 = var._1();
+ mean = mean;
+ }
+
+ template <typename V>
+ inline
+ float
+ mahalanobis<V>::operator()(const V& v) const
+ {
+ return (v - mean).t() * var_1 * (v - mean);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
+ } // end of namespace mln::fun::stat
+
+ } // end of namespace mln::fun
} // end of namespace mln
-#endif // ! MLN_CONVERT_TO_FUN_HH
+#endif // ! MLN_FUN_X2V_NORM_MAHALANOBIS_HH
diff --git a/milena/mln/value/builtin/ops.hh b/milena/mln/value/builtin/ops.hh
index 24dbfd7..c4bcab6 100644
--- a/milena/mln/value/builtin/ops.hh
+++ b/milena/mln/value/builtin/ops.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
#ifndef MLN_VALUE_BUILTIN_OPS_HH
# define MLN_VALUE_BUILTIN_OPS_HH
-/*! \file mln/value/builtin/ops.hh
- *
- * \brief Definitions of binary operators when lhs is a built-in and
- * rhs is an mln object.
- */
+/// \file mln/value/builtin/ops.hh
+///
+/// Definitions of binary operators when lhs is a built-in and
+/// rhs is an mln object.
# include <mln/value/scalar.hh>
# include <mln/trait/op/all.hh>
@@ -149,6 +149,7 @@
+
# define mln_internal_op_obj_builtins_(De, Symb, Name) \
\
mln_internal_##De##_op_obj_bi_(Symb, Name, signed char); \
@@ -317,6 +318,55 @@
+
+// Operator less (<) is a special case.
+
+# define mln_internal_decl_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs); \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_def_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs) \
+ { \
+ return exact(lhs) Symb value::scalar(rhs); \
+ } \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs) \
+ { \
+ return value::scalar(lhs) Symb exact(rhs); \
+ } \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_builtins_op_less_(De, Symb, Name) \
+ \
+ mln_internal_##De##_op_less_(Symb, Name, signed char); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned char); \
+ mln_internal_##De##_op_less_(Symb, Name, signed short); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned short); \
+ mln_internal_##De##_op_less_(Symb, Name, signed int); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned int); \
+ mln_internal_##De##_op_less_(Symb, Name, signed long); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned long); \
+ mln_internal_##De##_op_less_(Symb, Name, float); \
+ mln_internal_##De##_op_less_(Symb, Name, double); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
// FIXME: What about pointers, arrays, bool, etc.
// FIXME: Mod is not defined for float and double...
@@ -468,6 +518,12 @@ namespace mln
typedef mln_trait_op_less(O, mln::value::scalar_<B>) ret;
};
+ template <typename B, typename O>
+ struct set_binary_< op::less, mln::value::Built_In, B, mln::Object, O >
+ {
+ typedef mln_trait_op_less(mln::value::scalar_<B>, O) ret;
+ };
+
// 'Op+' is commutative so "o + b" => "o +
scalar(b)".
@@ -548,6 +604,10 @@ namespace mln
mln_internal_builtins_opeq_obj_(decl, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(decl, <, less);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -583,6 +643,10 @@ namespace mln
mln_internal_builtins_opeq_obj_(def, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(def, <, less);
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/world/inter_pixel/image2full.hh
b/milena/mln/world/inter_pixel/compute.hh
similarity index 56%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/compute.hh
index 03102f7..9cb01fe 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/compute.hh
@@ -25,20 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_COMPUTE_HH
+# define MLN_WORLD_INTER_PIXEL_COMPUTE_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/compute.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// FIXME: insert comment.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
namespace mln
@@ -50,44 +47,53 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
+ template <typename I, typename F>
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input, const Function_vv2v<F>& f);
-# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename F>
+ inline
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input_, const Function_vv2v<F>& f_)
{
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
+ trace::entering("world::inter_pixel::compute");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ mln_precondition(input.is_valid());
- trace::exiting("world::inter_pixel::image2full");
+ typedef mln_unmorph(I) I_;
+ typedef mln_ch_value(I_, mln_result(F)) O_;
+ O_ output_;
+ initialize(output_, input.unmorph_());
+
+ typedef image_if<O_, is_separator> O;
+ O output(output_, is_separator());
+
+ mln_piter(O) e(output.domain());
+ for_all(e)
+ {
+ mln_site(I) p1, p2;
+ separator_to_pixels(e, p1, p2);
+ output(e) = f(input(p1), input(p2));
+ }
+
+ trace::exiting("world::inter_pixel::compute");
return output;
}
-
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_COMPUTE_HH
diff --git a/milena/mln/world/inter_pixel/display_edge.hh
b/milena/mln/world/inter_pixel/display_edge.hh
index 6eb43c4..9cfa046 100644
--- a/milena/mln/world/inter_pixel/display_edge.hh
+++ b/milena/mln/world/inter_pixel/display_edge.hh
@@ -82,4 +82,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE
+#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh
b/milena/mln/world/inter_pixel/immerse.hh
similarity index 59%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/immerse.hh
index 03102f7..59df2a6 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/immerse.hh
@@ -25,20 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IMMERSE_HH
+# define MLN_WORLD_INTER_PIXEL_IMMERSE_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/immerse.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// Convert a classical image to an inter-pixel image.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/data/paste_without_localization.hh>
+# include <mln/geom/nsites.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
namespace mln
@@ -50,44 +47,48 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
+ /// Convert an image to an inter-pixel image.
///
+ /// \param[in] input An image.
/// \return An inter-pixel image.
//
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
+ template <typename I>
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input);
-# ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
+ template <typename I>
+ inline
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input_)
{
- trace::entering("world::inter_pixel::image2full");
+ trace::entering("world::inter_pixel::immerse");
+
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ const I& input = exact(input_);
mln_precondition(input.is_valid());
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ mln_domain(I) b(2 * input.domain().pmin(),
+ 2 * input.domain().pmax());
+ mln_concrete(I) output(b);
+ mln_assertion(geom::nsites(output | is_pixel()) == input.domain().nsites());
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+ data::paste_without_localization(input, (output | is_pixel()).rw());
+ trace::exiting("world::inter_pixel::immerse");
+ return output | is_pixel();
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IMMERSE_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh
b/milena/mln/world/inter_pixel/is_pixel.hh
similarity index 56%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/is_pixel.hh
index 03102f7..a393de6 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/is_pixel.hh
@@ -25,20 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
+# define MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/is_pixel.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// FIXME: doc.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
namespace mln
@@ -50,44 +46,48 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
-
-
-# ifndef MLN_INCLUDE_ONLY
+ struct is_pixel : public Function_p2b< is_pixel >
+ {
+ typedef bool result;
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
+ };
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ inline
+ bool
+ is_pixel::operator()(const Gpoint<P>& p_) const
+ {
+ const P& p = exact(p_);
+ const unsigned n = P::dim;
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] % 2 == 1)
+ return false;
+ return true;
+ }
+
+ template <typename P>
+ inline
+ bool
+ is_pixel::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh
b/milena/mln/world/inter_pixel/is_separator.hh
similarity index 56%
rename from milena/mln/world/inter_pixel/image2full.hh
rename to milena/mln/world/inter_pixel/is_separator.hh
index 03102f7..0c8f281 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/is_separator.hh
@@ -25,20 +25,18 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
+# define MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/is_separator.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
+/// FIXME: doc.
///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// \todo Make it work in n-D.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
namespace mln
@@ -50,44 +48,44 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
-
+ struct is_separator : public Function_p2b< is_separator >
+ {
+ typedef bool result;
-# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
+ };
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
-
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Gpoint<P>& p_) const
+ {
+ const P& p = exact(p_);
+ return p.row() % 2 + p.col() % 2 == 1;
+ }
+
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
diff --git a/milena/mln/world/inter_pixel/neighb2d.hh
b/milena/mln/world/inter_pixel/neighb2d.hh
index a61edeb..00e6418 100644
--- a/milena/mln/world/inter_pixel/neighb2d.hh
+++ b/milena/mln/world/inter_pixel/neighb2d.hh
@@ -101,4 +101,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D
+#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D_HH
diff --git a/milena/mln/world/inter_pixel/separator_to_pixels.hh
b/milena/mln/world/inter_pixel/separator_to_pixels.hh
new file mode 100644
index 0000000..9e77afc
--- /dev/null
+++ b/milena/mln/world/inter_pixel/separator_to_pixels.hh
@@ -0,0 +1,123 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+# define MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+
+/// \file mln/world/inter_pixel/separator_to_pixels.hh
+///
+/// FIXME: doc.
+///
+/// \todo Generalize to n-D.
+
+# include <mln/core/concept/gpoint.hh>
+# include <mln/core/concept/site_proxy.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+
+ template <typename P>
+ void
+ separator_to_pixels(const Gpoint<P>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+ template <typename Ps, typename P>
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename P>
+ inline
+ void
+ separator_to_pixels(const Gpoint<P>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const P& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ // FIXME: 2D only.
+ if (s.row() % 2)
+ {
+ // Horizontal edge.
+ p1 = point2d(s.row() - 1, s.col());
+ p2 = point2d(s.row() + 1, s.col());
+ }
+ else
+ {
+ // Vertical edge.
+ p1 = point2d(s.row(), s.col() - 1);
+ p2 = point2d(s.row(), s.col() + 1);
+ }
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+ template <typename Ps, typename P>
+ inline
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const Ps& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ separator_to_pixels(s.to_site(), p1, p2);
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
diff --git a/milena/tests/accu/Makefile.am b/milena/tests/accu/Makefile.am
index 7aca2bd..f7b9927 100644
--- a/milena/tests/accu/Makefile.am
+++ b/milena/tests/accu/Makefile.am
@@ -4,7 +4,8 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
image \
- site_set
+ site_set \
+ stat
check_PROGRAMS = \
all_accus \
diff --git a/milena/tests/fun/Makefile.am b/milena/tests/accu/stat/Makefile.am
similarity index 61%
copy from milena/tests/fun/Makefile.am
copy to milena/tests/accu/stat/Makefile.am
index 4ea605e..2e2b71c 100644
--- a/milena/tests/fun/Makefile.am
+++ b/milena/tests/accu/stat/Makefile.am
@@ -2,4 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x
+check_PROGRAMS = \
+ var
+
+var_SOURCES = var.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/fun/all.hh b/milena/tests/accu/stat/var.cc
similarity index 57%
copy from milena/mln/fun/all.hh
copy to milena/tests/accu/stat/var.cc
index 8e9ddad..40d2126 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/accu/stat/var.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,49 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/accu/stat/var.cc
+///
+/// Tests on mln::accu::stat::var.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
-namespace mln
+float my_rand(int c)
{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+int main()
+{
+ using namespace mln;
-}
+ typedef algebra::vec<3,float> vec3f;
+ enum { n = 1000 };
+ vec3f v[n];
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+ mln_assertion(a.n_items() == n);
-#endif // ! MLN_FUN_ALL_HH
+ vec3f m = a.mean();
+ mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+ mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+ mln_assertion(m[2] > 1.4 && m[2] < 1.6);
+
+ algebra::mat<3,3,float> s_1 = a.variance()._1();
+ mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+ mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+ mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
diff --git a/milena/tests/fun/Makefile.am b/milena/tests/fun/Makefile.am
index 4ea605e..7cea3a5 100644
--- a/milena/tests/fun/Makefile.am
+++ b/milena/tests/fun/Makefile.am
@@ -2,4 +2,12 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x
+SUBDIRS = \
+ i2v \
+ p2b \
+ p2p \
+ p2v \
+ stat \
+ v2v \
+ vv2v \
+ x2x
diff --git a/milena/tests/world/inter_pixel/Makefile.am
b/milena/tests/fun/stat/Makefile.am
similarity index 61%
copy from milena/tests/world/inter_pixel/Makefile.am
copy to milena/tests/fun/stat/Makefile.am
index cffbcdd..c9bc2e6 100644
--- a/milena/tests/world/inter_pixel/Makefile.am
+++ b/milena/tests/fun/stat/Makefile.am
@@ -2,12 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = \
- dim2
+check_PROGRAMS = \
+ mahalanobis
-check_PROGRAMS = \
- image2full
-
-image2full_SOURCES = image2full.cc
+mahalanobis_SOURCES = mahalanobis.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/fun/all.hh b/milena/tests/fun/stat/mahalanobis.cc
similarity index 55%
copy from milena/mln/fun/all.hh
copy to milena/tests/fun/stat/mahalanobis.cc
index 8e9ddad..7df7af2 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/fun/stat/mahalanobis.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,50 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/fun/stat/mahalanobis.cc
+///
+/// Tests on mln::fun::stat::mahalanobis.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
+#include <mln/fun/stat/mahalanobis.hh>
-namespace mln
+float my_rand(int c)
{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+int main()
+{
+ using namespace mln;
-}
+ typedef algebra::vec<3,float> vec3f;
+ enum { n = 1000 };
+ vec3f v[n];
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+// vec3f m = a.mean();
+// mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+// mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+// mln_assertion(m[2] > 1.4 && m[2] < 1.6);
-#endif // ! MLN_FUN_ALL_HH
+ fun::stat::mahalanobis<vec3f> f(a.variance(), a.mean());
+
+// algebra::mat<3,3,float> s_1 = a.variance()._1();
+// mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+// mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+// mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
diff --git a/milena/tests/world/inter_pixel/Makefile.am
b/milena/tests/world/inter_pixel/Makefile.am
index cffbcdd..fdbcea2 100644
--- a/milena/tests/world/inter_pixel/Makefile.am
+++ b/milena/tests/world/inter_pixel/Makefile.am
@@ -5,9 +5,11 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
dim2
-check_PROGRAMS = \
- image2full
+check_PROGRAMS = \
+ image2full \
+ immerse
image2full_SOURCES = image2full.cc
+immerse_SOURCES = immerse.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/convert/to_fun.hh b/milena/tests/world/inter_pixel/compute.cc
similarity index 52%
copy from milena/mln/convert/to_fun.hh
copy to milena/tests/world/inter_pixel/compute.cc
index 86a1ddc..9226a67 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/tests/world/inter_pixel/compute.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,55 +25,63 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CONVERT_TO_FUN_HH
-# define MLN_CONVERT_TO_FUN_HH
+/// \file tests/world/inter_pixel/compute.cc
+///
+/// Tests on mln::world::inter_pixel::compute.
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+#include <cmath>
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/immerse.hh>
+#include <mln/world/inter_pixel/compute.hh>
+#include <mln/world/inter_pixel/neighb2d.hh>
+#include <mln/morpho/watershed/flooding.hh>
+#include <mln/debug/println.hh>
-namespace mln
+
+
+struct d_t : mln::Function_vv2v<d_t>
{
+ typedef int result;
- namespace convert
+ int operator()(int i1, int i2) const
{
+ return std::abs(i2 - i1);
+ }
+}
+ d;
- /// Convert a C unary function into an mln::fun::C.
- template <typename R, typename A>
- fun::C<R(*)(A)> to_fun(R (*f)(A));
- /// Convert an image into a function.
- template <typename I>
- pw::value_<I> to_fun(const Image<I>& ima);
+int main()
+{
+ using namespace mln;
-# ifndef MLN_INCLUDE_ONLY
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
- {
- return pw::value(ima);
- }
+ using namespace world::inter_pixel;
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
-# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
+ int refs[] = { 0, 1, 0, 1, 0,
+ 2, 0, 1, 0, 1,
+ 0, 2, 0, 3, 0,
+ 7, 0, 4, 0, 3,
+ 0, 1, 0, 4, 0 };
-} // end of namespace mln
+ mln_assertion(compute(imax, d) == (make::image2d(refs) | is_separator()));
+ mln_VAR(g, compute(imax, d));
-#endif // ! MLN_CONVERT_TO_FUN_HH
+ unsigned n_basins;
+ debug::println(morpho::watershed::flooding(g, e2e(), n_basins));
+}
diff --git a/milena/mln/fun/all.hh b/milena/tests/world/inter_pixel/immerse.cc
similarity index 61%
copy from milena/mln/fun/all.hh
copy to milena/tests/world/inter_pixel/immerse.cc
index 8e9ddad..42094b9 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/world/inter_pixel/immerse.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,42 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/world/inter_pixel/immerse.cc
+///
+/// Tests on mln::world::inter_pixel::immerse.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/immerse.hh>
-namespace mln
+int main()
{
+ using namespace mln;
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
-}
+ using namespace world::inter_pixel;
+
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ int refs[] = { 3, 0, 4, 0, 5,
+ 0, 0, 0, 0, 0,
+ 1, 0, 3, 0, 6,
+ 0, 0, 0, 0, 0,
+ 8, 0, 7, 0, 3 };
+ mln_assertion(imax == (make::image2d(refs) | is_pixel()));
-#endif // ! MLN_FUN_ALL_HH
+ mln_piter_(Ix) p(imax.domain());
+ for_all(p)
+ mln_assertion(is_pixel()(p));
+}
--
1.6.1.2