https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a maker of image3d from an array of 2D images.
* mln/trait/concrete.hh: Upgrade file doc style.
(mon_concrete_): New macro.
* mln/core/image/slice_image.hh (ch_value): New specialization.
* mln/make/image2d.hh (todo): New.
* mln/make/image3d.hh: New.
* mln/make/all.hh: Update.
* tests/make/image3d.cc: New.
* tests/make/Makefile.am: Update.
mln/core/image/slice_image.hh | 14 ++++++
mln/make/all.hh | 1
mln/make/image2d.hh | 3 +
mln/make/image3d.hh | 90 ++++++++++++++++++++++++++++++++++++++++++
mln/trait/concrete.hh | 12 +++--
tests/make/Makefile.am | 2
tests/make/image3d.cc | 54 +++++++++++++++++++++++++
7 files changed, 171 insertions(+), 5 deletions(-)
Index: mln/trait/concrete.hh
--- mln/trait/concrete.hh (revision 3215)
+++ mln/trait/concrete.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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,15 +29,16 @@
#ifndef MLN_TRAIT_CONCRETE_HH
# define MLN_TRAIT_CONCRETE_HH
-/*! \file mln/trait/concrete.hh
- *
- * \brief Definition of the concrete image trait.
- */
+/// \file mln/trait/concrete.hh
+///
+/// Definition of the concrete image trait.
# include <mln/trait/ch_value.hh>
# define mln_concrete(I) typename mln::trait::concrete< I >::ret
+# define mln_concrete_(I) mln::trait::concrete< I >::ret
+
# define mln_concrete_ch_value(I, V) mln_ch_value(mln_concrete(I), V)
Index: mln/core/image/slice_image.hh
--- mln/core/image/slice_image.hh (revision 3215)
+++ mln/core/image/slice_image.hh (working copy)
@@ -132,6 +132,20 @@
+
+ namespace trait
+ {
+
+ template <typename I, typename V>
+ struct ch_value< slice_image<I>, V >
+ {
+ typedef image2d<V> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+
# ifndef MLN_INCLUDE_ONLY
Index: mln/make/all.hh
--- mln/make/all.hh (revision 3215)
+++ mln/make/all.hh (working copy)
@@ -51,6 +51,7 @@
# include <mln/make/graph.hh>
# include <mln/make/image.hh>
# include <mln/make/image2d.hh>
+# include <mln/make/image3d.hh>
# include <mln/make/mat.hh>
# include <mln/make/pix.hh>
# include <mln/make/pixel.hh>
Index: mln/make/image2d.hh
--- mln/make/image2d.hh (revision 3215)
+++ mln/make/image2d.hh (working copy)
@@ -31,6 +31,9 @@
/// \file mln/make/image2d.hh
///
/// Routine to create a 2D image from a 1D array.
+///
+/// \todo Think about removing make::image2d since it is redundant
+/// with convert::to and convert::from_to.
# include <mln/core/image/image2d.hh>
Index: mln/make/image3d.hh
--- mln/make/image3d.hh (revision 0)
+++ mln/make/image3d.hh (revision 0)
@@ -0,0 +1,90 @@
+// Copyright (C) 2008 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_MAKE_IMAGE3D_HH
+# define MLN_MAKE_IMAGE3D_HH
+
+/// \file mln/make/image3d.hh
+///
+/// Routine to create a 3D image from an array of 2D images.
+///
+/// \todo Think about removing make::image3d since it is redundant
+/// with convert::to and convert::from_to.
+
+# include <mln/core/image/image3d.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/core/image/slice_image.hh>
+# include <mln/data/paste.hh>
+# include <mln/util/array.hh>
+
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /// Create an image3d from an array of 2D images.
+ ///
+ template <typename I>
+ mln::image3d<mln_value(I)>
+ image3d(const util::array<I>& ima);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ mln::image3d<mln_value(I)>
+ image3d(const util::array<I>& ima)
+ {
+ mlc_is_a(mln_pset(I), Box)::check();
+ mln_precondition(! ima.is_empty());
+
+ def::coord n_slices = ima.nelements();
+ mln::box2d b = ima[0].domain();
+ mln::box3d b_ = make::box3d(0, b.pmin().row(), b.pmin().col(),
+ n_slices - 1, b.pmax().row(), b.pmax().col());
+ mln::image3d<mln_value(I)> output(b_);
+ for (def::coord sli = 0; sli < n_slices; ++sli)
+ {
+ mln_assertion(ima[sli].domain() == b);
+ data::paste(ima[sli], slice(output, sli).rw());
+ }
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_IMAGE3D_HH
Index: tests/make/Makefile.am
--- tests/make/Makefile.am (revision 3215)
+++ tests/make/Makefile.am (working copy)
@@ -5,12 +5,14 @@
check_PROGRAMS = \
dual_neighb \
image2d \
+ image3d \
mat \
w_window \
w_window_directional
dual_neighb_SOURCES = dual_neighb.cc
image2d_SOURCES = image2d.cc
+image3d_SOURCES = image3d.cc
mat_SOURCES = mat.cc
w_window_SOURCES = w_window.cc
w_window_directional_SOURCES = w_window_directional.cc
Index: tests/make/image3d.cc
--- tests/make/image3d.cc (revision 0)
+++ tests/make/image3d.cc (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (C) 2008 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.
+
+/// \file tests/make/image3d.cc
+///
+/// Tests on mln::make::image3d.
+
+#include <mln/make/image3d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/core/routine/duplicate.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned n_slices = 3;
+
+ image3d<int> vol(n_slices, 2, 4);
+ debug::iota(vol);
+
+ typedef image2d<int> I;
+ util::array<I> ima;
+ for (unsigned i = 0; i < n_slices; ++i)
+ ima.append( duplicate(slice(vol, i)) );
+
+ image3d<int> vol_ = make::image3d(ima);
+ mln_assertion(vol_ == vol);
+}
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a slice morpher.
* mln/core/image/slice_image.hh: New.
* mln/core/image/all.hh: Update.
* tests/core/image/slice_image.cc: New.
* tests/core/image/Makefile.am: Update.
* tests/core/image/p2p_image.cc: Fix file doc.
mln/core/image/all.hh | 1
mln/core/image/slice_image.hh | 276 ++++++++++++++++++++++++++++++++++++++++
tests/core/image/Makefile.am | 2
tests/core/image/p2p_image.cc | 2
tests/core/image/slice_image.cc | 51 +++++++
5 files changed, 331 insertions(+), 1 deletion(-)
Index: mln/core/image/all.hh
--- mln/core/image/all.hh (revision 3214)
+++ mln/core/image/all.hh (working copy)
@@ -78,6 +78,7 @@
//# include <mln/core/image/rle_encode.hh>
//# include <mln/core/image/rle_image.hh>
# include <mln/core/image/safe.hh>
+# include <mln/core/image/slice_image.hh>
# include <mln/core/image/sparse_encode.hh>
# include <mln/core/image/sparse_image.hh>
# include <mln/core/image/sub_image.hh>
Index: mln/core/image/slice_image.hh
--- mln/core/image/slice_image.hh (revision 0)
+++ mln/core/image/slice_image.hh (revision 0)
@@ -0,0 +1,276 @@
+// Copyright (C) 2008 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_CORE_IMAGE_SLICE_IMAGE_HH
+# define MLN_CORE_IMAGE_SLICE_IMAGE_HH
+
+/// \file mln/core/image/slice_image.hh
+///
+/// Definition of an image FIXME: Doc!
+///
+/// \todo Write init_.
+
+# include <mln/core/internal/image_domain_morpher.hh>
+# include <mln/core/alias/box3d.hh>
+# include <mln/core/alias/box2d.hh>
+
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I> struct slice_image;
+
+
+ namespace internal
+ {
+
+ /// Data structure for \c mln::slice_image<I>.
+ template <typename I>
+ struct data< slice_image<I> >
+ {
+ data(I& ima, def::coord sli);
+
+ I ima_;
+ def::coord sli_;
+ box2d b_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I>
+ struct image_< slice_image<I> > : default_image_morpher< I,
+ mln_value(I),
+ slice_image<I> >
+ {
+ typedef trait::image::category::domain_morpher category;
+
+ typedef trait::image::dimension::two_d dimension;
+
+// typedef trait::image::ext_domain::none ext_domain; // No extension of domain.
+// typedef trait::image::ext_value::irrelevant ext_value;
+// typedef trait::image::ext_io::irrelevant ext_io;
+
+ typedef trait::image::vw_io::none vw_io;
+ typedef trait::image::vw_set::none vw_set;
+ typedef trait::image::value_alignement::not_aligned value_alignement;
+ typedef trait::image::value_storage::disrupted value_storage;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ /// FIXME: Doc!
+ template <typename I>
+ struct slice_image : public internal::image_domain_morpher< I,
+ box2d,
+ slice_image<I> >
+ {
+ /// Skeleton.
+ typedef slice_image< tag::image_<I> > skeleton;
+
+ /// Constructor without argument.
+ slice_image();
+
+ /// Constructor from an image \p ima and a predicate \p f.
+ slice_image(I& ima, def::coord sli);
+
+ void init_(I& ima, def::coord sli);
+
+
+ /// Give the definition domain.
+ const box2d& domain() const;
+
+ /// Give the slice number.
+ def::coord sli() const;
+
+ /// Read-only access to the image value located at point \p p.
+ mln_rvalue(I) operator()(const point2d& p) const;
+
+ /// Read-write access to the image value located at point \p p.
+ mln_morpher_lvalue(I) operator()(const point2d& p);
+ };
+
+
+
+ template <typename I>
+ slice_image<I>
+ slice(Image<I>& ima, def::coord sli);
+
+ template <typename I>
+ slice_image<const I>
+ slice(const Image<I>& ima, def::coord sli);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+// // init_.
+
+// template <typename I, typename J>
+// void init_(tag::image_t, slice_image<I>& target, const J& model)
+// {
+// I ima;
+// init_(tag::image, ima, exact(model));
+// def::coord sli;
+// // FIXME
+// // init_(tag::???, sli, exact(model));
+// target.init_(ima, sli);
+// }
+
+
+ // internal::data< slice_image<I> >
+
+ namespace internal
+ {
+
+ template <typename I>
+ inline
+ data< slice_image<I> >::data(I& ima, def::coord sli)
+ : ima_(ima),
+ sli_(sli)
+ {
+ b_ = make::box2d(ima.domain().pmin().row(), ima.domain().pmin().col(),
+ ima.domain().pmax().row(), ima.domain().pmax().col());
+ }
+
+ }
+
+
+ // slice_image<I>
+
+ template <typename I>
+ inline
+ slice_image<I>::slice_image()
+ {
+ }
+
+ template <typename I>
+ inline
+ slice_image<I>::slice_image(I& ima, def::coord sli)
+ {
+ init_(ima, sli);
+ }
+
+ template <typename I>
+ inline
+ void
+ slice_image<I>::init_(I& ima, def::coord sli)
+ {
+ mln_precondition(! this->is_valid());
+ this->data_ = new internal::data< slice_image<I> >(ima, sli);
+ }
+
+ template <typename I>
+ inline
+ const box2d&
+ slice_image<I>::domain() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->b_;
+ }
+
+ template <typename I>
+ inline
+ def::coord
+ slice_image<I>::sli() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->sli_;
+ }
+
+ template <typename I>
+ inline
+ mln_rvalue(I)
+ slice_image<I>::operator()(const point2d& p) const
+ {
+ mln_precondition(this->has(p));
+ point3d p_(this->data_->sli_, p.row(), p.col());
+ mln_precondition(this->data_->ima_.has(p_));
+ return this->data_->ima_(p_);
+ }
+
+ template <typename I>
+ inline
+ mln_morpher_lvalue(I)
+ slice_image<I>::operator()(const point2d& p)
+ {
+ mln_precondition(this->has(p));
+ point3d p_(this->data_->sli_, p.row(), p.col());
+ mln_precondition(this->data_->ima_.has(p_));
+ return this->data_->ima_(p_);
+ }
+
+
+ // Routines.
+
+ template <typename I>
+ inline
+ slice_image<I>
+ slice(Image<I>& ima_, def::coord sli)
+ {
+ mlc_equal(mln_pset(I), box3d)::check();
+
+ I& ima = exact(ima_);
+ mln_precondition(ima.is_valid());
+ mln_precondition(sli >= ima.domain().pmin().sli() &&
+ sli <= ima.domain().pmax().sli());
+
+ slice_image<I> tmp(ima, sli);
+ return tmp;
+ }
+
+ template <typename I>
+ inline
+ slice_image<const I>
+ slice(const Image<I>& ima_, def::coord sli)
+ {
+ mlc_equal(mln_pset(I), box3d)::check();
+
+ I& ima = exact(ima_);
+ mln_precondition(ima.is_valid());
+ mln_precondition(sli >= ima.domain().pmin().sli() &&
+ sli <= ima.domain().pmax().sli());
+
+ slice_image<I> tmp(ima, sli);
+ return tmp;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_IMAGE_SLICE_IMAGE_HH
Index: tests/core/image/slice_image.cc
--- tests/core/image/slice_image.cc (revision 0)
+++ tests/core/image/slice_image.cc (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (C) 2008 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.
+
+/// \file tests/core/image/slice_image.cc
+///
+/// Tests on mln::slice_image.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/slice_image.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image3d<int> ima(3, 2, 4);
+
+ for (def::coord s = 0; s < 3; ++s)
+ debug::iota(slice(ima, s).rw());
+
+ mln_assertion( slice(ima, 1) == slice(ima, 0) );
+ mln_assertion( slice(ima, 2) == slice(ima, 0) );
+}
Index: tests/core/image/p2p_image.cc
--- tests/core/image/p2p_image.cc (revision 3214)
+++ tests/core/image/p2p_image.cc (working copy)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/core/image/image2d.cc
+/// \file tests/core/image/p2p_image.cc
///
/// Tests on mln::p2p_image.
Index: tests/core/image/Makefile.am
--- tests/core/image/Makefile.am (revision 3214)
+++ tests/core/image/Makefile.am (working copy)
@@ -25,6 +25,7 @@
plain \
## rle_image \
safe_image \
+ slice_image \
## sparse_image \
sub_image \
t_image \
@@ -54,6 +55,7 @@
plain_SOURCES = plain.cc
##rle_image_SOURCES = rle_image.cc
safe_image_SOURCES = safe_image.cc
+slice_image_SOURCES = slice_image.cc
##sparse_image_SOURCES = sparse_image.cc
sub_image_SOURCES = sub_image.cc
t_image_SOURCES = t_image.cc
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add fun p2p translation and p2p_image morpher.
* mln/core/image/p2p_image.hh: New.
* mln/core/image/all.hh: Update.
* mln/fun/p2p/all.hh: New.
* mln/fun/p2p/mirror.hh (endif): Fix comment style.
* mln/fun/p2p/translation.hh: New.
* tests/core/image/p2p_image.cc: New.
* tests/core/image/Makefile.am: Update.
* tests/fun/p2p: New.
* tests/fun/p2p/translation.cc: New.
* tests/fun/p2p/Makefile.am: New.
* tests/fun/Makefile.am: Update.
* mln/core/image/image_if.hh (undef): Fix, i.e., remove.
mln/core/image/all.hh | 1
mln/core/image/image_if.hh | 3
mln/core/image/p2p_image.hh | 274 ++++++++++++++++++++++++++++++++++++++++++
mln/fun/p2p/all.hh | 53 ++++++++
mln/fun/p2p/mirror.hh | 2
mln/fun/p2p/translation.hh | 116 +++++++++++++++++
tests/core/image/Makefile.am | 2
tests/core/image/p2p_image.cc | 60 +++++++++
tests/fun/Makefile.am | 2
tests/fun/p2p/Makefile.am | 10 +
tests/fun/p2p/translation.cc | 44 ++++++
11 files changed, 562 insertions(+), 5 deletions(-)
Index: mln/core/image/image_if.hh
--- mln/core/image/image_if.hh (revision 3213)
+++ mln/core/image/image_if.hh (working copy)
@@ -264,7 +264,4 @@
} // end of namespace mln
-# undef Super
-
-
#endif // ! MLN_CORE_IMAGE_IMAGE_IF_HH
Index: mln/core/image/p2p_image.hh
--- mln/core/image/p2p_image.hh (revision 0)
+++ mln/core/image/p2p_image.hh (revision 0)
@@ -0,0 +1,274 @@
+// Copyright (C) 2008 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_CORE_IMAGE_P2P_IMAGE_HH
+# define MLN_CORE_IMAGE_P2P_IMAGE_HH
+
+/// \file mln/core/image/p2p_image.hh
+///
+/// Definition of a image FIXME: Doc!
+
+# include <mln/core/internal/image_domain_morpher.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/accu/bbox.hh>
+
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename F> struct p2p_image;
+
+
+ namespace internal
+ {
+
+ /// Data structure for \c mln::p2p_image<I,F>.
+ template <typename I, typename F>
+ struct data< p2p_image<I,F> >
+ {
+ data(I& ima, const F& f);
+
+ I ima_;
+ F f_;
+ mln_pset(I) b_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I, typename F>
+ struct image_< p2p_image<I,F> > : default_image_morpher< I,
+ mln_value(I),
+ p2p_image<I,F> >
+ {
+ typedef trait::image::category::domain_morpher category;
+
+ typedef trait::image::ext_domain::none ext_domain; // No extension of domain.
+ typedef trait::image::ext_value::irrelevant ext_value;
+ typedef trait::image::ext_io::irrelevant ext_io;
+
+ typedef trait::image::vw_io::none vw_io;
+ typedef trait::image::vw_set::none vw_set;
+ typedef trait::image::value_alignement::not_aligned value_alignement;
+ typedef trait::image::value_storage::disrupted value_storage;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ /// FIXME: Doc!
+ template <typename I, typename F>
+ struct p2p_image : public internal::image_domain_morpher< I,
+ mln_pset(I),
+ p2p_image<I, F> >
+ {
+ /// Skeleton.
+ typedef p2p_image< tag::image_<I>, tag::function_<F> > skeleton;
+
+ /// Constructor without argument.
+ p2p_image();
+
+ /// Constructor from an image \p ima and a predicate \p f.
+ p2p_image(I& ima, const F& f);
+
+ void init_(I& ima, const F& f);
+
+ /// Give the definition domain.
+ const mln_pset(I)& domain() const;
+
+ /// Give the p2p function.
+ const F& fun() const;
+
+ /// Read-only access to the image value located at point \p p.
+ mln_rvalue(I) operator()(const mln_psite(I)& p) const;
+
+ /// Read-write access to the image value located at point \p p.
+ mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
+ };
+
+
+
+ /// FIXME: Doc!
+ template <typename I, typename F>
+ p2p_image<I,F>
+ apply_p2p(Image<I>& ima, const Function_p2p<F>& f);
+
+ /// FIXME: Doc!
+ template <typename I, typename F>
+ p2p_image<const I,F>
+ apply_p2p(const Image<I>& ima, const Function_p2p<F>& f);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // init_.
+
+ template <typename I, typename F>
+ void init_(tag::function_t, F& f, const p2p_image<I,F>& model)
+ {
+ f = model.fun();
+ }
+
+ template <typename I, typename F, typename J>
+ void init_(tag::image_t, p2p_image<I,F>& target, const J& model)
+ {
+ I ima;
+ init_(tag::image, ima, exact(model));
+ F f;
+ init_(tag::function, f, exact(model));
+ target.init_(ima, f);
+ }
+
+ // internal::data< p2p_image<I,F> >
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ data< p2p_image<I,F> >::data(I& ima, const F& f)
+ : ima_(ima),
+ f_(f)
+ {
+ accu::bbox<mln_site(I)> a;
+ mln_pset(I) b = ima.domain();
+ a.take(f(b.pmin()));
+ a.take(f(b.pmax()));
+ b_ = a.to_result();
+ mln_invariant(b_.nsites() == b.nsites());
+ }
+
+ }
+
+
+ // p2p_image<I,F>
+
+ template <typename I, typename F>
+ inline
+ p2p_image<I,F>::p2p_image()
+ {
+ }
+
+ template <typename I, typename F>
+ inline
+ p2p_image<I,F>::p2p_image(I& ima, const F& f)
+ {
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ p2p_image<I,F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ this->data_ = new internal::data< p2p_image<I,F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ const mln_pset(I)&
+ p2p_image<I,F>::domain() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->b_;
+ }
+
+ template <typename I, typename F>
+ inline
+ const F&
+ p2p_image<I,F>::fun() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_;
+ }
+
+ template <typename I, typename F>
+ inline
+ mln_rvalue(I)
+ p2p_image<I,F>::operator()(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->has(p));
+ mln_invariant(this->data_->ima_.has(this->data_->f_.inverse(p)));
+ return this->data_->ima_(this->data_->f_.inverse(p));
+ }
+
+ template <typename I, typename F>
+ inline
+ mln_morpher_lvalue(I)
+ p2p_image<I,F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->has(p));
+ mln_invariant(this->data_->ima_.has(this->data_->f_.inverse(p)));
+ return this->data_->ima_(this->data_->f_.inverse(p));
+ }
+
+
+ // Routines.
+
+ template <typename I, typename F>
+ inline
+ p2p_image<I,F>
+ apply_p2p(Image<I>& ima_, const Function_p2p<F>& f)
+ {
+ mlc_is_a(mln_pset(I), Box)::check();
+
+ I& ima = exact(ima_);
+ mln_precondition(ima.is_valid());
+
+ p2p_image<I,F> tmp(ima, exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ inline
+ p2p_image<const I, F>
+ apply_p2p(const Image<I>& ima_, const Function_p2p<F>& f)
+ {
+ mlc_is_a(mln_pset(I), Box)::check();
+
+ const I& ima = exact(ima_);
+ mln_precondition(ima.is_valid());
+
+ p2p_image<const I, F> tmp(ima, exact(f));
+ return tmp;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_IMAGE_P2P_IMAGE_HH
Index: mln/core/image/all.hh
--- mln/core/image/all.hh (revision 3213)
+++ mln/core/image/all.hh (working copy)
@@ -73,6 +73,7 @@
//# include <mln/core/image/mono_rle_image.hh>
//# include <mln/core/image/obased_rle_encode.hh>
//# include <mln/core/image/obased_rle_image.hh>
+# include <mln/core/image/p2p_image.hh>
# include <mln/core/image/plain.hh>
//# include <mln/core/image/rle_encode.hh>
//# include <mln/core/image/rle_image.hh>
Index: mln/fun/p2p/all.hh
--- mln/fun/p2p/all.hh (revision 0)
+++ mln/fun/p2p/all.hh (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (C) 2008 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_FUN_P2P_ALL_HH
+# define MLN_FUN_P2P_ALL_HH
+
+/// \file mln/fun/p2p/all.hh
+///
+/// File that includes all functions from grid point to grid point.
+
+
+namespace mln
+{
+ namespace fun
+ {
+
+ /// Namespace of functions from grid point to grid point.
+ namespace p2p
+ {}
+
+ }
+}
+
+
+# include <mln/fun/p2p/mirror.hh>
+# include <mln/fun/p2p/translation.hh>
+
+
+#endif // ! MLN_FUN_P2P_ALL_HH
Index: mln/fun/p2p/mirror.hh
--- mln/fun/p2p/mirror.hh (revision 3213)
+++ mln/fun/p2p/mirror.hh (working copy)
@@ -87,5 +87,5 @@
} // end of namespace mln
-#endif /* MLN_FUN_P2P_MIRROR_HH */
+#endif // ! MLN_FUN_P2P_MIRROR_HH
Index: mln/fun/p2p/translation.hh
--- mln/fun/p2p/translation.hh (revision 0)
+++ mln/fun/p2p/translation.hh (revision 0)
@@ -0,0 +1,116 @@
+// Copyright (C) 2008 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_FUN_P2P_TRANSLATION_HH
+# define MLN_FUN_P2P_TRANSLATION_HH
+
+/// \file mln/fun/p2p/translation.hh
+///
+/// FIXME: doc
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2p
+ {
+
+ template <typename P>
+ struct translation_t : public Function_p2p< translation_t<P> >
+ {
+ typedef P result;
+
+ translation_t(const mln_delta(P)& dp);
+
+ P operator()(const P& p) const;
+ P inverse(const P& p) const;
+
+ protected:
+ mln_delta(P) dp_;
+ };
+
+
+ template <typename D>
+ translation_t<mln_site(D)>
+ translation(const Gdpoint<D>& dp);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ translation_t<P>::translation_t(const mln_delta(P)& dp)
+ : dp_(dp)
+ {
+ }
+
+ template <typename P>
+ inline
+ P
+ translation_t<P>::operator()(const P& p) const
+ {
+ return p + dp_;
+ }
+
+ template <typename P>
+ inline
+ P
+ translation_t<P>::inverse(const P& p) const
+ {
+ return p - dp_;
+ }
+
+
+ template <typename D>
+ inline
+ translation_t<mln_site(D)>
+ translation(const Gdpoint<D>& dp)
+ {
+ translation_t<mln_site(D)> tmp(exact(dp));
+ return tmp;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2p
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2P_TRANSLATION_HH
+
+
Index: tests/core/image/p2p_image.cc
--- tests/core/image/p2p_image.cc (revision 0)
+++ tests/core/image/p2p_image.cc (revision 0)
@@ -0,0 +1,60 @@
+// Copyright (C) 2008 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.
+
+/// \file tests/core/image/image2d.cc
+///
+/// Tests on mln::p2p_image.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/p2p_image.hh>
+#include <mln/fun/p2p/translation.hh>
+
+#include <mln/debug/iota.hh>
+
+
+
+# define ima_ apply_p2p(ima, fun::p2p::translation(dp))
+
+
+
+int main()
+{
+ using namespace mln;
+
+ box2d b = make::box2d(0,0, 2,2);
+ image2d<int> ima(b, 0); // No border.
+
+ debug::iota(ima);
+
+ dpoint2d dp(-1,+1);
+ box2d b_ = make::box2d(-1,+1, 1,3);
+
+ mln_assertion( ima_.domain() == b_ );
+
+ mln_assertion( ima_(point2d(-1,+1)) == 1 );
+ mln_assertion( ima_(point2d( 1, 3)) == 9 );
+}
Index: tests/core/image/Makefile.am
--- tests/core/image/Makefile.am (revision 3213)
+++ tests/core/image/Makefile.am (working copy)
@@ -21,6 +21,7 @@
## mono_obased_rle_image \
## mono_rle_image \
## obased_rle_image \
+ p2p_image \
plain \
## rle_image \
safe_image \
@@ -49,6 +50,7 @@
##mono_obased_rle_image_SOURCES = mono_obased_rle_image.cc
##mono_rle_image_SOURCES = mono_rle_image.cc
##obased_rle_image_SOURCES = obased_rle_image.cc
+p2p_image_SOURCES = p2p_image.cc
plain_SOURCES = plain.cc
##rle_image_SOURCES = rle_image.cc
safe_image_SOURCES = safe_image.cc
Index: tests/fun/p2p/translation.cc
--- tests/fun/p2p/translation.cc (revision 0)
+++ tests/fun/p2p/translation.cc (revision 0)
@@ -0,0 +1,44 @@
+// Copyright (C) 2008 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.
+
+/// \file tests/fun/p2p/translation.cc
+///
+/// Tests on mln::fun::p2p::translation.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/fun/p2p/translation.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d p(0,0);
+ dpoint2d dp(-1,+1);
+
+ mln_invariant(fun::p2p::translation(dp)(p) == point2d(-1,+1));
+}
Index: tests/fun/p2p/Makefile.am
--- tests/fun/p2p/Makefile.am (revision 0)
+++ tests/fun/p2p/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ translation
+
+translation_SOURCES = translation.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/fun/Makefile.am
--- tests/fun/Makefile.am (revision 3213)
+++ tests/fun/Makefile.am (working copy)
@@ -2,4 +2,4 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2v v2v vv2v x2x
+SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x