* mln/core/concept/gpoint.hh: Add operator /.
* mln/world/inter_pixel/all.hh: Add ful2image.hh inclusion.
* mln/world/inter_pixel/full2image.hh: Fix domain.
---
milena/ChangeLog | 7 +++++
milena/mln/core/concept/gpoint.hh | 20 ++++++++++++---
milena/mln/world/inter_pixel/all.hh | 1 +
milena/mln/world/inter_pixel/full2image.hh | 37 ++++++++++++++-------------
4 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e0e1cee..44d34d3 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-11 Fabien Freling <fabien.freling(a)lrde.epita.fr>
+
+ Fix full2image() domain for cropped images.
+ * mln/core/concept/gpoint.hh: Add operator /.
+ * mln/world/inter_pixel/all.hh: Add ful2image.hh inclusion.
+ * mln/world/inter_pixel/full2image.hh: Fix domain.
+
2009-05-11 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Small fixes.
diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh
index 504e2ac..601d5d2 100644
--- a/milena/mln/core/concept/gpoint.hh
+++ b/milena/mln/core/concept/gpoint.hh
@@ -82,6 +82,13 @@ namespace mln
typedef L ret;
};
+ template < typename L, typename R >
+ struct set_binary_< op::div,
+ mln::Gpoint, L,
+ mln::Object, mln::value::scalar_<R> >
+ {
+ typedef L ret;
+ };
template <typename P>
struct set_unary_< op::ord, mln::Gpoint, P >
@@ -279,7 +286,7 @@ namespace mln
* \relates mln::Gpoint
*/
template <typename P, typename D>
- P operator/(Gpoint<P>& p, const value::Scalar<D>& dp);
+ P operator/(const Gpoint<P>& p, const value::scalar_<D>& dp);
// FIXME : add operators and traits?
@@ -400,7 +407,7 @@ namespace mln
P
operator*(const Gpoint<P>& p, const value::scalar_<S>& s)
{
- int s_ = s.to_equiv();
+ S s_ = s.to_equiv();
const unsigned n = P::dim;
P tmp = exact(p);
for (unsigned i = 0; i < n; ++i)
@@ -439,9 +446,14 @@ namespace mln
template <typename P, typename S>
inline
P
- operator/(Gpoint<P>& p, const value::Scalar<S>& s_)
+ operator/(const Gpoint<P>& p, const value::scalar_<S>& s_)
{
- return p.to_vec() / s_;
+ S 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;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/world/inter_pixel/all.hh b/milena/mln/world/inter_pixel/all.hh
index da3b105..37536b2 100644
--- a/milena/mln/world/inter_pixel/all.hh
+++ b/milena/mln/world/inter_pixel/all.hh
@@ -38,6 +38,7 @@
# include <mln/world/inter_pixel/compute.hh>
+# include <mln/world/inter_pixel/full2image.hh>
# include <mln/world/inter_pixel/immerse.hh>
# include <mln/world/inter_pixel/is_separator.hh>
# include <mln/world/inter_pixel/is_pixel.hh>
diff --git a/milena/mln/world/inter_pixel/full2image.hh
b/milena/mln/world/inter_pixel/full2image.hh
index 50f6b28..15ebcd5 100644
--- a/milena/mln/world/inter_pixel/full2image.hh
+++ b/milena/mln/world/inter_pixel/full2image.hh
@@ -31,14 +31,11 @@
/// \file mln/world/inter_pixel/full2image.hh
///
/// Convert an inter-pixel image to a classical image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
-# 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
@@ -56,27 +53,31 @@ namespace mln
///
/// \return A classical image without inter-pixel data.
//
- template <typename T>
- image2d<T>
- full2image(const image2d<T>& input);
+ template <typename I>
+ I
+ full2image(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- full2image(const image2d<T>& input)
+ template <typename I>
+ I
+ full2image(const Image<I>& input_)
{
trace::entering("world::inter_pixel::full2image");
+
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ const I& input = exact(input_);
mln_precondition(input.is_valid());
- image2d<T> output((input.nrows() + 1) / 2, (input.ncols() + 1) / 2);
+ mln_domain(I) b(input.domain().pmin() / 2,
+ input.domain().pmax() / 2);
+ mln_concrete(I) output(b);
+ mln_assertion(geom::nsites(output) == geom::nsites(input | is_pixel()));
- for (int row = geom::min_row(input); row <= geom::max_row(input); row += 2)
- for (int col = geom::min_col(input); col <= geom::max_col(input); col += 2)
- opt::at(output, row / 2, col / 2) =
- opt::at(input, row, col);
+ data::paste_without_localization(input | is_pixel(), output);
trace::exiting("world::inter_pixel::full2image");
return output;
--
1.6.1.2