URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-26 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add transformed images.
* mln/core/tr_image.hh: New.
* tests/tr_image.cc: New.
---
mln/core/tr_image.hh | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/tr_image.cc | 66 ++++++++++++++++++
2 files changed, 252 insertions(+)
Index: trunk/milena/tests/tr_image.cc
===================================================================
--- trunk/milena/tests/tr_image.cc (revision 0)
+++ trunk/milena/tests/tr_image.cc (revision 1179)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/image2d_b.cc
+ *
+ * \brief Tests on mln::image2d_b.
+ */
+
+
+#include <iostream>
+#include <mln/fun/x2x/translation.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/core/tr_image.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d_b<int_u8> lena = io::pgm::load("../img/lena.pgm");
+ image2d_b<int_u8> out(lena.domain());
+
+ fun::x2x::translation<2,float> rot1(make::vec(10., 10.));
+
+ tr_image<fun::x2x::translation<2,float>, image2d_b<int_u8> > inter(lena, rot1);
+
+
+ image2d_b<int_u8>::fwd_piter p(out.domain());
+
+ for_all(p)
+ {
+ metal::vec<2,int> vec = (image2d_b<int_u8>::point)p;
+ if (inter.owns_(vec))
+ out(p) = inter(vec);
+ else
+ out(p) = 255;
+ }
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/mln/core/tr_image.hh
===================================================================
--- trunk/milena/mln/core/tr_image.hh (revision 0)
+++ trunk/milena/mln/core/tr_image.hh (revision 1179)
@@ -0,0 +1,186 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_TR_IMAGE_HH
+# define MLN_CORE_TR_IMAGE_HH
+
+/*! \file mln/core/tr_image.hh
+ *
+ * \brief Definition of an image class FIXME
+ */
+
+# include <cmath>
+
+# include <mln/core/internal/image_identity.hh>
+# include <mln/metal/vec.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename T, typename I> struct tr_image;
+
+ namespace internal
+ {
+
+ template <typename T, typename I>
+ struct data_< tr_image<T,I> >
+ {
+ data_(I& ima, T& tr);
+
+ I ima_;
+ T tr_;
+ };
+
+ } // end of namespace mln::internal
+
+ /*! \brief FIXME
+ *
+ */
+ template <typename T, typename I>
+ struct tr_image : public mln::internal::image_identity_< I, mln_pset(I), tr_image<T,I> >
+ {
+
+ /// Super type.
+ typedef mln::internal::image_identity_< I, mln_pset(I), tr_image<T,I> > super_;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef mln_value(I) value;
+
+ /// Return type of read-write access.
+ typedef mln_lvalue(I) lvalue; // FIXME: Depends on lvalue presence in I.
+
+ /// Return type of read-only access.
+ typedef mln_rvalue(I) rvalue;
+
+ /// Value set associated type.
+ typedef mln::value::set<value> vset;
+
+
+ /// Skeleton.
+ typedef tr_image< T, tag::image_<I> > skeleton;
+
+
+ /// Constructors.
+ tr_image(I& ima, T& tr);
+ tr_image();
+
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Test if a pixel value is accessible at \p p.
+ using super_::owns_;
+
+ /// Test if a pixel value is accessible at \p v.
+ bool owns_(const mln::metal::vec<I::point::dim, float>& v) const;
+
+ /// Read-only access of pixel value at point site \p p.
+ /// Mutable access is only OK for reading (not writing).
+ using super_::operator();
+
+ mln_value(I) operator()(const mln::metal::vec<I::point::dim, float>& v) const;
+
+ void set_tr(T& tr);
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ // internal::data_< tr_image<I,S> >
+
+ template <typename T, typename I>
+ data_< tr_image<T,I> >::data_(I& ima, T& tr)
+ : ima_(ima),
+ tr_(tr)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ template <typename T, typename I>
+ tr_image<T,I>::tr_image(I& ima, T& tr)
+ {
+ mln_precondition(ima.has_data());
+ this->data_ = new internal::data_< tr_image<T,I> >(ima, tr);
+ }
+
+ template <typename T, typename I>
+ tr_image<T,I>::tr_image()
+ {
+ }
+
+ template <typename T, typename I>
+ bool tr_image<T,I>::has_data() const
+ {
+ mln_invariant(this->data_->ima_.has_data());
+ return true;
+ }
+
+ template <typename T, typename I>
+ bool tr_image<T,I>::owns_(const metal::vec<I::point::dim, float>& v) const
+ {
+ mln_point(I) p;
+ metal::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
+ for (unsigned i = 0; i < I::point::dim; ++i)
+ p[i] = static_cast<int>(round(v2[i]));
+ return this->data_->ima_.owns_(p);
+ }
+
+ template <typename T, typename I>
+ mln_value(I)
+ tr_image<T,I>::operator()(const metal::vec<I::point::dim, float>& v) const
+ {
+ mln_point(I) p;
+ metal::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
+ for (unsigned i = 0; i < I::point::dim; ++i)
+ p[i] = static_cast<int>(round(v2[i]));
+ mln_assertion(this->data_->ima_.owns_(p));
+ return this->data_->ima_(p);
+ }
+
+ template <typename T, typename I>
+ void
+ tr_image<T,I>::set_tr(T& tr)
+ {
+ this->data_->tr_ = tr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_TR_IMAGE_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-25 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Test a diamond inherance for image_identity
* sandbox/garrigues/image_identity/image_domain_morpher.hh: New.
* sandbox/garrigues/image_identity/image_identity.cc: New.
* sandbox/garrigues/image_identity/image_identity.hh: New.
* sandbox/garrigues/image_identity/image_value_morpher.hh: New.
* sandbox/garrigues/image_identity/interpolated.cc: New.
* sandbox/garrigues/image_identity/interpolated.hh: New.
* sandbox/garrigues/image_identity: New.
---
image_domain_morpher.hh | 122 +++++++++++++++++++++++++++++++
image_identity.cc | 9 ++
image_identity.hh | 77 +++++++++++++++++++
image_value_morpher.hh | 95 ++++++++++++++++++++++++
interpolated.cc | 70 ++++++++++++++++++
interpolated.hh | 185 ++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 558 insertions(+)
Index: trunk/milena/sandbox/garrigues/image_identity/image_identity.cc
===================================================================
--- trunk/milena/sandbox/garrigues/image_identity/image_identity.cc (revision 0)
+++ trunk/milena/sandbox/garrigues/image_identity/image_identity.cc (revision 1176)
@@ -0,0 +1,9 @@
+namespace sandbox
+{
+
+}
+
+int main()
+{
+
+}
Index: trunk/milena/sandbox/garrigues/image_identity/image_domain_morpher.hh
===================================================================
--- trunk/milena/sandbox/garrigues/image_identity/image_domain_morpher.hh (revision 0)
+++ trunk/milena/sandbox/garrigues/image_identity/image_domain_morpher.hh (revision 1176)
@@ -0,0 +1,122 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_INTERNAL_IMAGE_DOMAIN_MORPHER_HH
+# define MLN_CORE_INTERNAL_IMAGE_DOMAIN_MORPHER_HH
+
+/*! \file mln/core/internal/image_domain_morpher.hh
+ *
+ * \brief Definition of a base class for image morphers w.r.t. domain.
+ */
+
+# include <mln/core/internal/image_morpher.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+
+ /*! \brief A base class for image morphers w.r.t. domain.
+ *
+ * Parameter \p S is a point set type.
+ *
+ * \internal
+ */
+ template <typename I, typename S, typename E>
+ class image_domain_morpher_ : public virtual image_morpher_<I, S, E>
+ {
+ public:
+
+ /// Value_Set associated type.
+ typedef mln_vset(I) vset;
+
+ /// Value associated type.
+ typedef mln_value(I) value;
+
+ /// Return type of read-only access.
+ typedef mln_rvalue(I) rvalue;
+
+ /// Return type of read-write access.
+ typedef typename internal::morpher_lvalue_<I>::ret lvalue;
+
+
+ /// Give the set of values.
+ const vset& values() const;
+
+ /// Read-only access of pixel value at point site \p p.
+ rvalue operator()(const mln_psite(S)& p) const;
+
+ /// Read-write access of pixel value at point site \p p.
+ lvalue operator()(const mln_psite(S)& p);
+
+ protected:
+ image_domain_morpher_();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename S, typename E>
+ image_domain_morpher_<I,S,E>::image_domain_morpher_()
+ {
+ }
+
+ template <typename I, typename S, typename E>
+ const mln_vset(I)&
+ image_domain_morpher_<I,S,E>::values() const
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->values();
+ }
+
+ template <typename I, typename S, typename E>
+ mln_rvalue(I)
+ image_domain_morpher_<I,S,E>::operator()(const mln_psite(S)& p) const
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->operator()(p);
+ }
+
+ template <typename I, typename S, typename E>
+ typename image_domain_morpher_<I,S,E>::lvalue
+ image_domain_morpher_<I,S,E>::operator()(const mln_psite(S)& p)
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->operator()(p);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_IMAGE_DOMAIN_MORPHER_HH
Index: trunk/milena/sandbox/garrigues/image_identity/image_value_morpher.hh
===================================================================
--- trunk/milena/sandbox/garrigues/image_identity/image_value_morpher.hh (revision 0)
+++ trunk/milena/sandbox/garrigues/image_identity/image_value_morpher.hh (revision 1176)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_INTERNAL_IMAGE_VALUE_MORPHER_HH
+# define MLN_CORE_INTERNAL_IMAGE_VALUE_MORPHER_HH
+
+/*! \file mln/core/internal/image_value_morpher.hh
+ *
+ * \brief Definition of a base class for image morphers w.r.t. value.
+ */
+
+# include <mln/core/internal/image_morpher.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+
+ /*! \brief A base class for image morphers w.r.t. value.
+ *
+ * Parameter \p S is a point set type.
+ *
+ * \internal
+ */
+ template <typename I, typename E>
+ class image_value_morpher_ : public virtual image_morpher_<I, mln_pset(I), E>
+ {
+ public:
+
+ const mln_pset(I)& domain() const;
+ bool owns_(const mln_psite(I)& p) const;
+
+ protected:
+ image_value_morpher_();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename E>
+ image_value_morpher_<I,E>::image_value_morpher_()
+ {
+ }
+
+ template <typename I, typename E>
+ const mln_pset(I)&
+ image_value_morpher_<I,E>::domain() const
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->domain();
+ }
+
+ template <typename I, typename E>
+ bool
+ image_value_morpher_<I,E>::owns_(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->owns_(p);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_IMAGE_VALUE_MORPHER_HH
Index: trunk/milena/sandbox/garrigues/image_identity/interpolated.hh
===================================================================
--- trunk/milena/sandbox/garrigues/image_identity/interpolated.hh (revision 0)
+++ trunk/milena/sandbox/garrigues/image_identity/interpolated.hh (revision 1176)
@@ -0,0 +1,185 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_INTERPOLATED_HH
+# define MLN_CORE_INTERPOLATED_HH
+
+/*! \file mln/core/interpolated.hh
+ *
+ * \brief Definition of an image class FIXME
+ */
+
+# include <cmath>
+
+# include "image_identity.hh"
+# include <mln/metal/vec.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename I> struct interpolated;
+
+ namespace internal
+ {
+
+ template <typename I>
+ struct data_< interpolated<I> >
+ {
+ data_(I& ima);
+
+ I ima_;
+ };
+
+ } // end of namespace mln::internal
+
+ /*! \brief FIXME
+ *
+ */
+ template <typename I>
+ struct interpolated : public mln::internal::image_identity_< I, mln_pset(I), interpolated<I> >
+ {
+
+ typedef mln::internal::image_identity_< I, mln_pset(I), interpolated<I> > super_;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef mln_value(I) value;
+
+ /// Return type of read-write access.
+ typedef mln_lvalue(I) lvalue; // FIXME: Depends on lvalue presence in I.
+
+ /// Return type of read-only access.
+ typedef mln_rvalue(I) rvalue;
+
+ /// Value set associated type.
+ typedef mln::value::set<value> vset;
+
+
+ /// Skeleton.
+ typedef interpolated< tag::image_<I> > skeleton;
+
+
+ /// Constructors.
+ interpolated(I& ima);
+ interpolated();
+
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Test if a pixel value is accessible at \p p.
+ using super_::owns_;
+
+ /// Test if a pixel value is accessible at \p v.
+ bool owns_(const mln::metal::vec<I::point::dim, float>& v) const;
+
+ /// Read-only access of pixel value at point site \p p.
+ /// Mutable access is only OK for reading (not writing).
+ using super_::operator();
+
+ mln_value(I) operator()(const mln::metal::vec<I::point::dim, float>& v) const;
+
+
+ /// Give the set of values of the image.
+ const vset& values() const;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ // internal::data_< interpolated<I,S> >
+
+ template <typename I>
+ data_< interpolated<I> >::data_(I& ima)
+ : ima_(ima)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ template <typename I>
+ interpolated<I>::interpolated(I& ima)
+ {
+ mln_precondition(ima.has_data());
+ this->data_ = new internal::data_< interpolated<I> >(ima);
+ }
+
+ template <typename I>
+ interpolated<I>::interpolated()
+ {
+ }
+
+ template <typename I>
+ bool interpolated<I>::has_data() const
+ {
+ mln_invariant(this->data_->ima_.has_data());
+ return true;
+ }
+
+ template <typename I>
+ bool interpolated<I>::owns_(const mln::metal::vec<I::point::dim, float>& v) const
+ {
+ mln_point(I) p;
+ for (unsigned i = 0; i < I::point::dim; ++i)
+ p[i] = static_cast<int>(round(v[i]));
+ return this->data_->ima_.owns_(p);
+ }
+
+ template <typename I>
+ mln_value(I)
+ interpolated<I>::operator()(const mln::metal::vec<I::point::dim, float>& v) const
+ {
+ mln_point(I) p;
+ for (unsigned i = 0; i < I::point::dim; ++i)
+ p[i] = static_cast<int>(round(v[i]));
+ mln_assertion(this->data_->ima_.owns_(p));
+ return this->data_->ima_(p);
+ }
+
+ // FIXME : Should we remove this method? (and inherit it from
+ // identity morpher)
+ template <typename I>
+ const mln::value::set<mln_value(I) >&
+ interpolated<I>::values() const
+ {
+ return vset::the();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERPOLATED_HH
Index: trunk/milena/sandbox/garrigues/image_identity/image_identity.hh
===================================================================
--- trunk/milena/sandbox/garrigues/image_identity/image_identity.hh (revision 0)
+++ trunk/milena/sandbox/garrigues/image_identity/image_identity.hh (revision 1176)
@@ -0,0 +1,77 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_INTERNAL_IMAGE_IDENTITY_HH
+# define MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH
+
+/*! \file mln/core/internal/image_identity.hh
+ *
+ * \brief Definition of a base class for image morphers w.r.t. identity.
+ */
+
+# include "image_value_morpher.hh"
+# include "image_domain_morpher.hh"
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+
+ /*! \brief A base class for image morphers w.r.t. identity.
+ *
+ * Parameter \p S is a point set type.
+ *
+ * \internal
+ */
+ template <typename I, typename S, typename E>
+ class image_identity_ : public image_domain_morpher_<I, S, E>,
+ public image_value_morpher_<I, E>
+ {
+ public:
+
+ protected:
+ image_identity_();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename S, typename E>
+ image_identity_<I,S,E>::image_identity_()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH
Index: trunk/milena/sandbox/garrigues/image_identity/interpolated.cc
===================================================================
--- trunk/milena/sandbox/garrigues/image_identity/interpolated.cc (revision 0)
+++ trunk/milena/sandbox/garrigues/image_identity/interpolated.cc (revision 1176)
@@ -0,0 +1,70 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/image2d_b.cc
+ *
+ * \brief Tests on mln::image2d_b.
+ */
+
+
+#include <iostream>
+#include <mln/core/image2d_b.hh>
+#include "interpolated.hh"
+
+#include <mln/metal/vec.hh>
+
+#include <mln/level/fill.hh>
+
+#include <mln/debug/println.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned nrows = 4;
+ const unsigned ncols = 4;
+ const unsigned border = 4;
+
+ image2d_b<float> f(nrows, ncols, border);
+ float tab[] = {1., 3., 5., 7.,
+ 4., 7., 10., 13.,
+ 7., 11., 15., 19.,
+ 10., 15., 20., 25.};
+ level::fill(f, tab);
+
+ interpolated< image2d_b<float> > inter(f);
+
+ metal::vec<2, float> v1 = make::vec(2.3, 0.6);
+ metal::vec<2, float> v2 = make::vec(3.2, 1.8);
+
+ debug::println(f);
+
+ std::cout << v1 << " : " << inter(v1) << std::endl;
+ std::cout << v2 << " : " << inter(v2) << std::endl;
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-25 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Rename image_identity morpher.
* mln/core/internal/image_identity_morpher.hh: Rename as...
* mln/core/internal/image_identity.hh: ...this.
---
image_identity.hh | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 140 insertions(+)
Index: trunk/milena/mln/core/internal/image_identity_morpher.hh (deleted)
===================================================================
Index: trunk/milena/mln/core/internal/image_identity.hh
===================================================================
--- trunk/milena/mln/core/internal/image_identity.hh (revision 0)
+++ trunk/milena/mln/core/internal/image_identity.hh (revision 1174)
@@ -0,0 +1,140 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_INTERNAL_IMAGE_IDENTITY_HH
+# define MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH
+
+/*! \file mln/core/internal/image_identity.hh
+ *
+ * \brief Definition of a base class for image morphers w.r.t. identity.
+ */
+
+# include <mln/core/internal/image_morpher.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+
+ /*! \brief A base class for image morphers w.r.t. identity.
+ *
+ * Parameter \p S is a point set type.
+ *
+ * \internal
+ */
+ template <typename I, typename S, typename E>
+ class image_identity_ : public image_morpher_<I, S, E>
+ {
+ public:
+
+ /// Value_Set associated type.
+ typedef mln_vset(I) vset;
+
+ /// Value associated type.
+ typedef mln_value(I) value;
+
+ /// Return type of read-only access.
+ typedef mln_rvalue(I) rvalue;
+
+ /// Return type of read-write access.
+ typedef typename internal::morpher_lvalue_<I>::ret lvalue;
+
+
+ /// Give the set of values.
+ const vset& values() const;
+
+ /// Read-only access of pixel value at point site \p p.
+ rvalue operator()(const mln_psite(S)& p) const;
+
+ /// Read-write access of pixel value at point site \p p.
+ lvalue operator()(const mln_psite(S)& p);
+
+ const mln_pset(I)& domain() const;
+ bool owns_(const mln_psite(I)& p) const;
+
+ protected:
+ image_identity_();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename S, typename E>
+ image_identity_<I,S,E>::image_identity_()
+ {
+ }
+
+ template <typename I, typename S, typename E>
+ const mln_vset(I)&
+ image_identity_<I,S,E>::values() const
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->values();
+ }
+
+ template <typename I, typename S, typename E>
+ mln_rvalue(I)
+ image_identity_<I,S,E>::operator()(const mln_psite(S)& p) const
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->operator()(p);
+ }
+
+ template <typename I, typename S, typename E>
+ typename image_identity_<I,S,E>::lvalue
+ image_identity_<I,S,E>::operator()(const mln_psite(S)& p)
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->operator()(p);
+ }
+
+ template <typename I, typename S, typename E>
+ const mln_pset(I)&
+ image_identity_<I,S,E>::domain() const
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->domain();
+ }
+
+ template <typename I, typename S, typename E>
+ bool
+ image_identity_<I,S,E>::owns_(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->delegatee_() != 0);
+ return this->delegatee_()->owns_(p);
+ }
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-25 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add transformed meshes.
* mln/core/tr_mesh.hh: New.
---
tr_mesh.hh | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
Index: trunk/milena/mln/core/tr_mesh.hh
===================================================================
--- trunk/milena/mln/core/tr_mesh.hh (revision 0)
+++ trunk/milena/mln/core/tr_mesh.hh (revision 1170)
@@ -0,0 +1,65 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_TR_MESH_HH
+# define MLN_CORE_TR_MESH_HH
+
+/*! \file mln/core/tr_mesh.hh
+ * \brief Definition of mln::tr_mesh.
+ */
+
+# include <mln/core/concept/mesh.hh>
+# include <mln/core/bool.hh>
+
+
+namespace mln
+{
+
+ /// Base class for implementation classes of tranformed meshes.
+ template <typename T, typename M>
+ struct tr_mesh : public Mesh< tr_mesh<T,M> >
+ {
+ typedef metal::false_ regular;
+
+ tr_mesh(const T& tr)
+ : t_(tr)
+ {
+ }
+
+ T t_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_TR_MESH_HH