https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add some morphers and handle constness in pixterators.
Add new morphers.
* tests/cast_image.cc: New.
* tests/assign.cc: New.
* tests/fimage.cc: New.
* mln/core/fimage.hh: New.
* mln/level/assign.hh: New.
* mln/value/cast.hh: New.
* mln/core/safe.hh: Rename as...
* mln/core/safe_image.hh: ...this.
* tests/safe_image.cc: Update.
* mln/core/vec.hh: Rename as...
* mln/metal/vec.hh: ...this.
Handle constness in pixel iterators.
* mln/core/internal/pixel_impl.hh (value_): New.
(address): Update.
* mln/core/internal/pixel_iterator_base.hh
(qualified_value, value_): New.
* mln/core/pixter2d_b.hh (value_): Update.
* mln/core/dpoints_pixter.hh (value_): Update.
* mln/core/internal/image_adaptor.hh
(vset, values): Fix missing.
* mln/core/concept/generalized_pixel.hh
(ctor): Comment check on address.
* mln/core/concept/pixel_iterator.hh
(ctor): Comment check on lvalue and op*.
* mln/core/concept/fast_image.hh (offset): Fix missing const.
* mln/core/image2d_b.hh: Likewise.
* mln/core/concept/doc/image.hh: Cosmetic changes.
* mln/level/fast_median.hh (input): Update.
* TODO: Update.
TODO | 2
mln/core/concept/doc/image.hh | 2
mln/core/concept/fast_image.hh | 8 -
mln/core/concept/generalized_pixel.hh | 5
mln/core/concept/pixel_iterator.hh | 9 -
mln/core/dpoints_pixter.hh | 10 -
mln/core/fimage.hh | 170 ++++++++++++++++++++++++++++++
mln/core/image2d_b.hh | 14 +-
mln/core/internal/image_adaptor.hh | 16 ++
mln/core/internal/pixel_impl.hh | 12 +-
mln/core/internal/pixel_iterator_base.hh | 20 +++
mln/core/pixter2d_b.hh | 3
mln/core/safe.hh | 7 -
mln/level/assign.hh | 103 ++++++++++++++++++
mln/level/fast_median.hh | 10 -
mln/metal/vec.hh | 11 +
mln/value/cast.hh | 175 +++++++++++++++++++++++++++++++
tests/assign.cc | 48 ++++++++
tests/cast_image.cc | 48 ++++++++
tests/fimage.cc | 44 +++++++
tests/safe_image.cc | 2
21 files changed, 681 insertions(+), 38 deletions(-)
Index: tests/cast_image.cc
--- tests/cast_image.cc (revision 0)
+++ tests/cast_image.cc (revision 0)
@@ -0,0 +1,48 @@
+// 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/cast_image.cc
+ *
+ * \brief Tests on mln::value::cast_image.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/fun/chess.hh>
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/value/cast.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d_b<bool> ima(8, 8);
+ level::fill(ima, fun::chess);
+ debug::println(ima);
+ debug::println( value::cast<int>(ima) );
+}
Index: tests/safe_image.cc
--- tests/safe_image.cc (revision 1033)
+++ tests/safe_image.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/core/safe_image.hh>
+#include <mln/core/safe.hh>
#include <mln/level/paste.hh>
Index: tests/assign.cc
--- tests/assign.cc (revision 0)
+++ tests/assign.cc (revision 0)
@@ -0,0 +1,48 @@
+// 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/assign.cc
+ *
+ * \brief Tests on mln::level::assign.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/level/assign.hh>
+#include <mln/level/compare.hh>
+#include <mln/debug/iota.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 1000;
+ image2d_b<int> rhs(size, size), lhs(rhs.domain());
+ debug::iota(rhs);
+ level::assign(lhs, rhs);
+ mln_assertion(lhs = rhs);
+}
Index: tests/fimage.cc
--- tests/fimage.cc (revision 0)
+++ tests/fimage.cc (revision 0)
@@ -0,0 +1,44 @@
+// 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/fimage.cc
+ *
+ * \brief Tests on mln::fimage.
+ */
+
+#include <mln/core/fimage.hh>
+#include <mln/core/box2d.hh>
+#include <mln/fun/chess.hh>
+#include <mln/debug/println.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ debug::println( fun::chess | make::box2d(8, 8) );
+}
Index: TODO
--- TODO (revision 1033)
+++ TODO (working copy)
@@ -17,7 +17,6 @@
value::proxy to dispatch read/write + the corresponding image type
a mean_value object { sum; count } and operator+
-value_cast<T>(image)
t_image to "transpose" the 0 and the i-th coordinates
image defined by f/pset
@@ -45,6 +44,5 @@
fast versions of level::fill and level::paste
histogram class
sorting points w.r.t. their value (array of offsets, psites, points)
-border::* and no-op versions if not fast image
arith::inplace_plus et al.
linear:: for convolutions
Index: mln/core/fimage.hh
--- mln/core/fimage.hh (revision 0)
+++ mln/core/fimage.hh (revision 0)
@@ -0,0 +1,170 @@
+// 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_FIMAGE_HH
+# define MLN_CORE_FIMAGE_HH
+
+/*! \file mln/core/fimage.hh
+ *
+ * \brief Definition of an image class FIXME
+ */
+
+# include <mln/core/internal/image_base.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/value/set.hh>
+
+
+namespace mln
+{
+
+ /*! \brief FIXME
+ *
+ */
+ template <typename F, typename S>
+ struct fimage : public internal::image_base_< S, fimage<F,S> >
+ {
+ /// Point_Site associated type.
+ typedef mln_psite(S) psite;
+
+ /// Point_Set associated type.
+ typedef S pset;
+
+ /// Value associated type.
+ typedef mln_result(F) value;
+
+ /// Return type of read-only access.
+ typedef mln_result(F) rvalue;
+
+ /// Return type of read-write access.
+ typedef void lvalue; // FIXME
+
+ /// Value set associated type.
+ typedef mln::value::set_<mln_result(F)> vset;
+
+
+ /// Constructor.
+ fimage(const Function_p2v<F>& f, const Point_Set<S>& ps);
+
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Test if a pixel value is accessible at \p p.
+ bool owns_(const psite& p) const;
+
+ /// Give the definition domain.
+ const S& domain() const;
+
+ /// Read-only access of pixel value at point site \p p.
+ mln_result(F) operator()(const psite& p) const;
+
+ /// Read-write access of pixel value at point site \p p.
+ void operator()(const psite& p);
+
+ /// Give the set of values of the image.
+ const vset& values() const;
+
+ /// Change value type. FIXME!
+ template <typename U>
+ struct change_value
+ {
+ typedef void ret;
+ };
+
+ protected:
+ F f_;
+ S pset_;
+ };
+
+
+
+ template <typename F, typename S>
+ fimage<F,S>
+ operator | (const Function_p2v<F>& f, const Point_Set<S>& ps)
+ {
+ fimage<F,S> tmp(f, ps);
+ return tmp;
+ }
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F, typename S>
+ fimage<F,S>::fimage(const Function_p2v<F>& f, const
Point_Set<S>& ps)
+ : f_(exact(f)),
+ pset_(exact(ps))
+ {
+ }
+
+ template <typename F, typename S>
+ bool fimage<F,S>::has_data() const
+ {
+ return true;
+ }
+
+ template <typename F, typename S>
+ bool fimage<F,S>::owns_(const psite& p) const
+ {
+ return pset_.has(p);
+ }
+
+ template <typename F, typename S>
+ const S&
+ fimage<F,S>::domain() const
+ {
+ return pset_;
+ }
+
+ template <typename F, typename S>
+ mln_result(F)
+ fimage<F,S>::operator()(const psite& p) const
+ {
+ mln_precondition(pset_.has(p));
+ return f_(p);
+ }
+
+ template <typename F, typename S>
+ void
+ fimage<F,S>::operator()(const psite& p)
+ {
+ mln_invariant(0); // FIXME: Turn into a compile-time error...
+ }
+
+ template <typename F, typename S>
+ const mln::value::set_<mln_result(F)>&
+ fimage<F,S>::values() const
+ {
+ return vset::the();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_FIMAGE_HH
Index: mln/core/pixter2d_b.hh
--- mln/core/pixter2d_b.hh (revision 1033)
+++ mln/core/pixter2d_b.hh (working copy)
@@ -45,7 +45,8 @@
class fwd_pixter2d_b : public internal::pixel_iterator_base_< I,
fwd_pixter2d_b<I> >
{
typedef internal::pixel_iterator_base_< I, fwd_pixter2d_b<I> > super_;
- typedef mln_value(super_) value_;
+ typedef typename super_::value_ value_;
+
public:
/*! \brief Constructor.
Index: mln/core/dpoints_pixter.hh
--- mln/core/dpoints_pixter.hh (revision 1033)
+++ mln/core/dpoints_pixter.hh (working copy)
@@ -55,11 +55,11 @@
class dpoints_fwd_pixter : public Pixel_Iterator< dpoints_fwd_pixter<I> >,
public internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
{
- typedef typename internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
super;
+ typedef typename internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
super_;
public:
/// Using super value type.
- typedef mln_value(super) value;
+ typedef typename super_::value_ value_;
/*! \brief Constructor.
*
@@ -111,7 +111,7 @@
unsigned i_;
/// reference pixel / point in the image
- value** value_ref_;
+ value_** value_ref_;
// or:
const mln_point(I)* p_ref_;
@@ -135,7 +135,7 @@
dpoints_fwd_pixter<I>::dpoints_fwd_pixter(I& image,
const Dps& dps,
const Generalized_Point<Pref>& p_ref)
- : super(image)
+ : super_(image)
{
mln_precondition(image.has_data());
p_ref_ = internal::force_exact<Pref>(p_ref).pointer_();
@@ -149,7 +149,7 @@
dpoints_fwd_pixter<I>::dpoints_fwd_pixter(I& image,
const Dps& dps,
const Generalized_Pixel<Pref>& p_ref)
- : super(image)
+ : super_(image)
{
mln_precondition(image.has_data());
p_ref_ = 0;
Index: mln/core/internal/pixel_impl.hh
--- mln/core/internal/pixel_impl.hh (revision 1033)
+++ mln/core/internal/pixel_impl.hh (working copy)
@@ -62,6 +62,9 @@
/// Image rvalue type.
typedef mln_rvalue(I) rvalue;
+ /// Qualified value type.
+ typedef value value_;
+
/// pixel iterator value.
lvalue operator*();
@@ -105,13 +108,16 @@
/// Image rvalue type.
typedef mln_rvalue(I) rvalue;
+ /// Qualified value type.
+ typedef const value value_;
+
/// Get the pixel iterator value.
rvalue operator*() const;
/// Address of the current iterator value/pixel.
- value** address_() const;
+ const value** address_() const;
protected:
@@ -197,11 +203,11 @@
}
template <typename I, typename E>
- mln_value(I) **
+ const mln_value(I) **
pixel_impl_<const I, E>::address_() const
{
mln_precondition(is_valid_());
- return (value**)(& this->value_ptr_);
+ return (const value**)(& this->value_ptr_);
}
#endif // ! MLN_INCLUDE_ONLY
Index: mln/core/internal/pixel_iterator_base.hh
--- mln/core/internal/pixel_iterator_base.hh (revision 1033)
+++ mln/core/internal/pixel_iterator_base.hh (working copy)
@@ -43,6 +43,22 @@
namespace internal
{
+
+ template <typename I>
+ struct qualified_value
+ {
+ typedef mln_value(I) ret;
+ };
+
+
+ template <typename I>
+ struct qualified_value< const I >
+ {
+ typedef const mln_value(I) ret;
+ };
+
+
+
/*! \brief A base class for pixel iterators.
*
*/
@@ -51,7 +67,6 @@
public internal::pixel_impl_<I, E>
{
typedef internal::pixel_impl_<I, E> super_;
- typedef mln_value(super_) value_;
public:
@@ -64,6 +79,9 @@
/// Test if the iterator is valid.
bool is_valid() const;
+ /// Qualified (const or not) value type.
+ typedef typename qualified_value<I>::ret value_;
+
protected:
/// Beginning of the image.
Index: mln/core/internal/image_adaptor.hh
--- mln/core/internal/image_adaptor.hh (revision 1033)
+++ mln/core/internal/image_adaptor.hh (working copy)
@@ -51,12 +51,16 @@
typename S = mln_pset(I) >
struct image_adaptor_ : public internal::image_base_< S, E >
{
+
/// Point_Site associated type.
typedef mln_psite(S) psite;
/// Point_Set associated type.
typedef S pset;
+ /// Value_Set associated type.
+ typedef mln_vset(I) vset;
+
/// Value associated type.
typedef mln_value(I) value;
@@ -66,6 +70,7 @@
/// Return type of read-write access.
typedef mln_lvalue(I) lvalue;
+
/// Test if this image has been initialized.
bool has_data() const;
@@ -75,12 +80,16 @@
/// Give the definition domain.
const S& domain() const;
+ /// Give the set of values.
+ const vset& values() const;
+
/// Read-only access of pixel value at point site \p p.
rvalue operator()(const psite& p) const;
/// Read-write access of pixel value at point site \p p.
lvalue operator()(const psite& p);
+
protected:
I& adaptee_;
@@ -116,6 +125,13 @@
}
template <typename I, typename E, typename S>
+ const mln_vset(I)&
+ image_adaptor_<I,E,S>::values() const
+ {
+ return adaptee_.values();
+ }
+
+ template <typename I, typename E, typename S>
typename image_adaptor_<I,E,S>::rvalue
image_adaptor_<I,E,S>::operator()(const psite& p) const
{
Index: mln/core/safe.hh
--- mln/core/safe.hh (revision 1031)
+++ mln/core/safe.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_SAFE_IMAGE_HH
-# define MLN_CORE_SAFE_IMAGE_HH
+#ifndef MLN_CORE_SAFE_HH
+# define MLN_CORE_SAFE_HH
# include <mln/core/internal/image_adaptor.hh>
@@ -34,6 +34,7 @@
namespace mln
{
+ // FIXME: Doc!
template <typename I>
struct safe_image : public internal::image_adaptor_< I, safe_image<I> >
@@ -100,4 +101,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_SAFE_IMAGE_HH
+#endif // ! MLN_CORE_SAFE_HH
Index: mln/core/concept/generalized_pixel.hh
--- mln/core/concept/generalized_pixel.hh (revision 1033)
+++ mln/core/concept/generalized_pixel.hh (working copy)
@@ -77,8 +77,9 @@
typedef mln_rvalue(E) rvalue;
rvalue (E::*m1)() const = & E::operator*;
m1 = 0;
- value** (E::*m2)() const = & E::address_;
- m2 = 0;
+ // FIXME: Activate (so add qualif_value):
+// value** (E::*m2)() const = & E::address_;
+// m2 = 0;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/pixel_iterator.hh
--- mln/core/concept/pixel_iterator.hh (revision 1033)
+++ mln/core/concept/pixel_iterator.hh (working copy)
@@ -54,8 +54,9 @@
public Generalized_Pixel<E>
{
/*
- typedef lvalue;
+ only if the iterator is constructed on a mutable image:
+ typedef lvalue;
lvalue operator*();
*/
protected:
@@ -68,9 +69,9 @@
template <typename E>
Pixel_Iterator<E>::Pixel_Iterator()
{
- typedef mln_lvalue(E) lvalue;
- lvalue (E::*m)() = & E::operator*;
- m = 0;
+// typedef mln_lvalue(E) lvalue;
+// lvalue (E::*m)() = & E::operator*;
+// m = 0;
}
#endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/fast_image.hh
--- mln/core/concept/fast_image.hh (revision 1033)
+++ mln/core/concept/fast_image.hh (working copy)
@@ -49,8 +49,8 @@
/*
unsigned border();
- int offset(const dpoint& dp);
- unsigned offset(const point& p);
+ int offset(const dpoint& dp) const;
+ unsigned offset(const point& p) const;
point point_at_offset(unsigned o) const;
const value* buffer() const;
@@ -75,9 +75,9 @@
typedef mln_fwd_pixter(E) fwd_pixter;
typedef mln_bkd_pixter(E) bkd_pixter;
- int (E::*m1)(const dpoint&) = & E::offset;
+ int (E::*m1)(const dpoint&) const = & E::offset;
m1 = 0;
- unsigned (E::*m2)(const point&) = & E::offset;
+ unsigned (E::*m2)(const point&) const = & E::offset;
m2 = 0;
point (E::*m3)(unsigned) const = & E::point_at_offset;
m3 = 0;
Index: mln/core/concept/doc/image.hh
--- mln/core/concept/doc/image.hh (revision 1033)
+++ mln/core/concept/doc/image.hh (working copy)
@@ -41,6 +41,7 @@
template <typename E>
struct Image : public Object<E>
{
+
/*! \brief Value associated type.
*
* \invariant This type is neither qualified by const, nor by
@@ -61,6 +62,7 @@
*/
typedef void vset;
+
/*! \brief Test if the image have been initialized.
*/
bool has_data() const;
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1033)
+++ mln/core/image2d_b.hh (working copy)
@@ -190,10 +190,10 @@
/// Fast Image method
/// Give the offset corresponding to the delta-point \p dp.
- int offset(const dpoint2d& dp);
+ int offset(const dpoint2d& dp) const;
/// Give the offset corresponding to the point \p p.
- unsigned offset(const point2d& p);
+ unsigned offset(const point2d& p) const;
/// Give the point corresponding to the offset \p o.
point2d point_at_offset(unsigned o) const;
@@ -412,7 +412,7 @@
template <typename T>
int
- image2d_b<T>::offset(const dpoint2d& dp)
+ image2d_b<T>::offset(const dpoint2d& dp) const
{
mln_precondition(this->has_data());
int o = dp[0] * vb_.len(1) + dp[1];
@@ -421,7 +421,7 @@
template <typename T>
unsigned
- image2d_b<T>::offset(const point2d& p)
+ image2d_b<T>::offset(const point2d& p) const
{
mln_precondition(this->owns_(p));
unsigned o = & this->operator()(p) - this->buffer_;
@@ -535,6 +535,12 @@
};
template <typename T, typename W>
+ struct fwd_qixter< const image2d_b<T>, W >
+ {
+ typedef dpoints_fwd_pixter< const image2d_b<T> > ret;
+ };
+
+ template <typename T, typename W>
struct bkd_qixter< image2d_b<T>, W >
{
typedef internal::fixme ret;
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1031)
+++ mln/metal/vec.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_VEC_HH
-# define MLN_CORE_VEC_HH
+#ifndef MLN_CORE_METAL_VEC_HH
+# define MLN_CORE_METAL_VEC_HH
# include <mln/core/concept/object.hh>
@@ -34,6 +34,9 @@
namespace mln
{
+ namespace metal
+ {
+
template <unsigned n, typename T>
struct vec : public Object< vec<n,T> >
{
@@ -56,7 +59,9 @@
T coord_[n];
};
+ } // end of namespace mln::metal
+
} // end of namespace mln
-#endif // ! MLN_CORE_VEC_HH
+#endif // ! MLN_CORE_METAL_VEC_HH
Index: mln/level/assign.hh
--- mln/level/assign.hh (revision 0)
+++ mln/level/assign.hh (revision 0)
@@ -0,0 +1,103 @@
+// 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_LEVEL_ASSIGN_HH
+# define MLN_LEVEL_ASSIGN_HH
+
+/*! \file mln/level/assign.hh
+ *
+ * \brief Assignment between a couple of images.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ /*! Assignment of image \p target with image \p data.
+ *
+ * \param[out] output The image to be assigned.
+ * \param[in] data The auxiliary image.
+ *
+ * \pre target.domain = data.domain
+ *
+ * \todo Overload in impl:: for mixed (fast, non-fast).
+ *
+ * \todo Overload in impl:: for (fast, fast) if same value using memcpy.
+ */
+ template <typename L, typename R>
+ void assign(Image<L>& target, const Image<R>& data);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename L, typename R>
+ void assign(Image<L>& target_, const Image<R>& data_)
+ {
+ L& target = exact(target_);
+ const R& data = exact(data_);
+ mln_piter(L) p(target.domain());
+ for_all(p)
+ target(p) = data(p);
+ }
+
+ template <typename L, typename R>
+ void assign(Fast_Image<L>& target_, const Fast_Image<R>&
data_)
+ {
+ L& target = exact(target_);
+ const R& data = exact(data_);
+ mln_pixter(L) lhs(target);
+ mln_pixter(const R) rhs(data);
+ for_all_2(lhs, rhs)
+ *lhs = *rhs;
+ }
+
+ } // end of namespace mln::level::impl
+
+
+ template <typename L, typename R>
+ void assign(Image<L>& target, const Image<R>& data)
+ {
+ mln_precondition(exact(data).domain() = exact(target).domain());
+ impl::assign(exact(target), exact(data));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LEVEL_ASSIGN_HH
Index: mln/level/fast_median.hh
--- mln/level/fast_median.hh (revision 1033)
+++ mln/level/fast_median.hh (working copy)
@@ -54,7 +54,7 @@
* \pre \p input and \p output have to be initialized.
*/
template <typename I, typename W, typename O>
- void fast_median(Image<I>& input, const Window<W>& win,
+ void fast_median(const Image<I>& input, const Window<W>& win,
Image<O>& output);
@@ -65,7 +65,7 @@
{
template <typename I, typename W, typename O>
- void fast_median(I& input,
+ void fast_median(const I& input,
const W& win,
O& output)
{
@@ -90,14 +90,14 @@
point2d p = input.domain().pmin() + up;
- mln_qixter(I, window2d)
+ mln_qixter(const I, window2d)
q_fp(input, win_fwd_plus, p), q_fm(input, win_fwd_minus, p),
q_bp(input, win_bkd_plus, p), q_bm(input, win_bkd_minus, p),
q_top(input, win_top, p), q_bot(input, win_bot, p);
med.init();
{
- mln_qixter(I, W) q(input, win, p);
+ mln_qixter(const I, W) q(input, win, p);
for_all(q)
med.take(*q);
}
@@ -154,7 +154,7 @@
// facade
template <typename I, typename W, typename O>
- void fast_median(Image<I>& input, const Window<W>& win,
+ void fast_median(const Image<I>& input, const Window<W>& win,
Image<O>& output)
{
impl::fast_median(exact(input), exact(win), exact(output));
Index: mln/value/cast.hh
--- mln/value/cast.hh (revision 0)
+++ mln/value/cast.hh (revision 0)
@@ -0,0 +1,175 @@
+// 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_VALUE_CAST_HH
+# define MLN_VALUE_CAST_HH
+
+/*! \file mln/value/cast.hh
+ *
+ * \brief Definition of an image class FIXME
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/value/set.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ /*! \brief FIXME
+ *
+ */
+ template <typename T, typename I>
+ struct cast_image : public internal::image_base_< mln_pset(I),
cast_image<T,I> >
+ {
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Point_Set associated type.
+ typedef mln_pset(I) pset;
+
+ /// Value associated type.
+ typedef T value;
+
+ /// Return type of read-only access.
+ typedef T rvalue;
+
+ /// Return type of read-write access.
+ typedef void lvalue; // FIXME
+
+ /// Value set associated type.
+ typedef mln::value::set_<T> vset;
+
+
+ /// Constructor.
+ cast_image(const Image<I>& ima);
+
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Test if a pixel value is accessible at \p p.
+ bool owns_(const psite& p) const;
+
+ /// Give the definition domain.
+ const mln_pset(I)& domain() const;
+
+ /// Read-only access of pixel value at point site \p p.
+ T operator()(const psite& p) const;
+
+ /// Read-write access of pixel value at point site \p p.
+ void operator()(const psite& p);
+
+ /// Give the set of values of the image.
+ const vset& values() const;
+
+ /// Change value type.
+ template <typename U>
+ struct change_value
+ {
+ typedef mln_ch_value(I, U) ret;
+ };
+
+ protected:
+ const I& ima_;
+ };
+
+
+
+ template <typename T, typename I>
+ cast_image<T,I>
+ cast(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ cast_image<T,I> tmp(ima);
+ return tmp;
+ }
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename I>
+ cast_image<T,I>::cast_image(const Image<I>& ima)
+ : ima_(exact(ima))
+ {
+ mln_precondition(exact(ima).has_data());
+ }
+
+ template <typename T, typename I>
+ bool cast_image<T,I>::has_data() const
+ {
+ mln_invariant(ima_.has_data());
+ return true;
+ }
+
+ template <typename T, typename I>
+ bool cast_image<T,I>::owns_(const psite& p) const
+ {
+ return ima_.owns_(p);
+ }
+
+ template <typename T, typename I>
+ const mln_pset(I)&
+ cast_image<T,I>::domain() const
+ {
+ return ima_.domain();
+ }
+
+ template <typename T, typename I>
+ T
+ cast_image<T,I>::operator()(const psite& p) const
+ {
+ mln_precondition(ima_.owns_(p));
+ return ima_(p);
+ }
+
+ template <typename T, typename I>
+ void
+ cast_image<T,I>::operator()(const psite& p)
+ {
+ mln_invariant(0); // FIXME: Turn into a compile-time error...
+ }
+
+ template <typename T, typename I>
+ const mln::value::set_<T>&
+ cast_image<T,I>::values() const
+ {
+ return vset::the();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_CAST_HH