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
January 2008
- 6 participants
- 89 discussions
08 Jan '08
Roland> + // FIXME: Exercize more image types.
Compromise, exercise, surprise.
Je n'ai pas retenu s'il y avait une règle, je me souviens juste
que je fais souvent l'erreur d'écrire ces trois là avec -ize
alors qu'il ne faut pas. Bienvenu au club :)
--
Alexandre Duret-Lutz
2
1
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix mln_ch_value w.r.t. stack_image.
* mln/trait/ch_value.hh (ch_value_< M< n, tag::image_<I> >, V>):
Fix the definition of this case, notably used to convert the value
type of a stack_image.
* tests/trait_ch_value.cc: Add a test to exercize this case.
mln/trait/ch_value.hh | 22 +++++++++++++++++-----
tests/trait_ch_value.cc | 16 ++++++++++++++--
2 files changed, 31 insertions(+), 7 deletions(-)
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 1634)
+++ mln/trait/ch_value.hh (working copy)
@@ -53,14 +53,15 @@
namespace trait
{
-
- template <typename I, typename V> struct ch_value; // Fwd decl.
+ // Fwd decl.
+ template <typename I, typename V> struct ch_value;
namespace impl
{
- template <typename I, typename V> struct ch_value_; // Decl.
+ // Decl.
+ template <typename I, typename V> struct ch_value_;
template < template <class> class M, typename T,
typename V >
@@ -90,12 +91,22 @@
typedef M< P, V > ret;
};
+ // For mln::value::stack_image<n,I>.
template < template <unsigned, class> class M, unsigned n, typename I,
typename V >
- struct ch_value_< M< n, tag::image_<I> >, V > // For mln::value::stack_image<n,I> !
+ struct ch_value_< M< n, tag::image_<I> >, V >
{
+ /* FIXME: The code used to read
+
typedef metal::vec<n, V> value;
typedef mln_ch_value(I, value) ret;
+
+ here. But this is wrong IMHO (Roland). Changing the value
+ type of a stack image (in fact, a vectorial image) shall
+ alter the *value type* of the image, not the type of the
+ *components* of the vector. Hence the current definition.
+ */
+ typedef mln_ch_value(I, V) ret;
};
template < template <class, class> class M, typename I, typename S,
@@ -110,7 +121,8 @@
struct ch_value_< M< tag::function_<F>, tag::pset_<S> >, V >
{
typedef typename S::mesh mesh;
- typedef typename image_from_mesh< mesh, V >::ret ret; // FIXME: from_psite instead? coord=int!?
+ // FIXME: from_psite instead? coord=int!?
+ typedef typename image_from_mesh< mesh, V >::ret ret;
};
} // end of namespace mln::trait::impl
Index: tests/trait_ch_value.cc
--- tests/trait_ch_value.cc (revision 1634)
+++ tests/trait_ch_value.cc (working copy)
@@ -30,14 +30,26 @@
* \brief Tests on mln::trait::ch_value.
*/
-#include <mln/core/image2d.hh>
#include <mln/trait/ch_value.hh>
+#include <mln/core/image2d.hh>
+#include <mln/value/stack.hh>
+
int main()
{
using namespace mln;
typedef image2d<int> I;
- trait::ch_value<I, bool>::ret ima;
+ typedef trait::ch_value<I, bool>::ret J;
+ J ima1;
+
+ // Stack image.
+ typedef value::stack_image<3, I> K;
+ typedef trait::ch_value<K, float>::ret L;
+ L ima2;
+ mlc_equal(L, image2d<float>)::check();
+
+ // FIXME: Exercize more image types.
+ // ...
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-01-07 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Some fixes for unit-tests.
* mln/convert/to_p_set.hh,
* mln/core/concept/value.hh,
* mln/make/voronoi.hh,
* mln/make/w_window3d_int.hh,
* mln/util/tree_to_image.hh,
* mln/value/equiv.hh,
* mln/value/float01.hh,
* mln/value/graylevel_f.hh,
* mln/value/int_u_sat.hh,
* mln/value/internal/gray_f.hh,
* mln/value/viter.hh: Fix headers.
* tests/morpho/contrast.cc: Simplify test.
* mln/value/rgb8_non_templated.hh: Remove deprecated.
---
mln/convert/to_p_set.hh | 1 +
mln/core/concept/value.hh | 2 +-
mln/make/voronoi.hh | 1 +
mln/make/w_window3d_int.hh | 2 +-
mln/util/tree_to_image.hh | 1 +
mln/value/equiv.hh | 1 +
mln/value/float01.hh | 3 ++-
mln/value/graylevel_f.hh | 3 +--
mln/value/int_u_sat.hh | 1 +
mln/value/internal/gray_f.hh | 1 +
mln/value/viter.hh | 2 +-
tests/morpho/contrast.cc | 6 +++---
12 files changed, 15 insertions(+), 9 deletions(-)
Index: trunk/milena/tests/morpho/contrast.cc
===================================================================
--- trunk/milena/tests/morpho/contrast.cc (revision 1633)
+++ trunk/milena/tests/morpho/contrast.cc (revision 1634)
@@ -47,11 +47,11 @@
using namespace mln;
using value::int_u8;
- win::rectangle2d rect(5, 5);
- border::thickness = 2;
+ win::rectangle2d rect(3, 3);
+ border::thickness = 1;
image2d<int_u8> lena;
- io::pgm::load(lena, "../../img/lena.pgm");
+ io::pgm::load(lena, "../../img/tiny.pgm");
image2d<int_u8> out = morpho::contrast(lena, rect);
io::pgm::save(out, "out.pgm");
Index: trunk/milena/mln/core/concept/value.hh
===================================================================
--- trunk/milena/mln/core/concept/value.hh (revision 1633)
+++ trunk/milena/mln/core/concept/value.hh (revision 1634)
@@ -91,7 +91,7 @@
} // end of namespace mln
-# include <mln/value/cast.hh>
+//# include <mln/value/cast.hh>
#endif // ! MLN_CORE_CONCEPT_VALUE_HH
Index: trunk/milena/mln/value/rgb8_non_templated.hh (deleted)
===================================================================
Index: trunk/milena/mln/value/graylevel_f.hh
===================================================================
--- trunk/milena/mln/value/graylevel_f.hh (revision 1633)
+++ trunk/milena/mln/value/graylevel_f.hh (revision 1634)
@@ -381,9 +381,8 @@
inline
graylevel_f::graylevel_f(const graylevel_f& rhs)
+ : Floating<graylevel_f>()
{
- mln_precondition(rhs.v_ >= 0);
- mln_precondition(rhs.v_ <= 1);
this->v_ = rhs.v_;
}
Index: trunk/milena/mln/value/internal/gray_f.hh
===================================================================
--- trunk/milena/mln/value/internal/gray_f.hh (revision 1633)
+++ trunk/milena/mln/value/internal/gray_f.hh (revision 1634)
@@ -209,6 +209,7 @@
inline
gray_f::gray_f(const gray_f& g)
+ : Floating<gray_f>()
{
this->v_ = g.v_;
}
Index: trunk/milena/mln/value/int_u_sat.hh
===================================================================
--- trunk/milena/mln/value/int_u_sat.hh (revision 1633)
+++ trunk/milena/mln/value/int_u_sat.hh (revision 1634)
@@ -38,6 +38,7 @@
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
+# include <mln/value/int_u.hh>
# include <mln/trait/value_.hh>
# include <mln/debug/format.hh>
Index: trunk/milena/mln/value/equiv.hh
===================================================================
--- trunk/milena/mln/value/equiv.hh (revision 1633)
+++ trunk/milena/mln/value/equiv.hh (revision 1634)
@@ -159,5 +159,6 @@
} // end of namespace mln
+# include <mln/value/cast.hh>
#endif // ! MLN_VALUE_EQUIV_HH
Index: trunk/milena/mln/value/viter.hh
===================================================================
--- trunk/milena/mln/value/viter.hh (revision 1633)
+++ trunk/milena/mln/value/viter.hh (revision 1634)
@@ -34,7 +34,7 @@
*/
# include <mln/core/concept/value_iterator.hh>
-
+# include <mln/core/concept/value_set.hh>
namespace mln
Index: trunk/milena/mln/value/float01.hh
===================================================================
--- trunk/milena/mln/value/float01.hh (revision 1633)
+++ trunk/milena/mln/value/float01.hh (revision 1634)
@@ -37,7 +37,7 @@
# include <utility>
# include <mln/core/concept/value.hh>
-# include <mln/value/float01_.hh>
+# include <mln/value/concept/floating.hh>
# include <mln/trait/value_.hh>
# include <mln/trait/all.hh> // FIXME!
# include <mln/trait/value_.hh>
@@ -285,5 +285,6 @@
} // end of namespace mln
+# include <mln/value/float01_.hh>
#endif // ! MLN_VALUE_FLOAT01_HH
Index: trunk/milena/mln/make/voronoi.hh
===================================================================
--- trunk/milena/mln/make/voronoi.hh (revision 1633)
+++ trunk/milena/mln/make/voronoi.hh (revision 1634)
@@ -36,6 +36,7 @@
# include <vector>
# include <map>
+# include <mln/core/concept/neighborhood.hh>
# include <mln/core/mesh_p.hh>
# include <mln/accu/mean.hh>
# include <mln/estim/min_max.hh>
Index: trunk/milena/mln/make/w_window3d_int.hh
===================================================================
--- trunk/milena/mln/make/w_window3d_int.hh (revision 1633)
+++ trunk/milena/mln/make/w_window3d_int.hh (revision 1634)
@@ -52,7 +52,7 @@
* \return A 3D int-weighted window.
*/
template <unsigned M>
- mln::w_window3d_int w_window3d_int(int (&weights)[M][N]);
+ mln::w_window3d_int w_window3d_int(int (&weights)[M]);
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/convert/to_p_set.hh
===================================================================
--- trunk/milena/mln/convert/to_p_set.hh (revision 1633)
+++ trunk/milena/mln/convert/to_p_set.hh (revision 1634)
@@ -36,6 +36,7 @@
# include <set>
# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/core/concept/point_site.hh>
# include <mln/core/p_set.hh>
# include <mln/pw/image.hh>
Index: trunk/milena/mln/util/tree_to_image.hh
===================================================================
--- trunk/milena/mln/util/tree_to_image.hh (revision 1633)
+++ trunk/milena/mln/util/tree_to_image.hh (revision 1634)
@@ -39,6 +39,7 @@
# include <mln/core/concept/image.hh>
# include <mln/util/tree.hh>
# include <mln/core/p_set.hh>
+# include <mln/level/fill.hh>
namespace mln
{
1
0
07 Jan '08
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-01-07 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add resize function for fast 2d image in mln::geom.
* mln/geom/resize.hh: New function for resize fast iamge.
* tests/geom/resize.cc: Test this function.
* tests/geom/Makefile.am: And add this test in the Makefile.
* mln/core/concept/object.hh: Update copyright.
---
mln/core/concept/object.hh | 4 -
mln/geom/resize.hh | 174 +++++++++++++++++++++++++++++++++++++++++++++
tests/geom/Makefile.am | 2
tests/geom/resize.cc | 68 +++++++++++++++++
4 files changed, 246 insertions(+), 2 deletions(-)
Index: trunk/milena/tests/geom/resize.cc
===================================================================
--- trunk/milena/tests/geom/resize.cc (revision 0)
+++ trunk/milena/tests/geom/resize.cc (revision 1633)
@@ -0,0 +1,68 @@
+// Copyright (C) 2007, 2008 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/geom/resize.cc
+ *
+ * \brief Tests on mln::geom::resize.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/geom/resize.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/level/compare.hh>
+
+int
+main ()
+{
+ using namespace mln;
+
+ {
+ image2d<int> ima (8, 16);
+
+ debug::iota(ima);
+
+ image2d<int> out = geom::resize(ima, 0.5);
+
+ int ws[4][8] =
+ {
+ { 9, 11, 13, 15, 17, 19, 21, 23},
+ { 41, 43, 45, 47, 49, 51, 53, 55},
+ { 73, 75, 77, 79, 81, 83, 85, 87},
+ {105, 107, 109, 111, 113, 115, 117, 119}
+ };
+
+ image2d<int> ref(make::image2d(ws));
+
+ mln_assertion (out == ref);
+ }
+
+}
Index: trunk/milena/tests/geom/Makefile.am
===================================================================
--- trunk/milena/tests/geom/Makefile.am (revision 1632)
+++ trunk/milena/tests/geom/Makefile.am (revision 1633)
@@ -17,6 +17,7 @@
nrows \
nslis \
pmin_pmax \
+resize \
seed2tiling \
seed2tiling_roundness \
shift \
@@ -36,6 +37,7 @@
nrows_SOURCES = nrows.cc
nslis_SOURCES = nslis.cc
pmin_pmax_SOURCES = pmin_pmax.cc
+resize_SOURCES = resize.cc
seed2tiling_SOURCES = seed2tiling.cc
seed2tiling_roundness_SOURCES = seed2tiling_roundness.cc
shift_SOURCES = shift.cc
Index: trunk/milena/mln/core/concept/object.hh
===================================================================
--- trunk/milena/mln/core/concept/object.hh (revision 1632)
+++ trunk/milena/mln/core/concept/object.hh (revision 1633)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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
@@ -93,7 +93,7 @@
* <LI> \ref mln::win
*
* \section copyright Copyright and License.
- * Copyright (C) 2007 EPITA Research and Development Laboratory
+ * Copyright (C) 2007, 2008 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
Index: trunk/milena/mln/geom/resize.hh
===================================================================
--- trunk/milena/mln/geom/resize.hh (revision 0)
+++ trunk/milena/mln/geom/resize.hh (revision 1633)
@@ -0,0 +1,174 @@
+// Copyright (C) 2007, 2008 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_GEOM_RESIZE_HH
+# define MLN_GEOM_RESIZE_HH
+
+/*! \file mln/geom/resize.hh
+ *
+ * \brief Resize an image.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/clone.hh>
+# include <mln/make/w_window1d.hh>
+# include <mln/accu/mean.hh>
+# include <mln/border/resize.hh>
+# include <mln/border/fill.hh>
+# include <mln/debug/println.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /*!
+ * \brief Resize an image \p input_ with \p ratio.
+ *
+ * \param[in] input_ The image to resize.
+ * \param[in] ratio The ratio of the resize image.
+ *
+ * \precondition \p input_ has to be initialized.
+ * \precondition \p ratio <= 1.
+ *
+ * \return The resized image.
+ */
+ template <typename I>
+ I
+ resize(const Image<I>& input_, const float ratio);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+
+ template <typename I>
+ I
+ resize_1d_(const I& input, const float ratio)
+ {
+ trace::entering("mln::geom::impl::resize_1d_");
+ typedef mln_value(I) V;
+
+ std::size_t cols = input.bbox().len(0);
+ std::size_t new_cols = (std::size_t)(ratio * cols);
+
+ std::size_t n = (std::size_t)(1 / ratio);
+
+ I output (new_cols);
+ level::fill(output, 0);
+
+ for (std::size_t j = 0; j < cols; ++j)
+ {
+ output(point1d(j / n)) += input(point1d(j));
+ if (!((j + 1) % n))
+ output(point1d(j / n)) /= n;
+ }
+
+ trace::exiting("mln::geom::impl::resize_1d_");
+ return output;
+ }
+
+ template <typename I>
+ I
+ resize_2d_(const I& input, const float ratio)
+ {
+ trace::entering("mln::geom::impl::resize_2d_");
+ typedef mln_value(I) V;
+
+ std::size_t rows = input.bbox().len(0);
+ std::size_t cols = input.bbox().len(1);
+ std::size_t new_rows = (std::size_t)(ratio * rows);
+ std::size_t new_cols = (std::size_t)(ratio * cols);
+
+ std::size_t n = (std::size_t)(1 / ratio);
+ std::size_t nn = n * n;
+
+ I output (new_rows, new_cols);
+ std::vector<V> v (new_cols);
+
+ for (std::size_t i = 0; i < rows; ++i)
+ {
+ std::size_t in = i / n;
+
+ if (!(i % n))
+ for (std::size_t j = 0; j < new_cols; ++j)
+ v[j] = 0;
+
+ for (std::size_t j = 0; j < cols; ++j)
+ v[j / n] += input(point2d(i, j));
+
+ if (!((i + 1) % n))
+ for (std::size_t j = 0; j < cols; ++j)
+ output(point2d(in, j / n)) = v[j / n] / nn;
+ }
+
+ trace::exiting("mln::geom::impl::resize_2d_");
+ return output;
+ }
+
+ } // end of namespace mln::geom::impl
+
+
+ template <typename I>
+ I
+ resize(const Image<I>& input_, const float ratio)
+ {
+ trace::entering("mln::geom::resize");
+
+ const I input = exact (input_);
+ mln_precondition(input.has_data());
+ mln_precondition(ratio <= 1.0f);
+ mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
+
+ I output;
+ typedef mln_point(I) P;
+
+ /// FIXME : Find a better way for the disjunction.
+
+// if (P::dim == 1)
+// output = impl::resize_1d_(input, ratio);
+
+ if (P::dim == 2)
+ output = impl::resize_2d_(input, ratio);
+
+ trace::exiting("mln::geom::resize");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_RESIZE_HH
1
0
05 Jan '08
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-01-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Fix convertions between the 4 graylevels types.
* mln/value/graylevel.hh,
* mln/value/graylevel_f.hh,
* mln/value/internal/gray_.hh,
* mln/value/internal/gray_f.hh: All these convertion now work:
gray_f -> gray_<n>, gray_f -> graylevel<n>, gray_f -> graylevel_f,
gray_<n> -> gray_f, gray_<n> -> graylevel<n>, gray_<n> ->
graylevel_f, graylevel_f -> gray_f, graylevel_f -> graylevel<n>,
graylevel_<n> -> gray_<n>, graylevel_<n> -> graylevel_f<n>.
* tests/value/graylevel.cc: Add more tests for convertions.
---
mln/value/graylevel.hh | 84 +++++++++------------------
mln/value/graylevel_f.hh | 96 ++++++++++++++++---------------
mln/value/internal/gray_.hh | 15 ----
mln/value/internal/gray_f.hh | 130 +++++++++++++++++++++++++++++++------------
tests/value/graylevel.cc | 41 ++++++++++---
5 files changed, 206 insertions(+), 160 deletions(-)
Index: trunk/milena/tests/value/graylevel.cc
===================================================================
--- trunk/milena/tests/value/graylevel.cc (revision 1629)
+++ trunk/milena/tests/value/graylevel.cc (revision 1630)
@@ -56,10 +56,17 @@
// }
+#define test_convertion(T1, T2, VAL) \
+{ \
+ T1(T2(VAL)); \
+ T1 test = T2(VAL); \
+ test = T2(VAL); \
+}
int main()
{
using namespace mln::value;
+ using namespace mln::value::internal;
using mln::literal::white;
using mln::literal::black;
@@ -126,20 +133,38 @@
a / float01_f(.23);
a / float01_<16>(.23);
+ }
- c = a;
- mln_assertion(c == white);
+ {
+ // Convertions.
- c = (a * 2) / 2;
- mln_assertion(c == white);
+ test_convertion(gl8, gray_<8>, 255);
+ test_convertion(gl8, gray_f, 0.4);
+ test_convertion(gl8, glf, 0.4);
+
+ test_convertion(glf, gray_<8>, 255);
+ test_convertion(glf, gray_f, 0.4);
+ test_convertion(glf, gl8, 142);
- c = c / 6;
+ test_convertion(gray_f, gray_<8>, 4);
+ test_convertion(glf, gray_f, 0.4);
}
{
- gl8 c = white;
- mln_assertion(c == white);
- mln_assertion(c.value() == float(255));
+ // FIXME : comparaison with literals doesn't work
+// c = a;
+// mln_assertion(c == white);
+
+// c = (a * 2) / 2;
+// mln_assertion(c == white);
+
+// c = c / 6;
}
+// {
+// gl8 c = white;
+// mln_assertion(c == white);
+// mln_assertion(c.value() == float(255));
+// }
+
}
Index: trunk/milena/mln/value/graylevel.hh
===================================================================
--- trunk/milena/mln/value/graylevel.hh (revision 1629)
+++ trunk/milena/mln/value/graylevel.hh (revision 1630)
@@ -102,8 +102,6 @@
struct set_precise_binary_< op::div, mln::value::graylevel<n>, mln::value::graylevel<m> >
{
typedef mln::value::internal::gray_f ret;
- // FIXME : Was...
- //typedef mln::value::internal::gray_< mlc_max_int(m, n) > ret;
};
template < unsigned n, typename I >
@@ -151,8 +149,6 @@
template < unsigned n, typename S >
struct set_precise_binary_< op::div, mln::value::graylevel<n>, mln::value::scalar_<S> >
{
- // typedef mln_trait_op_times(mln::value::graylevel<n>,
- // mln::value::scalar_<S>) ret;
typedef mln::value::internal::gray_f ret;
};
@@ -201,49 +197,61 @@
//
// |--------------------------------------------|
- // | + || gl | glf |gray_i | int | float |
+ // | + || gl | glf |gray_n | int | float |
// |============================================|
- // |gl ||gray_i|gray_f |gray_i | X | X |
+ // |gl ||gray_n|gray_f |gray_n | X | X |
// |--------------------------------------------|
// |glf || |gray_f |gray_f | X | X |
// |--------------------------------------------|
- // |gray|| |gray_i | X | X |
+ // |gray|| |gray_n | X | X |
// |--------------------------------------------|
// |--------------------------------------------|
- // | - || gl | glf |gray_i | int | float |
+ // | - || gl | glf |gray_n | int | float |
// |============================================|
- // |gl ||gray_i|gray_f |gray_i | X | X |
+ // |gl ||gray_n|gray_f |gray_n | X | X |
// |--------------------------------------------|
// |glf || |gray_f |gray_f | X | X |
// |--------------------------------------------|
- // |gray|| |gray_i | X | X |
+ // |gray|| |gray_n | X | X |
// |--------------------------------------------|
// |--------------------------------------------|
- // | * || gl | glf |gray_i | int | float |
+ // | * || gl | glf |gray_n | int | float |
// |============================================|
- // |gl ||gray_i|gray_f |gray_i |gray_i |gray_f |
+ // |gl ||gray_n|gray_f |gray_n |gray_n |gray_f |
// |--------------------------------------------|
// |glf || |gray_f |gray_f |gray_f |gray_f |
// |--------------------------------------------|
- // |gray|| |gray_i |gray_i |gray_f |
+ // |gray|| |gray_n |gray_n |gray_f |
// |--------------------------------------------|
// |--------------------------------------------|
- // | / || gl | glf |gray_i | int | float |
+ // | / || gl | glf |gray_n | int | float |
// |============================================|
- // |gl ||gray_i|gray_f |gray_i |gray_i |gray_i |
+ // |gl ||gray_f|gray_f |gray_n |gray_f |gray_f |
// |--------------------------------------------|
// |glf || |gray_f |gray_f |gray_f |gray_f |
// |--------------------------------------------|
- // |gray|| |gray_i |gray_i |gray_f |
+ // |gray|| |gray_f |gray_f |gray_f |
// |--------------------------------------------|
- /// Valid convertions :
- // glf -> gl (round)
- // gl -> gray_i
- // gray_i-> gl
+// Valid Convertions are :
+
+// gray_f -> gray_<n>
+// gray_f -> graylevel<n>
+// gray_f -> graylevel_f
+
+// gray_<n> -> gray_f
+// gray_<n> -> graylevel<n>
+// gray_<n> -> graylevel_f
+
+// graylevel_f -> gray_f
+// graylevel_f -> graylevel<n>
+
+// graylevel_<n> -> gray_<n>
+// graylevel_<n> -> graylevel_f<n>
+
template <unsigned n>
struct graylevel
@@ -268,11 +276,6 @@
/// Assigment with int.
graylevel<n>& operator=(int val);
- /// Constructor from graylevel_f.
- graylevel(const graylevel_f& rhs);
- /// Assigment with graylevel_f.
- graylevel<n>& operator=(const graylevel_f& rhs);
-
/// Constructor from any graylevel.
template <unsigned m>
graylevel(const graylevel<m>& rhs);
@@ -280,20 +283,6 @@
template <unsigned m>
graylevel<n>& operator=(const graylevel<m>& rhs);
- /// Constructor from internal::gray_f.
- graylevel(const internal::gray_f& rhs);
- /// Assigment with internal::gray_f.
- graylevel<n>& operator=(const internal::gray_f& rhs);
-
-
- /// Constructor from internal::gray_f.
- template <unsigned m>
- graylevel(const internal::gray_<m>& rhs);
- /// Assigment with internal::gray_f.
- template <unsigned m>
- graylevel<n>& operator=(const internal::gray_<m>& rhs);
-
-
/// Ctors with literals.
/// \{
graylevel(const literal::black_t&);
@@ -554,23 +543,6 @@
}
template <unsigned n>
-
- inline
- graylevel<n>::graylevel(const graylevel_f& rhs)
- {
- this->v_ = int(round(rhs.value() * (mlc_pow_int(2, n) - 1)));
- }
-
- template <unsigned n>
- inline
- graylevel<n>&
- graylevel<n>::operator=(const graylevel_f& rhs)
- {
- *this = internal::gray_f(rhs);
- return *this;
- }
-
- template <unsigned n>
inline
unsigned
graylevel<n>::value() const
Index: trunk/milena/mln/value/graylevel_f.hh
===================================================================
--- trunk/milena/mln/value/graylevel_f.hh (revision 1629)
+++ trunk/milena/mln/value/graylevel_f.hh (revision 1630)
@@ -43,7 +43,6 @@
# include <mln/literal/ops.hh>
# include <mln/value/float01_f.hh>
-//# include <mln/value/internal/gray_f.hh>
# include <mln/trait/value_.hh>
@@ -73,40 +72,23 @@
namespace trait
{
-
- // template < template <class, class> class Name>
- // struct set_precise_binary_< Name, mln::value::graylevel_f, mln::value::graylevel_f >
- // {
- // typedef mln::value::internal::gray_f ret;
- // };
-
-
- // template < template <class, class> class Name, unsigned n>
- // struct set_precise_binary_< Name, mln::value::graylevel_f, mln::value::graylevel<n> >
- // {
- // typedef mln::value::internal::gray_f ret;
- // };
-
- // template <>
- // struct set_precise_binary_< op::greater, mln::value::graylevel_f, mln::value::graylevel_f >
- // {
- // typedef bool ret;
- // };
-
- // template <>
- // struct set_precise_binary_< op::eq, mln::value::graylevel_f, mln::value::graylevel_f >
- // {
- // typedef bool ret;
- // };
-
-
- //
template <>
struct set_precise_binary_< op::plus, mln::value::graylevel_f, mln::value::graylevel_f >
{
typedef mln::value::internal::gray_f ret;
};
+ template <unsigned n>
+ struct set_precise_binary_< op::plus, mln::value::graylevel_f, mln::value::graylevel<n> >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+ template <unsigned n>
+ struct set_precise_binary_< op::plus, mln::value::graylevel<n>, mln::value::graylevel_f >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+
template <>
struct set_precise_binary_< op::minus, mln::value::graylevel_f, mln::value::graylevel_f >
{
@@ -252,6 +234,10 @@
graylevel_f& operator=(const literal::white_t&);
/// \}
+ /// Convertion to graylevel<n>
+ template <unsigned n>
+ operator graylevel<n>() const;
+
/// Access to std type.
float value() const;
};
@@ -266,34 +252,42 @@
mln_trait_op_plus_(graylevel_f, graylevel_f)
operator+(const graylevel_f& lhs, const graylevel_f& rhs);
- // graylevel_f + Integer<I> (doesn't compile)
- template <typename I>
- graylevel_f
- operator+(const graylevel_f& lhs, const Integer<I>& i);
- // graylevel_f + Floating<I> (doesn't compile)
- template <typename I>
- graylevel_f
- operator+(const graylevel_f& lhs, const Floating<I>& i);
+ // graylevel_f + graylevel<n>
+ template <unsigned n>
+ mln_trait_op_plus(graylevel_f, graylevel<n>)
+ operator+(const graylevel_f& lhs, const graylevel<n>& rhs);
+ // graylevel<n> + graylevel_f
+ template <unsigned n>
+ mln_trait_op_plus(graylevel_f, graylevel<n>)
+ operator+(const graylevel<n>& lhs, const graylevel_f& rhs);
// graylevel_f - graylevel_f
mln_trait_op_minus_(graylevel_f, graylevel_f)
operator-(const graylevel_f& lhs, const graylevel_f& rhs);
- // graylevel_f - Integer<I> (doesn't compile)
- template <typename I>
- graylevel_f
- operator-(const graylevel_f& lhs, const Integer<I>& i);
-
- // graylevel_f - Floating<I> (doesn't compile)
- template <typename I>
- graylevel_f
- operator-(const graylevel_f& lhs, const Floating<I>& i);
-
// graylevel_f * graylevel_f
mln_trait_op_times_(graylevel_f, graylevel_f)
operator*(const graylevel_f& lhs, const graylevel_f& rhs);
+
+ // With Builtins
+
+ // graylevel_f * T
+ template <unsigned n, typename T>
+ mln_trait_op_times(graylevel_f, T)
+ operator*(const graylevel_f& lhs, const T& rhs);
+
+ // T * graylevel_f
+ template <unsigned n, typename T>
+ mln_trait_op_times(graylevel_f, T)
+ operator*(const T& lhs, const graylevel_f& rhs);
+
+ // graylevel_f / T
+ template <unsigned n, typename T>
+ internal::gray_f
+ operator/(const graylevel_f& lhs, const T& rhs);
+
// With Integer.
// graylevel_f * Integer<I>
@@ -383,6 +377,7 @@
mln_precondition(rhs.to_float() >= 0);
mln_precondition(rhs.to_float() <= 1);
this->v_ = rhs.to_float();
+ return *this;
}
inline
@@ -445,6 +440,13 @@
return *this;
}
+ template <unsigned n>
+ inline
+ graylevel_f::operator graylevel<n>() const
+ {
+ return graylevel<n>(internal::gray_f(*this));
+ }
+
inline
float
graylevel_f::value() const
Index: trunk/milena/mln/value/internal/gray_.hh
===================================================================
--- trunk/milena/mln/value/internal/gray_.hh (revision 1629)
+++ trunk/milena/mln/value/internal/gray_.hh (revision 1630)
@@ -40,8 +40,6 @@
# include <mln/metal/math/max.hh>
# include <mln/metal/math/pow.hh>
-//# include <mln/value/graylevel.hh>
-//# include <mln/value/graylevel_f.hh>
# include <mln/value/concept/integer.hh>
@@ -178,6 +176,7 @@
/// Convertion to graylevel_f.
operator graylevel_f() const;
+
};
@@ -317,7 +316,6 @@
return graylevel_f(float(this->v_) / denom);
}
-
// Operators.
template <unsigned n>
@@ -627,17 +625,6 @@
return tmp;
}
-// template <unsigned m, typename S>
-// inline static
-// mln_trait_op_times(graylevel<m>, scalar_<S>)
-// times(const graylevel<m>& lhs, const scalar_<S>& rhs)
-// {
-// typedef mln_trait_op_times(graylevel<m>, scalar_<S>) ret;
-// ret tmp(lhs.value() * rhs.to_equiv());
-// return tmp;
-// }
-
-
template <unsigned m, typename S>
inline static
mln_trait_op_times(graylevel<m>, scalar_<S>)
Index: trunk/milena/mln/value/internal/gray_f.hh
===================================================================
--- trunk/milena/mln/value/internal/gray_f.hh (revision 1629)
+++ trunk/milena/mln/value/internal/gray_f.hh (revision 1630)
@@ -43,7 +43,6 @@
# include <mln/literal/ops.hh>
# include <mln/value/float01_f.hh>
-//# include <mln/value/internal/gray_.hh>
# include <mln/trait/value_.hh>
@@ -61,8 +60,12 @@
namespace value
{
/// \{ Fwd decls.
- class gray;
- struct gray_f;
+ namespace internal
+ {
+ template <unsigned n> class gray_;
+ class gray_f;
+ }
+
struct float01_f;
/// \}
}
@@ -74,19 +77,19 @@
template < template <class, class> class Name>
- struct set_precise_binary_< Name, mln::value::gray_f, mln::value::gray_f >
+ struct set_precise_binary_< Name, mln::value::internal::gray_f, mln::value::internal::gray_f >
{
- typedef mln::value::gray_f ret;
+ typedef mln::value::internal::gray_f ret;
};
template <>
- struct set_precise_binary_< op::greater, mln::value::gray_f, mln::value::gray_f >
+ struct set_precise_binary_< op::greater, mln::value::internal::gray_f, mln::value::internal::gray_f >
{
typedef bool ret;
};
template <>
- struct set_precise_binary_< op::eq, mln::value::gray_f, mln::value::gray_f >
+ struct set_precise_binary_< op::eq, mln::value::internal::gray_f, mln::value::internal::gray_f >
{
typedef bool ret;
};
@@ -94,7 +97,7 @@
// Nessecary??
// template <typename F>
// struct set_binary_< op::eq,
-// mln::value::Floating, mln::value::gray_f,
+// mln::value::Floating, mln::value::internal::gray_f,
// mln::value::Floating, F >
// {
// typedef bool ret;
@@ -105,10 +108,10 @@
// 'gray_f' as a value.
template <>
- struct value_<mln::value::gray_f>
+ struct value_<mln::value::internal::gray_f>
{
private:
- typedef mln::value::gray_f self_;
+ typedef mln::value::internal::gray_f self_;
typedef float equiv_;
public:
@@ -157,6 +160,13 @@
gray_f& operator=(const gray_f& rhs);
/// \}
+ /// \{ Constructors/assigments with gray_<n>.
+ template <unsigned n>
+ gray_f(const gray_<n>& rhs);
+ template <unsigned n>
+ gray_f& operator=(const gray_<n>& rhs);
+ /// \}
+
/// \{ Constructors/assigments with float.
gray_f(float val);
gray_f& operator=(float val);
@@ -171,6 +181,10 @@
template <unsigned m>
operator graylevel<m>() const;
+ /// Convertion to gray_<n>
+ template <unsigned m>
+ operator gray_<m>() const;
+
/// Convertion to graylevel_f
operator graylevel_f() const;
@@ -207,6 +221,22 @@
return *this;
}
+ template <unsigned n>
+ gray_f::gray_f(const gray_<n>& rhs)
+ {
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
+ this->v_ = float(rhs.value()) / denom;
+ }
+
+ template <unsigned n>
+ gray_f&
+ gray_f::operator=(const gray_<n>& rhs)
+ {
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
+ this->v_ = float(rhs.value()) / denom;
+ return *this;
+ }
+
inline
gray_f::gray_f(float val)
{
@@ -242,6 +272,14 @@
return graylevel<m>(int(round(this->v_ * (mlc_pow_int(2, m) - 1))));
}
+
+ template <unsigned m>
+ inline
+ gray_f::operator gray_<m>() const
+ {
+ return gray_<m>(int(round(this->v_ * (mlc_pow_int(2, m) - 1))));
+ }
+
inline
gray_f::operator graylevel_f() const
{
@@ -296,49 +334,71 @@
return lhs.value() + rhs.value();
}
- // Op glf + Integer
- template <typename I>
+ // Op glf + gl<n>
+ template <unsigned n>
inline
- graylevel_f
- operator+(const graylevel_f& lhs, const Integer<I>& i)
+ mln_trait_op_plus(graylevel_f, graylevel<n>)
+ operator+(const graylevel_f& lhs, const graylevel<n>& rhs)
{
- typename I::graylevel_f_plus_int_is_undefined__Please_use_the__to_enc__method a;
+ return lhs.value() + graylevel_f(rhs).value();
}
-// // Op glf + Float
-// template <typename I>
-// inline
-// graylevel_f
-// operator+(const graylevel_f& lhs, const Floating<I>& i)
-// {
-// typename I::graylevel_f_plus_float_is_undefined__Please_use_the__to_enc__method a;
-// }
+ // Op gl<n> + glf
+ template <unsigned n>
+ inline
+ mln_trait_op_plus(graylevel_f, graylevel<n>)
+ operator+(const graylevel<n>& lhs, const graylevel_f& rhs)
+ {
+ return rhs.value() + graylevel_f(lhs).value();
+ }
- // Op glf - glf
+ // Op glf + Another type
+ template <typename I>
inline
- mln_trait_op_minus_(graylevel_f, graylevel_f)
- operator-(const graylevel_f& lhs, const graylevel_f& rhs)
+ void
+ operator+(const graylevel_f& lhs, const I& i)
{
- return lhs.value() - rhs.value();
+ typename Object<I>::wrong_use_of_graylevel_f___Please_use_the__to_enc__method a;
+ }
+
+
+ // Op Another type + glf
+ template <typename I>
+ inline
+ void
+ operator+(const I& i, const graylevel_f& rhs)
+ {
+ typename Object<I>::wrong_use_of_graylevel_f___Please_use_the__to_enc__method a;
}
- // Op glf - Integer
+
+ // Op glf - Another type
template <typename I>
inline
- graylevel_f
- operator-(const graylevel_f& lhs, const Integer<I>& i)
+ void
+ operator-(const graylevel_f& lhs, const I& i)
{
- typename I::graylevel_f_minus_int_is_undefined__Please_use_the__to_enc__method a;
+ typename Object<I>::wrong_use_of_graylevel_f___Please_use_the__to_enc__method a;
}
- // Op glf - Float
+
+ // Op Another type - glf
template <typename I>
inline
- graylevel_f
- operator-(const graylevel_f& lhs, const Floating<I>& i)
+ void
+ operator-(const I& i, const graylevel_f& rhs)
+ {
+ typename Object<I>::wrong_use_of_graylevel_f___Please_use_the__to_enc__method a;
+ }
+
+ // Op glf - glf
+
+ inline
+ mln_trait_op_minus_(graylevel_f, graylevel_f)
+ operator-(const graylevel_f& lhs, const graylevel_f& rhs)
{
- typename I::graylevel_f_minus_float_is_undefined__Please_use_the__to_enc__method a;
+ return lhs.value() - rhs.value();
}
// Op glf * glf
2
1
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-01-03 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Improve operators on graylevels.
* mln/core/exact.hh: (mln_exact(T)) New.
* mln/trait/op/times.hh: Try to display an explicit error when
calling mln_trait_op_times with types not exact.
* mln/value/internal/gray_.hh,
* mln/value/internal/gray_f.hh,
* mln/value/graylevel.hh,
* mln/value/graylevel_f.hh: Review and complete the allowed and
forbidden operators, resolve includes recursion.
* tests/value/graylevel.cc: Add some tests to test if times and
div compile well.
* tests/value/graylevel_full.cc: Disable some tests to isolate
some bugs.
* tests/value/int_u8.cc: Add a test for div between int_u8 and
float.
---
mln/core/exact.hh | 5
mln/trait/op/times.hh | 11
mln/value/graylevel.hh | 130 ++++++++-
mln/value/graylevel_f.hh | 188 +++++++++++++
mln/value/internal/gray_.hh | 162 ++++++++++--
mln/value/internal/gray_f.hh | 156 ++++++++++-
tests/value/graylevel.cc | 64 ++++
tests/value/graylevel_full.cc | 567 ++++++++++++++++++++++--------------------
tests/value/int_u8.cc | 1
9 files changed, 961 insertions(+), 323 deletions(-)
Index: trunk/milena/tests/value/int_u8.cc
===================================================================
--- trunk/milena/tests/value/int_u8.cc (revision 1628)
+++ trunk/milena/tests/value/int_u8.cc (revision 1629)
@@ -183,6 +183,7 @@
c /= 2;
sym_compare_assert(c, ==, 50.f);
+ d /= 2.4f;
}
Index: trunk/milena/tests/value/graylevel_full.cc
===================================================================
--- trunk/milena/tests/value/graylevel_full.cc (revision 1628)
+++ trunk/milena/tests/value/graylevel_full.cc (revision 1629)
@@ -53,8 +53,8 @@
// Constructions
{
+ // With int
gl8 x;
-
gl8 a = 12;
gl8 b(12);
mln_assertion(a == b);
@@ -79,276 +79,317 @@
mln_assertion(f == g);
mln_assertion(h == g);
- }
-
- // Literals
- {
- gl8 a(white);
- gl16 b(white);
-
- a = white;
- b = white;
-
- mln_assertion(a == b);
- mln_assertion(a.value() == float(255));
- mln_assertion(b.value() == float(65535));
- mln_assertion(a == white);
- mln_assertion(b == white);
-
- gl8 c(white);
- mln_assertion(c == white);
- mln_assertion(c.value() == float(255));
-
- a = black;
- b = black;
-
- mln_assertion(a == b);
- mln_assertion(a.value() == float(0));
- mln_assertion(b.value() == float(0));
- }
- // Assigment
+ // FIXME : make the following tests compile.
{
- gl8 a;
- gl16 b;
+ // With gray_f.
+ //gl8 a = mln::value::internal::gray_f(12.5);
- a = white;
- mln_assertion(a == white);
- mln_assertion(a.value() == float(255));
-
- a = 23;
- mln_assertion(a != white);
- mln_assertion(a != black);
- mln_assertion(a.value() == float(23));
-
- b = 2;
- mln_assertion(b != white);
- mln_assertion(b != black);
- mln_assertion(b.value() == float(2));
-
- a = b;
- mln_assertion(a.value() == float(2 / 256));
-
- signed char c = 51;
- a = c;
- mln_assertion(a.value() == float(51));
-
- // bounds
- a = 255;
- mln_assertion(a.value() == float(255));
- a = 0;
- mln_assertion(a.value() == float(0));
}
-
- // Addition
- {
- gl8 a;
- gl16 b;
-
- // gl8 <- gl8 + gl8
- a = 42;
- a += a;
- mln_assertion(a.value() == float(84));
-
- a = 42;
- a = a + a;
- mln_assertion(a.value() == float(84));
-
- // gl8 <- gl8 + gl16
- a = 42;
- b = 16969;
- a = a + b;
- mln_assertion(a.value() == float((42 + b.value() / 257) ));
- a = 42;
- b = 16969;
- a += b;
- mln_assertion(a.value() == float((42 + b.value() / 256) ));
-
-
- // gl16 <- gl8 + gl16
- a = 42;
- b = 16969;
- b += a;
- mln_assertion(b.value() == float((42 * 256 + 16969) ));
-
- a = 42;
- b = 16969;
- b = b + a;
-
- mln_assertion(b.value() == float((42 * 256 + 16969) ));
-
- a = 42;
- b = 16969;
- b = a + b;
- mln_assertion(b.value() == float((42 * 256 + 16969) ));
-
- // misc
- a = 255;
- b = 0;
- a = a + b;
- mln_assertion(a.value() == float(255));
-
- a = 0;
- b = 65535;
- a = a + b;
- mln_assertion(a.value() == float(255));
}
+ // Literals
+// {
+// gl8 a(white);
+// gl16 b(white);
+
+// a = white;
+// b = white;
+
+// mln_assertion(a == b);
+// mln_assertion(a.value() == float(255));
+// mln_assertion(b.value() == float(65535));
+// mln_assertion(a == white);
+// mln_assertion(b == white);
+
+// gl8 c(white);
+// mln_assertion(c == white);
+// mln_assertion(c.value() == float(255));
+
+// a = black;
+// b = black;
+
+// mln_assertion(a == b);
+// mln_assertion(a.value() == float(0));
+// mln_assertion(b.value() == float(0));
+// }
+
+// // Assigment
+// {
+// gl8 a;
+// gl16 b;
+
+// a = white;
+// mln_assertion(a == white);
+// mln_assertion(a.value() == float(255));
+
+// a = 23;
+// mln_assertion(a != white);
+// mln_assertion(a != black);
+// mln_assertion(a.value() == float(23));
+
+// b = 2;
+// mln_assertion(b != white);
+// mln_assertion(b != black);
+// mln_assertion(b.value() == float(2));
+
+// a = b;
+// mln_assertion(a.value() == float(2 / 256));
+
+// signed char c = 51;
+// a = c;
+// mln_assertion(a.value() == float(51));
+
+// // bounds
+// a = 255;
+// mln_assertion(a.value() == float(255));
+// a = 0;
+// mln_assertion(a.value() == float(0));
+// }
- // Soustraction
- {
- gl8 a;
- gl16 b;
-
- // gl8 <- gl8 - gl8
- a = 42;
- a -= a;
- mln_assertion(a == black);
-
- a = 42;
- a = a - a;
- mln_assertion(a == black);
-
- // gl8 <- gl8 - gl16
- a = 42;
- b = 5969;
-
- a = b;
-
- {
- a = 42;
- gl16 t;
-
- t = a - b;
- t = t + b;
- mln_assertion(a == t);
- }
-
- a = 42;
- a = a - b;
- mln_assertion(a.value() == (42 * 256 - b.value()) / 256 );
- a = 42;
- b = 9969;
- a -= b;
- mln_assertion(a.value() == (42 * 256 - b.value()) / 256 );
-
-
- // gl16 <- gl8 - gl16
- a = 100;
- b = 30969;
- b -= a;
- mln_assertion(b.value() == float(30969 - 100 * 256));
-
- a = 100;
- b = 20969;
- b = a - b;
- mln_assertion(b.value() == float((100 * 256 - 20969) ));
-
- // misc
- a = 255;
- b = 0;
- a = a - b;
- mln_assertion(a.value() == float(255));
-
- gl8(255) - gl16(65535);
- mln_assertion( gl8(255) == gl16(65535) );
- a = 255;
- b = 65535;
- a = a - b;
- mln_assertion(a.value() == float(0));
-
- // ...
- {
- graylevel<2> a = 1;
- graylevel<3> b = 5;
- graylevel<2> c;
- graylevel<3> d;
-
- c = b - a;
- d = b - a;
- mln_assertion(c == d);
- }
-
- }
-
- // Multiplication
- {
- gl8 a;
- gl16 b;
-
- // gl8 <- gl8 * gl8
- a = 8;
- a *= a;
- mln_assertion(a.value() == 64);
-
- a = 7;
- a = a * a;
- mln_assertion(a.value() == 49);
-
- // gl8 <- gl8 * gl16
- a = 10;
- b = 20;
- a = a * b;
- mln_assertion(a.value() == float((10 * 256* b.value())/256));
-
- a = 10;
- b = 16;
- a *= b;
- mln_assertion(a.value() == float((10 * 256* b.value())/256));
-
- mln_assertion((gl8(12) * gl16(12345)).to_enc() == float((12 * 256* 12345)));
-
-
- // gl16 <- gl8 * gl16
- a = 10;
- b = 24;
- b *= a;
- mln_assertion(b.value() == float((10 * 256 * 24) ));
-
- a = 10;
- b = 24;
- b = a * b;
- mln_assertion(b.value() == float((10 * 256 * 24) ));
-
- // misc
- a = 255;
- b = 0;
- a = a * b;
- mln_assertion(a == black);
-
- a = 0;
- b = 65535;
- a = a * b;
- mln_assertion(a == black);
-
- // ...
- {
- graylevel<2> a = 1;
- graylevel<3> b = 2;
- graylevel<2> c;
- graylevel<3> d;
-
- c = a * b;
- d = a * b;
- mln_assertion(c == d);
- }
-
+ // Addition
{
+// gl8 a;
+// gl16 b;
- // ...
- gl8 a = 7;
- gl16 b = 596;
+// // gl8 <- gl8 + gl8
+// a = 42;
+// a += a;
+// mln_assertion(a.value() == float(84));
+
+// a = 42;
+// a = a + a;
+// mln_assertion(a.value() == float(84));
+
+// // gl8 <- gl8 + gl16
+// a = 42;
+// b = 16969;
+// a = a + b;
+// mln_assertion(a.value() == float((42 + b.value() / 257) ));
+// a = 42;
+// b = 16969;
+// a += b;
+// mln_assertion(a.value() == float((42 + b.value() / 256) ));
+
+
+// // gl16 <- gl8 + gl16
+// a = 42;
+// b = 16969;
+// b += a;
+// mln_assertion(b.value() == float((42 * 256 + 16969) ));
+
+// a = 42;
+// b = 16969;
+// b = b + a;
+
+// mln_assertion(b.value() == float((42 * 256 + 16969) ));
+
+// a = 42;
+// b = 16969;
+// b = a + b;
+// mln_assertion(b.value() == float((42 * 256 + 16969) ));
+
+// // misc
+// a = 255;
+// b = 0;
+// a = a + b;
+// mln_assertion(a.value() == float(255));
+
+// a = 0;
+// b = 65535;
+// a = a + b;
+// mln_assertion(a.value() == float(255));
+ }
+
+
+// // Soustraction
+// {
+// gl8 a;
+// gl16 b;
+
+// // gl8 <- gl8 - gl8
+// a = 42;
+// a -= a;
+// mln_assertion(a == black);
+
+// a = 42;
+// a = a - a;
+// mln_assertion(a == black);
+
+// // gl8 <- gl8 - gl16
+// a = 42;
+// b = 5969;
+
+// a = b;
+
+// {
+// a = 42;
+// gl16 t;
+
+// t = a - b;
+// t = t + b;
+// mln_assertion(a == t);
+// }
+
+// a = 42;
+// a = a - b;
+// mln_assertion(a.value() == (42 * 256 - b.value()) / 256 );
+// a = 42;
+// b = 9969;
+// a -= b;
+// mln_assertion(a.value() == (42 * 256 - b.value()) / 256 );
+
+
+// // gl16 <- gl8 - gl16
+// a = 100;
+// b = 30969;
+// b -= a;
+// mln_assertion(b.value() == float(30969 - 100 * 256));
+
+// a = 100;
+// b = 20969;
+// b = a - b;
+// mln_assertion(b.value() == float((100 * 256 - 20969) ));
+
+// // misc
+// a = 255;
+// b = 0;
+// a = a - b;
+// mln_assertion(a.value() == float(255));
+
+// gl8(255) - gl16(65535);
+// mln_assertion( gl8(255) == gl16(65535) );
+// a = 255;
+// b = 65535;
+// a = a - b;
+// mln_assertion(a.value() == float(0));
+
+// // ...
+// {
+// graylevel<2> a = 1;
+// graylevel<3> b = 5;
+// graylevel<2> c;
+// graylevel<3> d;
+
+// c = b - a;
+// d = b - a;
+// mln_assertion(c == d);
+// }
+
+// }
+
+// // Multiplication
+// {
+// gl8 a;
+// gl16 b;
+
+// // gl8 <- gl8 * gl8
+// a = 8;
+// a *= a;
+// mln_assertion(a.value() == 64);
+
+// a = 7;
+// a = a * a;
+// mln_assertion(a.value() == 49);
+
+// // gl8 <- gl8 * gl16
+// a = 10;
+// b = 20;
+// a = a * b;
+// mln_assertion(a.value() == float((10 * 256* b.value())/256));
+
+// a = 10;
+// b = 16;
+// a *= b;
+// mln_assertion(a.value() == float((10 * 256* b.value())/256));
+
+// mln_assertion((gl8(12) * gl16(12345)).to_enc() == float((12 * 256* 12345)));
+
+
+// // gl16 <- gl8 * gl16
+// a = 10;
+// b = 24;
+// b *= a;
+// mln_assertion(b.value() == float((10 * 256 * 24) ));
+
+// a = 10;
+// b = 24;
+// b = a * b;
+// mln_assertion(b.value() == float((10 * 256 * 24) ));
+
+// // misc
+// a = 255;
+// b = 0;
+// a = a * b;
+// mln_assertion(a == black);
+
+// a = 0;
+// b = 65535;
+// a = a * b;
+// mln_assertion(a == black);
+
+
+// // With Floating.
+// // a = 8;
+// // a = a * 0.5;
+// // mln_assertion(a.value() == 4.f);
+
+// // a = 8;
+// // a *= 0.5;
+// // mln_assertion(a.value() == 4.f);
+
+// // ...
+// {
+// graylevel<2> a = 1;
+// graylevel<3> b = 2;
+// graylevel<2> c;
+// graylevel<3> d;
+
+// c = a * b;
+// d = a * b;
+// mln_assertion(c == d);
+// }
+
+// {
+
+// // ...
+// gl8 a = 7;
+// gl16 b = 596;
+
+// gl8 p;
+// p = b;
+
+// gl8 q;
+// gl8 r;
+
+// q = a * p;
+// r = a * b / 256;
+// }
+
+// }
+// // division
+// {
+// // gl8 a = 2;
+// // a = a / 2;
+// // mln_assertion(a.value() == 1);
+
+// // a = 6;
+// // a = a / 1.5;
+// // mln_assertion(a.value() == 4.f);
+
+// }
+
+// {
+// gl8 a = 1;
+// int_u8 b = 1;
+// float01_f c = 0.5;
+
+// // Theses lines are forbidden. Since we can't add or substract
+// // graylevel with int or float.
+// // a + b;
+// // a - b;
+// // a + c;
+// // a - c;
+// }
- gl8 p;
- p = b;
-
- gl8 q;
- gl8 r;
-
- q = a * p;
- r = a * b / 256;
- }
-
- }
- // FIXME : division
}
Index: trunk/milena/tests/value/graylevel.cc
===================================================================
--- trunk/milena/tests/value/graylevel.cc (revision 1628)
+++ trunk/milena/tests/value/graylevel.cc (revision 1629)
@@ -34,13 +34,29 @@
#include <mln/value/gl8.hh>
#include <mln/value/gl16.hh>
+#include <mln/value/glf.hh>
+
#include <mln/value/int_u8.hh>
+#include <mln/value/float01_f.hh>
+#include <mln/value/float01_.hh>
+
#include <mln/literal/black.hh>
#include <mln/literal/white.hh>
+// FIXME : make a more explicit error message.
+// template <typename T>
+// void foo()
+// {
+// typedef mln::value::gl8 g;
+// // mln_trait_op_times(int, mln::value::Integer<g>) tmp;
+// mln_trait_op_times(int, mln::value::Integer<g>) tmp;
+// }
+
+
+
int main()
{
using namespace mln::value;
@@ -48,6 +64,9 @@
using mln::literal::white;
using mln::literal::black;
+
+ // FIXME : make all the test pass.
+
gl8 a(white);
gl8 b(white);
@@ -60,14 +79,53 @@
gl8 c = a + b;
}
+
{
gl8 a(white);
gl8 b(white);
gl8 c;
- c = (a + b) / 2;
- mln_assertion(c == white);
- mln_assertion(c.value() == 255);
+ // gl8 * int
+ a * 2;
+ 2 * a;
+
+
+ // gl8 * double
+ a * 2.0;
+ 2.0 * a;
+
+ // gl8 * bool
+ a * false;
+ false * a;
+
+ // gl8 * Integer
+ a * int_u8(23);
+ int_u8(23) * a;
+
+ // gl8 * Floating
+ a * float01_f(.23);
+ float01_f(.23) * a;
+
+ float01_<16>(.23) * a;
+ a * float01_<16>(.23);
+
+
+ // gl8 / int
+ a / 1.5;
+
+ // gl8 / double
+ mln_assertion(a / 2.0 == glf(0.5));
+
+ // gl8 / bool
+ mln_assertion(a / true == a);
+
+ // gl8 / Integer
+ a / int_u8(23);
+
+ // gl8 / Floating
+ a / float01_f(.23);
+ a / float01_<16>(.23);
+
c = a;
mln_assertion(c == white);
Index: trunk/milena/mln/trait/op/times.hh
===================================================================
--- trunk/milena/mln/trait/op/times.hh (revision 1628)
+++ trunk/milena/mln/trait/op/times.hh (revision 1629)
@@ -50,11 +50,22 @@
namespace op
{
+
template <typename L, typename R>
struct times : public solve_binary<times, L, R>
{
};
+
+ // FIXME: Try to make the code below compile.
+
+// template <typename L, typename R>
+// struct times : mlc_equal< mln_exact(R), R >::check_t
+// {
+// typedef solve_binary<mln::trait::op::times, L, R> solve_t;
+// typedef typename solve_t::ret ret;
+// };
+
} // end of namespace mln::trait::op
} // end of namespace mln::trait
Index: trunk/milena/mln/core/exact.hh
===================================================================
--- trunk/milena/mln/core/exact.hh (revision 1628)
+++ trunk/milena/mln/core/exact.hh (revision 1629)
@@ -35,6 +35,11 @@
# include <mln/core/internal/exact.hh>
+/// FIXME: Doc!
+#define mln_exact(T) typename internal::exact_<T>::ret
+
+
+
namespace mln
{
Index: trunk/milena/mln/value/graylevel.hh
===================================================================
--- trunk/milena/mln/value/graylevel.hh (revision 1628)
+++ trunk/milena/mln/value/graylevel.hh (revision 1629)
@@ -43,8 +43,8 @@
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
+# include <mln/value/graylevel_f.hh>
# include <mln/value/int_u.hh>
-# include <mln/value/internal/gray_.hh>
# include <mln/trait/value_.hh>
@@ -63,7 +63,13 @@
{
/// \{ Fwd decls.
- class gray_;
+ namespace internal
+ {
+ template <unsigned n> class gray_;
+ class gray_f;
+ template <unsigned n_src, unsigned n_dest>
+ long convert(int val);
+ }
template <unsigned n> struct graylevel;
struct float01_f;
/// \}
@@ -95,8 +101,9 @@
template < unsigned n, unsigned m >
struct set_precise_binary_< op::div, mln::value::graylevel<n>, mln::value::graylevel<m> >
{
- // FIXME : correct?
- typedef mln::value::internal::gray_< mlc_max_int(m, n) > ret;
+ typedef mln::value::internal::gray_f ret;
+ // FIXME : Was...
+ //typedef mln::value::internal::gray_< mlc_max_int(m, n) > ret;
};
template < unsigned n, typename I >
@@ -137,15 +144,16 @@
struct set_precise_binary_< op::times, mln::value::graylevel<n>, mln::value::scalar_<S> >
{
typedef mln_value_equiv(S) E;
- typedef mlc_equal(E, float) is_float; // FIXME: Or double...
- typedef mlc_if(is_float, float, mln::value::internal::gray_<n>) ret;
+ typedef mln::metal::or_< mlc_equal(E, float), mlc_equal(E, double) > is_float;
+ typedef mlc_if(is_float, mln::value::internal::gray_f, mln::value::internal::gray_<n>) ret;
};
template < unsigned n, typename S >
struct set_precise_binary_< op::div, mln::value::graylevel<n>, mln::value::scalar_<S> >
{
- typedef mln_trait_op_times(mln::value::graylevel<n>,
- mln::value::scalar_<S>) ret;
+ // typedef mln_trait_op_times(mln::value::graylevel<n>,
+ // mln::value::scalar_<S>) ret;
+ typedef mln::value::internal::gray_f ret;
};
// 'graylevel<n>' as a value.
@@ -247,6 +255,7 @@
internal::gray_<n>,// Interoperation.
graylevel<n> > // Exact.
{
+
/// Constructor without argument.
graylevel();
/// Copy constructor.
@@ -264,7 +273,6 @@
/// Assigment with graylevel_f.
graylevel<n>& operator=(const graylevel_f& rhs);
-
/// Constructor from any graylevel.
template <unsigned m>
graylevel(const graylevel<m>& rhs);
@@ -272,6 +280,19 @@
template <unsigned m>
graylevel<n>& operator=(const graylevel<m>& rhs);
+ /// Constructor from internal::gray_f.
+ graylevel(const internal::gray_f& rhs);
+ /// Assigment with internal::gray_f.
+ graylevel<n>& operator=(const internal::gray_f& rhs);
+
+
+ /// Constructor from internal::gray_f.
+ template <unsigned m>
+ graylevel(const internal::gray_<m>& rhs);
+ /// Assigment with internal::gray_f.
+ template <unsigned m>
+ graylevel<n>& operator=(const internal::gray_<m>& rhs);
+
/// Ctors with literals.
/// \{
@@ -323,41 +344,99 @@
mln_trait_op_plus(graylevel<n>, graylevel<m>)
operator+(const graylevel<n>& lhs, const graylevel<m>& rhs);
+ // graylevel<n> + Another type (doesn't compile)
+ template <unsigned n, typename I>
+ void
+ operator+(const graylevel<n>& lhs, const I& i);
+
+ // graylevel<n> + Another type (doesn't compile)
+ template <unsigned n, typename I>
+ void
+ operator+(const I& i, const graylevel<n>& rhs);
+
// graylevel<n> - graylevel<m>
template <unsigned n, unsigned m>
mln_trait_op_minus(graylevel<n>, graylevel<m>)
operator-(const graylevel<n>& lhs, const graylevel<m>& rhs);
+ // graylevel<n> - Another type (doesn't compile)
+ template <unsigned n, typename I>
+ void
+ operator-(const graylevel<n>& lhs, const I& i);
+
+ // graylevel<n> - Another type (doesn't compile)
+ template <unsigned n, typename I>
+ void
+ operator-(const I& i, const graylevel<n>& rhs);
+
// graylevel<n> * graylevel<m>
template <unsigned n, unsigned m>
mln_trait_op_times(graylevel<n>, graylevel<m>)
operator*(const graylevel<n>& lhs, const graylevel<m>& rhs);
+ // With Builtins
+
+ // graylevel<n> * T
+ template <unsigned n, typename T>
+ mln_trait_op_times(graylevel<n>, T)
+ operator*(const graylevel<n>& lhs, const T& rhs);
+
+ // T * graylevel<n>
+ template <unsigned n, typename T>
+ mln_trait_op_times(graylevel<n>, T)
+ operator*(const T& lhs, const graylevel<n>& rhs);
+
+ // graylevel<n> / T
+ template <unsigned n, typename T>
+ internal::gray_f
+ //mln_trait_op_div(graylevel<n>, T)
+ operator/(const graylevel<n>& lhs, const T& rhs);
+
// With Integer.
// graylevel<n> * Integer<I>
template <unsigned n, typename I>
- mln_trait_op_times(graylevel<n>, Integer<I>)
+ mln_trait_op_times(graylevel<n>, I)
operator*(const graylevel<n>& lhs, const Integer<I>& rhs);
// Integer<I> * graylevel<n>
template <typename I, unsigned n>
- mln_trait_op_times(Integer<I>, graylevel<n>)
+ mln_trait_op_times(I, graylevel<n>)
operator*(const Integer<I>& lhs, const graylevel<n>& rhs);
+ // graylevel<n> / Integer<I>
+ template <unsigned n, typename I>
+ mln_trait_op_div(graylevel<n>, I)
+ operator/(const graylevel<n>& lhs, const Integer<I>& rhs);
+
+ // Integer<I> / graylevel<n>
+ template <typename I, unsigned n>
+ mln_trait_op_div(I, graylevel<n>)
+ operator/(const Integer<I>& lhs, const graylevel<n>& rhs);
+
// With Floating.
// graylevel<n> * Floating<F>
template <unsigned n, typename F>
- mln_trait_op_times(graylevel<n>, Floating<F>)
+ mln_trait_op_times(graylevel<n>, F)
operator*(const graylevel<n>& lhs, const Floating<F>& rhs);
// Floating<F>, graylevel<n>
template <typename F, unsigned n>
- mln_trait_op_times(Floating<F>, graylevel<n>)
+ mln_trait_op_times(F, graylevel<n>)
operator*(const Floating<F>& lhs, const graylevel<n>& rhs);
+ // graylevel<n> / Floating<F>
+ template <unsigned n, typename F>
+ mln_trait_op_div(graylevel<n>, F)
+ operator/(const graylevel<n>& lhs, const Floating<F>& rhs);
+
+ // Floating<F> / graylevel<n>
+ template <typename F, unsigned n>
+ mln_trait_op_div(F, graylevel<n>)
+ operator/(const Floating<F>& lhs, const graylevel<n>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
// Graylevel<n>.
@@ -411,7 +490,7 @@
inline
graylevel<n>::graylevel(const graylevel<m>& rhs)
{
- *this = internal::gray_<m>(rhs);
+ this->v_ = internal::convert<m, n>(rhs.value());
}
template <unsigned n>
@@ -420,7 +499,7 @@
graylevel<n>&
graylevel<n>::operator=(const graylevel<m>& rhs)
{
- *this = internal::gray_<m>(rhs);
+ this->v_ = internal::convert<m, n>(rhs.value());
return *this;
}
@@ -475,6 +554,23 @@
}
template <unsigned n>
+
+ inline
+ graylevel<n>::graylevel(const graylevel_f& rhs)
+ {
+ this->v_ = int(round(rhs.value() * (mlc_pow_int(2, n) - 1)));
+ }
+
+ template <unsigned n>
+ inline
+ graylevel<n>&
+ graylevel<n>::operator=(const graylevel_f& rhs)
+ {
+ *this = internal::gray_f(rhs);
+ return *this;
+ }
+
+ template <unsigned n>
inline
unsigned
graylevel<n>::value() const
@@ -532,4 +628,8 @@
} // end of namespace mln
+
+#include <mln/value/internal/gray_f.hh>
+#include <mln/value/internal/gray_.hh>
+
#endif // ! MLN_VALUE_GRAYLEVEL_HH
Index: trunk/milena/mln/value/graylevel_f.hh
===================================================================
--- trunk/milena/mln/value/graylevel_f.hh (revision 1628)
+++ trunk/milena/mln/value/graylevel_f.hh (revision 1629)
@@ -43,7 +43,7 @@
# include <mln/literal/ops.hh>
# include <mln/value/float01_f.hh>
-# include <mln/value/internal/gray_.hh>
+//# include <mln/value/internal/gray_f.hh>
# include <mln/trait/value_.hh>
@@ -74,24 +74,104 @@
{
- template < template <class, class> class Name>
- struct set_precise_binary_< Name, mln::value::graylevel_f, mln::value::graylevel_f >
+ // template < template <class, class> class Name>
+ // struct set_precise_binary_< Name, mln::value::graylevel_f, mln::value::graylevel_f >
+ // {
+ // typedef mln::value::internal::gray_f ret;
+ // };
+
+
+ // template < template <class, class> class Name, unsigned n>
+ // struct set_precise_binary_< Name, mln::value::graylevel_f, mln::value::graylevel<n> >
+ // {
+ // typedef mln::value::internal::gray_f ret;
+ // };
+
+ // template <>
+ // struct set_precise_binary_< op::greater, mln::value::graylevel_f, mln::value::graylevel_f >
+ // {
+ // typedef bool ret;
+ // };
+
+ // template <>
+ // struct set_precise_binary_< op::eq, mln::value::graylevel_f, mln::value::graylevel_f >
+ // {
+ // typedef bool ret;
+ // };
+
+
+ //
+ template <>
+ struct set_precise_binary_< op::plus, mln::value::graylevel_f, mln::value::graylevel_f >
{
typedef mln::value::internal::gray_f ret;
};
template <>
- struct set_precise_binary_< op::greater, mln::value::graylevel_f, mln::value::graylevel_f >
+ struct set_precise_binary_< op::minus, mln::value::graylevel_f, mln::value::graylevel_f >
{
- typedef bool ret;
+ typedef mln::value::internal::gray_f ret;
};
template <>
- struct set_precise_binary_< op::eq, mln::value::graylevel_f, mln::value::graylevel_f >
+ struct set_precise_binary_< op::times, mln::value::graylevel_f, mln::value::graylevel_f >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+
+ template <>
+ struct set_precise_binary_< op::div, mln::value::graylevel_f, mln::value::graylevel_f >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+
+ template < typename I >
+ struct set_binary_< op::times,
+ mln::value::Integer, mln::value::graylevel_f,
+ mln::value::Integer, I >
{
- typedef bool ret;
+ typedef mln::value::internal::gray_f ret;
};
+ template < typename I >
+ struct set_binary_< op::times,
+ mln::value::Integer, I,
+ mln::value::Integer, mln::value::graylevel_f >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+
+
+ template < typename F >
+ struct set_binary_< op::times,
+ mln::value::Integer, mln::value::graylevel_f,
+ mln::value::Floating, F >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+
+ template < typename F >
+ struct set_binary_< op::times,
+ mln::value::Floating, F,
+ mln::value::Integer, mln::value::graylevel_f >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+
+
+ template < typename S >
+ struct set_precise_binary_< op::times, mln::value::graylevel_f, mln::value::scalar_<S> >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+
+ template < typename S >
+ struct set_precise_binary_< op::div, mln::value::graylevel_f, mln::value::scalar_<S> >
+ {
+ typedef mln::value::internal::gray_f ret;
+ };
+
+
/// Forward declaration.
template <typename T> struct value_;
@@ -182,6 +262,84 @@
/// Op<<.
std::ostream& operator<<(std::ostream& ostr, const graylevel_f& g);
+ // graylevel_f + graylevel_f
+ mln_trait_op_plus_(graylevel_f, graylevel_f)
+ operator+(const graylevel_f& lhs, const graylevel_f& rhs);
+
+ // graylevel_f + Integer<I> (doesn't compile)
+ template <typename I>
+ graylevel_f
+ operator+(const graylevel_f& lhs, const Integer<I>& i);
+
+ // graylevel_f + Floating<I> (doesn't compile)
+ template <typename I>
+ graylevel_f
+ operator+(const graylevel_f& lhs, const Floating<I>& i);
+
+ // graylevel_f - graylevel_f
+ mln_trait_op_minus_(graylevel_f, graylevel_f)
+ operator-(const graylevel_f& lhs, const graylevel_f& rhs);
+
+ // graylevel_f - Integer<I> (doesn't compile)
+ template <typename I>
+ graylevel_f
+ operator-(const graylevel_f& lhs, const Integer<I>& i);
+
+ // graylevel_f - Floating<I> (doesn't compile)
+ template <typename I>
+ graylevel_f
+ operator-(const graylevel_f& lhs, const Floating<I>& i);
+
+ // graylevel_f * graylevel_f
+ mln_trait_op_times_(graylevel_f, graylevel_f)
+ operator*(const graylevel_f& lhs, const graylevel_f& rhs);
+
+ // With Integer.
+
+ // graylevel_f * Integer<I>
+ template <typename I>
+ mln_trait_op_times(graylevel_f, I)
+ operator*(const graylevel_f& lhs, const Integer<I>& rhs);
+
+ // Integer<I> * graylevel_f
+ template <typename I>
+ mln_trait_op_times(I, graylevel_f)
+ operator*(const Integer<I>& lhs, const graylevel_f& rhs);
+
+ // graylevel_f / Integer<I>
+ template <typename I>
+ mln_trait_op_div(graylevel_f, I)
+ operator/(const graylevel_f& lhs, const Integer<I>& rhs);
+
+ // Integer<I> / graylevel_f
+ template <typename I>
+ mln_trait_op_div(I, graylevel_f)
+ operator/(const Integer<I>& lhs, const graylevel_f& rhs);
+
+ // With Floating.
+
+ // graylevel_f * Floating<F>
+ template <typename F>
+ mln_trait_op_times(graylevel_f, F)
+ operator*(const graylevel_f& lhs, const Floating<F>& rhs);
+
+ // Floating<F>, graylevel_f
+ template <typename F>
+ mln_trait_op_times(F, graylevel_f)
+ operator*(const Floating<F>& lhs, const graylevel_f& rhs);
+
+
+ // graylevel_f / Floating<F>
+ template <typename F>
+ mln_trait_op_div(graylevel_f, F)
+ operator/(const graylevel_f& lhs, const Floating<F>& rhs);
+
+ // Floating<F> / graylevel_f
+ template <typename F>
+ mln_trait_op_div(F, graylevel_f)
+ operator/(const Floating<F>& lhs, const graylevel_f& rhs);
+
+
# ifndef MLN_INCLUDE_ONLY
// graylevel_f.
@@ -195,6 +353,8 @@
inline
graylevel_f::graylevel_f(float val)
{
+ mln_precondition(val >= 0);
+ mln_precondition(val <= 1);
this->v_ = val;
}
@@ -202,6 +362,8 @@
graylevel_f&
graylevel_f::operator=(float val)
{
+ mln_precondition(val >= 0);
+ mln_precondition(val <= 1);
this->v_ = val;
return *this;
}
@@ -209,6 +371,8 @@
template <unsigned n>
graylevel_f::graylevel_f(const graylevel<n>& rhs)
{
+ mln_precondition(rhs.to_float() >= 0);
+ mln_precondition(rhs.to_float() <= 1);
this->v_ = rhs.to_float();
}
@@ -216,12 +380,16 @@
graylevel_f&
graylevel_f::operator=(const graylevel<n>& rhs)
{
+ mln_precondition(rhs.to_float() >= 0);
+ mln_precondition(rhs.to_float() <= 1);
this->v_ = rhs.to_float();
}
inline
graylevel_f::graylevel_f(const graylevel_f& rhs)
{
+ mln_precondition(rhs.v_ >= 0);
+ mln_precondition(rhs.v_ <= 1);
this->v_ = rhs.v_;
}
@@ -229,6 +397,8 @@
graylevel_f&
graylevel_f::operator=(const graylevel_f& rhs)
{
+ mln_precondition(rhs.v_ >= 0);
+ mln_precondition(rhs.v_ <= 1);
this->v_ = rhs.v_;
return *this;
}
@@ -296,4 +466,8 @@
} // end of namespace mln
+
+#include <mln/value/internal/gray_f.hh>
+#include <mln/value/internal/gray_.hh>
+
#endif // ! MLN_VALUE_GRAYLEVEL_F_HH
Index: trunk/milena/mln/value/internal/gray_.hh
===================================================================
--- trunk/milena/mln/value/internal/gray_.hh (revision 1628)
+++ trunk/milena/mln/value/internal/gray_.hh (revision 1629)
@@ -40,8 +40,8 @@
# include <mln/metal/math/max.hh>
# include <mln/metal/math/pow.hh>
-# include <mln/value/graylevel.hh>
-# include <mln/value/graylevel_f.hh>
+//# include <mln/value/graylevel.hh>
+//# include <mln/value/graylevel_f.hh>
# include <mln/value/concept/integer.hh>
@@ -61,7 +61,11 @@
/// \{ Fwd decls.
template <unsigned N> class graylevel;
class graylevel_f;
- namespace internal { template <unsigned n> class gray_; }
+ namespace internal
+ {
+ template <unsigned n> class gray_;
+ class gray_f;
+ }
/// \}
}
@@ -173,7 +177,7 @@
operator graylevel<m>() const;
/// Convertion to graylevel_f.
-// operator graylevel_f() const;
+ operator graylevel_f() const;
};
@@ -305,6 +309,15 @@
}
+ template <unsigned n>
+ inline
+ gray_<n>::operator graylevel_f() const
+ {
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
+ return graylevel_f(float(this->v_) / denom);
+ }
+
+
// Operators.
template <unsigned n>
@@ -464,6 +477,25 @@
return internal::gray_<n>(lhs) + internal::gray_<m>(rhs);
}
+ // Op gl + Another type
+ template <unsigned n, typename I>
+ inline
+ void
+ operator+(const graylevel<n>& lhs, const I& i)
+ {
+ typename graylevel<n>::wrong_use_of_graylevel___Please_use_the__to_enc__method a;
+ }
+
+
+ // Op Another type + gl
+ template <unsigned n, typename I>
+ inline
+ void
+ operator+(const I& i, const graylevel<n>& rhs)
+ {
+ typename graylevel<n>::wrong_use_of_graylevel___Please_use_the__to_enc__method a;
+ }
+
// Op gl - gl
template <unsigned n, unsigned m>
@@ -474,6 +506,25 @@
return internal::gray_<n>(lhs) - internal::gray_<m>(rhs);
}
+ // Op gl - Another type
+ template <unsigned n, typename I>
+ inline
+ void
+ operator-(const graylevel<n>& lhs, const I& i)
+ {
+ typename graylevel<n>::wrong_use_of_graylevel___Please_use_the__to_enc__method a;
+ }
+
+
+ // Op Another type - gl
+ template <unsigned n, typename I>
+ inline
+ void
+ operator-(const I& i, const graylevel<n>& rhs)
+ {
+ typename graylevel<n>::wrong_use_of_graylevel___Please_use_the__to_enc__method a;
+ }
+
// Op gl * gl
template <unsigned n, unsigned m>
@@ -484,11 +535,11 @@
return internal::gray_<n>(lhs) * internal::gray_<m>(rhs);
}
- // Op symm gl * Int
+ // Op symm gl * Integer
template <unsigned n, typename I>
inline
- mln_trait_op_times(graylevel<n>, Integer<I>)
+ internal::gray_<n>
operator*(const graylevel<n>& lhs, const Integer<I>& rhs)
{
return internal::gray_<n>(lhs) * int(exact(rhs));
@@ -496,30 +547,62 @@
template <typename I, unsigned n>
inline
- mln_trait_op_times(Integer<I>, graylevel<n>)
+ mln_trait_op_times(I, graylevel<n>)
operator*(const Integer<I>& lhs, const graylevel<n>& rhs)
{
return internal::gray_<n>(rhs) * int(exact(lhs));
}
- // Op symm gl * Float
+ // Op symm gl * Floating
template <unsigned n, typename F>
inline
- mln_trait_op_times(graylevel<n>, Floating<F>)
+ mln_trait_op_times(graylevel<n>, F)
operator*(const graylevel<n>& lhs, const Floating<F>& rhs)
{
- return lhs.to_float() * exact(rhs);
+ return lhs.to_float() * float(exact(rhs));
}
template <typename F, unsigned n>
inline
- mln_trait_op_times(Floating<F>, graylevel<n>)
+ mln_trait_op_times(F, graylevel<n>)
operator*(const Floating<F>& lhs, const graylevel<n>& rhs)
{
- return rhs.to_float() * exact(lhs);
+ return rhs.to_float() * float(exact(lhs));
}
+ // Op * Builtin
+
+ template <unsigned n, typename T>
+ mln_trait_op_times(graylevel<n>, T)
+ operator*(const graylevel<n>& lhs, const T& rhs)
+ {
+ return lhs * scalar_<T>(rhs);
+ }
+
+ template <unsigned n, typename T>
+ mln_trait_op_times(graylevel<n>, T)
+ operator*(const T& lhs, const graylevel<n>& rhs)
+ {
+ return rhs * scalar_<T>(lhs);
+ }
+
+
+ // Op / Builtin
+
+ /// \{ Fwd decls.
+ namespace internal
+ {
+ class gray_f;
+ }
+ /// \}
+
+ template <unsigned n, typename T>
+ mln::value::internal::gray_f
+ operator/(const graylevel<n>& lhs, const T& rhs)
+ {
+ return lhs / scalar_<T>(rhs);
+ }
// Op * scalar
@@ -534,42 +617,66 @@
struct helper_gray__op_< gray_<n> >
{
template <unsigned m, typename S>
- inline
- static gray_<n> times(const graylevel<m>& lhs, const scalar_<S>& rhs)
- {
- gray_<n> tmp(lhs.value() * rhs.to_equiv());
+ inline static
+ mln_trait_op_times(graylevel<m>, scalar_<S>)
+ times(const graylevel<m>& lhs, const scalar_<S>& rhs)
+ {
+ typedef mln_trait_op_times(graylevel<m>, scalar_<S>) ret;
+ ret tmp(typename ret::equiv
+ (lhs.value() * typename ret::equiv(rhs.to_equiv())));
return tmp;
}
+
+// template <unsigned m, typename S>
+// inline static
+// mln_trait_op_times(graylevel<m>, scalar_<S>)
+// times(const graylevel<m>& lhs, const scalar_<S>& rhs)
+// {
+// typedef mln_trait_op_times(graylevel<m>, scalar_<S>) ret;
+// ret tmp(lhs.value() * rhs.to_equiv());
+// return tmp;
+// }
+
+
template <unsigned m, typename S>
- inline
- static gray_<n> div(const graylevel<m>& lhs, const scalar_<S>& rhs)
- {
- gray_<n> tmp(lhs.value() / rhs.to_equiv());
+ inline static
+ mln_trait_op_times(graylevel<m>, scalar_<S>)
+ div(const graylevel<m>& lhs, const scalar_<S>& rhs)
+ {
+ typedef mln_trait_op_times(graylevel<m>, scalar_<S>) ret;
+ ret tmp(typename ret::equiv
+ (lhs.value() / typename ret::equiv(rhs.to_equiv())));
return tmp;
}
};
template <>
- struct helper_gray__op_< float >
+ struct helper_gray__op_< gray_f >
{
template <unsigned n, typename S>
- inline
- static float times(const graylevel<n>& lhs, const scalar_<S>& rhs)
+ inline static
+ mln_trait_op_times(graylevel<n>, scalar_<S>)
+ times(const graylevel<n>& lhs, const scalar_<S>& rhs)
{
- float tmp(lhs.to_float() * float(rhs.to_equiv()));
+ typedef mln_trait_op_times(graylevel<n>, scalar_<S>) ret;
+ ret tmp(lhs.to_float() * typename ret::equiv(rhs.to_equiv()));
return tmp;
}
template <unsigned n, typename S>
- inline
- static float div(const graylevel<n>& lhs, const scalar_<S>& rhs)
+ inline static
+ mln_trait_op_div(graylevel<n>, scalar_<S>)
+ div(const graylevel<n>& lhs, const scalar_<S>& rhs)
{
- float tmp(lhs.to_float() / float(rhs.to_equiv()));
+ typedef mln_trait_op_div(graylevel<n>, scalar_<S>) ret;
+ ret tmp(typename ret::equiv
+ (lhs.to_float() / typename ret::equiv(rhs.to_equiv())));
return tmp;
}
};
} // end of namespace mln::value::internal
+ // Op graylevel<n> * scalar_<S>
template <unsigned n, typename S>
inline
mln_trait_op_times(graylevel<n>, scalar_<S>)
@@ -579,6 +686,7 @@
return internal::helper_gray__op_<ret>::times(lhs, rhs);
}
+ // Op graylevel<n> / scalar_<S>
template <unsigned n, typename S>
inline
mln_trait_op_div(graylevel<n>, scalar_<S>)
Index: trunk/milena/mln/value/internal/gray_f.hh
===================================================================
--- trunk/milena/mln/value/internal/gray_f.hh (revision 1628)
+++ trunk/milena/mln/value/internal/gray_f.hh (revision 1629)
@@ -39,12 +39,11 @@
# include <mln/core/contract.hh>
# include <mln/metal/math/pow.hh>
-# include <mln/math/two_pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
# include <mln/value/float01_f.hh>
-# include <mln/value/gray.hh>
+//# include <mln/value/internal/gray_.hh>
# include <mln/trait/value_.hh>
@@ -80,11 +79,13 @@
typedef mln::value::gray_f ret;
};
+ template <>
struct set_precise_binary_< op::greater, mln::value::gray_f, mln::value::gray_f >
{
typedef bool ret;
};
+ template <>
struct set_precise_binary_< op::eq, mln::value::gray_f, mln::value::gray_f >
{
typedef bool ret;
@@ -182,6 +183,7 @@
/// \internal Op<<.
std::ostream& operator<<(std::ostream& ostr, const gray_f& g);
+
# ifndef MLN_INCLUDE_ONLY
// gray_f.
@@ -193,8 +195,8 @@
inline
gray_f::gray_f(const gray_f& g)
- : v_(g.v_)
{
+ this->v_ = g.v_;
}
inline
@@ -220,17 +222,16 @@
}
inline
- gray_f&
gray_f::gray_f(const graylevel_f& rhs)
- : v_(rhs.v_)
{
+ this->v_ = rhs.value();
}
inline
gray_f&
- gray_f::gray_f& operator=(const graylevel_f& rhs)
+ gray_f::operator=(const graylevel_f& rhs)
{
- this->v_ = rhs.v_;
+ this->v_ = rhs.value();
return *this;
}
@@ -238,7 +239,7 @@
inline
gray_f::operator graylevel<m>() const
{
- return graylevel<m>(round(this->v_ * (mlc_pow_int(2, m) - 1)));
+ return graylevel<m>(int(round(this->v_ * (mlc_pow_int(2, m) - 1))));
}
inline
@@ -266,6 +267,145 @@
} // end of namespace mln::value::internal
+
+ // Graylevel_F operators.
+
+ // Op glf == Int
+
+ template <typename I>
+ inline
+ bool
+ operator==(const Integer<I>& lhs, const graylevel_f& rhs)
+ {
+ return rhs.value() == exact(lhs);
+ }
+
+ // Op glf == glf
+ inline
+ bool
+ operator==(const graylevel_f& lhs, const graylevel_f& rhs)
+ {
+ return rhs.value() == lhs.value();
+ }
+
+ // Op glf + glf
+ inline
+ mln_trait_op_plus_(graylevel_f, graylevel_f)
+ operator+(const graylevel_f& lhs, const graylevel_f& rhs)
+ {
+ return lhs.value() + rhs.value();
+ }
+
+ // Op glf + Integer
+ template <typename I>
+ inline
+ graylevel_f
+ operator+(const graylevel_f& lhs, const Integer<I>& i)
+ {
+ typename I::graylevel_f_plus_int_is_undefined__Please_use_the__to_enc__method a;
+ }
+
+// // Op glf + Float
+// template <typename I>
+// inline
+// graylevel_f
+// operator+(const graylevel_f& lhs, const Floating<I>& i)
+// {
+// typename I::graylevel_f_plus_float_is_undefined__Please_use_the__to_enc__method a;
+// }
+
+ // Op glf - glf
+
+ inline
+ mln_trait_op_minus_(graylevel_f, graylevel_f)
+ operator-(const graylevel_f& lhs, const graylevel_f& rhs)
+ {
+ return lhs.value() - rhs.value();
+ }
+
+ // Op glf - Integer
+ template <typename I>
+ inline
+ graylevel_f
+ operator-(const graylevel_f& lhs, const Integer<I>& i)
+ {
+ typename I::graylevel_f_minus_int_is_undefined__Please_use_the__to_enc__method a;
+ }
+
+ // Op glf - Float
+ template <typename I>
+ inline
+ graylevel_f
+ operator-(const graylevel_f& lhs, const Floating<I>& i)
+ {
+ typename I::graylevel_f_minus_float_is_undefined__Please_use_the__to_enc__method a;
+ }
+
+ // Op glf * glf
+ inline
+ mln_trait_op_times_(graylevel_f, graylevel_f)
+ operator*(const graylevel_f& lhs, const graylevel_f& rhs)
+ {
+ return lhs.value() * rhs.value();
+ }
+
+ // Op symm glf * Int
+
+ template <typename I>
+ inline
+ mln_trait_op_times(graylevel_f, I)
+ operator*(const graylevel_f& lhs, const Integer<I>& rhs)
+ {
+ return lhs.value() * int(exact(rhs));
+ }
+
+ template <typename I>
+ inline
+ mln_trait_op_times(I, graylevel_f)
+ operator*(const Integer<I>& lhs, const graylevel_f& rhs)
+ {
+ return rhs.value() * int(exact(lhs));
+ }
+
+ // Op symm glf * Float
+
+ template <typename F>
+ inline
+ mln_trait_op_times(graylevel_f, F)
+ operator*(const graylevel_f& lhs, const Floating<F>& rhs)
+ {
+ return lhs.value() * exact(rhs);
+ }
+
+ template <typename F>
+ inline
+ mln_trait_op_times(F, graylevel_f)
+ operator*(const Floating<F>& lhs, const graylevel_f& rhs)
+ {
+ return rhs.value() * exact(lhs);
+ }
+
+
+
+ // Op * scalar
+ template <typename S>
+ inline
+ mln_trait_op_times(graylevel_f, S)
+ operator*(const graylevel_f& lhs, const scalar_<S>& rhs)
+ {
+ return lhs.value() * rhs;
+ }
+
+ // Op / scalar
+ template <typename S>
+ inline
+ mln_trait_op_div(graylevel_f, S)
+ operator/(const graylevel_f& lhs, const scalar_<S>& rhs)
+ {
+ mln_precondition(rhs.to_equiv() != 0);
+ return lhs.value() / rhs;
+ }
+
} // end of namespace mln::value
} // end of namespace mln
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-01-02 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix and update morpho and util tests.
* tests/util/tree_fast_to_image.cc,
* tests/util/tree_to_image.cc,
* tests/morpho/contrast.cc,
* tests/morpho/dilation.cc,
* tests/morpho/dilation_max_h.cc,
* tests/morpho/erosion.cc,
* tests/morpho/erosion_min_h.cc,
* tests/morpho/gradient.cc,
* tests/morpho/hit_or_miss.cc,
* tests/morpho/laplacian.cc,
* tests/morpho/opening_area.cc,
* tests/morpho/thinning.cc: Fix path of images and update brief.
---
morpho/contrast.cc | 4 ++--
morpho/dilation.cc | 4 ++--
morpho/dilation_max_h.cc | 4 ++--
morpho/erosion.cc | 4 ++--
morpho/erosion_min_h.cc | 4 ++--
morpho/gradient.cc | 4 ++--
morpho/hit_or_miss.cc | 4 ++--
morpho/laplacian.cc | 4 ++--
morpho/opening_area.cc | 4 ++--
morpho/thinning.cc | 4 ++--
util/tree_fast_to_image.cc | 1 +
util/tree_to_image.cc | 15 ++++++++-------
12 files changed, 29 insertions(+), 27 deletions(-)
Index: trunk/milena/tests/util/tree_fast_to_image.cc
===================================================================
--- trunk/milena/tests/util/tree_fast_to_image.cc (revision 1627)
+++ trunk/milena/tests/util/tree_fast_to_image.cc (revision 1628)
@@ -131,6 +131,7 @@
};
+ debug::printl (output);
image2d<int_u8> ref (make::image2d(vs));
mln_assertion(ref == output);
}
Index: trunk/milena/tests/util/tree_to_image.cc
===================================================================
--- trunk/milena/tests/util/tree_to_image.cc (revision 1627)
+++ trunk/milena/tests/util/tree_to_image.cc (revision 1628)
@@ -113,6 +113,7 @@
int_u8 vs[16][16] = {
+
{110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
{110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
{110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
@@ -121,14 +122,14 @@
{ 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
{ 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
{ 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
- {180, 180, 0, 0, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
- {180, 180, 0, 0, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
- {180, 180, 0, 0, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
- {180, 180, 0, 0, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
- {180, 180, 0, 0, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
{180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
- { 0, 0, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
- { 0, 0, 0, 0, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}
+ {252, 252, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {252, 252, 252, 252, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}
};
Index: trunk/milena/tests/morpho/contrast.cc
===================================================================
--- trunk/milena/tests/morpho/contrast.cc (revision 1627)
+++ trunk/milena/tests/morpho/contrast.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_contrast.cc
+/*! \file tests/morpho/contrast.cc
*
* \brief Test on mln::morpho::contrast.
*/
@@ -51,7 +51,7 @@
border::thickness = 2;
image2d<int_u8> lena;
- io::pgm::load(lena, "../img/lena.pgm");
+ io::pgm::load(lena, "../../img/lena.pgm");
image2d<int_u8> out = morpho::contrast(lena, rect);
io::pgm::save(out, "out.pgm");
Index: trunk/milena/tests/morpho/gradient.cc
===================================================================
--- trunk/milena/tests/morpho/gradient.cc (revision 1627)
+++ trunk/milena/tests/morpho/gradient.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_gradient.cc
+/*! \file tests/morpho/gradient.cc
*
* \brief Test on mln::morpho::gradient.
*/
@@ -50,7 +50,7 @@
border::thickness = 2;
image2d<int_u8> lena;
- io::pgm::load(lena, "../img/tiny.pgm");
+ io::pgm::load(lena, "../../img/tiny.pgm");
io::pgm::save( morpho::gradient(lena, rect),
"out.pgm" );
Index: trunk/milena/tests/morpho/erosion.cc
===================================================================
--- trunk/milena/tests/morpho/erosion.cc (revision 1627)
+++ trunk/milena/tests/morpho/erosion.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_erosion.cc
+/*! \file tests/morpho/erosion.cc
*
* \brief Test on mln::morpho::erosion.
*/
@@ -75,7 +75,7 @@
// 25 66 15
image2d<int_u8> lena;
- io::pgm::load(lena, "../img/lena.pgm");
+ io::pgm::load(lena, "../../img/lena.pgm");
// trace::quiet = false;
Index: trunk/milena/tests/morpho/thinning.cc
===================================================================
--- trunk/milena/tests/morpho/thinning.cc (revision 1627)
+++ trunk/milena/tests/morpho/thinning.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_thinning.cc
+/*! \file tests/morpho/thinning.cc
*
* \brief Test on mln::morpho::thinning.
*/
@@ -63,7 +63,7 @@
{
image2d<bool> pic;
- io::pbm::load(pic, "../img/picasso.pbm");
+ io::pbm::load(pic, "../../img/picasso.pbm");
io::pbm::save(morpho::thinning(pic, win_fg, win_bg), "out.pbm" );
}
// {
Index: trunk/milena/tests/morpho/hit_or_miss.cc
===================================================================
--- trunk/milena/tests/morpho/hit_or_miss.cc (revision 1627)
+++ trunk/milena/tests/morpho/hit_or_miss.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_hit_or_miss.cc
+/*! \file tests/morpho/hit_or_miss.cc
*
* \brief Test on mln::morpho::hit_or_miss.
*/
@@ -76,7 +76,7 @@
border::thickness = 2;
image2d<bool> pic;
- io::pbm::load(pic, "../img/picasso.pbm");
+ io::pbm::load(pic, "../../img/picasso.pbm");
image2d<bool> out = morpho::hit_or_miss(pic, win_hit, win_miss);
io::pbm::save(out, "out.pbm");
Index: trunk/milena/tests/morpho/dilation_max_h.cc
===================================================================
--- trunk/milena/tests/morpho/dilation_max_h.cc (revision 1627)
+++ trunk/milena/tests/morpho/dilation_max_h.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_dilation_max_h.cc
+/*! \file tests/morpho/dilation_max_h.cc
*
* \brief Test on mln::morpho::dilatation_fast.
*/
@@ -53,7 +53,7 @@
border::thickness = 66;
image2d<int_u8> lena;
- io::pgm::load(lena, "../img/lena.pgm");
+ io::pgm::load(lena, "../../img/lena.pgm");
{
p_array<point2d> vec = convert::to_p_array(rec, point2d::origin);
Index: trunk/milena/tests/morpho/dilation.cc
===================================================================
--- trunk/milena/tests/morpho/dilation.cc (revision 1627)
+++ trunk/milena/tests/morpho/dilation.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_dilation.cc
+/*! \file tests/morpho/dilation.cc
*
* \brief Test on mln::morpho::dilation.
*/
@@ -61,7 +61,7 @@
border::thickness = 66;
image2d<int_u8> lena;
- io::pgm::load(lena, "../img/lena.pgm");
+ io::pgm::load(lena, "../../img/lena.pgm");
// {
// image2d<int_u8> out(lena.domain());
Index: trunk/milena/tests/morpho/laplacian.cc
===================================================================
--- trunk/milena/tests/morpho/laplacian.cc (revision 1627)
+++ trunk/milena/tests/morpho/laplacian.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_laplacian.cc
+/*! \file tests/morpho/laplacian.cc
*
* \brief Test on mln::morpho::laplacian.
*/
@@ -54,7 +54,7 @@
border::thickness = 2;
image2d<int_u8> tiny;
- io::pgm::load(tiny, "../img/tiny.pgm");
+ io::pgm::load(tiny, "../../img/tiny.pgm");
image2d<int> lap(tiny.domain());
morpho::laplacian(tiny, rect, lap);
Index: trunk/milena/tests/morpho/opening_area.cc
===================================================================
--- trunk/milena/tests/morpho/opening_area.cc (revision 1627)
+++ trunk/milena/tests/morpho/opening_area.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_opening_area.cc
+/*! \file tests/morpho/opening_area.cc
*
* \brief Test on mln::morpho::opening_area.
*/
@@ -47,7 +47,7 @@
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, "../img/lena.pgm");
+ io::pgm::load(lena, "../../img/lena.pgm");
image2d<int_u8> out(lena.domain());
morpho::opening_area(lena, c4(), 510, out);
Index: trunk/milena/tests/morpho/erosion_min_h.cc
===================================================================
--- trunk/milena/tests/morpho/erosion_min_h.cc (revision 1627)
+++ trunk/milena/tests/morpho/erosion_min_h.cc (revision 1628)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho_erosion_min_h.cc
+/*! \file tests/morpho/erosion_min_h.cc
*
* \brief Test on mln::morpho::erosion_fast
*/
@@ -53,7 +53,7 @@
border::thickness = 66;
image2d<int_u8> lena;
- io::pgm::load(lena, "../img/lena.pgm");
+ io::pgm::load(lena, "../../img/lena.pgm");
{
p_array<point2d> vec = convert::to_p_array(rec, point2d::origin);
1
0
01 Jan '08
Happy New Year!
I wanted to recall that as of today, files altered by patches in the
Olena Project must mention the year 2008 in their copyright header.
Thanks in advance!
Roland
1
0
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix the tests in tests/morpho.
* mln/morpho/erosion.spe.hh
(erosion_iterative_(kind::logic, speed::fastest, const I&, const W&)):
Fix the assignment of the out pixter in the case of a non-centered
window.
* mln/value/int_u_sat.hh (mln::value::props< int_u_sat<n> >):
Remove.
Superseded by...
(mln::trait::value_< mln::value::int_u_sat<n> >): ...this (new
specialization).
* mln/set/inter.hh (mln::set::inter): Fix uses of the tracing
mechanism.
* mln/value/int_u.hh: Don't use Doxygen comments to announce
forward declarations.
* tests/morpho/contrast.cc,
* tests/morpho/dilation.cc,
* tests/morpho/dilation_max_h.cc,
* tests/morpho/erosion.cc,
* tests/morpho/erosion_min_h.cc,
* tests/morpho/gradient.cc,
* tests/morpho/hit_or_miss.cc,
* tests/morpho/laplacian.cc,
* tests/morpho/opening_area.cc,
* tests/morpho/thinning.cc:
Catch up with the new I/O interface of Milena.
mln/morpho/erosion.spe.hh | 13 +++++++++-
mln/set/inter.hh | 6 ++--
mln/value/int_u.hh | 6 +---
mln/value/int_u_sat.hh | 50 +++++++++++++++++++++++++++--------------
tests/morpho/contrast.cc | 5 ++--
tests/morpho/dilation.cc | 5 ++--
tests/morpho/dilation_max_h.cc | 5 ++--
tests/morpho/erosion.cc | 5 ++--
tests/morpho/erosion_min_h.cc | 5 ++--
tests/morpho/gradient.cc | 5 ++--
tests/morpho/hit_or_miss.cc | 8 +++---
tests/morpho/laplacian.cc | 9 ++++---
tests/morpho/opening_area.cc | 8 +++---
tests/morpho/thinning.cc | 8 +++---
14 files changed, 86 insertions(+), 52 deletions(-)
Index: milena/tests/morpho/contrast.cc
--- milena/tests/morpho/contrast.cc (revision 1626)
+++ milena/tests/morpho/contrast.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -50,7 +50,8 @@
win::rectangle2d rect(5, 5);
border::thickness = 2;
- image2d<int_u8> lena = io::pgm::load("../img/tiny.pgm");
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../img/lena.pgm");
image2d<int_u8> out = morpho::contrast(lena, rect);
io::pgm::save(out, "out.pgm");
Index: milena/tests/morpho/gradient.cc
--- milena/tests/morpho/gradient.cc (revision 1626)
+++ milena/tests/morpho/gradient.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -49,7 +49,8 @@
win::rectangle2d rect(5, 5);
border::thickness = 2;
- image2d<int_u8> lena = io::pgm::load("../img/tiny.pgm");
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../img/tiny.pgm");
io::pgm::save( morpho::gradient(lena, rect),
"out.pgm" );
Index: milena/tests/morpho/erosion.cc
--- milena/tests/morpho/erosion.cc (revision 1626)
+++ milena/tests/morpho/erosion.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -74,7 +74,8 @@
// 11 29 1
// 25 66 15
- image2d<int_u8> lena = io::pgm::load("../img/lena.pgm");
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../img/lena.pgm");
// trace::quiet = false;
Index: milena/tests/morpho/thinning.cc
--- milena/tests/morpho/thinning.cc (revision 1626)
+++ milena/tests/morpho/thinning.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -62,9 +62,9 @@
border::thickness = 2;
{
- image2d<bool> pic = io::pbm::load("../img/picasso.pbm");
- io::pbm::save( morpho::thinning(pic, win_fg, win_bg),
- "out.pbm" );
+ image2d<bool> pic;
+ io::pbm::load(pic, "../img/picasso.pbm");
+ io::pbm::save(morpho::thinning(pic, win_fg, win_bg), "out.pbm" );
}
// {
// image2d<int_u8> pic = io::pgm::load("../img/picasso.pgm");
Index: milena/tests/morpho/dilation_max_h.cc
--- milena/tests/morpho/dilation_max_h.cc (revision 1626)
+++ milena/tests/morpho/dilation_max_h.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -52,7 +52,8 @@
win::rectangle2d rec(21, 21);
border::thickness = 66;
- image2d<int_u8> lena = io::pgm::load("../img/lena.pgm");
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../img/lena.pgm");
{
p_array<point2d> vec = convert::to_p_array(rec, point2d::origin);
Index: milena/tests/morpho/hit_or_miss.cc
--- milena/tests/morpho/hit_or_miss.cc (revision 1626)
+++ milena/tests/morpho/hit_or_miss.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -75,9 +75,9 @@
border::thickness = 2;
- image2d<bool>
- pic = io::pbm::load("../img/picasso.pbm"),
- out = morpho::hit_or_miss(pic, win_hit, win_miss);
+ image2d<bool> pic;
+ io::pbm::load(pic, "../img/picasso.pbm");
+ image2d<bool> out = morpho::hit_or_miss(pic, win_hit, win_miss);
io::pbm::save(out, "out.pbm");
mln_postcondition(morpho::hit_or_miss(morpho::complementation(pic),
Index: milena/tests/morpho/dilation.cc
--- milena/tests/morpho/dilation.cc (revision 1626)
+++ milena/tests/morpho/dilation.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -60,7 +60,8 @@
win::rectangle2d rec(21, 21);
border::thickness = 66;
- image2d<int_u8> lena = io::pgm::load("../img/lena.pgm");
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../img/lena.pgm");
// {
// image2d<int_u8> out(lena.domain());
Index: milena/tests/morpho/laplacian.cc
--- milena/tests/morpho/laplacian.cc (revision 1626)
+++ milena/tests/morpho/laplacian.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -53,9 +53,10 @@
win::rectangle2d rect(5, 5);
border::thickness = 2;
- image2d<int_u8> lena = io::pgm::load("../img/tiny.pgm");
- image2d<int> lap(lena.domain());
- morpho::laplacian(lena, rect, lap);
+ image2d<int_u8> tiny;
+ io::pgm::load(tiny, "../img/tiny.pgm");
+ image2d<int> lap(tiny.domain());
+ morpho::laplacian(tiny, rect, lap);
io::pgm::save( arith::plus_cst< value::int_u_sat<8> >(lap, 128),
"out.pgm" );
Index: milena/tests/morpho/opening_area.cc
--- milena/tests/morpho/opening_area.cc (revision 1626)
+++ milena/tests/morpho/opening_area.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -46,9 +46,9 @@
using namespace mln;
using value::int_u8;
- image2d<int_u8>
- lena = io::pgm::load("../img/lena.pgm"),
- out(lena.domain());
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../img/lena.pgm");
+ image2d<int_u8> out(lena.domain());
morpho::opening_area(lena, c4(), 510, out);
io::pgm::save(out, "out.pgm");
Index: milena/tests/morpho/erosion_min_h.cc
--- milena/tests/morpho/erosion_min_h.cc (revision 1626)
+++ milena/tests/morpho/erosion_min_h.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -52,7 +52,8 @@
win::rectangle2d rec(21, 21);
border::thickness = 66;
- image2d<int_u8> lena = io::pgm::load("../img/lena.pgm");
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../img/lena.pgm");
{
p_array<point2d> vec = convert::to_p_array(rec, point2d::origin);
Index: milena/mln/value/int_u.hh
--- milena/mln/value/int_u.hh (revision 1626)
+++ milena/mln/value/int_u.hh (working copy)
@@ -51,17 +51,15 @@
namespace value
{
- /// \{ Fwd decls.
+ // Fwd decls.
template <unsigned n> struct int_u;
- /// \}
}
namespace literal
{
- /// \{ Fwd decls.
+ // Fwd decls.
struct zero_t;
struct one_t;
- /// \}
}
Index: milena/mln/value/int_u_sat.hh
--- milena/mln/value/int_u_sat.hh (revision 1626)
+++ milena/mln/value/int_u_sat.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -47,6 +47,35 @@
namespace value
{
+ // Fwd decls.
+ template <unsigned n> struct int_u_sat;
+ }
+
+ namespace trait
+ {
+
+ template <unsigned n>
+ struct value_< mln::value::int_u_sat<n> >
+ {
+ // FIXME: Overhaul these traits (see other value traits).
+ static const std::size_t card = metal::math::pow_int<2, n>::value;
+ static const mln::value::int_u_sat<n> min() { return 0; }
+ static const mln::value::int_u_sat<n> max() { return card - 1; }
+ static const unsigned nbits = n;
+
+ typedef trait::value::nature::integer nature;
+ typedef trait::value::kind::data kind;
+ // FIXME: Is that right?
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef float sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace value
+ {
/*! \brief Unsigned integer value class with saturation behavior.
@@ -90,24 +119,10 @@
// Safety.
+ // FIXME: We shouldn't have to do that.
template <> struct int_u_sat<0>;
template <> struct int_u_sat<1>;
-
-
- template <unsigned n>
- struct props< int_u_sat<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const int_u_sat<n> min() { return 0; }
- static const int_u_sat<n> max() { return card_ - 1; }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- };
-
-
-
/*! \brief Print a saturated unsigned integer \p i into the output
* stream \p ostr.
*
@@ -135,6 +150,9 @@
static const unsigned max_ = mln_max(int_u<n>);
if (i < 0)
this->v_ = 0;
+ // FIXME: This comparison triggers a warning between signed and
+ // unsigned values from the compiler. If it is valid, use a
+ // cast and leave a comment about it.
else if (i > max_)
this->v_ = max_;
else
Index: milena/mln/set/inter.hh
--- milena/mln/set/inter.hh (revision 1626)
+++ milena/mln/set/inter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -80,8 +80,8 @@
std::set_intersection(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
- return convert::to_window(s);
trace::exiting("set::inter");
+ return convert::to_window(s);
}
template <typename Wl, typename Wr>
@@ -99,8 +99,8 @@
std::set_intersection(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
- return convert::to_p_set(s);
trace::exiting("set::inter");
+ return convert::to_p_set(s);
}
# endif // ! MLN_INCLUDE_ONLY
Index: milena/mln/morpho/erosion.spe.hh
--- milena/mln/morpho/erosion.spe.hh (revision 1626)
+++ milena/mln/morpho/erosion.spe.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -178,10 +178,14 @@
mln_pixter(O) p_out(output);
for_all_2(p, p_out)
+ // Consider P only if its value is `true' (the erosion
+ // is anti-extensive).
if (p.val())
for_all(q)
if (! q.val())
{
+ // Assign `false' to the value of P_OUT as soon
+ // as a `false' value is found in its vicinity.
p_out.val() = false;
break;
}
@@ -194,10 +198,17 @@
mln_pixter(O) p_out(output);
for_all_2(p, p_out)
for_all(q)
+ {
+ // Stop as soon as a `false' value is found the
+ // window.
if (! q.val())
break;
+ // If a `false' value was not found, then Q is now
+ // invalid (past the end of the window), and vice
+ // versa. Use this information to assign P_OUT.
p_out.val() = ! q.is_valid();
}
+ }
trace::exiting("morpho::impl::erosion_iterative_(kind::logic, speed::fastest)");
return output;
1
0