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
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Some renaming and add phantom border routines.
* mln/pw: New directory.
* mln/fun/var.hh: Rename as...
* mln/pw/var.hh: ...this.
* mln/fun/val.hh: Rename as...
* mln/pw/cst.hh: ...this.
* mln/fun/pw_value.hh: Renameas ...
* mln/pw/value.hh: ...this.
* mln/core/concept/image.hh: .
* mln/core/concept/iterator.hh: .
* tests/erosion.cc,
* tests/pw_value.cc,
* TODO: Update.
* mln/convert/to_window.hh: Fix doc.
* mln/border/resize.hh: New.
* mln/border/fill.hh: New.
* mln/border/all.hh: New.
* mln/border/duplicate.hh: New.
* mln/border/mirror.hh: New.
TODO | 15 -------
mln/border/all.hh | 54 ++++++++++++++++++++++++++++
mln/border/duplicate.hh | 75 +++++++++++++++++++++++++++++++++++++++
mln/border/fill.hh | 76 ++++++++++++++++++++++++++++++++++++++++
mln/border/mirror.hh | 75 +++++++++++++++++++++++++++++++++++++++
mln/border/resize.hh | 81 +++++++++++++++++++++++++++++++++++++++++++
mln/convert/to_window.hh | 2 -
mln/core/concept/image.hh | 4 ++
mln/core/concept/iterator.hh | 6 +++
mln/pw/cst.hh | 41 ++++++++++++---------
mln/pw/value.hh | 57 ++++++++++++------------------
mln/pw/var.hh | 28 +++++++-------
tests/erosion.cc | 10 ++---
tests/pw_value.cc | 6 +--
14 files changed, 442 insertions(+), 88 deletions(-)
Index: tests/erosion.cc
--- tests/erosion.cc (revision 1030)
+++ tests/erosion.cc (working copy)
@@ -40,8 +40,8 @@
#include <mln/level/fill.hh>
#include <mln/morpho/erosion.hh>
-#include <mln/fun/pw_value.hh>
-#include <mln/fun/val.hh>
+#include <mln/pw/value.hh>
+#include <mln/pw/cst.hh>
#include <mln/fun/ops.hh>
@@ -61,18 +61,16 @@
morpho::erosion(lena, rec, out);
io::save_pgm(out, "out.pgm");
- /*
{
image2d_b<bool> bin(lena.domain()), out(lena.domain());
- level::fill(bin, pw_value(1) > val(127));
+ level::fill(bin, pw::value(lena) > pw::cst(127));
morpho::erosion(bin, rec, out);
image2d_b<int_u8> test(lena.domain());
- image2d_b<int_u8>::piter p(lena.domain());
+ image2d_b<int_u8>::fwd_piter p(lena.domain());
for_all(p)
test(p) = out(p) ? 255 : 0;
io::save_pgm(test, "test.pgm");
}
- */
}
Index: tests/pw_value.cc
--- tests/pw_value.cc (revision 1030)
+++ tests/pw_value.cc (working copy)
@@ -31,9 +31,9 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/fun/pw_value.hh>
#include <mln/fun/ops.hh>
-#include <mln/fun/val.hh>
+#include <mln/pw/value.hh>
+#include <mln/pw/cst.hh>
int main()
@@ -44,5 +44,5 @@
point2d p = make::point2d(1, 1);
ima(p) = 51;
- std::cout << (pw_value(ima) = val(51))(p) << std::endl;
+ mln_assertion( (pw::value(ima) = pw::cst(51))(p) = true );
}
Index: TODO
--- TODO (revision 1030)
+++ TODO (working copy)
@@ -31,12 +31,12 @@
* renaming
mlc into metal
-point-wise material: pw::value_of, pw::constant, and pw::variable
* clean-up
accu::histo and median: remove inheritance
+select_function in fun::internal::selector_p2? etc.
* processing routines
@@ -48,16 +48,3 @@
border::* and no-op versions if not fast image
arith::inplace_plus et al.
linear:: for convolutions
-
-
-svn mv genpoint.hh generalized_point.hh
-svn mv genpixel.hh generalized_pixel.hh
-svn mv psite.hh point_site.hh
-svn mv viter.hh value_iterator.hh
-svn mv piter.hh point_iterator.hh
-
-
-svn mv doc/genpoint.hh doc/generalized_point.hh
-svn mv doc/genpixel.hh doc/generalized_pixel.hh
-svn mv doc/viter.hh doc/value_iterator.hh
-svn mv doc/piter.hh doc/point_iterator.hh
Index: mln/convert/to_window.hh
--- mln/convert/to_window.hh (revision 1030)
+++ mln/convert/to_window.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/convert/to_window.hh
*
- * \brief Convertions to mln::Image.
+ * \brief Convertions to mln::Window.
*/
# include <mln/core/concept/neighborhood.hh>
Index: mln/pw/var.hh
--- mln/pw/var.hh (revision 0)
+++ mln/pw/var.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_VAR_HH
-# define MLN_FUN_VAR_HH
+#ifndef MLN_PW_VAR_HH
+# define MLN_PW_VAR_HH
-/*! \file mln/fun/var.hh
+/*! \file mln/pw/var.hh
*
* \brief FIXME.
*/
@@ -41,31 +41,31 @@
// FIXME: Doc!
- namespace fun
+ namespace pw
{
template <typename V>
struct var_ : public Function_p2v< var_<V> >
{
typedef V result;
+
var_(const V& v);
+
template <typename P>
const V& operator()(const P&) const;
+
private:
const V& v_;
};
- } // end of namespace mln::fun
-
template <typename V>
- fun::var_<V> var(const V& v);
+ var_<V> var(const V& v);
# ifndef MLN_INCLUDE_ONLY
- namespace fun
- {
+ // pw::var_<V>
template <typename V>
var_<V>::var_(const V& v)
@@ -81,18 +81,20 @@
return v_;
}
- } // end of namespace mln::fun
+ // pw::var(v)
template <typename V>
- fun::var_<V> var(const V& v)
+ var_<V> var(const V& v)
{
- fun::var_<V> tmp(v);
+ var_<V> tmp(v);
return tmp;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::pw
+
} // end of namespace mln
-#endif // ! MLN_FUN_VAR_HH
+#endif // ! MLN_PW_VAR_HH
Index: mln/pw/cst.hh
--- mln/pw/cst.hh (revision 0)
+++ mln/pw/cst.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_VAL_HH
-# define MLN_FUN_VAL_HH
+#ifndef MLN_PW_CST_HH
+# define MLN_PW_CST_HH
-/*! \file mln/fun/val.hh
+/*! \file mln/pw/cst.hh
*
* \brief FIXME.
*/
@@ -39,35 +39,38 @@
namespace mln
{
- // FIXME: Doc!
-
- namespace fun
+ namespace pw
{
+ // FIXME: Doc!
+
template <typename T>
- struct val_ : public Function_p2v< val_<T> >
+ struct cst_ : public Function_p2v< cst_<T> >
{
typedef T result;
- val_(T t);
+
+ cst_(T t);
+
template <typename P>
T operator()(const P&) const;
+
private:
T t_;
};
- } // end of namespace mln::fun
+
+ // FIXME: Doc!
template <typename T>
- fun::val_<T> val(T t);
+ cst_<T> cst(T t);
# ifndef MLN_INCLUDE_ONLY
- namespace fun
- {
+ // pw::cst_<T>
template <typename T>
- val_<T>::val_(T t)
+ cst_<T>::cst_(T t)
: t_(t)
{
}
@@ -75,23 +78,25 @@
template <typename T>
template <typename P>
T
- val_<T>::operator()(const P&) const
+ cst_<T>::operator()(const P&) const
{
return t_;
}
- } // end of namespace mln::fun
+ // pw::cst(t)
template <typename T>
- fun::val_<T> val(T t)
+ cst_<T> cst(T t)
{
- fun::val_<T> tmp(t);
+ cst_<T> tmp(t);
return tmp;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::pw
+
} // end of namespace mln
-#endif // ! MLN_FUN_VAL_HH
+#endif // ! MLN_PW_CST_HH
Index: mln/pw/value.hh
--- mln/pw/value.hh (revision 0)
+++ mln/pw/value.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_PW_VALUE_HH
-# define MLN_FUN_PW_VALUE_HH
+#ifndef MLN_PW_VALUE_HH
+# define MLN_PW_VALUE_HH
-/*! \file mln/fun/pw_value.hh
+/*! \file mln/fun/pw/value.hh
*
* \brief FIXME.
*/
@@ -42,19 +42,7 @@
namespace mln
{
- // Fwd decl.
- namespace fun { template <typename I> struct pw_value; }
-
-
-
- // FIXME: Doc!
-
- template <typename I>
- fun::pw_value<I> pw_value(const Image<I>& ima);
-
-
-
- namespace fun
+ namespace pw
{
// FIXME: Move!
@@ -70,16 +58,16 @@
struct select_function_< value::binary_kind, E > : Function_p2b<E>
{};
- } // end of namespace mln::fun::internal
+ } // end of namespace mln::pw::internal
// FIXME: Doc!
template <typename I>
- struct pw_value : public internal::select_function_< mln_value_kind(I), pw_value<I> >
+ struct value_ : public internal::select_function_< mln_value_kind(I), value_<I> >
{
typedef mln_value(I) result;
- pw_value(const I& ima);
+ value_(const I& ima);
mln_rvalue(I) operator()(const mln_psite(I)& p) const;
protected:
const I& ima_;
@@ -87,44 +75,47 @@
+ // FIXME: Doc!
+
+ template <typename I>
+ value_<I> value(const Image<I>& ima);
+
+
+
# ifndef MLN_INCLUDE_ONLY
- // fun::pw_value<I>
+ // pw::value_<I>
template <typename I>
- pw_value<I>::pw_value(const I& ima)
+ value_<I>::value_(const I& ima)
: ima_(ima)
{
}
template <typename I>
mln_rvalue(I)
- pw_value<I>::operator()(const mln_psite(I)& p) const
+ value_<I>::operator()(const mln_psite(I)& p) const
{
mln_precondition(ima_.owns_(p));
return ima_(p);
}
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::fun
-
-# ifndef MLN_INCLUDE_ONLY
-
- // pw_value
+ // pw::value(ima)
template <typename I>
- fun::pw_value<I>
- pw_value(const Image<I>& ima)
+ value_<I>
+ value(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- fun::pw_value<I> tmp(exact(ima));
+ value_<I> tmp(exact(ima));
return tmp;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::pw
+
} // end of namespace mln
-#endif // ! MLN_FUN_PW_VALUE_HH
+#endif // ! MLN_PW_VALUE_HH
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 1030)
+++ mln/core/concept/image.hh (working copy)
@@ -134,6 +134,10 @@
m6 = 0;
lvalue (E::*m7)(const psite& p) = & E::operator();
m7 = 0;
+
+ typedef mln_vset(E) vset;
+ const vset& (E::*m8)() const = & E::values;
+ m8 = 0;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/iterator.hh
--- mln/core/concept/iterator.hh (revision 1030)
+++ mln/core/concept/iterator.hh (working copy)
@@ -40,6 +40,12 @@
# define for_all(x) for(x.start(); x.is_valid(); x.next())
+/*! \brief Loop to browse all the elements targetted by the couples of
+ * iterators \p x1 and \p x2.
+ */
+# define for_all_2(x1, x2) for(x1.start(),x2.start(); x1.is_valid(); x1.next(),x2.next())
+
+
/*! \brief Loop to browse all the remaining elements targetted by the
* iterator \p x.
*/
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 0)
+++ mln/border/resize.hh (revision 0)
@@ -0,0 +1,81 @@
+// 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_BORDER_RESIZE_HH
+# define MLN_BORDER_RESIZE_HH
+
+/*! \file mln/border/resize.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Resize the virtual (outer) border of image \p ima to at least
+ * \p thickness.
+ *
+ * \param[in,out] ima The image whose border is to be resized.
+ * \param[in] thickness The expected minimum border size.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \warning If the image border already has a size greater than \p
+ * thickness, this routine is a no-op.
+ *
+ * \todo Implement it.
+ */
+ template <typename I>
+ void resize(const Fast_Image<I>& ima, unsigned thickness);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void resize(const Fast_Image<I>& ima_, unsigned thickness)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima_.has_data());
+ if (ima.border() >= thickness)
+ return;
+ mln_invariant(0); // FIXME: NYI
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_RESIZE_HH
Index: mln/border/fill.hh
--- mln/border/fill.hh (revision 0)
+++ mln/border/fill.hh (revision 0)
@@ -0,0 +1,76 @@
+// 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_BORDER_FILL_HH
+# define MLN_BORDER_FILL_HH
+
+/*! \file mln/border/fill.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Fill the virtual (outer) border of image \p ima with the
+ * single value \p v.
+ *
+ * \param[in,out] ima The image whose border is to be filled.
+ * \param[in] v The value to assign to all border pixels.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Implement it + optimize with memset if possible.
+ */
+ template <typename I>
+ void fill(const Fast_Image<I>& ima, const mln_value(I)& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void fill(const Fast_Image<I>& ima_, const mln_value(I)& v)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima_.has_data());
+ mln_invariant(0); // FIXME: NYI
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_FILL_HH
Index: mln/border/all.hh
--- mln/border/all.hh (revision 0)
+++ mln/border/all.hh (revision 0)
@@ -0,0 +1,54 @@
+// 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_BORDER_ALL_HH
+# define MLN_BORDER_ALL_HH
+
+/*! \file mln/border/all.hh
+ *
+ * \brief File that includes all border-related routines.
+ */
+
+
+namespace mln
+{
+
+ /*! Namespace of routines related to image virtual (outer) border.
+ */
+ namespace border {}
+
+}
+
+
+# include <mln/border/duplicate.hh>
+# include <mln/border/fill.hh>
+# include <mln/border/mirror.hh>
+# include <mln/border/resize.hh>
+# include <mln/border/thickness.hh>
+
+
+#endif // ! MLN_BORDER_ALL_HH
Index: mln/border/duplicate.hh
--- mln/border/duplicate.hh (revision 0)
+++ mln/border/duplicate.hh (revision 0)
@@ -0,0 +1,75 @@
+// 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_BORDER_DUPLICATE_HH
+# define MLN_BORDER_DUPLICATE_HH
+
+/*! \file mln/border/duplicate.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Assign the virtual (outer) border of image \p ima with the
+ * dupplicate of the inner border of this image.
+ *
+ * \param[in,out] ima The image whose border is to be duplicated.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Implement it + optimize with memcpy if possible.
+ */
+ template <typename I>
+ void duplicate(const Fast_Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void duplicate(const Fast_Image<I>& ima_)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima_.has_data());
+ mln_invariant(0); // FIXME: NYI
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_DUPLICATE_HH
Index: mln/border/mirror.hh
--- mln/border/mirror.hh (revision 0)
+++ mln/border/mirror.hh (revision 0)
@@ -0,0 +1,75 @@
+// 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_BORDER_MIRROR_HH
+# define MLN_BORDER_MIRROR_HH
+
+/*! \file mln/border/mirror.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Mirror the virtual (outer) border of image \p ima with the
+ * (inner) level contents of this image.
+ *
+ * \param[in,out] ima The image whose border is to be mirrored.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Implement it + optimize with memset if possible.
+ */
+ template <typename I>
+ void mirror(const Fast_Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void mirror(const Fast_Image<I>& ima_)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima_.has_data());
+ mln_invariant(0); // FIXME: NYI
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_MIRROR_HH
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Clean up stc/scoop.hxx a bit.
* stc/scoop.hxx: Add a copyright header.
Typos.
Re-indent some parts.
(helper_check): Fix documentation.
Actually use check_final_stm and check_delegatee_inherited as
described in the documentation.
(helper_find): Add some documentation.
scoop.hxx | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 53 insertions(+), 12 deletions(-)
Index: static/stc/scoop.hxx
--- static/stc/scoop.hxx (revision 1027)
+++ static/stc/scoop.hxx (working copy)
@@ -1,3 +1,29 @@
+// Copyright (C) 2005, 2006, 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 oln/stc/scoop.hxx
\brief To be included within a namespace to import SCOOP 2 equipment. */
@@ -102,7 +128,8 @@
/*
- FIXME: Inactivate since dummy code (many class are not Abstractions but abstraction<Exact>).
+ FIXME: Inactivate since dummy code (many class are not Abstractions
+ but abstraction<Exact>).
template <template <class> class abstraction, typename Exact>
struct super_trait_< abstraction<Exact> >
@@ -241,7 +268,7 @@
* Returns the statement for class 'from' corresponding to 'target'.
* This statement is either defined in 'vtypes' or in 'single_vtype'.
*
- * This routine is local; it does not recourse on superior classes.
+ * This routine is local; it does not recur on superior classes.
*
*/
@@ -308,7 +335,8 @@
};
template <typename orig, typename target, typename stm>
- struct check_no_final_inherited <orig, /* if curr == */ mlc::none, target, stm>
+ struct check_no_final_inherited <orig, /* if curr == */ mlc::none,
+ target, stm>
{
};
@@ -342,7 +370,7 @@
* check_delegatee_inherited
*/
- template <typename curr, typename target>
+ template <typename curr>
struct check_delegatee_inherited
: mlc::assert_< stc::is_found< typename first_stm<curr,
typedef_::delegatee>::ret::second_elt >,
@@ -422,7 +450,7 @@
* super = super(curr);
*
* if (stm == stc::abstract) {
- * check_no_stm_inherited(curr, super, target);
+ * check_no_stm_inherited((curr, abstract), super, target);
* return check(super, target);
* }
* if (stm == stc::final<T>) {
@@ -463,10 +491,8 @@
: check_no_final_inherited< mlc::pair_<curr, stc::final<T> >,
stc_super(curr),
target >
+ , check_final_stm< curr, target, T >
{
- /* FIXME:
- check_final_stm(T);
- */
typedef typename check<stc_super(curr), target>::ret ret;
};
@@ -476,10 +502,8 @@
: check_no_final_inherited< mlc::pair_<curr, stc::not_delegated>,
stc_super(curr),
target >
+ , check_delegatee_inherited< curr >
{
- /* FIXME:
- check_delegatee_inherited(curr);
- */
typedef typename check<stc_super(curr), target>::ret ret;
};
@@ -662,6 +686,7 @@
*
* delegator_find(from, target)
* {
+ * // FIXME: This precondition is not actually enforced in the algorithm.
* precondition(target != delegatee);
* delegatee = superior_find(from, delegatee);
* if (delegatee == mlc::not_found)
@@ -696,8 +721,23 @@
/*
* helper_find(from, target, where, res)
*
+ * FIXME: ...
*
- *
+ * helper_find(from, target, where, res)
+ * {
+ * if (res == mlc::not_found)
+ * return delegator_find(from, target)
+ * else if (res = stc::abstract)
+ * {
+ * res_d = delegator_find(source, target)
+ * assert(res_d != mlc::not_found,
+ * "<target> declared <where> but not defined at <from>")
+ * }
+ * else if (res = stc::not_delegated)
+ * return superior_find(from, target)
+ * else
+ * return res
+ * }
*/
template <typename from, typename target, typename where>
@@ -712,6 +752,7 @@
/* if res == */ stc::abstract >
{
typedef typename delegator_find<from, target>::ret res_d;
+ // FIXME: Might be shorten using mlc::assert_and_return_.
struct check_
: mlc::assert_< stc::is_found<res_d>,
ERROR::vtype_declared_but_not_defined
Index: ChangeLog
===================================================================
--- ChangeLog (revision 1028)
+++ ChangeLog (revision 1029)
@@ -1,15 +1,3 @@
-2007-07-23 Roland Levillain <roland(a)lrde.epita.fr>
-
- Clean up stc/scoop.hxx a bit.
-
- * stc/scoop.hxx: Add a copyright header.
- Typos.
- Re-indent some parts.
- (helper_check): Fix documentation.
- Actually use check_final_stm and check_delegatee_inherited as
- described in the documentation.
- (helper_find): Add some documentation.
-
2007-06-29 Roland Levillain <roland(a)lrde.epita.fr>
Add support for Doxygen in Milena.
Index: static/ChangeLog
===================================================================
--- static/ChangeLog (revision 1028)
+++ static/ChangeLog (revision 1029)
@@ -1,3 +1,15 @@
+2007-07-23 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Clean up stc/scoop.hxx a bit.
+
+ * stc/scoop.hxx: Add a copyright header.
+ Typos.
+ Re-indent some parts.
+ (helper_check): Fix documentation.
+ Actually use check_final_stm and check_delegatee_inherited as
+ described in the documentation.
+ (helper_find): Add some documentation.
+
2007-07-17 Roland Levillain <roland(a)lrde.epita.fr>
Update stc/scoop.{hh,hxx} with the latest version from Olena.
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Handle low quantization and fast properties.
* tests/transform.cc: New.
* tests/fill.cc: New.
* mln/core/macros.hh (mln_value_kind, mln_vset): New.
* mln/core/trait/is_fast.hh: New.
* mln/core/trait/all.hh: New.
* mln/core/trait/is_lowq.hh: New.
* mln/core/internal/image_base.hh
(select_image_concept_): New.
* mln/core/concept/image.hh (vset, values): New.
Update.
* mln/core/concept/fast_image.hh (operator[]): New.
* mln/metal/math.hh: New.
* mln/metal/bool.hh: New.
* mln/metal/bexpr.hh: New.
* mln/value/lut_vec.hh: New.
* mln/value/int_u.hh (nbits, card): New.
* tests/README (g++-2.95): New hints.
* tests/pixter_dpoint2d.cc: Fix warning.
* tests/erosion.cc: Fix doc.
* doc/Doxyfile.in: Update.
* mln/debug/iota.hh: New overload.
* mln/fun/pw_value.hh (function_): Rename as...
(select_function_): ...this.
* mln/core/trait/pixter.hh
(pixter, qixter, nixter): Remove; obsolete.
* mln/core/concept/value_set.hh (viter): Likewise.
* mln/core/concept/doc/image.hh,
* mln/core/concept/doc/value_set.hh,
* mln/core/concept/doc/fast_image.hh: Update.
* mln/core/image2d_b.hh: Update.
* mln/metal/none.hh: Fix doc.
* mln/morpho/erosion.hh: Update.
* mln/level/fill.hh: Add todos.
New overload.
* mln/level/fast_median.hh: Fix doc.
* mln/level/transform.hh: New overload.
* mln/value/props.hh (min): Change to var.
* mln/value/kind.hh: Fix doc.
* mln/value/set.hh (viter): Remove; obsolete.
doc/Doxyfile.in | 1
mln/core/concept/doc/fast_image.hh | 25 +++++
mln/core/concept/doc/image.hh | 17 +++
mln/core/concept/doc/value_set.hh | 4
mln/core/concept/fast_image.hh | 20 +++-
mln/core/concept/image.hh | 6 +
mln/core/concept/value_set.hh | 2
mln/core/image2d_b.hh | 65 +++++++++++++-
mln/core/internal/image_base.hh | 20 ++++
mln/core/macros.hh | 12 ++
mln/core/tags.hh | 1
mln/core/trait/all.hh | 52 +++++++++++
mln/core/trait/is_fast.hh | 60 +++++++++++++
mln/core/trait/is_lowq.hh | 65 ++++++++++++++
mln/core/trait/pixter.hh | 15 ---
mln/debug/iota.hh | 23 +++++
mln/fun/pw_value.hh | 6 -
mln/level/fast_median.hh | 2
mln/level/fill.hh | 75 ++++++++++++++--
mln/level/transform.hh | 56 +++++++++++-
mln/metal/bexpr.hh | 102 ++++++++++++++++++++++
mln/metal/bool.hh | 76 +++++++++++++++++
mln/metal/math.hh | 63 ++++++++++++++
mln/metal/none.hh | 2
mln/morpho/erosion.hh | 2
mln/value/int_u.hh | 3
mln/value/kind.hh | 2
mln/value/lut_vec.hh | 165 +++++++++++++++++++++++++++++++++++++
mln/value/props.hh | 85 ++++++++++---------
mln/value/set.hh | 11 --
tests/README | 4
tests/erosion.cc | 4
tests/fill.cc | 63 ++++++++++++++
tests/pixter_dpoint2d.cc | 2
tests/transform.cc | 66 ++++++++++++++
35 files changed, 1066 insertions(+), 111 deletions(-)
Index: tests/README
--- tests/README (revision 1025)
+++ tests/README (working copy)
@@ -1 +1,3 @@
-g++-4.1 -I.. -ansi -pedantic -W -Wall -Wextra -Wconversion sample.cc
+g++-4.1 -ansi -pedantic -W -Wall -Wextra -Wconversion -I.. sample.cc
+
+g++-2.95 -ansi -pedantic -W -Wall -Wconversion -ftemplate-depth-51 -I.. sample.cc
\ No newline at end of file
Index: tests/transform.cc
--- tests/transform.cc (revision 0)
+++ tests/transform.cc (revision 0)
@@ -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/transform.cc
+ *
+ * \brief Tests on mln::level::transform
+ */
+
+#include <cmath>
+
+#include <mln/core/image2d_b.hh>
+#include <mln/level/transform.hh>
+#include <mln/debug/iota.hh>
+
+
+struct mysqrt : mln::Function_v2v<mysqrt>
+{
+ typedef unsigned short result;
+ result operator()(unsigned short c) const
+ {
+ return result( std::sqrt(float(c)) );
+ }
+};
+
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 10000;
+ image2d_b<unsigned short>
+ ima(size, size);
+
+ (std::cout << "iota... ").flush();
+ debug::iota(ima);
+ std::cout << "done" << std::endl;
+
+ (std::cout << "transform... ").flush();
+ level::transform(ima, mysqrt(), ima);
+ std::cout << "done" << std::endl;
+}
Index: tests/pixter_dpoint2d.cc
--- tests/pixter_dpoint2d.cc (revision 1025)
+++ tests/pixter_dpoint2d.cc (working copy)
@@ -67,7 +67,7 @@
qixter qix(ima, win, p);
for_all(p)
- if (p[0] > 0 && p[1] > 0 && p[0] < size - 1 && p[1] < size - 1)
+ if (p[0] > 0 && p[1] > 0 && p[0] < int(size - 1) && p[1] < int(size - 1))
for_all(qix)
mln_assertion(*qix = value);
}
Index: tests/erosion.cc
--- tests/erosion.cc (revision 1025)
+++ tests/erosion.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/median.cc
+/*! \file tests/erosion.cc
*
- * \brief Test on mln::level::median.
+ * \brief Test on mln::morpho::erosion.
*/
#include <mln/core/image2d_b.hh>
Index: tests/fill.cc
--- tests/fill.cc (revision 0)
+++ tests/fill.cc (revision 0)
@@ -0,0 +1,63 @@
+// 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/fill.cc
+ *
+ * \brief Tests on mln::level::fill
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/level/fill.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/value/props.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+
+ unsigned u = 300;
+ unsigned char uc = u;
+ mln_assertion(uc = 44);
+
+// {
+// const unsigned size = 3;
+// image2d_b<unsigned> ima(size, size);
+// level::fill(ima, u);
+// debug::println(ima);
+// }
+
+ {
+ const unsigned size = 10000;
+ image2d_b<unsigned char> ima(size, size);
+ for (unsigned i = 0; i < 5; ++i)
+ level::fill(ima, uc);
+ }
+
+}
Index: doc/Doxyfile.in
--- doc/Doxyfile.in (revision 1025)
+++ doc/Doxyfile.in (working copy)
@@ -1055,6 +1055,7 @@
"mln_fwd_viter(T)=typename T::fwd_viter" \
"mln_bkd_viter(T)=typename T::bkd_viter" \
"mln_value(T)=typename T::value" \
+ "mln_vset(T)=typename T::vset" \
"mln_rvalue(T)=typename T::rvalue" \
"mln_lvalue(T)=typename T::lvalue" \
"mln_coord(T)=typename T::coord" \
Index: mln/debug/iota.hh
--- mln/debug/iota.hh (revision 1025)
+++ mln/debug/iota.hh (working copy)
@@ -49,6 +49,9 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename I>
void iota(Image<I>& input_)
{
@@ -59,6 +62,26 @@
input(p) = ++i;
}
+ template <typename I>
+ void iota(Fast_Image<I>& input_)
+ {
+ unsigned i = 0;
+ I& input = exact(input_);
+ mln_pixter(I) p(input);
+ for_all(p)
+ *p = ++i;
+ }
+
+ } // end of namespace mln::debug::impl
+
+
+ template <typename I>
+ void iota(Image<I>& input)
+ {
+ mln_precondition(exact(input).has_data());
+ impl::iota(exact(input));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::debug
Index: mln/fun/pw_value.hh
--- mln/fun/pw_value.hh (revision 1025)
+++ mln/fun/pw_value.hh (working copy)
@@ -63,11 +63,11 @@
{
template <typename K, typename E>
- struct function_ : Function_p2v<E>
+ struct select_function_ : Function_p2v<E>
{};
template <typename E>
- struct function_< value::binary_kind, E > : Function_p2b<E>
+ struct select_function_< value::binary_kind, E > : Function_p2b<E>
{};
} // end of namespace mln::fun::internal
@@ -76,7 +76,7 @@
// FIXME: Doc!
template <typename I>
- struct pw_value : public internal::function_< mln_kind(I), pw_value<I> >
+ struct pw_value : public internal::select_function_< mln_value_kind(I), pw_value<I> >
{
typedef mln_value(I) result;
pw_value(const I& ima);
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 1025)
+++ mln/core/macros.hh (working copy)
@@ -105,14 +105,14 @@
// p
-/// Shortcut to access the piter type associated to T.
+/// Shortcut to access the type of point iterator (piter) associated to T.
# define mln_piter(T) typename T::fwd_piter
# define mln_piter_(T) T::fwd_piter
-/// Shortcut to access the pset type associated to T.
+/// Shortcut to access the type of point set (pset) associated to T.
# define mln_pset(T) typename T::pset
-/// Shortcut to access the psite type associated to T.
+/// Shortcut to access the type of point site (psite) associated to T.
# define mln_psite(T) typename T::psite
/// Shortcut to access the point type associated to T.
@@ -145,6 +145,12 @@
/// Shortcut to access the value type associated to T.
# define mln_value(T) typename T::value
+/// Shortcut to the kind of values for an image with type \c I.
+# define mln_value_kind(T) typename mln::value::props< mln_value(I) >::kind
+
+/// Shortcut to access the type of value set (vset) associated to T.
+# define mln_vset(T) typename T::vset
+
/// Shortcut to access the viter type associated to T.
# define mln_viter(T) typename T::fwd_viter
Index: mln/core/trait/is_fast.hh
--- mln/core/trait/is_fast.hh (revision 0)
+++ mln/core/trait/is_fast.hh (revision 0)
@@ -0,0 +1,60 @@
+// 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_TRAIT_IS_FAST_HH
+# define MLN_CORE_TRAIT_IS_FAST_HH
+
+/*! \file mln/core/trait/is_fast.hh
+ *
+ * \brief Definition of the is_fast image trait.
+ */
+
+# include <mln/metal/bool.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+
+ // FIXME: Doc!
+
+ template <typename I>
+ struct is_fast
+ {
+ typedef metal::false_ ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_TRAIT_IS_FAST_HH
Index: mln/core/trait/all.hh
--- mln/core/trait/all.hh (revision 0)
+++ mln/core/trait/all.hh (revision 0)
@@ -0,0 +1,52 @@
+// 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_TRAIT_ALL_HH
+# define MLN_CORE_TRAIT_ALL_HH
+
+/*! \file mln/core/trait/all.hh
+ *
+ * \brief File that includes all traits.
+ */
+
+
+namespace mln
+{
+
+ /*! Namespace for image traits.
+ */
+ namespace trait {}
+
+}
+
+
+# include <mln/core/trait/is_fast.hh>
+# include <mln/core/trait/is_lowq.hh>
+# include <mln/core/trait/pixter.hh>
+
+
+#endif // ! MLN_CORE_TRAIT_ALL_HH
Index: mln/core/trait/pixter.hh
--- mln/core/trait/pixter.hh (revision 1025)
+++ mln/core/trait/pixter.hh (working copy)
@@ -57,11 +57,6 @@
typedef metal::none ret;
};
- template <typename I>
- struct pixter : fwd_pixter<I>
- {
- };
-
// qixter
@@ -77,11 +72,6 @@
typedef metal::none ret;
};
- template <typename I, typename W>
- struct qixter : fwd_qixter<I, W>
- {
- };
-
// nixter
@@ -97,11 +87,6 @@
typedef metal::none ret;
};
- template <typename I, typename N>
- struct nixter : fwd_nixter<I, N>
- {
- };
-
} // end of namespace mln::trait
Index: mln/core/trait/is_lowq.hh
--- mln/core/trait/is_lowq.hh (revision 0)
+++ mln/core/trait/is_lowq.hh (revision 0)
@@ -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_TRAIT_IS_LOWQ_HH
+# define MLN_CORE_TRAIT_IS_LOWQ_HH
+
+/*! \file mln/core/trait/is_lowq.hh
+ *
+ * \brief Definition of the is_lowq image trait.
+ */
+
+# include <mln/metal/bool.hh>
+# include <mln/value/props.hh>
+
+
+# define mln_is_lowq(I) typename mln::trait::is_lowq< I >::ret
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+
+ // FIXME: Doc!
+
+ template <typename I>
+ struct is_lowq
+ {
+ typedef typename metal::bool_<( mln_card(mln_value(I)) != 0 )>::type ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_TRAIT_IS_LOWQ_HH
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 1025)
+++ mln/core/internal/image_base.hh (working copy)
@@ -42,12 +42,30 @@
namespace internal
{
+
+
+ template <typename Is_fast, typename E>
+ struct select_image_concept_;
+
+ template <typename E>
+ struct select_image_concept_< metal::true_, E >
+ : public Fast_Image<E>
+ {};
+
+ template <typename E>
+ struct select_image_concept_< metal::false_, E >
+ : public Image<E>
+ {};
+
+
+
/*! \brief A base class for images.
*
* \internal
*/
template <typename S, typename E>
- struct image_base_ : public Image<E>
+ struct image_base_ : public select_image_concept_< typename trait::is_fast<E>::ret,
+ E >
{
/// Point_Set associated type.
typedef S pset;
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 1025)
+++ mln/core/concept/image.hh (working copy)
@@ -33,6 +33,7 @@
*/
# include <mln/core/concept/point_set.hh>
+# include <mln/core/trait/all.hh>
namespace mln
@@ -52,8 +53,10 @@
typedef value;
typedef rvalue;
typedef lvalue;
+ typedef vset;
bool has_data() const;
+ const vset& values() const;
bool owns_(const psite& p) const;
const pset& domain() const;
@@ -138,4 +141,7 @@
} // end of namespace mln
+# include <mln/core/concept/fast_image.hh>
+
+
#endif // ! MLN_CORE_CONCEPT_IMAGE_HH
Index: mln/core/concept/value_set.hh
--- mln/core/concept/value_set.hh (revision 1025)
+++ mln/core/concept/value_set.hh (working copy)
@@ -48,7 +48,6 @@
{
/*
typedef value;
- typedef viter;
typedef fwd_viter;
typedef bkd_viter;
@@ -71,7 +70,6 @@
Value_Set<E>::Value_Set()
{
typedef mln_value(E) value;
- typedef mln_viter(E) viter;
typedef mln_fwd_viter(E) fwd_viter;
typedef mln_bkd_viter(E) bkd_viter;
Index: mln/core/concept/fast_image.hh
--- mln/core/concept/fast_image.hh (revision 1025)
+++ mln/core/concept/fast_image.hh (working copy)
@@ -33,7 +33,6 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/trait/pixter.hh>
namespace mln
@@ -55,6 +54,9 @@
point point_at_offset(unsigned o) const;
const value* buffer() const;
+
+ rvalue operator[](unsigned o) const;
+ lvalue operator[](unsigned o);
*/
protected:
@@ -69,7 +71,6 @@
{
typedef mln_point(E) point;
typedef mln_dpoint(E) dpoint;
- typedef mln_value(E) value;
typedef mln_fwd_pixter(E) fwd_pixter;
typedef mln_bkd_pixter(E) bkd_pixter;
@@ -80,11 +81,22 @@
m2 = 0;
point (E::*m3)(unsigned) const = & E::point_at_offset;
m3 = 0;
- const value* (E::*m4)() const = & E::buffer;
+ unsigned (E::*m4)() const = & E::border;
m4 = 0;
- unsigned (E::*m5)() const = & E::border;
+
+ typedef mln_value(E) value;
+
+ const value* (E::*m5)() const = & E::buffer;
m5 = 0;
+ typedef mln_rvalue(E) rvalue;
+ typedef mln_lvalue(E) lvalue;
+
+ rvalue (E::*m6)(unsigned) const = & E::operator[];
+ m6 = 0;
+ lvalue (E::*m7)(unsigned) = & E::operator[];
+ m7 = 0;
+
// FIXME: how to check that qixter are defined when W is unknown!
}
Index: mln/core/concept/doc/image.hh
--- mln/core/concept/doc/image.hh (revision 1025)
+++ mln/core/concept/doc/image.hh (working copy)
@@ -56,6 +56,11 @@
*/
typedef void lvalue;
+ /*! \brief Value set associated type.
+ * \invariant This type has to derive from mln::Value_Set.
+ */
+ typedef void vset;
+
/*! \brief Test if the image have been initialized.
*/
bool has_data() const;
@@ -73,13 +78,19 @@
*/
const pset& domain() const;
- /*! \brief Read access to the image value located at \p p.
+ /*! \brief Give the set of values of the image.
+ *
+ * \return A reference to the value set.
+ */
+ const vset& values() const;
+
+ /*! \brief Read-only access to the image value located at \p p.
*
* \param[in] p A point site.
*
* \pre The image has to own the site \p p.
*
- * \return The value at \p p.
+ * \return The value at \p p (not assignable).
*/
rvalue operator()(const psite& p) const;
@@ -89,7 +100,7 @@
*
* \pre The image has to own the site \p p.
*
- * \return The value at \p p.
+ * \return The value at \p p (assignable).
*/
lvalue operator()(const psite& p);
Index: mln/core/concept/doc/value_set.hh
--- mln/core/concept/doc/value_set.hh (revision 1025)
+++ mln/core/concept/doc/value_set.hh (working copy)
@@ -46,10 +46,6 @@
*/
typedef void value;
- /*! \brief Viter associated type.
- */
- typedef void viter;
-
/*! \brief Forward Viter associated type.
*/
typedef void fwd_viter;
Index: mln/core/concept/doc/fast_image.hh
--- mln/core/concept/doc/fast_image.hh (revision 1025)
+++ mln/core/concept/doc/fast_image.hh (working copy)
@@ -51,7 +51,7 @@
/*! \brief Give the offset corresponding to the delta-point \p
* dp.
*
- * \param[in] p A delta-point.
+ * \param[in] dp A delta-point.
*
* \pre The image has to be initialized.
*/
@@ -69,7 +69,7 @@
/*! \brief Give the point at offset \p o.
*
- * \param[in] p An offset.
+ * \param[in] o An offset.
*
* \pre The image has to be initialized.
* \pre o < ncells()
@@ -85,6 +85,27 @@
*/
const value* buffer() const;
+ /*! \brief Read-only access to the image value at offset \p o.
+ *
+ * \param[in] o An offset.
+ *
+ * \pre o < ncells()
+ *
+ * \return The value at \p o (not assignable).
+ */
+ rvalue operator[](unsigned o) const;
+
+
+ /*! \brief Read-write access to the image value at offset \p o.
+ *
+ * \param[in] o An offset.
+ *
+ * \pre o < ncells()
+ *
+ * \return The value at \p o (assignable).
+ */
+ lvalue operator[](unsigned o);
+
};
} // end of namespace mln::doc
Index: mln/core/tags.hh
--- mln/core/tags.hh (revision 1025)
+++ mln/core/tags.hh (working copy)
@@ -42,6 +42,7 @@
// FIXME: ...
+
} // end of namespace mln::core
} // end of namespace mln
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1025)
+++ mln/core/image2d_b.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/core/box2d.hh>
# include <mln/border/thickness.hh>
+# include <mln/value/set.hh>
# include <mln/fun/all.hh>
@@ -50,6 +51,23 @@
namespace mln
{
+ // Fwd decl.
+ template <typename T> struct image2d_b;
+
+
+ namespace trait
+ {
+
+ template <typename T>
+ struct is_fast< image2d_b<T> >
+ {
+ typedef metal::true_ ret;
+ };
+
+ } // end of mln::trait
+
+
+
/*! \brief Basic 2D image class.
*
* The parameter \c T is the type of pixel values. This image class
@@ -71,6 +89,7 @@
// end of warning
+
// FIXME:
// /// Forward pixel iterator associated to image2d
@@ -99,6 +118,9 @@
typedef image2d_b<U> ret;
};
+ /// Value_Set associated type.
+ typedef mln::value::set_<T> vset;
+
/// Constructor without argument.
image2d_b();
@@ -134,6 +156,9 @@
/// Test if this image has been initialized.
bool has_data() const;
+ /// Give the set of values of the image.
+ const vset& values() const;
+
/// Give the definition domain.
const box2d& domain() const;
@@ -143,12 +168,18 @@
/// Give the number of cells (points including border ones).
std::size_t ncells() const;
- /// Read-only access to the image value located at \p p.
+ /// Read-only access to the image value located at point \p p.
const T& operator()(const point2d& p) const;
- /// Read-write access to the image value located at \p p.
+ /// Read-write access to the image value located at point \p p.
T& operator()(const point2d& p);
+ /// Read-only access to the image value located at offset \p o.
+ const T& operator[](unsigned o) const;
+
+ /// Read-write access to the image value located at offset \p o.
+ T& operator[](unsigned o);
+
/// Read-only access to the image value located at (\p row, \p col).
const T& at(int row, int col) const;
@@ -279,6 +310,13 @@
}
template <typename T>
+ const typename image2d_b<T>::vset&
+ image2d_b<T>::values() const
+ {
+ return vset::the();
+ }
+
+ template <typename T>
const box2d&
image2d_b<T>::domain() const
{
@@ -328,6 +366,22 @@
template <typename T>
const T&
+ image2d_b<T>::operator[](unsigned o) const
+ {
+ mln_precondition(o < ncells());
+ return *(buffer_ + o);
+ }
+
+ template <typename T>
+ T&
+ image2d_b<T>::operator[](unsigned o)
+ {
+ mln_precondition(o < ncells());
+ return *(buffer_ + o);
+ }
+
+ template <typename T>
+ const T&
image2d_b<T>::at(int row, int col) const
{
mln_precondition(this->owns_(make::point2d(row, col)));
@@ -380,7 +434,6 @@
image2d_b<T>::point_at_offset(unsigned o) const
{
mln_precondition(o < ncells());
- mln_precondition(this->has_data());
point2d p = make::point2d(o / vb_.len(1) + vb_.min_row(),
o % vb_.len(1) + vb_.min_col());
mln_postcondition(& this->operator()(p) = this->buffer_ + o);
@@ -462,6 +515,12 @@
};
template <typename T>
+ struct fwd_pixter< const image2d_b<T> >
+ {
+ typedef fwd_pixter2d_b< const image2d_b<T> > ret;
+ };
+
+ template <typename T>
struct bkd_pixter< image2d_b<T> >
{
typedef internal::fixme ret;
Index: mln/metal/math.hh
--- mln/metal/math.hh (revision 0)
+++ mln/metal/math.hh (revision 0)
@@ -0,0 +1,63 @@
+// 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_METAL_MATH_HH
+# define MLN_METAL_MATH_HH
+
+/*! \file mln/metal/math.hh
+ *
+ * \brief Definition of some mathematical static functions.
+ */
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ // pow<x, n>
+
+ template <int x, unsigned n>
+ struct pow
+ {
+ enum { value = x * pow<x, n-1>::value };
+ };
+
+ template <int x>
+ struct pow< x, 0 >
+ {
+ enum { value = 1 };
+ };
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_MATH_HH
Index: mln/metal/bool.hh
--- mln/metal/bool.hh (revision 0)
+++ mln/metal/bool.hh (revision 0)
@@ -0,0 +1,76 @@
+// 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_METAL_BOOL_HH
+# define MLN_METAL_BOOL_HH
+
+/*! \file mln/metal/bool.hh
+ *
+ * \brief Definition of a Boolean value type.
+ */
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ // Fwd decls.
+ struct true_;
+ struct false_;
+
+
+
+ // FIXME: Doc!
+
+ template <bool b> struct bool_;
+
+ template <>
+ struct bool_< true >
+ {
+ typedef true_ type;
+ static const bool value = true;
+ };
+
+ template <>
+ struct bool_< false >
+ {
+ typedef false_ type;
+ static const bool value = false;
+ };
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+# include <mln/metal/bexpr.hh>
+
+
+#endif // ! MLN_METAL_BOOL_HH
Index: mln/metal/none.hh
--- mln/metal/none.hh (revision 1025)
+++ mln/metal/none.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_CORE_METAL_NONE_HH
# define MLN_CORE_METAL_NONE_HH
-/*! \file mln/core/metal/none.hh
+/*! \file mln/metal/none.hh
*
* \brief Definition of a type that means "none".
*/
Index: mln/metal/bexpr.hh
--- mln/metal/bexpr.hh (revision 0)
+++ mln/metal/bexpr.hh (revision 0)
@@ -0,0 +1,102 @@
+// 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_METAL_BEXPR_HH
+# define MLN_METAL_BEXPR_HH
+
+/*! \file mln/metal/bexpr.hh
+ *
+ * \brief Definition of types for static Boolean expressions.
+ */
+
+# include <mln/metal/bool.hh>
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+
+ /// "true" type.
+ struct true_
+ {
+ static void check();
+ typedef true_ eval;
+ enum { to_bool = true };
+ };
+
+
+ /// "false" type.
+ struct false_
+ {
+ typedef false_ eval;
+ enum { to_bool = false };
+ };
+
+
+ /// Negate type.
+ template <typename B>
+ struct not_ : bool_<( ! B::to_bool )>::type
+ {};
+
+
+ /// And type.
+ template <typename L, typename R>
+ struct and_ : bool_<( L::to_bool && R::to_bool )>::type
+ {};
+
+
+ /// Or type.
+ template <typename L, typename R>
+ struct or_ : bool_<( L::to_bool || R::to_bool )>::type
+ {};
+
+
+ /// Xor type.
+ template <typename L, typename R>
+ struct xor_ : bool_<( L::to_bool ^ R::to_bool )>::type
+ {};
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ void true_::check()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_BOOL_HH
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 1025)
+++ mln/morpho/erosion.hh (working copy)
@@ -132,7 +132,7 @@
template <typename I, typename W, typename O>
void erosion_wrt_win(const Image<I>& input, const Window<W>& win, Image<O>& output)
{
- erosion_wrt_value(mln_kind(I)(), exact(input), exact(win), output);
+ erosion_wrt_value(mln_value_kind(I)(), exact(input), exact(win), output);
// |
// --> call stage 2: dispatch w.r.t. the value kind
}
Index: mln/level/fill.hh
--- mln/level/fill.hh (revision 1025)
+++ mln/level/fill.hh (working copy)
@@ -33,6 +33,8 @@
* \brief Fill an image, that is, set pixel values.
*/
+# include <cstring>
+
# include <mln/core/concept/image.hh>
# include <mln/core/concept/function.hh>
@@ -49,6 +51,8 @@
* \param[in] v The value to assign to all pixels.
*
* \pre \p ima has to be initialized.
+ *
+ * \todo Optimize when \p ima is large and sizeof(mln_value(I)) > 1.
*/
template <typename I>
void fill(Image<I>& ima, const mln_value(I)& v);
@@ -60,6 +64,8 @@
* \param[in] f The function.
*
* \pre \p ima has to be initialized.
+ *
+ * \todo Take benefit from quantization when possible.
*/
template <typename I, typename F>
void fill(Image<I>& ima, const Function_p2v<F>& f);
@@ -74,6 +80,8 @@
* " value f(const point& p) "
*
* \pre \p ima has to be initialized.
+ *
+ * \todo Take benefit from quantization when possible.
*/
template <typename I>
void fill(Image<I>& ima, mln_value(I) (*f)(const mln_point(I)& p));
@@ -103,28 +111,70 @@
* the one of \p data.
*
* \pre \p ima.domain <= \p data.domain.
+ *
+ * \todo Use memcpy when possible.
*/
template <typename I, typename J>
void fill(Image<I>& ima, const Image<J>& data);
+
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
+
+ // fill_with_value
+
template <typename I>
- void fill(Image<I>& ima_,
- const mln_value(I)& value)
+ void fill_with_value(Image<I>& ima_, const mln_value(I)& value,
+ bool force_call = false)
{
+ force_call = false; // just to avoid warning ("unused param")
I& ima = exact(ima_);
- mln_precondition(ima.has_data());
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = value;
}
+ template <typename I>
+ void fill_with_value(Fast_Image<I>& ima_, const mln_value(I)& value)
+ {
+ I& ima = exact(ima_);
+ if (sizeof(mln_value(I)) = 1)
+ {
+ std::memset((void*)(ima.buffer()),
+ value,
+ sizeof(mln_value(I)) * ima.ncells());
+ }
+ else
+ {
+ // FIXME: Use memcpy on a chunck when image size is large!
+ fill_with_value(ima, value, true);
+ }
+ }
+
+
+ } // end of namespace mln::level::impl
+
+
+
+ // with: value
+
+ template <typename I>
+ void fill(Image<I>& ima, const mln_value(I)& value)
+ {
+ mln_precondition(exact(ima).has_data());
+ impl::fill_with_value(exact(ima), value);
+ }
+
+
+ // with: Function_p2v<F>
+
template <typename I, typename F>
- void fill(Image<I>& ima_,
- const Function_p2v<F>& f_)
+ void fill(Image<I>& ima_, const Function_p2v<F>& f_)
{
I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -134,6 +184,9 @@
ima(p) = f(p);
}
+
+ // with: value f(const point&)
+
template <typename I>
void fill(Image<I>& ima_,
mln_value(I) (*f)(const mln_point(I)& p))
@@ -145,9 +198,11 @@
ima(p) = f(p);
}
+
+ // with: value arr[N]
+
template <typename I, unsigned N>
- void fill(Image<I>& ima_,
- mln_value(I) (&arr)[N])
+ void fill(Image<I>& ima_, mln_value(I) (&arr)[N])
{
I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -158,9 +213,11 @@
ima(p) = arr[i++];
}
+
+ // with: Image<J>
+
template <typename I, typename J>
- void fill(Image<I>& ima_,
- const Image<J>& data_)
+ void fill(Image<I>& ima_, const Image<J>& data_)
{
I& ima = exact(ima_);
const J& data = exact(data_);
Index: mln/level/fast_median.hh
--- mln/level/fast_median.hh (revision 1025)
+++ mln/level/fast_median.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_LEVEL_FAST_MEDIAN_HH
# define MLN_LEVEL_FAST_MEDIAN_HH
-/*! \file mln/level/median.hh
+/*! \file mln/level/fast_median.hh
*
* \brief Fast Median filtering of an image.
*/
Index: mln/level/transform.hh
--- mln/level/transform.hh (revision 1025)
+++ mln/level/transform.hh (working copy)
@@ -36,6 +36,9 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/function.hh>
+# include <mln/value/set.hh>
+# include <mln/value/lut_vec.hh>
+
namespace mln
{
@@ -61,20 +64,67 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename I, typename F, typename O>
- void transform(const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
+ void transform(metal::false_, // general case
+ const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
{
const I& input = exact(input_);
const F& f = exact(f_);
O& output = exact(output_);
- mln_precondition(output.domain() >= input.domain());
-
mln_piter(I) p(input.domain());
for_all(p)
output(p) = f( input(p) );
}
+ template <typename I, typename F, typename O>
+ void transform(metal::true_, // low quantization
+ const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const F& f = exact(f_);
+ O& output = exact(output_);
+
+ value::lut_vec<mln_vset(I), mln_result(F)> lut(input.values(), f);
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ output(p) = lut(input(p));
+ }
+
+// template <typename I, typename F, typename O>
+// void transform(metal::true_, // low quantization
+// const Fast_Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
+// {
+// const I& input = exact(input_);
+// const F& f = exact(f_);
+// O& output = exact(output_);
+
+// value::lut_vec<mln_vset(I), mln_result(F)> lut(input.values(), f);
+// mln_pixter(const I) pi(input); // FIXME
+// mln_pixter(O) po(output);
+// po.start();
+// for_all(pi)
+// {
+// *po = lut(*pi);
+// po.next();
+// }
+// }
+
+ } // end of namespace mln::level::impl
+
+
+ template <typename I, typename F, typename O>
+ void transform(const Image<I>& input, const Function_v2v<F>& f, Image<O>& output)
+ {
+ mln_precondition(exact(output).domain() >= exact(input).domain());
+ impl::transform(mln_is_lowq(I)(),
+ exact(input), exact(f), exact(output));
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::level
Index: mln/value/lut_vec.hh
--- mln/value/lut_vec.hh (revision 0)
+++ mln/value/lut_vec.hh (revision 0)
@@ -0,0 +1,165 @@
+// 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_LUT_VEC_HH
+# define MLN_VALUE_LUT_VEC_HH
+
+/*! \file mln/value/lut_vec.hh
+ *
+ * \brief Define some basic lut_vecs of values from value types.
+ */
+
+# include <vector>
+
+# include <mln/core/concept/value_set.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/value/props.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ // Fwd decls.
+ template <typename S> struct fwd_viter_;
+ template <typename S> struct bkd_viter_;
+
+
+ /*! Class that defines FIXME
+ *
+ * \warning This is a multi-set!!!
+ * FIXME
+ *
+ */
+ template <typename S, typename T>
+ struct lut_vec : public Value_Set< lut_vec<S,T> >
+ {
+ /// Value associated type.
+ typedef T value;
+
+ /// Forward Viter associated type.
+ typedef fwd_viter_< lut_vec<S,T> > fwd_viter;
+
+ /// Backward Viter associated type.
+ typedef bkd_viter_< lut_vec<S,T> > bkd_viter;
+
+ /// Give the \p i-th value.
+ T operator[](std::size_t i) const;
+
+ /// Give the number of values.
+ std::size_t nvalues() const;
+
+ // Apply the look-up-table. FIXME: Doc!
+ T operator()(const mln_value(S)& val) const;
+
+ /// Test if \p v belongs to this set.
+ bool has(const value& v) const;
+
+ /// Give the index of value \p v in this set.
+ std::size_t index_of(const value& v) const;
+
+ /// Ctor. FIXME!
+ template <typename F>
+ lut_vec(const S& vset, const Function_v2v<F>& f);
+
+ protected:
+
+ const S& vset_;
+ std::vector<T> vec_;
+ unsigned n_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename S, typename T>
+ bool
+ lut_vec<S,T>::has(const T&) const
+ {
+ mln_invariant(0); // FIXME
+ return false;
+ }
+
+ template <typename S, typename T>
+ std::size_t
+ lut_vec<S,T>::index_of(const T& v) const
+ {
+ mln_invariant(0); // FIXME
+ return 0;
+ }
+
+ template <typename S, typename T>
+ template <typename F>
+ lut_vec<S,T>::lut_vec(const S& vset, const Function_v2v<F>& f)
+ : vset_(vset)
+ {
+ const F& f_ = exact(f);
+ n_ = vset.nvalues();
+ vec_.reserve(n_);
+ for (unsigned i = 0; i < n_; ++i)
+ vec_[i] = f_(vset[i]);
+ }
+
+ template <typename S, typename T>
+ T
+ lut_vec<S,T>::operator()(const mln_value(S)& val) const
+ {
+ unsigned i = vset_.index_of(val);
+ mln_precondition(i < n_);
+ return vec_[vset_.index_of(val)];
+ }
+
+ template <typename S, typename T>
+ T
+ lut_vec<S,T>::operator[](std::size_t i) const
+ {
+ mln_precondition(i < nvalues());
+ return vec_[i];
+ }
+
+ template <typename S, typename T>
+ std::size_t
+ lut_vec<S,T>::nvalues() const
+ {
+ return vec_.size();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+
+} // end of namespace mln
+
+
+# include <mln/value/viter.hh>
+
+
+#endif // ! MLN_VALUE_LUT_VEC_HH
Index: mln/value/props.hh
--- mln/value/props.hh (revision 1025)
+++ mln/value/props.hh (working copy)
@@ -41,19 +41,19 @@
/// Get the minimum value of type \c T.
-# define mln_min(T) mln::value::props<T>::min()
+# define mln_min(T) mln::value::props< T >::min
/// Get the maximum value of type \c T.
-# define mln_max(T) mln::value::props<T>::max()
+# define mln_max(T) mln::value::props< T >::max
/// Get the number of values for value type \c T.
-# define mln_card(T) mln::value::props<T>::card()
+# define mln_card(T) mln::value::props< T >::card
-/// Get the kind of the value type of image \c I.
-# define mln_kind(I) typename mln::value::props< mln_value(I) >::kind
+/// Get the kind of value type \c T.
+# define mln_kind(T) typename mln::value::props< T >::kind
@@ -71,119 +71,124 @@
struct props
{
/// Minimum value for type \c T.
- static T min();
+ static const T min;
/// Maximum value for type \c T.
- static T max();
+ static const T max;
/// Number of values for type \c T.
- static std::size_t card();
+ static const std::size_t card;
};
-# ifndef MLN_INCLUDE_ONLY
+
+ // bool
template <>
struct props<bool>
{
- static bool min() { return false; }
- static bool max() { return true; }
- static std::size_t card() { return 2; }
+ static const bool min = false;
+ static const bool max = true;
+ static const std::size_t card = 2;
typedef binary_kind kind;
};
+
// integers
template <>
struct props<unsigned char>
{
- static unsigned char min() { return 0; }
- static unsigned char max() { return 255; }
- static std::size_t card() { return 256; }
+ static const unsigned char min = 0;
+ static const unsigned char max = 255;
+ static const std::size_t card = 256;
typedef data_kind kind;
};
template <>
struct props<signed char>
{
- static signed char min() { return -128; }
- static signed char max() { return 127; }
- static std::size_t card() { return 256; }
+ static const signed char min = -128;
+ static const signed char max = 127;
+ static const std::size_t card = 256;
typedef data_kind kind;
};
template <>
struct props<unsigned short>
{
- static unsigned short min() { return 0; }
- static unsigned short max() { return 65535; }
- static std::size_t card() { return 65536; }
+ static const unsigned short min = 0;
+ static const unsigned short max = 65535;
+ static const std::size_t card = 65536;
typedef data_kind kind;
};
template <>
struct props<signed short>
{
- static signed short min() { return -32768; }
- static signed short max() { return 32767; }
- static std::size_t card() { return 655356; }
+ static const signed short min = -32768;
+ static const signed short max = 32767;
+ static const std::size_t card = 655356;
typedef data_kind kind;
};
template <>
struct props<unsigned int>
{
- static unsigned int min() { return 0; }
- static unsigned int max() { return UINT_MAX; }
- static std::size_t card() { return std::size_t(UINT_MAX) + 1; }
+ static const unsigned int min = 0;
+ static const unsigned int max = UINT_MAX;
typedef data_kind kind;
+ static const std::size_t card = 0;
};
template <>
struct props<signed int>
{
- static signed int min() { return INT_MIN; }
- static signed int max() { return INT_MAX; }
- static std::size_t card() { return std::size_t(UINT_MAX) + 1; }
+ static const signed int min = INT_MIN;
+ static const signed int max = INT_MAX;
typedef data_kind kind;
+ static const std::size_t card = 0;
};
template <>
struct props<unsigned long int>
{
- static unsigned long int min() { return 0; }
- static unsigned long int max() { return ULONG_MAX; }
+ static const unsigned long int min = 0;
+ static const unsigned long int max = ULONG_MAX;
typedef data_kind kind;
+ static const std::size_t card = 0;
};
template <>
struct props<signed long int>
{
- static signed long int min() { return LONG_MIN; }
- static signed long int max() { return LONG_MAX; }
+ static const signed long int min = LONG_MIN;
+ static const signed long int max = LONG_MAX;
typedef data_kind kind;
+ static const std::size_t card = 0;
};
+
// floating
template <>
struct props<float>
{
- static float min() { return FLT_MIN; }
- static float max() { return FLT_MAX; }
+ static const float min() { return FLT_MIN; }
+ static const float max() { return FLT_MAX; }
typedef data_kind kind;
+ static const std::size_t card = 0;
};
template <>
struct props<double>
{
- static double min() { return DBL_MIN; }
- static double max() { return DBL_MAX; }
+ static const double min() { return DBL_MIN; }
+ static const double max() { return DBL_MAX; }
typedef data_kind kind;
+ static const std::size_t card = 0;
};
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::value
} // end of namespace mln
Index: mln/value/kind.hh
--- mln/value/kind.hh (revision 1025)
+++ mln/value/kind.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_VALUE_KIND_HH
# define MLN_VALUE_KIND_HH
-/*! \file mln/value/tags.hh
+/*! \file mln/value/kind.hh
*
* \brief Define the set of kinds of value.
*/
Index: mln/value/set.hh
--- mln/value/set.hh (revision 1025)
+++ mln/value/set.hh (working copy)
@@ -64,9 +64,6 @@
/// Backward Viter associated type.
typedef bkd_viter_< set_<T> > bkd_viter;
- /// Viter associated type.
- typedef fwd_viter viter;
-
/// Test if \p v belongs to this set: always true!
bool has(const T& v) const;
@@ -129,14 +126,6 @@
} // end of namespace mln::value
-
- // FIXME: Turn definitions into objects!
- typedef value::set_<bool> Booleans;
- typedef value::set_<int> integers;
- typedef value::set_<unsigned> naturals;
-
-
-
} // end of namespace mln
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1025)
+++ mln/value/int_u.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/value.hh>
+# include <mln/metal/math.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/props.hh>
@@ -83,6 +84,8 @@
template <unsigned n>
struct props< int_u_<n> > : public props< typename internal::encoding_<n>::ret >
{
+ static const unsigned nbits = n;
+ static const std::size_t card = metal::pow<2, n>::value;
};