Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
November 2007
- 9 participants
- 147 discussions
23 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add documentation and make some better tests.
* mln/core/h_mat.hh,
* mln/core/h_vec.hh,
* mln/core/image_if.hh,
* mln/core/image_if_interval.hh,
* mln/core/image_if_value.hh,
* mln/core/tr_image.hh,
* mln/core/tr_mesh.hh,
* mln/fun/x2x/composed.hh,
* mln/fun/x2x/rotation.hh,
* mln/fun/x2x/translation.hh: Add Documentation.
* tests/image_if_interval.cc,
* tests/image_if_value.cc,
* tests/line_piter.cc: Better tests.
---
mln/core/h_mat.hh | 30 +++++++++++++++++++-----------
mln/core/h_vec.hh | 11 +++++++----
mln/core/image_if.hh | 6 +++++-
mln/core/image_if_interval.hh | 7 ++++++-
mln/core/image_if_value.hh | 7 +++++--
mln/core/tr_image.hh | 3 ++-
mln/core/tr_mesh.hh | 1 +
mln/fun/x2x/composed.hh | 15 ++++++++++++++-
mln/fun/x2x/rotation.hh | 7 +++++++
mln/fun/x2x/translation.hh | 6 ++++++
tests/image_if_interval.cc | 7 +++++++
tests/image_if_value.cc | 7 +++++++
tests/line_piter.cc | 4 ++++
13 files changed, 90 insertions(+), 21 deletions(-)
Index: trunk/milena/tests/image_if_value.cc
===================================================================
--- trunk/milena/tests/image_if_value.cc (revision 1523)
+++ trunk/milena/tests/image_if_value.cc (revision 1524)
@@ -45,4 +45,11 @@
debug::iota(ima);
debug::println(ima);
debug::println(ima | 5);
+
+ I::fwd_piter p(ima.domain());
+ for_all(p)
+ {
+ mln_assertion((ima(p) == 5) ==
+ ((ima | 5).has(p)));
+ }
}
Index: trunk/milena/tests/image_if_interval.cc
===================================================================
--- trunk/milena/tests/image_if_interval.cc (revision 1523)
+++ trunk/milena/tests/image_if_interval.cc (revision 1524)
@@ -45,4 +45,11 @@
debug::iota(ima);
debug::println(ima);
debug::println(ima | value::interval(4, 7) );
+
+ I::fwd_piter p(ima.domain());
+ for_all(p)
+ {
+ mln_assertion((ima(p) >= 4 && ima(p) <= 7) ==
+ ((ima | value::interval(4, 7)).has(p)));
+ }
}
Index: trunk/milena/tests/line_piter.cc
===================================================================
--- trunk/milena/tests/line_piter.cc (revision 1523)
+++ trunk/milena/tests/line_piter.cc (revision 1524)
@@ -42,6 +42,10 @@
image2d<int> f(b, border);
image2d<int>::line_piter p(f.domain());
+ unsigned i = 1;
for_all(p)
+ {
+ mln_assertion(p[1] == 0 && p[0] == i++);
std::cout << p <<std::endl;
}
+}
Index: trunk/milena/mln/core/image_if.hh
===================================================================
--- trunk/milena/mln/core/image_if.hh (revision 1523)
+++ trunk/milena/mln/core/image_if.hh (revision 1524)
@@ -75,7 +75,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by a function.
*
*/
template <typename I, typename F>
@@ -118,6 +118,9 @@
// Image | Function_p2b.
+ /// ima | f creates an image_if with the image ima and the function
+ /// f.
+ /// {{{
template <typename I, typename F>
image_if<I,F>
operator | (Image<I>& ima, const Function_p2b<F>& f);
@@ -125,6 +128,7 @@
template <typename I, typename F>
image_if<const I,F>
operator | (const Image<I>& ima, const Function_p2b<F>& f);
+ /// }}}
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/core/h_vec.hh
===================================================================
--- trunk/milena/mln/core/h_vec.hh (revision 1523)
+++ trunk/milena/mln/core/h_vec.hh (revision 1524)
@@ -34,7 +34,7 @@
*/
# include <mln/metal/vec.hh>
-
+# include <mln/literal/one.hh>
namespace mln
{
@@ -82,7 +82,9 @@
} // end of namespace mln::trait
-
+ /*! \brief N-Dimensional vector with homogeneous coordinates.
+ *
+ */
template <unsigned d, typename C>
struct h_vec : public metal::vec<d + 1, C>
{
@@ -91,8 +93,9 @@
/// Constructor without argument.
h_vec();
-
+ /// Constructor with the underlying vector.
h_vec(const metal::vec<d+1, C>& other);
+
h_vec& operator=(const metal::vec<d+1, C>& rhs);
/// Back to the natural (non-homogeneous) space.
@@ -133,7 +136,7 @@
h_vec<n, T> tmp;
for (unsigned i = 0; i < n; ++i)
tmp[i] = this->data_[i];
- tmp[n] = 1; // FIXME: literal::one
+ tmp[n] = literal::one;
return tmp;
}
Index: trunk/milena/mln/core/tr_image.hh
===================================================================
--- trunk/milena/mln/core/tr_image.hh (revision 1523)
+++ trunk/milena/mln/core/tr_image.hh (revision 1524)
@@ -61,7 +61,8 @@
} // end of namespace mln::internal
- /*! \brief FIXME
+ /*! \brief Morpher that makes an image become transformed by a given
+ * transformation.
*
*/
template <typename T, typename I>
Index: trunk/milena/mln/core/image_if_value.hh
===================================================================
--- trunk/milena/mln/core/image_if_value.hh (revision 1523)
+++ trunk/milena/mln/core/image_if_value.hh (revision 1524)
@@ -75,7 +75,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by a single value.
*
*/
template <typename I>
@@ -124,6 +124,9 @@
// Image | value.
+ /// ima | v creates an image_if_value with the image ima and the
+ /// value v.
+ /// {{{
template <typename I>
image_if_value<I>
operator | (Image<I>& ima, const mln_value(I)& v);
@@ -131,7 +134,7 @@
template <typename I>
image_if_value<const I>
operator | (const Image<I>& ima, const mln_value(I)& v);
-
+ /// }}}
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/core/image_if_interval.hh
===================================================================
--- trunk/milena/mln/core/image_if_interval.hh (revision 1523)
+++ trunk/milena/mln/core/image_if_interval.hh (revision 1524)
@@ -83,7 +83,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by an interval.
*
*/
template <typename I>
@@ -109,6 +109,9 @@
// Image | [from, to].
+ /// ima | vv creates an image_if_interval with the image ima and the
+ /// interval vv.
+ /// {{{
template <typename I>
image_if_interval<I>
operator | (Image<I>& ima, const value::interval_<mln_value(I)>& vv);
@@ -116,6 +119,7 @@
template <typename I>
image_if_interval<const I>
operator | (const Image<I>& ima, const value::interval_<mln_value(I)>& vv);
+ /// }}}
@@ -163,6 +167,7 @@
// Operators.
+
template <typename I>
image_if_interval<I>
operator | (Image<I>& ima, const value::interval_<mln_value(I)>& vv)
Index: trunk/milena/mln/core/h_mat.hh
===================================================================
--- trunk/milena/mln/core/h_mat.hh (revision 1523)
+++ trunk/milena/mln/core/h_mat.hh (revision 1524)
@@ -39,27 +39,35 @@
namespace mln
{
-
- template <unsigned dim, typename T>
- struct h_mat : public metal::mat<dim+1, dim+1, T>
+ /*! \brief N-Dimensional matrix with homogeneous coordinates.
+ *
+ */
+ template <unsigned d, typename T>
+ struct h_mat : public metal::mat<d+1, d+1, T>
{
- h_mat();
+ /// Dimension is the 'natural' one (3 for 3D), not the one of the vector (dim + 1)
+ enum { N = d,
+ M = d,
+ dim = d * d };
- h_mat(const metal::mat<dim+1, dim+1, T>& x);
+ /// Constructor without argument.
+ h_mat();
+ /// Constructor with the underlying matrix.
+ h_mat(const metal::mat<d+1, d+1, T>& x);
};
# ifndef MLN_INCLUDE_ONLY
- template <unsigned dim, typename T>
- h_mat<dim,T>::h_mat()
- : metal::mat<dim+1, dim+1, T>(metal::mat<dim+1, dim+1, T>::Id)
+ template <unsigned d, typename T>
+ h_mat<d,T>::h_mat()
+ : metal::mat<d+1, d+1, T>(metal::mat<d+1, d+1, T>::Id)
{
}
- template <unsigned dim, typename T>
- h_mat<dim,T>::h_mat(const metal::mat<dim+1, dim+1, T>& x)
- : metal::mat<dim+1, dim+1, T>(x)
+ template <unsigned d, typename T>
+ h_mat<d,T>::h_mat(const metal::mat<d+1, d+1, T>& x)
+ : metal::mat<d+1, d+1, T>(x)
{
}
Index: trunk/milena/mln/core/tr_mesh.hh
===================================================================
--- trunk/milena/mln/core/tr_mesh.hh (revision 1523)
+++ trunk/milena/mln/core/tr_mesh.hh (revision 1524)
@@ -47,6 +47,7 @@
{
typedef metal::false_ regular;
+ /// Constructor with the transformation.
tr_mesh(const T& tr)
: t_(tr)
{
Index: trunk/milena/mln/fun/x2x/composed.hh
===================================================================
--- trunk/milena/mln/fun/x2x/composed.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/composed.hh (revision 1524)
@@ -60,6 +60,7 @@
struct helper_composed_;
+ /// Helper for describing a bijective composition.
template <typename F, typename G, typename E>
struct helper_composed_< F, G, E, true>
: public fun::internal::x2x_linear_impl_<mln_result(F), E >,
@@ -69,16 +70,21 @@
using super_::dim;
+ /// Constructor without argument.
helper_composed_();
+ /// Constructor with the two transformation to be composed.
helper_composed_(const F& f, const G& g);
using super_::operator();
+ /// Set the new first transformation.
void set_first(const F& f);
+ /// Set the new second transformation.
void set_second(const G& g);
+ /// Type of the inverse function.
typedef composed<mln_invert(G),mln_invert(F)> invert;
-
+ /// Return the inverse function.
invert inv() const;
protected:
@@ -87,6 +93,7 @@
G g_;
};
+ /// Helper for describing a non bijective composition.
template <typename F, typename G, typename E>
struct helper_composed_< F, G, E, false>
: public fun::internal::x2x_linear_impl_<mln_result(F), E >,
@@ -96,12 +103,16 @@
using super_::dim;
+ /// Constructor without argument.
helper_composed_();
+ /// Constructor with the two transformation to be composed.
helper_composed_(const F& f, const G& g);
using super_::operator();
+ /// Set the new first transformation.
void set_first(const F& f);
+ /// Set the new second transformation.
void set_second(const G& g);
protected:
@@ -126,8 +137,10 @@
metal::is<mln_argument(F), mln_result(G)>
>::check_t
{
+ /// Constructor without argument.
composed() {}
+ /// Constructor with the two transformation to be composed.
composed(const F& f, const G& g)
: internal::helper_composed_<F, G, composed<F,G>,
mlc_is(F, Bijection_x2x<F>)::value &&
Index: trunk/milena/mln/fun/x2x/translation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/translation.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/translation.hh (revision 1524)
@@ -60,15 +60,21 @@
{
typedef fun::internal::x2x_linear_impl_< metal::vec<n,C>, translation<n,C> > super_;
+ /// Type of the inverse function.
typedef translation<n,C> invert;
+ /// Return the inverse function.
invert inv() const;
+ /// Constructor without argument.
translation();
+ /// Constructor with the translation vector.
translation(const metal::vec<n,C>& t);
using super_::operator();
+ /// Perform the translation of the given vector
metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
+ /// Set a net translation vector.
void set_t(const metal::vec<n,C>& t);
protected:
Index: trunk/milena/mln/fun/x2x/rotation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/rotation.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/rotation.hh (revision 1524)
@@ -58,16 +58,23 @@
{
typedef fun::internal::x2x_linear_impl_< metal::vec<n,C>, rotation<n,C> > super_;
+ /// Type of the inverse function.
typedef rotation<n,C> invert;
+ /// Return the invere function.
invert inv() const;
+ /// Constructor without argument.
rotation();
+ /// Constructor with grade alpha and a facultative direction (rotation axis).
rotation(float alpha, unsigned dir = 2);
using super_::operator();
+ /// Perform the rotation of the given vector.
metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
+ /// Set a new grade alpha.
void set_alpha(float alpha);
+ /// Set a new rotation axis.
void set_dir(unsigned dir);
protected:
1
0
Re: [Olena-patches] milena r1523: Subdirectory level ready for rereading (except median)
by Guillaume Duhamel 23 Nov '07
by Guillaume Duhamel 23 Nov '07
23 Nov '07
Guillaume Duhamel wrote:
> URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
> ChangeLog:
> 2007-11-23 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
>
> Subdirectory display ready for rereading (except median).
>
> Level review.
> * mln/level/abs.hh,
> * mln/level/all.hh,
> * mln/level/memcpy_.hh,
> * mln/level/memset_.hh,
> * mln/level/paste.hh,
> * mln/level/paste.spe.hh,
> * mln/level/saturate.hh,
> * mln/level/sort_points.hh,
> * mln/level/take.hh: Review doc, add precondition and check typo.
>
> Add metal::is_not_const.
> * mln/metal/is_not_const.hh: New file for handling check in
> memcpy and memset in level.
> * mln/metal/all.hh: Add is_not_const header.
>
> Add tests.
> * tests/all.cc: New tests, which include all headers all.hh.
>
> ---
> mln/level/abs.hh | 4 +
> mln/level/all.hh | 9 +++-
> mln/level/memcpy_.hh | 59 +++++++++++++++++++++++------
> mln/level/memset_.hh | 57 +++++++++++++++++++++-------
> mln/level/paste.hh | 3 -
> mln/level/paste.spe.hh | 2
> mln/level/saturate.hh | 14 ++++++
> mln/level/sort_points.hh | 12 +++++
> mln/level/take.hh | 2
> mln/metal/all.hh | 1
> mln/metal/is_not_const.hh | 68 +++++++++++++++++++++++++++++++++
> tests/all.cc | 93 ++++++++++++++++++++++++++++++++++++++++++++++
> 12 files changed, 292 insertions(+), 32 deletions(-)
>
> Index: trunk/milena/tests/all.cc
> ===================================================================
> --- trunk/milena/tests/all.cc (revision 0)
> +++ trunk/milena/tests/all.cc (revision 1523)
> @@ -0,0 +1,93 @@
> +// 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/all.cc
> + *
> + * \brief Tests with all headers. (check norris tests)
> + */
> +
> +
> +#include <mln/test/all.hh>
> +#include <mln/convert/all.hh>
> +#include <mln/estim/all.hh>
> +#include <mln/debug/all.hh>
> +#include <mln/histo/all.hh>
> +#include <mln/pw/all.hh>
> +#include <mln/geom/all.hh>
> +#include <mln/core/trait/all.hh>
> +#include <mln/fun/i2v/all.hh>
> +#include <mln/fun/p2b/all.hh>
> +#include <mln/fun/p2v/all.hh>
> +#include <mln/fun/v2v/all.hh>
> +#include <mln/fun/x2x/all.hh>
> +#include <mln/fun/all.hh>
> +#include <mln/math/all.hh>
> +#include <mln/set/all.hh>
> +#include <mln/draw/all.hh>
> +#include <mln/metal/math/all.hh>
> +#include <mln/metal/all.hh>
> +#include <mln/morpho/all.hh>
> +#include <mln/io/pfm/all.hh>
> +#include <mln/io/pgm/all.hh>
> +#include <mln/io/fits/all.hh>
> +#include <mln/io/ppm/all.hh>
> +#include <mln/io/pbm/all.hh>
> +#include <mln/io/pnm/all.hh>
> +#include <mln/io/all.hh>
> +#include <mln/level/naive/all.hh>
> +#include <mln/level/approx/all.hh>
> +#include <mln/level/all.hh>
> +#include <mln/arith/all.hh>
> +#include <mln/linear/all.hh>
> +#include <mln/logical/all.hh>
> +#include <mln/canvas/morpho/all.hh>
> +#include <mln/canvas/browsing/all.hh>
> +#include <mln/canvas/all.hh>
> +#include <mln/accu/all.hh>
> +#include <mln/norm/all.hh>
> +#include <mln/value/internal/all.hh>
> +#include <mln/value/all.hh>
> +#include <mln/value/concept/all.hh>
> +#include <mln/value/builtin/all.hh>
> +#include <mln/make/all.hh>
> +#include <mln/border/all.hh>
> +#include <mln/labeling/all.hh>
> +#include <mln/util/all.hh>
> +#include <mln/trait/all.hh>
> +#include <mln/trait/value/all.hh>
> +#include <mln/trait/op/all.hh>
> +#include <mln/tag/all.hh>
> +#include <mln/trace/all.hh>
> +#include <mln/literal/all.hh>
> +#include <mln/display/all.hh>
> +#include <mln/win/all.hh>
> +
> +
> +int main ()
> +{
> +
> +}
> Index: trunk/milena/mln/metal/is_not_const.hh
> ===================================================================
> --- trunk/milena/mln/metal/is_not_const.hh (revision 0)
> +++ trunk/milena/mln/metal/is_not_const.hh (revision 1523)
> @@ -0,0 +1,68 @@
> +// 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_IS_NOT_CONST_HH
> +# define MLN_METAL_IS_NOT_CONST_HH
> +
> +/*!
> + * \file mln/metal/is_not_const.hh
> + *
> + * \brief FIXME.
> + */
> +
> +# include <mln/metal/bool.hh>
> +
> +
> +# define mlc_is_not_const(T) mln::metal::is_not_const< T >
> +
> +
> +namespace mln
> +{
> +
> + namespace metal
> + {
> +
> + template <typename T>
> + struct is_not_const : true_
> + {};
> +
> + template <typename T>
> + struct is_not_const< const T > : false_
> + {};
> +
> + template <typename T>
> + struct is_not_const< const T& > : false_
> + {};
> +
> + // FIXME: What about "T*const" and "const T*"?
> +
> + } // end of namespace mln::metal
> +
> +} // end of namespace mln
> +
> +
> +#endif // ! MLN_METAL_IS_NOT_CONST_HH
> Index: trunk/milena/mln/metal/all.hh
> ===================================================================
> --- trunk/milena/mln/metal/all.hh (revision 1522)
> +++ trunk/milena/mln/metal/all.hh (revision 1523)
> @@ -63,6 +63,7 @@
> # include <mln/metal/const.hh>
> # include <mln/metal/unconst.hh>
> # include <mln/metal/is_const.hh>
> +# include <mln/metal/is_not_const.hh>
>
> # include <mln/metal/unptr.hh>
> # include <mln/metal/unref.hh>
> Index: trunk/milena/mln/level/sort_points.hh
> ===================================================================
> --- trunk/milena/mln/level/sort_points.hh (revision 1522)
> +++ trunk/milena/mln/level/sort_points.hh (revision 1523)
> @@ -49,7 +49,7 @@
> {
>
> /*! Sort points the image \p input through a function \p f to set
> - * the \p output image.
> + * the \p output image in increasing way.
> *
> * \param[in] input The input image.
> *
> @@ -58,6 +58,16 @@
> template <typename I>
> p_array<mln_point(I)> sort_points_increasing(const Image<I>& input);
>
> + /*! Sort points the image \p input through a function \p f to set
> + * the \p output image in decreasing way.
> + *
> + * \param[in] input The input image.
> + *
> + * \pre \p input.has_data
> + */
> + template <typename I>
> + p_array<mln_point(I)> sort_points_decreasing(const Image<I>& input);
> +
>
> # ifndef MLN_INCLUDE_ONLY
>
> Index: trunk/milena/mln/level/take.hh
> ===================================================================
> --- trunk/milena/mln/level/take.hh (revision 1522)
> +++ trunk/milena/mln/level/take.hh (revision 1523)
> @@ -53,6 +53,8 @@
> * This routine runs: \n
> * for all p of \p input, \p a.take( \p input(p) ) \n
> *
> + * \pre \p input has to be initialized.
> + *
> * \warning This routine does not perform a.init().
> */
> template <typename A, typename I>
> Index: trunk/milena/mln/level/saturate.hh
> ===================================================================
> --- trunk/milena/mln/level/saturate.hh (revision 1522)
> +++ trunk/milena/mln/level/saturate.hh (revision 1523)
> @@ -53,6 +53,9 @@
> * The saturation is based on the min and max values of the output
> * value type. This assumes that the range of values in the input
> * image is larger than the one of the output image.
> + *
> + * \pre \p input and \p output have to own the same domain.
> + *
> */
> template <typename I, typename O>
> void saturate(const Image<I>& input, Image<O>& output);
> @@ -64,6 +67,9 @@
> * \param[in] min The minimum output value.
> * \param[in] max The maximum output value.
> * \param[out] output The output image.
> + *
> + * \pre \p input and \p output have to own the same domain.
> + *
> */
> template <typename I, typename O>
> void saturate(const Image<I>& input,
> @@ -75,7 +81,10 @@
> *
> * \param[in,out] input The input image.
> * \param[in] min The minimum output value.
> - * \param[in] max The maximum output value.
> + * \param[in] max The maximum output value
> + *
> + * \pre \p input has to be initialized.
> + *
> */
> template <typename I>
> void saturate_inplace(Image<I>& input,
> @@ -90,6 +99,7 @@
> trace::entering("level::saturate");
>
> mln_precondition(exact(input).domain() == exact(output).domain());
> +
> fun::v2v::saturate<mln_value(O)> f;
> level::transform(input, f, output);
>
> @@ -104,6 +114,7 @@
> trace::entering("level::saturate");
>
> mln_precondition(exact(input).domain() == exact(output).domain());
> +
> fun::v2v::saturate<mln_value(O)> f(min, max);
> level::transform(input, f, output);
>
> @@ -117,6 +128,7 @@
> trace::entering("level::saturate_inplace");
>
> mln_precondition(exact(input).has_data());
> +
> fun::v2v::saturate<mln_value(I)> f(min, max);
> level::apply(input, f);
>
> Index: trunk/milena/mln/level/memcpy_.hh
> ===================================================================
> --- trunk/milena/mln/level/memcpy_.hh (revision 1522)
> +++ trunk/milena/mln/level/memcpy_.hh (revision 1523)
> @@ -37,7 +37,7 @@
>
> # include <mln/core/concept/image.hh>
> # include <mln/core/pixel.hh>
> -
> +# include <mln/metal/is_not_const.hh>
>
> namespace mln
> {
> @@ -52,7 +52,13 @@
> * \param[in] src The source pixel (to get values).
> * \param[in] n The number of pixels to copy.
> *
> - * \pre FIXME: !
> + * \pre \p src has to be initialized.
> + * \pre \p dest has to be initialized.
> + * \pre \p src and dest image values have to own the same sizeof.
> + * \pre \p dest pixel has to be on \p dest image domain.
> + * \pre \p src pixel has to be on \p src image domain.
> + * \pre \p dest + \p n has to be on \p dest image domain.
> + * \pre \p src + \p n has to be on \p src image domain.
> */
> template <typename Pd, typename Ps>
> void memcpy_(Generalized_Pixel<Pd>& dest, const Generalized_Pixel<Ps>& src,
> @@ -61,20 +67,16 @@
>
> # ifndef MLN_INCLUDE_ONLY
>
> + namespace impl
> + {
> +
> template <typename Pd, typename Ps>
> - void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
> - std::size_t n)
> + void memcpy__(Pd& dest, const Ps& src, std::size_t n)
> {
> + trace::entering("level::impl::memcpy__");
> +
> typedef mln_image(Pd) Id;
> - // FIXME: metal::is_not_const<Id>::check();
> typedef mln_image(Ps) Is;
> - Pd& dest = internal::force_exact<Pd>(dest_);
> - Ps& src = internal::force_exact<Ps>(src_);
> -
> - mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
> - mln_precondition(dest.ima().has_data());
> - mln_precondition(src.ima().has_data());
> - // FIXME: Add precondition about n.
>
> if (n == 0)
> {
> @@ -100,6 +102,39 @@
> for (std::size_t i = 0; i < n; ++i)
> *p_d++ = *p_s++;
> }
> +
> + trace::exiting("level::impl::memcpy__");
> + }
> +
> + }
> +
> + template <typename Pd, typename Ps>
> + void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
> + std::size_t n)
> + {
> + trace::entering("level::memcpy_");
> +
> + typedef mln_image(Pd) Id;
> + metal::is_not_const<Id>::check();
> + typedef mln_image(Ps) Is;
> + Pd& dest = internal::force_exact<Pd>(dest_);
> + Ps& src = internal::force_exact<Ps>(src_);
> +
> + mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
> + mln_precondition(dest.ima().has_data());
> + mln_precondition(src.ima().has_data());
> +
> + mln_precondition(& dest.val() >= & dest.ima()[0]);
> + mln_precondition(& dest.val() < & dest.ima()[0] + dest.ima().ncells());
> + mln_precondition(& dest.val() + n <= & dest.ima()[0] + dest.ima().ncells());
> +
> + mln_precondition(& src.val() >= & src.ima()[0]);
> + mln_precondition(& src.val() < & src.ima()[0] + src.ima().ncells());
> + mln_precondition(& src.val() + n <= & src.ima()[0] + src.ima().ncells());
> +
> + impl::memcpy__(dest, src, n);
> +
> + trace::exiting("level::memcpy_");
> }
>
> # endif // ! MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/level/memset_.hh
> ===================================================================
> --- trunk/milena/mln/level/memset_.hh (revision 1522)
> +++ trunk/milena/mln/level/memset_.hh (revision 1523)
> @@ -35,7 +35,7 @@
>
> # include <mln/core/concept/image.hh>
> # include <mln/core/pixel.hh>
> -
> +# include <mln/metal/is_not_const.hh>
>
> namespace mln
> {
> @@ -49,7 +49,9 @@
> * \param[in] v The value to set pixels with.
> * \param[in] n The number of pixels to set.
> *
> - * \pre FIXME: !
> + * \pre \p pix image has to be initialized.
> + * \pre \p pix has to be on \p pix image domain.
> + * \pre \p pix + \p n has to be on \p pix image domain.
> */
> template <typename P>
> void memset_(Generalized_Pixel<P>& pix,
> @@ -63,7 +65,9 @@
> * \param[in] v The value to set to points.
> * \param[in] n The number of points to set.
> *
> - * \pre \p input has to be initialized. FIXME: More.
> + * \pre \p input image has to be initialized.
> + * \pre \p input has to own \p p.
> + * \pre \p p + \p n is <= \p input size.
> */
> template <typename I>
> void memset_(I& input, const mln_point(I)& p,
> @@ -72,19 +76,15 @@
>
> # ifndef MLN_INCLUDE_ONLY
>
> - template <typename P>
> - void memset_(Generalized_Pixel<P>& pix_,
> - const mln_value(P)& v, std::size_t n)
> + namespace impl
> {
> - typedef mln_image(P) I;
> - // FIXME: metal::is_not_const<I>::check();
>
> - P& pix = internal::force_exact<P>(pix_);
> - mln_precondition(pix.ima().has_data());
> - mln_precondition(& pix.val() >= & pix.ima()[0]);
> - mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
> - mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
> + template <typename P>
> + void memset__(P& pix, const mln_value(P)& v, std::size_t n)
> + {
> + trace::entering("level::impl::memset_");
>
> + typedef mln_image(P) I;
> if (n == 0)
> {
> return; // no-op
> @@ -108,12 +108,39 @@
> for (std::size_t i = 0; i < n; ++i)
> *ptr++ = v;
> }
> +
> + trace::exiting("level::impl::memset_");
> + }
> +
> + } // end of namespace mln::level::impl
> +
> +
> + template <typename P>
> + void memset_(Generalized_Pixel<P>& pix_,
> + const mln_value(P)& v, std::size_t n)
> + {
> + trace::entering("level::memset_");
> +
> + typedef mln_image(P) I;
> + metal::is_not_const<I>::check();
> +
> + P& pix = internal::force_exact<P>(pix_);
> + mln_precondition(pix.ima().has_data());
> + mln_precondition(& pix.val() >= & pix.ima()[0]);
> + mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
> + mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
> +
> + impl::memset__(pix, v, n);
> +
> + trace::exiting("level::memset_");
> }
>
> template <typename I>
> void memset_(I& input, const mln_point(I)& p,
> const mln_value(I)& v, std::size_t n)
> {
> + trace::entering("level::memset_");
> +
> mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
>
> mln_precondition(input.has_data());
> @@ -121,7 +148,9 @@
> mln_precondition(input.offset_at(p) + n <= input.ncells());
>
> pixel<I> pix(input, p);
> - memset_(pix, v, n);
> + impl::memset__(pix, v, n);
> +
> + trace::exiting("level::memset_");
> }
>
> # endif // ! MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/level/paste.spe.hh
> ===================================================================
> --- trunk/milena/mln/level/paste.spe.hh (revision 1522)
> +++ trunk/milena/mln/level/paste.spe.hh (revision 1523)
> @@ -48,14 +48,12 @@
> namespace impl
> {
>
> -
> namespace generic
> {
> template <typename I, typename J>
> void paste_(const I& data, J& destination);
> }
>
> -
> template <typename I, typename J>
> void paste_lines_(const I& data, J& destination)
> {
> Index: trunk/milena/mln/level/abs.hh
> ===================================================================
> --- trunk/milena/mln/level/abs.hh (revision 1522)
> +++ trunk/milena/mln/level/abs.hh (revision 1523)
> @@ -69,8 +69,10 @@
> void abs(const Image<I>& input, Image<O>& output)
> {
> trace::entering("level::abs");
> +
> mln_precondition(exact(input).domain() == exact(output).domain());
> level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
> +
> trace::exiting("level::abs");
> }
>
> @@ -78,8 +80,10 @@
> void abs_inplace(Image<I>& input)
> {
> trace::entering("level::abs_inplace");
> +
> mln_precondition(exact(input).has_data());
> level::apply(input, fun::v2v::abs<mln_value(I)>());
> +
> trace::exiting("level::abs_inplace");
> }
>
> Index: trunk/milena/mln/level/all.hh
> ===================================================================
> --- trunk/milena/mln/level/all.hh (revision 1522)
> +++ trunk/milena/mln/level/all.hh (revision 1523)
> @@ -40,8 +40,15 @@
> /// Namespace of image processing routines related to pixel levels.
> namespace level
> {
> +
> /// Implementation namespace of level namespace.
> - namespace impl {}
> + namespace impl {
> +
> + /// Generic implementation namespace of level namespace.
> + namespace generic {}
> +
> + }
> +
> }
>
> }
> Index: trunk/milena/mln/level/paste.hh
> ===================================================================
> --- trunk/milena/mln/level/paste.hh (revision 1522)
> +++ trunk/milena/mln/level/paste.hh (revision 1523)
> @@ -99,9 +99,10 @@
> template <typename I, typename J>
> void paste(const Image<I>& data_, Image<J>& destination_)
> {
> + trace::entering("level::paste");
> +
> const I& data = exact(data_);
> J& destination = exact(destination_);
> - trace::entering("level::paste");
>
> mlc_is(mln_trait_image_io(J), trait::image::io::write)::check();
> mlc_converts_to(mln_value(I), mln_value(J))::check();
>
Fix title.
1
0
milena r1523: Subdirectory display ready for rereading (except median)
by Guillaume Duhamel 23 Nov '07
by Guillaume Duhamel 23 Nov '07
23 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory display ready for rereading (except median).
Level review.
* mln/level/abs.hh,
* mln/level/all.hh,
* mln/level/memcpy_.hh,
* mln/level/memset_.hh,
* mln/level/paste.hh,
* mln/level/paste.spe.hh,
* mln/level/saturate.hh,
* mln/level/sort_points.hh,
* mln/level/take.hh: Review doc, add precondition and check typo.
Add metal::is_not_const.
* mln/metal/is_not_const.hh: New file for handling check in
memcpy and memset in level.
* mln/metal/all.hh: Add is_not_const header.
Add tests.
* tests/all.cc: New tests, which include all headers all.hh.
---
mln/level/abs.hh | 4 +
mln/level/all.hh | 9 +++-
mln/level/memcpy_.hh | 59 +++++++++++++++++++++++------
mln/level/memset_.hh | 57 +++++++++++++++++++++-------
mln/level/paste.hh | 3 -
mln/level/paste.spe.hh | 2
mln/level/saturate.hh | 14 ++++++
mln/level/sort_points.hh | 12 +++++
mln/level/take.hh | 2
mln/metal/all.hh | 1
mln/metal/is_not_const.hh | 68 +++++++++++++++++++++++++++++++++
tests/all.cc | 93 ++++++++++++++++++++++++++++++++++++++++++++++
12 files changed, 292 insertions(+), 32 deletions(-)
Index: trunk/milena/tests/all.cc
===================================================================
--- trunk/milena/tests/all.cc (revision 0)
+++ trunk/milena/tests/all.cc (revision 1523)
@@ -0,0 +1,93 @@
+// 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/all.cc
+ *
+ * \brief Tests with all headers. (check norris tests)
+ */
+
+
+#include <mln/test/all.hh>
+#include <mln/convert/all.hh>
+#include <mln/estim/all.hh>
+#include <mln/debug/all.hh>
+#include <mln/histo/all.hh>
+#include <mln/pw/all.hh>
+#include <mln/geom/all.hh>
+#include <mln/core/trait/all.hh>
+#include <mln/fun/i2v/all.hh>
+#include <mln/fun/p2b/all.hh>
+#include <mln/fun/p2v/all.hh>
+#include <mln/fun/v2v/all.hh>
+#include <mln/fun/x2x/all.hh>
+#include <mln/fun/all.hh>
+#include <mln/math/all.hh>
+#include <mln/set/all.hh>
+#include <mln/draw/all.hh>
+#include <mln/metal/math/all.hh>
+#include <mln/metal/all.hh>
+#include <mln/morpho/all.hh>
+#include <mln/io/pfm/all.hh>
+#include <mln/io/pgm/all.hh>
+#include <mln/io/fits/all.hh>
+#include <mln/io/ppm/all.hh>
+#include <mln/io/pbm/all.hh>
+#include <mln/io/pnm/all.hh>
+#include <mln/io/all.hh>
+#include <mln/level/naive/all.hh>
+#include <mln/level/approx/all.hh>
+#include <mln/level/all.hh>
+#include <mln/arith/all.hh>
+#include <mln/linear/all.hh>
+#include <mln/logical/all.hh>
+#include <mln/canvas/morpho/all.hh>
+#include <mln/canvas/browsing/all.hh>
+#include <mln/canvas/all.hh>
+#include <mln/accu/all.hh>
+#include <mln/norm/all.hh>
+#include <mln/value/internal/all.hh>
+#include <mln/value/all.hh>
+#include <mln/value/concept/all.hh>
+#include <mln/value/builtin/all.hh>
+#include <mln/make/all.hh>
+#include <mln/border/all.hh>
+#include <mln/labeling/all.hh>
+#include <mln/util/all.hh>
+#include <mln/trait/all.hh>
+#include <mln/trait/value/all.hh>
+#include <mln/trait/op/all.hh>
+#include <mln/tag/all.hh>
+#include <mln/trace/all.hh>
+#include <mln/literal/all.hh>
+#include <mln/display/all.hh>
+#include <mln/win/all.hh>
+
+
+int main ()
+{
+
+}
Index: trunk/milena/mln/metal/is_not_const.hh
===================================================================
--- trunk/milena/mln/metal/is_not_const.hh (revision 0)
+++ trunk/milena/mln/metal/is_not_const.hh (revision 1523)
@@ -0,0 +1,68 @@
+// 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_IS_NOT_CONST_HH
+# define MLN_METAL_IS_NOT_CONST_HH
+
+/*!
+ * \file mln/metal/is_not_const.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/metal/bool.hh>
+
+
+# define mlc_is_not_const(T) mln::metal::is_not_const< T >
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct is_not_const : true_
+ {};
+
+ template <typename T>
+ struct is_not_const< const T > : false_
+ {};
+
+ template <typename T>
+ struct is_not_const< const T& > : false_
+ {};
+
+ // FIXME: What about "T*const" and "const T*"?
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_IS_NOT_CONST_HH
Index: trunk/milena/mln/metal/all.hh
===================================================================
--- trunk/milena/mln/metal/all.hh (revision 1522)
+++ trunk/milena/mln/metal/all.hh (revision 1523)
@@ -63,6 +63,7 @@
# include <mln/metal/const.hh>
# include <mln/metal/unconst.hh>
# include <mln/metal/is_const.hh>
+# include <mln/metal/is_not_const.hh>
# include <mln/metal/unptr.hh>
# include <mln/metal/unref.hh>
Index: trunk/milena/mln/level/sort_points.hh
===================================================================
--- trunk/milena/mln/level/sort_points.hh (revision 1522)
+++ trunk/milena/mln/level/sort_points.hh (revision 1523)
@@ -49,7 +49,7 @@
{
/*! Sort points the image \p input through a function \p f to set
- * the \p output image.
+ * the \p output image in increasing way.
*
* \param[in] input The input image.
*
@@ -58,6 +58,16 @@
template <typename I>
p_array<mln_point(I)> sort_points_increasing(const Image<I>& input);
+ /*! Sort points the image \p input through a function \p f to set
+ * the \p output image in decreasing way.
+ *
+ * \param[in] input The input image.
+ *
+ * \pre \p input.has_data
+ */
+ template <typename I>
+ p_array<mln_point(I)> sort_points_decreasing(const Image<I>& input);
+
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/take.hh
===================================================================
--- trunk/milena/mln/level/take.hh (revision 1522)
+++ trunk/milena/mln/level/take.hh (revision 1523)
@@ -53,6 +53,8 @@
* This routine runs: \n
* for all p of \p input, \p a.take( \p input(p) ) \n
*
+ * \pre \p input has to be initialized.
+ *
* \warning This routine does not perform a.init().
*/
template <typename A, typename I>
Index: trunk/milena/mln/level/saturate.hh
===================================================================
--- trunk/milena/mln/level/saturate.hh (revision 1522)
+++ trunk/milena/mln/level/saturate.hh (revision 1523)
@@ -53,6 +53,9 @@
* The saturation is based on the min and max values of the output
* value type. This assumes that the range of values in the input
* image is larger than the one of the output image.
+ *
+ * \pre \p input and \p output have to own the same domain.
+ *
*/
template <typename I, typename O>
void saturate(const Image<I>& input, Image<O>& output);
@@ -64,6 +67,9 @@
* \param[in] min The minimum output value.
* \param[in] max The maximum output value.
* \param[out] output The output image.
+ *
+ * \pre \p input and \p output have to own the same domain.
+ *
*/
template <typename I, typename O>
void saturate(const Image<I>& input,
@@ -75,7 +81,10 @@
*
* \param[in,out] input The input image.
* \param[in] min The minimum output value.
- * \param[in] max The maximum output value.
+ * \param[in] max The maximum output value
+ *
+ * \pre \p input has to be initialized.
+ *
*/
template <typename I>
void saturate_inplace(Image<I>& input,
@@ -90,6 +99,7 @@
trace::entering("level::saturate");
mln_precondition(exact(input).domain() == exact(output).domain());
+
fun::v2v::saturate<mln_value(O)> f;
level::transform(input, f, output);
@@ -104,6 +114,7 @@
trace::entering("level::saturate");
mln_precondition(exact(input).domain() == exact(output).domain());
+
fun::v2v::saturate<mln_value(O)> f(min, max);
level::transform(input, f, output);
@@ -117,6 +128,7 @@
trace::entering("level::saturate_inplace");
mln_precondition(exact(input).has_data());
+
fun::v2v::saturate<mln_value(I)> f(min, max);
level::apply(input, f);
Index: trunk/milena/mln/level/memcpy_.hh
===================================================================
--- trunk/milena/mln/level/memcpy_.hh (revision 1522)
+++ trunk/milena/mln/level/memcpy_.hh (revision 1523)
@@ -37,7 +37,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/pixel.hh>
-
+# include <mln/metal/is_not_const.hh>
namespace mln
{
@@ -52,7 +52,13 @@
* \param[in] src The source pixel (to get values).
* \param[in] n The number of pixels to copy.
*
- * \pre FIXME: !
+ * \pre \p src has to be initialized.
+ * \pre \p dest has to be initialized.
+ * \pre \p src and dest image values have to own the same sizeof.
+ * \pre \p dest pixel has to be on \p dest image domain.
+ * \pre \p src pixel has to be on \p src image domain.
+ * \pre \p dest + \p n has to be on \p dest image domain.
+ * \pre \p src + \p n has to be on \p src image domain.
*/
template <typename Pd, typename Ps>
void memcpy_(Generalized_Pixel<Pd>& dest, const Generalized_Pixel<Ps>& src,
@@ -61,20 +67,16 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename Pd, typename Ps>
- void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
- std::size_t n)
+ void memcpy__(Pd& dest, const Ps& src, std::size_t n)
{
+ trace::entering("level::impl::memcpy__");
+
typedef mln_image(Pd) Id;
- // FIXME: metal::is_not_const<Id>::check();
typedef mln_image(Ps) Is;
- Pd& dest = internal::force_exact<Pd>(dest_);
- Ps& src = internal::force_exact<Ps>(src_);
-
- mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
- mln_precondition(dest.ima().has_data());
- mln_precondition(src.ima().has_data());
- // FIXME: Add precondition about n.
if (n == 0)
{
@@ -100,6 +102,39 @@
for (std::size_t i = 0; i < n; ++i)
*p_d++ = *p_s++;
}
+
+ trace::exiting("level::impl::memcpy__");
+ }
+
+ }
+
+ template <typename Pd, typename Ps>
+ void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
+ std::size_t n)
+ {
+ trace::entering("level::memcpy_");
+
+ typedef mln_image(Pd) Id;
+ metal::is_not_const<Id>::check();
+ typedef mln_image(Ps) Is;
+ Pd& dest = internal::force_exact<Pd>(dest_);
+ Ps& src = internal::force_exact<Ps>(src_);
+
+ mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
+ mln_precondition(dest.ima().has_data());
+ mln_precondition(src.ima().has_data());
+
+ mln_precondition(& dest.val() >= & dest.ima()[0]);
+ mln_precondition(& dest.val() < & dest.ima()[0] + dest.ima().ncells());
+ mln_precondition(& dest.val() + n <= & dest.ima()[0] + dest.ima().ncells());
+
+ mln_precondition(& src.val() >= & src.ima()[0]);
+ mln_precondition(& src.val() < & src.ima()[0] + src.ima().ncells());
+ mln_precondition(& src.val() + n <= & src.ima()[0] + src.ima().ncells());
+
+ impl::memcpy__(dest, src, n);
+
+ trace::exiting("level::memcpy_");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/memset_.hh
===================================================================
--- trunk/milena/mln/level/memset_.hh (revision 1522)
+++ trunk/milena/mln/level/memset_.hh (revision 1523)
@@ -35,7 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/pixel.hh>
-
+# include <mln/metal/is_not_const.hh>
namespace mln
{
@@ -49,7 +49,9 @@
* \param[in] v The value to set pixels with.
* \param[in] n The number of pixels to set.
*
- * \pre FIXME: !
+ * \pre \p pix image has to be initialized.
+ * \pre \p pix has to be on \p pix image domain.
+ * \pre \p pix + \p n has to be on \p pix image domain.
*/
template <typename P>
void memset_(Generalized_Pixel<P>& pix,
@@ -63,7 +65,9 @@
* \param[in] v The value to set to points.
* \param[in] n The number of points to set.
*
- * \pre \p input has to be initialized. FIXME: More.
+ * \pre \p input image has to be initialized.
+ * \pre \p input has to own \p p.
+ * \pre \p p + \p n is <= \p input size.
*/
template <typename I>
void memset_(I& input, const mln_point(I)& p,
@@ -72,19 +76,15 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename P>
- void memset_(Generalized_Pixel<P>& pix_,
- const mln_value(P)& v, std::size_t n)
+ namespace impl
{
- typedef mln_image(P) I;
- // FIXME: metal::is_not_const<I>::check();
- P& pix = internal::force_exact<P>(pix_);
- mln_precondition(pix.ima().has_data());
- mln_precondition(& pix.val() >= & pix.ima()[0]);
- mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
- mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
+ template <typename P>
+ void memset__(P& pix, const mln_value(P)& v, std::size_t n)
+ {
+ trace::entering("level::impl::memset_");
+ typedef mln_image(P) I;
if (n == 0)
{
return; // no-op
@@ -108,12 +108,39 @@
for (std::size_t i = 0; i < n; ++i)
*ptr++ = v;
}
+
+ trace::exiting("level::impl::memset_");
+ }
+
+ } // end of namespace mln::level::impl
+
+
+ template <typename P>
+ void memset_(Generalized_Pixel<P>& pix_,
+ const mln_value(P)& v, std::size_t n)
+ {
+ trace::entering("level::memset_");
+
+ typedef mln_image(P) I;
+ metal::is_not_const<I>::check();
+
+ P& pix = internal::force_exact<P>(pix_);
+ mln_precondition(pix.ima().has_data());
+ mln_precondition(& pix.val() >= & pix.ima()[0]);
+ mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
+ mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
+
+ impl::memset__(pix, v, n);
+
+ trace::exiting("level::memset_");
}
template <typename I>
void memset_(I& input, const mln_point(I)& p,
const mln_value(I)& v, std::size_t n)
{
+ trace::entering("level::memset_");
+
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
mln_precondition(input.has_data());
@@ -121,7 +148,9 @@
mln_precondition(input.offset_at(p) + n <= input.ncells());
pixel<I> pix(input, p);
- memset_(pix, v, n);
+ impl::memset__(pix, v, n);
+
+ trace::exiting("level::memset_");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/paste.spe.hh
===================================================================
--- trunk/milena/mln/level/paste.spe.hh (revision 1522)
+++ trunk/milena/mln/level/paste.spe.hh (revision 1523)
@@ -48,14 +48,12 @@
namespace impl
{
-
namespace generic
{
template <typename I, typename J>
void paste_(const I& data, J& destination);
}
-
template <typename I, typename J>
void paste_lines_(const I& data, J& destination)
{
Index: trunk/milena/mln/level/abs.hh
===================================================================
--- trunk/milena/mln/level/abs.hh (revision 1522)
+++ trunk/milena/mln/level/abs.hh (revision 1523)
@@ -69,8 +69,10 @@
void abs(const Image<I>& input, Image<O>& output)
{
trace::entering("level::abs");
+
mln_precondition(exact(input).domain() == exact(output).domain());
level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
+
trace::exiting("level::abs");
}
@@ -78,8 +80,10 @@
void abs_inplace(Image<I>& input)
{
trace::entering("level::abs_inplace");
+
mln_precondition(exact(input).has_data());
level::apply(input, fun::v2v::abs<mln_value(I)>());
+
trace::exiting("level::abs_inplace");
}
Index: trunk/milena/mln/level/all.hh
===================================================================
--- trunk/milena/mln/level/all.hh (revision 1522)
+++ trunk/milena/mln/level/all.hh (revision 1523)
@@ -40,8 +40,15 @@
/// Namespace of image processing routines related to pixel levels.
namespace level
{
+
/// Implementation namespace of level namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of level namespace.
+ namespace generic {}
+
+ }
+
}
}
Index: trunk/milena/mln/level/paste.hh
===================================================================
--- trunk/milena/mln/level/paste.hh (revision 1522)
+++ trunk/milena/mln/level/paste.hh (revision 1523)
@@ -99,9 +99,10 @@
template <typename I, typename J>
void paste(const Image<I>& data_, Image<J>& destination_)
{
+ trace::entering("level::paste");
+
const I& data = exact(data_);
J& destination = exact(destination_);
- trace::entering("level::paste");
mlc_is(mln_trait_image_io(J), trait::image::io::write)::check();
mlc_converts_to(mln_value(I), mln_value(J))::check();
1
0
23 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Remove deprecated files and fix makefile.
* mln/fun/x2x/bijective_tr.hh: Remove, was in function concept.
* mln/fun/x2x/translation_alt.hh: Remove, was in translation.hh.
* tests/fun/x2x/Makefile.am: Fix.
---
trunk/milena/tests/fun/x2x/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: trunk/milena/tests/fun/x2x/Makefile.am
===================================================================
--- trunk/milena/tests/fun/x2x/Makefile.am (revision 1521)
+++ trunk/milena/tests/fun/x2x/Makefile.am (revision 1522)
@@ -9,6 +9,6 @@
composed_SOURCES = composed.cc
rotation_SOURCES = rotation.cc
-translation_SOURCES = translation_SOURCES
+translation_SOURCES = translation.cc
TESTS = $(check_PROGRAMS)
Index: trunk/milena/mln/fun/x2x/bijective_tr.hh (deleted)
===================================================================
Index: trunk/milena/mln/fun/x2x/translation_alt.hh (deleted)
===================================================================
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Review the directory fun and add test.
* mln/fun/x2x/bijective_tr.hh,
* mln/fun/x2x/composed.hh,
* mln/fun/x2x/rotation.hh,
* mln/fun/x2x/translation.hh: Review.
* tests/fun/Makefile.am: Add tests.
* tests/fun/x2x/Makefile.am: Add tests.
* tests/fun_x2x_composed.cc,
* tests/fun_x2x_rotation.cc,
* tests/fun_x2x_translation.cc: Rename as...
* tests/fun/x2x/composed.cc,
* tests/fun/x2x/rotation.cc,
* tests/fun/x2x/translation.cc... this.
* tests/set/Makefile.am: Fix.
---
mln/fun/x2x/bijective_tr.hh | 10 ++++-
mln/fun/x2x/composed.hh | 16 +++++++--
mln/fun/x2x/rotation.hh | 25 ++------------
mln/fun/x2x/translation.hh | 9 ++---
tests/fun/Makefile.am | 2 +
tests/fun/x2x/Makefile.am | 11 ++++++
tests/fun/x2x/composed.cc | 66 +++++++++++++++++++++++++++++++++++++++
tests/fun/x2x/rotation.cc | 72 +++++++++++++++++++++++++++++++++++++++++++
tests/fun/x2x/translation.cc | 59 +++++++++++++++++++++++++++++++++++
tests/set/Makefile.am | 2 -
10 files changed, 239 insertions(+), 33 deletions(-)
Index: trunk/milena/tests/fun_x2x_translation.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun_x2x_rotation.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun_x2x_composed.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun/x2x/translation.cc
===================================================================
--- trunk/milena/tests/fun/x2x/translation.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/translation.cc (revision 1521)
@@ -0,0 +1,59 @@
+// 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/fun_x2x_translation.cc
+ *
+ * \brief Tests on mln::fun::x2x::translation.
+ */
+
+#include <cmath>
+#include <iostream>
+#include <mln/fun/x2x/translation.hh>
+#include <mln/fun/i2v/all_to.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ float
+ a = 2.3,
+ b = 0,
+ c = 2.9;
+
+ metal::vec<3,float> vec1 = make::vec(a, b, c);
+ fun::x2x::translation<3,float> tr1(all_to(1.6));
+
+ std::cout << vec1 << std::endl;
+ std::cout << tr1(vec1) << std::endl;
+ std::cout << tr1.inv()(vec1) << std::endl;
+ mln_assertion(tr1(tr1.inv()(vec1)) == vec1);
+ mln_assertion(fabs(tr1(vec1)[0] - 3.9) <= 0.125 &&
+ fabs(tr1(vec1)[1] - 1.6) <= 0.125 &&
+ fabs(tr1(vec1)[2] - 4.5) <= 0.125);
+}
Index: trunk/milena/tests/fun/x2x/rotation.cc
===================================================================
--- trunk/milena/tests/fun/x2x/rotation.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/rotation.cc (revision 1521)
@@ -0,0 +1,72 @@
+// 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/fun_x2x_rotation.cc
+ *
+ * \brief Tests on mln::fun::x2x::rotation.
+ */
+
+
+#include <iostream>
+#include <mln/fun/x2x/rotation.hh>
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/core/interpolated.hh>
+#include <mln/make/vec.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena = io::pgm::load("../../../img/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ interpolated<image2d<int_u8> > inter(lena);
+
+ fun::x2x::rotation<2,float> rot1(0.1);
+
+ image2d<int_u8>::fwd_piter p(out.domain());
+
+ for_all(p)
+ {
+ metal::vec<2,float> v = rot1.inv()((point2d::vec_t)(point2d)p);
+ if (inter.owns_(v))
+ out(p) = inter(v);
+ else
+ out(p) = 255;
+ }
+ io::pgm::save(out, "out.pgm");
+
+ fun::x2x::rotation<2,float> rot2(3.14116);
+ mln_assertion(fabs(rot2(make::vec(0.0, 1.0))[0] -
+ make::vec(0.0, -1.0)[0]) <= 0.125);
+ mln_assertion(fabs(rot2(make::vec(0.0, 1.0))[1] -
+ make::vec(0.0, -1.0)[1]) <= 0.125);
+}
Index: trunk/milena/tests/fun/x2x/Makefile.am
===================================================================
--- trunk/milena/tests/fun/x2x/Makefile.am (revision 1520)
+++ trunk/milena/tests/fun/x2x/Makefile.am (revision 1521)
@@ -1,3 +1,14 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ composed \
+ rotation \
+ translation
+
+composed_SOURCES = composed.cc
+rotation_SOURCES = rotation.cc
+translation_SOURCES = translation_SOURCES
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/fun/x2x/composed.cc
===================================================================
--- trunk/milena/tests/fun/x2x/composed.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/composed.cc (revision 1521)
@@ -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/fun_x2x_composed.cc
+ *
+ * \brief Tests on mln::fun::x2x::composed.
+ */
+
+
+#include <iostream>
+#include <mln/fun/x2x/translation.hh>
+#include <mln/fun/x2x/rotation.hh>
+#include <mln/fun/x2x/composed.hh>
+#include <mln/fun/i2v/all_to.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ float
+ a = 2.3,
+ b = 0,
+ c = 2.9;
+
+ metal::vec<3,float> vec1 = make::vec(a, b, c);
+ fun::x2x::translation<3,float> tr(all_to(1.6));
+ fun::x2x::rotation<3,float> rot(0.3, 1);
+
+ std::cout << "vec : " << vec1 << std::endl;
+ std::cout << "tr(vec) : " << tr(vec1) << std::endl;
+ std::cout << "rot(vec) : " << rot(vec1) << std::endl;
+ std::cout << "tr(rot(vec)) : " << compose(tr, rot)(vec1) << std::endl;
+ std::cout << "rot(rot_1(vec)) : " << compose(rot, rot.inv())(vec1) << std::endl;
+ std::cout << "tr(rot(tr(vec))) : " << compose(tr, compose(rot, tr))(vec1) << std::endl;
+ std::cout << "(rototr_1)(rot(tr(vec)))) : "
+ << compose(compose(rot, tr).inv(), compose(rot, tr))(vec1) << std::endl;
+ mln_assertion(fabs(compose(rot, tr)(vec1)[0] - rot(tr(vec1))[0]) <= 0.125);
+ mln_assertion(fabs(compose(rot, tr)(vec1)[1] - rot(tr(vec1))[1]) <= 0.125);
+ mln_assertion(fabs(compose(rot, tr)(vec1)[2] - rot(tr(vec1))[2]) <= 0.125);
+}
Index: trunk/milena/tests/fun/Makefile.am
===================================================================
--- trunk/milena/tests/fun/Makefile.am (revision 1520)
+++ trunk/milena/tests/fun/Makefile.am (revision 1521)
@@ -1,3 +1,5 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+SUBDIRS = x2x
Index: trunk/milena/tests/set/Makefile.am
===================================================================
--- trunk/milena/tests/set/Makefile.am (revision 1520)
+++ trunk/milena/tests/set/Makefile.am (revision 1521)
@@ -11,7 +11,7 @@
diff_SOURCES = diff.cc
inter_SOURCES = inter.cc
-is_subset_SOURCES = is_subset.cc
+is_subset_of_SOURCES = is_subset.cc
sym_diff_SOURCES = sym_diff.cc
uni_SOURCES = uni.cc
Index: trunk/milena/mln/fun/x2x/composed.hh
===================================================================
--- trunk/milena/mln/fun/x2x/composed.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/composed.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/composed.hh
*
- * \brief FIXME.
+ * \brief Definition of a composed transformation.
*/
# include <mln/core/concept/function.hh>
@@ -112,8 +112,9 @@
} // end of namespace mln::fun::x2x::internal
- // FIXME: Doc!
-
+ /*! \brief Represent a composition of two transformations.
+ *
+ */
template <typename F, typename G>
struct composed
: public internal::helper_composed_<F, G, composed<F,G>,
@@ -139,6 +140,13 @@
} // end of namespace mln::fun
+ /*! \brief Do a composition of two transformations
+ *
+ * \param[in] f The first transformation.
+ * \param[in] g The second transformation.
+ *
+ * \return The composed transformation fog.
+ */
template <typename F, typename G>
fun::x2x::composed<F,G> compose(F f, G g);
@@ -232,7 +240,9 @@
template <typename F, typename G>
fun::x2x::composed<F,G> compose(F f, G g)
{
+ trace::entering("fun::x2x::compose");
fun::x2x::composed<F,G> comp(f, g);
+ trace::exiting("fun::x2x::compose");
return comp;
}
Index: trunk/milena/mln/fun/x2x/bijective_tr.hh
===================================================================
--- trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/bijective_tr.hh
*
- * \brief FIXME.
+ * \brief Abstraction that describes a bijective transformation.
*/
# include <mln/core/concept/function.hh>
@@ -47,8 +47,12 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Abstraction that describes a bijective transformation.
+ *
+ * All bijective transformation from vector to vector should
+ * should inherit this class.
+ *
+ */
template <typename E>
struct bijective_tr : public Function_x2x< E >
{
Index: trunk/milena/mln/fun/x2x/translation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/translation.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/translation.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/translation.hh
*
- * \brief FIXME.
+ * \brief Define a translation function.
*/
# include <mln/core/concept/function.hh>
@@ -48,8 +48,9 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Represent a translation function.
+ *
+ */
template <unsigned n, typename C>
struct translation
@@ -82,8 +83,6 @@
template <unsigned n, typename C>
translation<n,C>::translation()
{
-// t_ = make::vec<n,C>(fun::i2v::all<C>(0));
-// this->m_ = h_mat<n,C>::Id;
}
template <unsigned n, typename C>
Index: trunk/milena/mln/fun/x2x/rotation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/rotation.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/rotation.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/rotation.hh
*
- * \brief FIXME.
+ * \brief Define a rotation function.
*/
# include <mln/core/concept/function.hh>
@@ -48,8 +48,9 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Represent a rotation function.
+ *
+ */
template <unsigned n, typename C>
struct rotation
: internal::x2x_linear_impl_< metal::vec<n,C>, rotation<n,C> >
@@ -82,9 +83,6 @@
template <unsigned n, typename C>
rotation<n,C>::rotation()
{
-// alpha_ = 0;
-// dir_ = 2;
-// this->m_ = h_mat<n,C>::Id;
}
template <unsigned n, typename C>
@@ -159,21 +157,6 @@
}
}
-// template <typename C> FIXME : template parameter should be swapped
-// void
-// rotation<2,C>::update()
-// {
-// const float cos_a = cos(alpha_);
-// const float sin_a = sin(alpha_);
-
-// m_ = metal::mat<3,3,C>::Id;
-// m_(0, 0) = cos_a;
-// m_(0, 1) = -sin_a;
-// m_(1, 0) = sin_a;
-// m_(1, 1) = cos_a;
-// }
-
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::fun::x2x
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory display ready for rereading.
* mln/display/all.hh,
* mln/display/color_pretty.hh,
* mln/display/remove.hh: Fix type and tracing.
Tests
* tests/display/save_and_show.cc,
* tests/display/show.cc: Update tests.
---
mln/display/all.hh | 8 +++++++-
mln/display/color_pretty.hh | 4 ++++
mln/display/remove.hh | 3 +--
tests/display/save_and_show.cc | 11 +++++++----
tests/display/show.cc | 15 +++++++++------
5 files changed, 28 insertions(+), 13 deletions(-)
Index: trunk/milena/tests/display/show.cc
===================================================================
--- trunk/milena/tests/display/show.cc (revision 1519)
+++ trunk/milena/tests/display/show.cc (revision 1520)
@@ -72,12 +72,15 @@
display::show (t, "display", 1);
}
-// image2d<value::rgb8> color_image (16, 16);
-// for (int i = 0; i < 16; ++i)
-// for (int j = 0; j < 16; ++j)
-// color_image(point2d(i, j)) = value::rgb8(0,0,255);
-// display::save (color_image);
-// display::show (color_image, "display");
+ /// Test with color image.
+ {
+ image2d<value::rgb8> color_image (16, 16);
+ for (int i = 0; i < 16; ++i)
+ for (int j = 0; j < 16; ++j)
+ color_image(point2d(i, j)) = value::rgb8(0,0,255);
+ display::save (color_image);
+ display::show (color_image, "display", 1);
+ }
display::remove ();
}
Index: trunk/milena/tests/display/save_and_show.cc
===================================================================
--- trunk/milena/tests/display/save_and_show.cc (revision 1519)
+++ trunk/milena/tests/display/save_and_show.cc (revision 1520)
@@ -68,8 +68,11 @@
display::save_and_show (t, "display", 1);
}
- /// FIXME: Uncomment this ASAP
-// image2d<value::rgb8> ima (100, 100);
-// level::fill(ima, value::rgb8 (0, 0, 255));
-// display::save_and_show (ima, "display", 1);
+ /// Test with color image.
+ {
+ image2d<value::rgb8> ima (100, 100);
+ level::fill(ima, value::rgb8 (0, 0, 255));
+ display::save_and_show (ima, "display", 1);
+ }
+
}
Index: trunk/milena/mln/display/color_pretty.hh
===================================================================
--- trunk/milena/mln/display/color_pretty.hh (revision 1519)
+++ trunk/milena/mln/display/color_pretty.hh (revision 1520)
@@ -141,6 +141,8 @@
const p_set<mln_point(I) >& s2_,
const p_set<mln_point(I) >& s3_)
{
+ trace::entering("display::impl::color_pretty_rgb");
+
const I& input = exact (input_);
image2d<value::rgb8> output(input.domain().bbox());
@@ -166,6 +168,8 @@
for_all(p)
output(p).blue() = 255;
}
+
+ trace::exiting("display::impl::color_pretty_rgb");
return output;
}
Index: trunk/milena/mln/display/all.hh
===================================================================
--- trunk/milena/mln/display/all.hh (revision 1519)
+++ trunk/milena/mln/display/all.hh (revision 1520)
@@ -41,7 +41,13 @@
namespace display
{
/// Implementation namespace of display namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of display namespace.
+ namespace generic {}
+
+ }
+
}
}
Index: trunk/milena/mln/display/remove.hh
===================================================================
--- trunk/milena/mln/display/remove.hh (revision 1519)
+++ trunk/milena/mln/display/remove.hh (revision 1520)
@@ -51,8 +51,7 @@
* save.
*
*/
- void
- remove();
+ void remove();
# ifndef MLN_INCLUDE_ONLY
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix bug.
* mln/border/duplicate.hh: Fix bug (move a line upper).
---
duplicate.hh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: trunk/milena/mln/border/duplicate.hh
===================================================================
--- trunk/milena/mln/border/duplicate.hh (revision 1518)
+++ trunk/milena/mln/border/duplicate.hh (revision 1519)
@@ -198,10 +198,11 @@
{
trace::entering("border::duplicate");
+ const I& ima = exact(ima_);
mln_precondition(ima.has_data());
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
- const I& ima = exact(ima_);
+
typedef mln_point(I) P;
if (!ima.border ())
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory border ready for rereading.
* mln/border/all.hh: Update with all headers.
* mln/border/mirror.hh: Add 2d version.
* mln/border/adjust.hh,
* mln/border/duplicate.hh,
* mln/border/equalize.hh,
* mln/border/fill.hh,
* mln/border/find.hh,
* mln/border/resize.hh,
* mln/border/get.hh: Check typo and tracing.
Tests
* tests/border/equalize.cc,
* tests/border/mirror.cc: New test for these algorithms.
* tests/border/Makefile.am: Add previous tests.
---
mln/border/adjust.hh | 3 -
mln/border/all.hh | 13 ++++--
mln/border/duplicate.hh | 23 ++++++----
mln/border/equalize.hh | 40 ++++++++++++++----
mln/border/fill.hh | 13 +++++-
mln/border/find.hh | 10 ++++
mln/border/get.hh | 10 ++++
mln/border/mirror.hh | 101 +++++++++++++++++++++++++++++++++++++++++++++--
mln/border/resize.hh | 2
tests/border/Makefile.am | 4 +
tests/border/equalize.cc | 46 +++++++++++++++++++++
tests/border/mirror.cc | 90 +++++++++++++++++++++++++++++++++++++++++
12 files changed, 328 insertions(+), 27 deletions(-)
Index: trunk/milena/tests/border/equalize.cc
===================================================================
--- trunk/milena/tests/border/equalize.cc (revision 0)
+++ trunk/milena/tests/border/equalize.cc (revision 1518)
@@ -0,0 +1,46 @@
+// 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/border/equalize.cc
+ *
+ * \brief Tests on mln::border::equalize.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/border/get.hh>
+#include <mln/border/equalize.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima1(3,3, 36);
+ image2d<int> ima2(3,3, 42);
+ border::equalize(ima1, ima2, 51);
+ mln_assertion(border::get(ima1) == 51);
+ mln_assertion(border::get(ima2) == 51);
+}
Index: trunk/milena/tests/border/Makefile.am
===================================================================
--- trunk/milena/tests/border/Makefile.am (revision 1517)
+++ trunk/milena/tests/border/Makefile.am (revision 1518)
@@ -5,16 +5,20 @@
check_PROGRAMS = \
adjust \
duplicate \
+ equalize \
fill \
find \
get \
+ mirror \
resize
adjust_SOURCES = adjust.cc
duplicate_SOURCES = duplicate.cc
+equalize_SOURCES = equalize.cc
fill_SOURCES = fill.cc
find_SOURCES = find.cc
get_SOURCES = get.cc
+mirror_SOURCES = mirror.cc
resize_SOURCES = resize.cc
TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/border/mirror.cc
===================================================================
--- trunk/milena/tests/border/mirror.cc (revision 0)
+++ trunk/milena/tests/border/mirror.cc (revision 1518)
@@ -0,0 +1,90 @@
+// 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/border_duplicate/test_border_duplicate_image2d_1.cc
+ *
+ * \brief Tests on mln::border::duplicate.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/border/mirror.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ image2d<int> ima(2, 3, 2);
+
+ debug::iota(ima);
+ border::mirror(ima);
+
+ mln_assertion(ima[ 0] == 1);
+ mln_assertion(ima[ 1] == 1);
+ mln_assertion(ima[ 2] == 4);
+ mln_assertion(ima[ 3] == 5);
+ mln_assertion(ima[ 4] == 6);
+ mln_assertion(ima[ 5] == 3);
+ mln_assertion(ima[ 6] == 3);
+ mln_assertion(ima[ 7] == 1);
+ mln_assertion(ima[ 8] == 1);
+ mln_assertion(ima[ 9] == 1);
+ mln_assertion(ima[10] == 2);
+ mln_assertion(ima[11] == 3);
+ mln_assertion(ima[12] == 3);
+ mln_assertion(ima[13] == 3);
+ mln_assertion(ima[14] == 2);
+ mln_assertion(ima[15] == 1);
+ mln_assertion(ima[16] == 1);
+ mln_assertion(ima[17] == 2);
+ mln_assertion(ima[18] == 3);
+ mln_assertion(ima[19] == 3);
+ mln_assertion(ima[20] == 2);
+ mln_assertion(ima[21] == 5);
+ mln_assertion(ima[22] == 4);
+ mln_assertion(ima[23] == 4);
+ mln_assertion(ima[24] == 5);
+ mln_assertion(ima[25] == 6);
+ mln_assertion(ima[26] == 6);
+ mln_assertion(ima[27] == 5);
+ mln_assertion(ima[28] == 4);
+ mln_assertion(ima[29] == 4);
+ mln_assertion(ima[30] == 4);
+ mln_assertion(ima[31] == 5);
+ mln_assertion(ima[32] == 6);
+ mln_assertion(ima[33] == 6);
+ mln_assertion(ima[34] == 6);
+ mln_assertion(ima[35] == 4);
+ mln_assertion(ima[36] == 4);
+ mln_assertion(ima[37] == 1);
+ mln_assertion(ima[38] == 2);
+ mln_assertion(ima[39] == 3);
+ mln_assertion(ima[40] == 6);
+ mln_assertion(ima[41] == 6);
+}
+
Index: trunk/milena/mln/border/resize.hh
===================================================================
--- trunk/milena/mln/border/resize.hh (revision 1517)
+++ trunk/milena/mln/border/resize.hh (revision 1518)
@@ -95,6 +95,7 @@
void resize(const Image<I>& ima_, unsigned thickness)
{
trace::entering("border::resize");
+
mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -106,6 +107,7 @@
ima, thickness);
mln_postcondition(border::get(ima) == thickness);
+
trace::exiting("border::resize");
}
Index: trunk/milena/mln/border/fill.hh
===================================================================
--- trunk/milena/mln/border/fill.hh (revision 1517)
+++ trunk/milena/mln/border/fill.hh (revision 1518)
@@ -50,7 +50,7 @@
*
* \pre \p ima has to be initialized.
*
- * \todo Implement it + optimize with memset if possible.
+ * \todo Optimize with memset if possible.
*/
template <typename I>
void fill(const Image<I>& ima, const mln_value(I)& v);
@@ -63,6 +63,8 @@
template <typename I>
void fill_size_1_(const I& ima, const mln_value(I)& v)
{
+ trace::entering("border::impl::fill_size_1_");
+
typedef mln_point(I) P;
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
@@ -80,11 +82,15 @@
std::memset((void*)&ima[st],
*(const int*)(&v),
ima.ncells () - st);
+
+ trace::exiting("border::impl::fill_size_1_");
}
template <typename I>
void fill_size_n_(const I& ima, const mln_value(I)& v)
{
+ trace::entering("border::impl::fill_size_n_");
+
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
std::size_t len_r = ima.bbox().len(P::dim - 1);
@@ -99,15 +105,19 @@
}
for (std::size_t i = st; i < ima.ncells (); ++i)
const_cast<I&>(ima)[i] = v;
+
+ trace::exiting("border::impl::fill_size_n_");
}
}
+
// Facade.
template <typename I>
void fill(const Image<I>& ima_, const mln_value(I)& v)
{
trace::entering("border::fill");
+
typedef mln_point(I) P;
const I& ima = exact(ima_);
@@ -119,6 +129,7 @@
impl::fill_size_1_(ima, v);
else
impl::fill_size_n_(ima, v);
+
trace::exiting("border::fill");
}
Index: trunk/milena/mln/border/all.hh
===================================================================
--- trunk/milena/mln/border/all.hh (revision 1517)
+++ trunk/milena/mln/border/all.hh (revision 1518)
@@ -41,18 +41,25 @@
namespace border
{
/// Implementation namespace of border namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of border namespace.
+ namespace generic {}
+
}
}
+}
+# include <mln/border/adjust.hh>
# include <mln/border/duplicate.hh>
+# include <mln/border/equalize.hh>
# include <mln/border/fill.hh>
+# include <mln/border/find.hh>
+# include <mln/border/get.hh>
# include <mln/border/mirror.hh>
# include <mln/border/resize.hh>
-# include <mln/border/adjust.hh>
-# include <mln/border/equalize.hh>
# include <mln/border/thickness.hh>
Index: trunk/milena/mln/border/duplicate.hh
===================================================================
--- trunk/milena/mln/border/duplicate.hh (revision 1517)
+++ trunk/milena/mln/border/duplicate.hh (revision 1518)
@@ -52,7 +52,7 @@
*
* \pre \p ima has to be initialized.
*
- * \todo Implement it + optimize with memcpy if possible.
+ * \todo Optimize with memcpy if possible.
*/
template <typename I>
void duplicate(const Image<I>& ima);
@@ -66,7 +66,7 @@
template <typename I>
void duplicate_1d_(const I& ima)
{
- mln_precondition(ima.has_data());
+ trace::entering("border::impl::duplicate_1d_");
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
@@ -79,12 +79,14 @@
std::size_t st = border + len_c - 1;
for (std::size_t i = st + 1; i < ima.ncells (); ++i)
const_cast<I&>(ima)[i] = ima[st];
+
+ trace::exiting("border::impl::duplicate_1d_");
}
template <typename I>
void duplicate_2d_(const I& ima)
{
- mln_precondition(ima.has_data());
+ trace::entering("border::impl::duplicate_2d_");
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
@@ -117,11 +119,15 @@
for (std::size_t k = 1; k <= border; ++k)
for (std::size_t i = st; i < st + real_len_c; ++i)
const_cast<I&>(ima)[k * real_len_c + i] = ima[i];
+
+ trace::exiting("border::impl::duplicate_2d_");
}
template <typename I>
void duplicate_3d_(const Image<I>& ima_)
{
+ trace::entering("border::impl::duplicate_3d_");
+
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -178,9 +184,9 @@
for (std::size_t k = 1; k <= border; ++k)
for (std::size_t i = 0; i < face; ++i)
const_cast<I&>(ima)[st + k * face + i] = ima[st + i];
- }
-
+ trace::exiting("border::impl::duplicate_3d_");
+ }
} // end of namespace mln::border::impl
@@ -190,13 +196,14 @@
template <typename I>
void duplicate(const Image<I>& ima_)
{
- mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
- const I& ima = exact(ima_);
- typedef mln_point(I) P;
trace::entering("border::duplicate");
mln_precondition(ima.has_data());
+ mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
+ const I& ima = exact(ima_);
+ typedef mln_point(I) P;
+
if (!ima.border ())
return;
Index: trunk/milena/mln/border/mirror.hh
===================================================================
--- trunk/milena/mln/border/mirror.hh (revision 1517)
+++ trunk/milena/mln/border/mirror.hh (revision 1518)
@@ -51,7 +51,7 @@
*
* \pre \p ima has to be initialized.
*
- * \todo Implement it + optimize with memset if possible.
+ * \todo Implement 1d and 3d version + optimize with memset if possible.
*/
template <typename I>
void mirror(const Image<I>& ima);
@@ -59,15 +59,110 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
+ template <typename I>
+ void mirror_1d_(const I& ima)
+ {
+ mln::internal::fixme();
+ }
+
+ template <typename I>
+ void mirror_2d_(const I& ima)
+ {
+ trace::entering("border::impl::mirror_2d_");
+
+ std::size_t border = ima.border ();
+ std::size_t nbrows = geom::max_row(ima) - geom::min_row(ima);
+ std::size_t nbcols = geom::max_col(ima) - geom::min_col(ima);
+ std::size_t real_nbcols = (nbcols + 1) + 2 * border;
+ std::size_t start = real_nbcols * border + border;
+ std::size_t s = start;
+
+ // duplicate top left corner
+ for (std::size_t i = 0; i < border; ++i)
+ for (std::size_t j = 0; j < border; ++j)
+ const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + j] = ima[s];
+
+ // duplicate top left corner
+ s = start + nbcols;
+ for (std::size_t i = 0; i < border; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + (nbcols + border + j)] = ima[s];
+
+ // duplicate bottom left corner
+ s = start + (nbrows * real_nbcols);
+ for (std::size_t i = 1; i <= border; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s - i + (j * (real_nbcols))] = ima[s];
+
+ // duplicate bottom right corner
+ s = start + (nbrows * real_nbcols) + nbcols;
+ for (std::size_t i = 1; i <= border; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s];
+
+ // mirror top border
+ s = start;
+ for (std::size_t i = 0; i <= nbcols; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + i - (j * real_nbcols)] = ima[s + i + ((j - 1)* real_nbcols)];
+
+ // mirror left border
+ s = start;
+ for (std::size_t i = 0; i <= nbrows; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + (i * real_nbcols) - j] = ima[s + (i * real_nbcols) + (j - 1)];
+
+ // mirror right border
+ s = start;
+ for (std::size_t i = 0; i <= nbrows; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + (i * real_nbcols + nbcols) + j] = ima[s + (i * real_nbcols + nbcols) - (j - 1)];
+
+ // mirror bottom border
+ s = start + (nbrows * real_nbcols);
+ for (std::size_t i = 0; i <= nbcols; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s + i - ((j - 1)* real_nbcols)];
+
+ trace::exiting("border::impl::mirror_2d_");
+ }
+
+ template <typename I>
+ void mirror_3d_(const I& ima)
+ {
+ mln::internal::fixme();
+ }
+
+
+ } // end of namespace mln::border::mirror
+
+
template <typename I>
void mirror(const Image<I>& ima_)
{
+ trace::entering("border::mirror");
+
const I& ima = exact(ima_);
+ mln_precondition(ima.has_data());
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
- mln_precondition(ima.has_data());
- mln::internal::fixme();
+ typedef mln_point(I) P;
+
+ if (!ima.border ())
+ return;
+
+ if (P::dim == 1)
+ impl::mirror_1d_(ima);
+ if (P::dim == 2)
+ impl::mirror_2d_(ima);
+ if (P::dim == 3)
+ impl::mirror_3d_(ima);
+
+ trace::exiting("border::mirror");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/border/adjust.hh
===================================================================
--- trunk/milena/mln/border/adjust.hh (revision 1517)
+++ trunk/milena/mln/border/adjust.hh (revision 1518)
@@ -58,13 +58,13 @@
void adjust(const Image<I>& ima, unsigned min_thickness);
-
# ifndef MLN_INCLUDE_ONLY
template <typename I>
void adjust(const Image<I>& ima_, unsigned min_thickness)
{
trace::entering("border::adjust");
+
mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -73,6 +73,7 @@
border::resize(ima, min_thickness);
mln_postcondition(border::get(ima) >= min_thickness);
+
trace::exiting("border::adjust");
}
Index: trunk/milena/mln/border/equalize.hh
===================================================================
--- trunk/milena/mln/border/equalize.hh (revision 1517)
+++ trunk/milena/mln/border/equalize.hh (revision 1518)
@@ -50,7 +50,8 @@
* \param[in,out] ima2 The second image whose border is to be equalizeed.
* \param[in] min_thickness The expected border minimum thickness of both images.
*
- * \pre \p ima has to be initialized.
+ * \pre \p ima1 has to be initialized.
+ * \pre \p ima2 has to be initialized.
*
* \warning If both image borders already have the same thickness
* and if this thickness is larger than \p min_thickness, this
@@ -64,18 +65,16 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename I, typename J>
- void equalize(const Image<I>& ima1_, const Image<J>& ima2_,
- unsigned min_thickness)
+ void equalize_(const I& ima1, const J& ima2, unsigned min_thickness)
{
- trace::entering("border::equalize");
- mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
- mlc_is(mln_trait_image_border(J), trait::image::border::some)::check();
- const I& ima1 = exact(ima1_);
- const J& ima2 = exact(ima2_);
- mln_precondition(ima1.has_data() && ima2.has_data());
+ trace::entering("border::impl::equalize_");
unsigned b1 = border::get(ima1), b2 = border::get(ima2);
+
if (! (b1 == b2 && b2 >= min_thickness))
// Something has to be done.
{
@@ -101,9 +100,32 @@
}
}
+ trace::exiting("border::impl::equalize_");
+ }
+
+ } // end of namespace mln::border::impl
+
+
+ // Facade
+
+ template <typename I, typename J>
+ void equalize(const Image<I>& ima1_, const Image<J>& ima2_,
+ unsigned min_thickness)
+ {
+ trace::entering("border::equalize");
+
+ mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
+ mlc_is(mln_trait_image_border(J), trait::image::border::some)::check();
+ const I& ima1 = exact(ima1_);
+ const J& ima2 = exact(ima2_);
+ mln_precondition(ima1.has_data() && ima2.has_data());
+
+ impl::equalize_(ima1, ima2, min_thickness);
+
mln_postcondition(border::get(ima1) == border::get(ima2) &&
border::get(ima1) >= min_thickness &&
border::get(ima2) >= min_thickness);
+
trace::exiting("border::equalize");
}
Index: trunk/milena/mln/border/get.hh
===================================================================
--- trunk/milena/mln/border/get.hh (revision 1517)
+++ trunk/milena/mln/border/get.hh (revision 1518)
@@ -46,6 +46,9 @@
*
* \param[in] ima The image.
* \result The border thickness (0 if there is no border).
+ *
+ * \pre \p ima has to be initialized.
+ *
*/
template <typename I>
unsigned get(const Image<I>& ima);
@@ -86,9 +89,14 @@
template <typename I>
unsigned get(const Image<I>& ima)
{
+ trace::entering("border::get");
+
mln_precondition(exact(ima).has_data());
- return border::impl::get_(mln_trait_image_border(I)(), mln_trait_image_category(I)(),
+ unsigned res = border::impl::get_(mln_trait_image_border(I)(), mln_trait_image_category(I)(),
exact(ima));
+
+ trace::exiting("border::get");
+ return res;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/border/find.hh
===================================================================
--- trunk/milena/mln/border/find.hh (revision 1517)
+++ trunk/milena/mln/border/find.hh (revision 1518)
@@ -46,6 +46,9 @@
*
* \param[in] ima The image.
* \result The border thickness (0 if there is no border).
+ *
+ * \pre \p ima has to be initialized.
+ *
*/
template <typename I>
unsigned find(const Image<I>& ima);
@@ -88,8 +91,13 @@
template <typename I>
unsigned find(const Image<I>& ima)
{
+ trace::entering("border::find");
+
mln_precondition(exact(ima).has_data());
- return border::impl::find_(mln_trait_image_speed(I)(), exact(ima));
+ unsigned res = border::impl::find_(mln_trait_image_speed(I)(), exact(ima));
+
+ trace::exiting("border::find");
+ return res;
}
# endif // ! MLN_INCLUDE_ONLY
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix modulus definition involving builtin.
* mln/value/builtin/ops.hh
(mln_internal_def_bi_dvmd_obj_): Fix.
ops.hh | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: mln/value/builtin/ops.hh
--- mln/value/builtin/ops.hh (revision 1516)
+++ mln/value/builtin/ops.hh (working copy)
@@ -239,7 +239,7 @@
mln_trait_op_##Name (value::scalar_< Builtin >, O) \
operator Symb (const Builtin & lhs, const Object<O>& rhs) \
{ \
- return value::scalar(lhs) / exact(rhs); \
+ return value::scalar(lhs) Symb exact(rhs); \
} \
\
struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory draw ready for rereading.
* mln/draw/mesh.hh: Check typo.
---
mesh.hh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: trunk/milena/mln/draw/mesh.hh
===================================================================
--- trunk/milena/mln/draw/mesh.hh (revision 1515)
+++ trunk/milena/mln/draw/mesh.hh (revision 1516)
@@ -42,6 +42,7 @@
namespace mln
{
+
namespace draw
{
@@ -90,7 +91,6 @@
for (unsigned i = 0; i < m.gr_.nb_node_; ++i)
exact(ima)(m.loc_[i]) = node_v;
-
}
template <typename I, typename P, typename V>
@@ -111,8 +111,8 @@
# endif // ! MLN_INCLUDE_ONLY
- } // end of draw
+ } // end of namespace mln::draw
-} // end of mln
+} // end of namespace mln
#endif // MLN_MESH_PSITE_HH
1
0