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
- 9625 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix bug.
* mln/border/duplicate.hh: Fix bug (move a line upper).
---
duplicate.hh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: trunk/milena/mln/border/duplicate.hh
===================================================================
--- trunk/milena/mln/border/duplicate.hh (revision 1518)
+++ trunk/milena/mln/border/duplicate.hh (revision 1519)
@@ -198,10 +198,11 @@
{
trace::entering("border::duplicate");
+ const I& ima = exact(ima_);
mln_precondition(ima.has_data());
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
- const I& ima = exact(ima_);
+
typedef mln_point(I) P;
if (!ima.border ())
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory border ready for rereading.
* mln/border/all.hh: Update with all headers.
* mln/border/mirror.hh: Add 2d version.
* mln/border/adjust.hh,
* mln/border/duplicate.hh,
* mln/border/equalize.hh,
* mln/border/fill.hh,
* mln/border/find.hh,
* mln/border/resize.hh,
* mln/border/get.hh: Check typo and tracing.
Tests
* tests/border/equalize.cc,
* tests/border/mirror.cc: New test for these algorithms.
* tests/border/Makefile.am: Add previous tests.
---
mln/border/adjust.hh | 3 -
mln/border/all.hh | 13 ++++--
mln/border/duplicate.hh | 23 ++++++----
mln/border/equalize.hh | 40 ++++++++++++++----
mln/border/fill.hh | 13 +++++-
mln/border/find.hh | 10 ++++
mln/border/get.hh | 10 ++++
mln/border/mirror.hh | 101 +++++++++++++++++++++++++++++++++++++++++++++--
mln/border/resize.hh | 2
tests/border/Makefile.am | 4 +
tests/border/equalize.cc | 46 +++++++++++++++++++++
tests/border/mirror.cc | 90 +++++++++++++++++++++++++++++++++++++++++
12 files changed, 328 insertions(+), 27 deletions(-)
Index: trunk/milena/tests/border/equalize.cc
===================================================================
--- trunk/milena/tests/border/equalize.cc (revision 0)
+++ trunk/milena/tests/border/equalize.cc (revision 1518)
@@ -0,0 +1,46 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/border/equalize.cc
+ *
+ * \brief Tests on mln::border::equalize.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/border/get.hh>
+#include <mln/border/equalize.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima1(3,3, 36);
+ image2d<int> ima2(3,3, 42);
+ border::equalize(ima1, ima2, 51);
+ mln_assertion(border::get(ima1) == 51);
+ mln_assertion(border::get(ima2) == 51);
+}
Index: trunk/milena/tests/border/Makefile.am
===================================================================
--- trunk/milena/tests/border/Makefile.am (revision 1517)
+++ trunk/milena/tests/border/Makefile.am (revision 1518)
@@ -5,16 +5,20 @@
check_PROGRAMS = \
adjust \
duplicate \
+ equalize \
fill \
find \
get \
+ mirror \
resize
adjust_SOURCES = adjust.cc
duplicate_SOURCES = duplicate.cc
+equalize_SOURCES = equalize.cc
fill_SOURCES = fill.cc
find_SOURCES = find.cc
get_SOURCES = get.cc
+mirror_SOURCES = mirror.cc
resize_SOURCES = resize.cc
TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/border/mirror.cc
===================================================================
--- trunk/milena/tests/border/mirror.cc (revision 0)
+++ trunk/milena/tests/border/mirror.cc (revision 1518)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/border_duplicate/test_border_duplicate_image2d_1.cc
+ *
+ * \brief Tests on mln::border::duplicate.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/border/mirror.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ image2d<int> ima(2, 3, 2);
+
+ debug::iota(ima);
+ border::mirror(ima);
+
+ mln_assertion(ima[ 0] == 1);
+ mln_assertion(ima[ 1] == 1);
+ mln_assertion(ima[ 2] == 4);
+ mln_assertion(ima[ 3] == 5);
+ mln_assertion(ima[ 4] == 6);
+ mln_assertion(ima[ 5] == 3);
+ mln_assertion(ima[ 6] == 3);
+ mln_assertion(ima[ 7] == 1);
+ mln_assertion(ima[ 8] == 1);
+ mln_assertion(ima[ 9] == 1);
+ mln_assertion(ima[10] == 2);
+ mln_assertion(ima[11] == 3);
+ mln_assertion(ima[12] == 3);
+ mln_assertion(ima[13] == 3);
+ mln_assertion(ima[14] == 2);
+ mln_assertion(ima[15] == 1);
+ mln_assertion(ima[16] == 1);
+ mln_assertion(ima[17] == 2);
+ mln_assertion(ima[18] == 3);
+ mln_assertion(ima[19] == 3);
+ mln_assertion(ima[20] == 2);
+ mln_assertion(ima[21] == 5);
+ mln_assertion(ima[22] == 4);
+ mln_assertion(ima[23] == 4);
+ mln_assertion(ima[24] == 5);
+ mln_assertion(ima[25] == 6);
+ mln_assertion(ima[26] == 6);
+ mln_assertion(ima[27] == 5);
+ mln_assertion(ima[28] == 4);
+ mln_assertion(ima[29] == 4);
+ mln_assertion(ima[30] == 4);
+ mln_assertion(ima[31] == 5);
+ mln_assertion(ima[32] == 6);
+ mln_assertion(ima[33] == 6);
+ mln_assertion(ima[34] == 6);
+ mln_assertion(ima[35] == 4);
+ mln_assertion(ima[36] == 4);
+ mln_assertion(ima[37] == 1);
+ mln_assertion(ima[38] == 2);
+ mln_assertion(ima[39] == 3);
+ mln_assertion(ima[40] == 6);
+ mln_assertion(ima[41] == 6);
+}
+
Index: trunk/milena/mln/border/resize.hh
===================================================================
--- trunk/milena/mln/border/resize.hh (revision 1517)
+++ trunk/milena/mln/border/resize.hh (revision 1518)
@@ -95,6 +95,7 @@
void resize(const Image<I>& ima_, unsigned thickness)
{
trace::entering("border::resize");
+
mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -106,6 +107,7 @@
ima, thickness);
mln_postcondition(border::get(ima) == thickness);
+
trace::exiting("border::resize");
}
Index: trunk/milena/mln/border/fill.hh
===================================================================
--- trunk/milena/mln/border/fill.hh (revision 1517)
+++ trunk/milena/mln/border/fill.hh (revision 1518)
@@ -50,7 +50,7 @@
*
* \pre \p ima has to be initialized.
*
- * \todo Implement it + optimize with memset if possible.
+ * \todo Optimize with memset if possible.
*/
template <typename I>
void fill(const Image<I>& ima, const mln_value(I)& v);
@@ -63,6 +63,8 @@
template <typename I>
void fill_size_1_(const I& ima, const mln_value(I)& v)
{
+ trace::entering("border::impl::fill_size_1_");
+
typedef mln_point(I) P;
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
@@ -80,11 +82,15 @@
std::memset((void*)&ima[st],
*(const int*)(&v),
ima.ncells () - st);
+
+ trace::exiting("border::impl::fill_size_1_");
}
template <typename I>
void fill_size_n_(const I& ima, const mln_value(I)& v)
{
+ trace::entering("border::impl::fill_size_n_");
+
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
std::size_t len_r = ima.bbox().len(P::dim - 1);
@@ -99,15 +105,19 @@
}
for (std::size_t i = st; i < ima.ncells (); ++i)
const_cast<I&>(ima)[i] = v;
+
+ trace::exiting("border::impl::fill_size_n_");
}
}
+
// Facade.
template <typename I>
void fill(const Image<I>& ima_, const mln_value(I)& v)
{
trace::entering("border::fill");
+
typedef mln_point(I) P;
const I& ima = exact(ima_);
@@ -119,6 +129,7 @@
impl::fill_size_1_(ima, v);
else
impl::fill_size_n_(ima, v);
+
trace::exiting("border::fill");
}
Index: trunk/milena/mln/border/all.hh
===================================================================
--- trunk/milena/mln/border/all.hh (revision 1517)
+++ trunk/milena/mln/border/all.hh (revision 1518)
@@ -41,18 +41,25 @@
namespace border
{
/// Implementation namespace of border namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of border namespace.
+ namespace generic {}
+
}
}
+}
+# include <mln/border/adjust.hh>
# include <mln/border/duplicate.hh>
+# include <mln/border/equalize.hh>
# include <mln/border/fill.hh>
+# include <mln/border/find.hh>
+# include <mln/border/get.hh>
# include <mln/border/mirror.hh>
# include <mln/border/resize.hh>
-# include <mln/border/adjust.hh>
-# include <mln/border/equalize.hh>
# include <mln/border/thickness.hh>
Index: trunk/milena/mln/border/duplicate.hh
===================================================================
--- trunk/milena/mln/border/duplicate.hh (revision 1517)
+++ trunk/milena/mln/border/duplicate.hh (revision 1518)
@@ -52,7 +52,7 @@
*
* \pre \p ima has to be initialized.
*
- * \todo Implement it + optimize with memcpy if possible.
+ * \todo Optimize with memcpy if possible.
*/
template <typename I>
void duplicate(const Image<I>& ima);
@@ -66,7 +66,7 @@
template <typename I>
void duplicate_1d_(const I& ima)
{
- mln_precondition(ima.has_data());
+ trace::entering("border::impl::duplicate_1d_");
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
@@ -79,12 +79,14 @@
std::size_t st = border + len_c - 1;
for (std::size_t i = st + 1; i < ima.ncells (); ++i)
const_cast<I&>(ima)[i] = ima[st];
+
+ trace::exiting("border::impl::duplicate_1d_");
}
template <typename I>
void duplicate_2d_(const I& ima)
{
- mln_precondition(ima.has_data());
+ trace::entering("border::impl::duplicate_2d_");
typedef mln_point(I) P;
typename I::line_piter pl(ima.domain());
@@ -117,11 +119,15 @@
for (std::size_t k = 1; k <= border; ++k)
for (std::size_t i = st; i < st + real_len_c; ++i)
const_cast<I&>(ima)[k * real_len_c + i] = ima[i];
+
+ trace::exiting("border::impl::duplicate_2d_");
}
template <typename I>
void duplicate_3d_(const Image<I>& ima_)
{
+ trace::entering("border::impl::duplicate_3d_");
+
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -178,9 +184,9 @@
for (std::size_t k = 1; k <= border; ++k)
for (std::size_t i = 0; i < face; ++i)
const_cast<I&>(ima)[st + k * face + i] = ima[st + i];
- }
-
+ trace::exiting("border::impl::duplicate_3d_");
+ }
} // end of namespace mln::border::impl
@@ -190,13 +196,14 @@
template <typename I>
void duplicate(const Image<I>& ima_)
{
- mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
- const I& ima = exact(ima_);
- typedef mln_point(I) P;
trace::entering("border::duplicate");
mln_precondition(ima.has_data());
+ mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
+ const I& ima = exact(ima_);
+ typedef mln_point(I) P;
+
if (!ima.border ())
return;
Index: trunk/milena/mln/border/mirror.hh
===================================================================
--- trunk/milena/mln/border/mirror.hh (revision 1517)
+++ trunk/milena/mln/border/mirror.hh (revision 1518)
@@ -51,7 +51,7 @@
*
* \pre \p ima has to be initialized.
*
- * \todo Implement it + optimize with memset if possible.
+ * \todo Implement 1d and 3d version + optimize with memset if possible.
*/
template <typename I>
void mirror(const Image<I>& ima);
@@ -59,15 +59,110 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
+ template <typename I>
+ void mirror_1d_(const I& ima)
+ {
+ mln::internal::fixme();
+ }
+
+ template <typename I>
+ void mirror_2d_(const I& ima)
+ {
+ trace::entering("border::impl::mirror_2d_");
+
+ std::size_t border = ima.border ();
+ std::size_t nbrows = geom::max_row(ima) - geom::min_row(ima);
+ std::size_t nbcols = geom::max_col(ima) - geom::min_col(ima);
+ std::size_t real_nbcols = (nbcols + 1) + 2 * border;
+ std::size_t start = real_nbcols * border + border;
+ std::size_t s = start;
+
+ // duplicate top left corner
+ for (std::size_t i = 0; i < border; ++i)
+ for (std::size_t j = 0; j < border; ++j)
+ const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + j] = ima[s];
+
+ // duplicate top left corner
+ s = start + nbcols;
+ for (std::size_t i = 0; i < border; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + (nbcols + border + j)] = ima[s];
+
+ // duplicate bottom left corner
+ s = start + (nbrows * real_nbcols);
+ for (std::size_t i = 1; i <= border; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s - i + (j * (real_nbcols))] = ima[s];
+
+ // duplicate bottom right corner
+ s = start + (nbrows * real_nbcols) + nbcols;
+ for (std::size_t i = 1; i <= border; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s];
+
+ // mirror top border
+ s = start;
+ for (std::size_t i = 0; i <= nbcols; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + i - (j * real_nbcols)] = ima[s + i + ((j - 1)* real_nbcols)];
+
+ // mirror left border
+ s = start;
+ for (std::size_t i = 0; i <= nbrows; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + (i * real_nbcols) - j] = ima[s + (i * real_nbcols) + (j - 1)];
+
+ // mirror right border
+ s = start;
+ for (std::size_t i = 0; i <= nbrows; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + (i * real_nbcols + nbcols) + j] = ima[s + (i * real_nbcols + nbcols) - (j - 1)];
+
+ // mirror bottom border
+ s = start + (nbrows * real_nbcols);
+ for (std::size_t i = 0; i <= nbcols; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s + i - ((j - 1)* real_nbcols)];
+
+ trace::exiting("border::impl::mirror_2d_");
+ }
+
+ template <typename I>
+ void mirror_3d_(const I& ima)
+ {
+ mln::internal::fixme();
+ }
+
+
+ } // end of namespace mln::border::mirror
+
+
template <typename I>
void mirror(const Image<I>& ima_)
{
+ trace::entering("border::mirror");
+
const I& ima = exact(ima_);
+ mln_precondition(ima.has_data());
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
- mln_precondition(ima.has_data());
- mln::internal::fixme();
+ typedef mln_point(I) P;
+
+ if (!ima.border ())
+ return;
+
+ if (P::dim == 1)
+ impl::mirror_1d_(ima);
+ if (P::dim == 2)
+ impl::mirror_2d_(ima);
+ if (P::dim == 3)
+ impl::mirror_3d_(ima);
+
+ trace::exiting("border::mirror");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/border/adjust.hh
===================================================================
--- trunk/milena/mln/border/adjust.hh (revision 1517)
+++ trunk/milena/mln/border/adjust.hh (revision 1518)
@@ -58,13 +58,13 @@
void adjust(const Image<I>& ima, unsigned min_thickness);
-
# ifndef MLN_INCLUDE_ONLY
template <typename I>
void adjust(const Image<I>& ima_, unsigned min_thickness)
{
trace::entering("border::adjust");
+
mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -73,6 +73,7 @@
border::resize(ima, min_thickness);
mln_postcondition(border::get(ima) >= min_thickness);
+
trace::exiting("border::adjust");
}
Index: trunk/milena/mln/border/equalize.hh
===================================================================
--- trunk/milena/mln/border/equalize.hh (revision 1517)
+++ trunk/milena/mln/border/equalize.hh (revision 1518)
@@ -50,7 +50,8 @@
* \param[in,out] ima2 The second image whose border is to be equalizeed.
* \param[in] min_thickness The expected border minimum thickness of both images.
*
- * \pre \p ima has to be initialized.
+ * \pre \p ima1 has to be initialized.
+ * \pre \p ima2 has to be initialized.
*
* \warning If both image borders already have the same thickness
* and if this thickness is larger than \p min_thickness, this
@@ -64,18 +65,16 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename I, typename J>
- void equalize(const Image<I>& ima1_, const Image<J>& ima2_,
- unsigned min_thickness)
+ void equalize_(const I& ima1, const J& ima2, unsigned min_thickness)
{
- trace::entering("border::equalize");
- mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
- mlc_is(mln_trait_image_border(J), trait::image::border::some)::check();
- const I& ima1 = exact(ima1_);
- const J& ima2 = exact(ima2_);
- mln_precondition(ima1.has_data() && ima2.has_data());
+ trace::entering("border::impl::equalize_");
unsigned b1 = border::get(ima1), b2 = border::get(ima2);
+
if (! (b1 == b2 && b2 >= min_thickness))
// Something has to be done.
{
@@ -101,9 +100,32 @@
}
}
+ trace::exiting("border::impl::equalize_");
+ }
+
+ } // end of namespace mln::border::impl
+
+
+ // Facade
+
+ template <typename I, typename J>
+ void equalize(const Image<I>& ima1_, const Image<J>& ima2_,
+ unsigned min_thickness)
+ {
+ trace::entering("border::equalize");
+
+ mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
+ mlc_is(mln_trait_image_border(J), trait::image::border::some)::check();
+ const I& ima1 = exact(ima1_);
+ const J& ima2 = exact(ima2_);
+ mln_precondition(ima1.has_data() && ima2.has_data());
+
+ impl::equalize_(ima1, ima2, min_thickness);
+
mln_postcondition(border::get(ima1) == border::get(ima2) &&
border::get(ima1) >= min_thickness &&
border::get(ima2) >= min_thickness);
+
trace::exiting("border::equalize");
}
Index: trunk/milena/mln/border/get.hh
===================================================================
--- trunk/milena/mln/border/get.hh (revision 1517)
+++ trunk/milena/mln/border/get.hh (revision 1518)
@@ -46,6 +46,9 @@
*
* \param[in] ima The image.
* \result The border thickness (0 if there is no border).
+ *
+ * \pre \p ima has to be initialized.
+ *
*/
template <typename I>
unsigned get(const Image<I>& ima);
@@ -86,9 +89,14 @@
template <typename I>
unsigned get(const Image<I>& ima)
{
+ trace::entering("border::get");
+
mln_precondition(exact(ima).has_data());
- return border::impl::get_(mln_trait_image_border(I)(), mln_trait_image_category(I)(),
+ unsigned res = border::impl::get_(mln_trait_image_border(I)(), mln_trait_image_category(I)(),
exact(ima));
+
+ trace::exiting("border::get");
+ return res;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/border/find.hh
===================================================================
--- trunk/milena/mln/border/find.hh (revision 1517)
+++ trunk/milena/mln/border/find.hh (revision 1518)
@@ -46,6 +46,9 @@
*
* \param[in] ima The image.
* \result The border thickness (0 if there is no border).
+ *
+ * \pre \p ima has to be initialized.
+ *
*/
template <typename I>
unsigned find(const Image<I>& ima);
@@ -88,8 +91,13 @@
template <typename I>
unsigned find(const Image<I>& ima)
{
+ trace::entering("border::find");
+
mln_precondition(exact(ima).has_data());
- return border::impl::find_(mln_trait_image_speed(I)(), exact(ima));
+ unsigned res = border::impl::find_(mln_trait_image_speed(I)(), exact(ima));
+
+ trace::exiting("border::find");
+ return res;
}
# endif // ! MLN_INCLUDE_ONLY
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix modulus definition involving builtin.
* mln/value/builtin/ops.hh
(mln_internal_def_bi_dvmd_obj_): Fix.
ops.hh | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: mln/value/builtin/ops.hh
--- mln/value/builtin/ops.hh (revision 1516)
+++ mln/value/builtin/ops.hh (working copy)
@@ -239,7 +239,7 @@
mln_trait_op_##Name (value::scalar_< Builtin >, O) \
operator Symb (const Builtin & lhs, const Object<O>& rhs) \
{ \
- return value::scalar(lhs) / exact(rhs); \
+ return value::scalar(lhs) Symb exact(rhs); \
} \
\
struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory draw ready for rereading.
* mln/draw/mesh.hh: Check typo.
---
mesh.hh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: trunk/milena/mln/draw/mesh.hh
===================================================================
--- trunk/milena/mln/draw/mesh.hh (revision 1515)
+++ trunk/milena/mln/draw/mesh.hh (revision 1516)
@@ -42,6 +42,7 @@
namespace mln
{
+
namespace draw
{
@@ -90,7 +91,6 @@
for (unsigned i = 0; i < m.gr_.nb_node_; ++i)
exact(ima)(m.loc_[i]) = node_v;
-
}
template <typename I, typename P, typename V>
@@ -111,8 +111,8 @@
# endif // ! MLN_INCLUDE_ONLY
- } // end of draw
+ } // end of namespace mln::draw
-} // end of mln
+} // end of namespace mln
#endif // MLN_MESH_PSITE_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory logical ready for rereading.
* mln/logical/all.hh,
* mln/logical/and.hh,
* mln/logical/and_not.hh,
* mln/logical/not.hh,
* mln/logical/or.hh: Check typo.
---
all.hh | 8 +++++++-
and.hh | 3 +++
and_not.hh | 1 +
not.hh | 6 ++++++
or.hh | 4 ++++
5 files changed, 21 insertions(+), 1 deletion(-)
Index: trunk/milena/mln/logical/and.hh
===================================================================
--- trunk/milena/mln/logical/and.hh (revision 1514)
+++ trunk/milena/mln/logical/and.hh (revision 1515)
@@ -37,6 +37,7 @@
# include <mln/core/concept/image.hh>
+
// Specializations are in:
# include <mln/logical/and.spe.hh>
@@ -105,6 +106,7 @@
mln_concrete(L) and_(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::and_");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_concrete(L) output;
@@ -120,6 +122,7 @@
void and_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::and_inplace");
+
mln_precondition(exact(rhs).domain() >= exact(lhs).domain());
impl::and__(mln_trait_image_speed(L)(), exact(lhs),
Index: trunk/milena/mln/logical/and_not.hh
===================================================================
--- trunk/milena/mln/logical/and_not.hh (revision 1514)
+++ trunk/milena/mln/logical/and_not.hh (revision 1515)
@@ -37,6 +37,7 @@
# include <mln/core/concept/image.hh>
+
// Specializations are in:
# include <mln/logical/and_not.spe.hh>
Index: trunk/milena/mln/logical/all.hh
===================================================================
--- trunk/milena/mln/logical/all.hh (revision 1514)
+++ trunk/milena/mln/logical/all.hh (revision 1515)
@@ -41,7 +41,13 @@
namespace logical
{
/// Implementation namespace of logical namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of logical namespace.
+ namespace generic {}
+
+ }
+
}
}
Index: trunk/milena/mln/logical/or.hh
===================================================================
--- trunk/milena/mln/logical/or.hh (revision 1514)
+++ trunk/milena/mln/logical/or.hh (revision 1515)
@@ -37,9 +37,11 @@
# include <mln/core/concept/image.hh>
+
// Specializations are in:
# include <mln/logical/or.spe.hh>
+
namespace mln
{
@@ -102,6 +104,7 @@
mln_concrete(L) or_(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::or_");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_concrete(L) output;
@@ -117,6 +120,7 @@
void or_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::or_inplace");
+
mln_precondition(exact(rhs).domain() >= exact(lhs).domain());
impl::or__(mln_trait_image_speed(L)(), exact(lhs),
Index: trunk/milena/mln/logical/not.hh
===================================================================
--- trunk/milena/mln/logical/not.hh (revision 1514)
+++ trunk/milena/mln/logical/not.hh (revision 1515)
@@ -37,6 +37,7 @@
# include <mln/core/concept/image.hh>
+
// Specializations are in:
# include <mln/logical/not.spe.hh>
@@ -65,6 +66,8 @@
* It performs: \n
* for all p of input.domain \n
* input(p) = not input(p)
+ *
+ * \pre \p input.has_data
*/
template <typename I>
void not_inplace(Image<I>& input);
@@ -99,6 +102,7 @@
mln_concrete(I) not_(const Image<I>& input)
{
trace::entering("logical::not");
+
mln_precondition(exact(input).has_data());
mln_concrete(I) output;
@@ -113,8 +117,10 @@
void not_inplace(Image<I>& input)
{
trace::entering("logical::not_inplace");
+
mln_precondition(exact(input).has_data());
impl::not__(mln_trait_image_speed(I)(), exact(input), exact(input));
+
trace::exiting("logical::not_inplace");
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory arith ready for rereading.
* mln/arith/all.hh,
* mln/arith/min.hh,
* mln/arith/min.spe.hh,
* mln/arith/minus.hh,
* mln/arith/plus.hh,
* mln/arith/times.hh: + fix tracing,
* mln/arith/revert.hh: Check typo.
* tests/arith/plus.cc: Update test for not display.
---
mln/arith/all.hh | 14 ++++++--
mln/arith/min.hh | 2 -
mln/arith/min.spe.hh | 1
mln/arith/minus.hh | 15 ++++++---
mln/arith/plus.hh | 12 +++++++
mln/arith/revert.hh | 2 +
mln/arith/times.hh | 16 ++++++++++
tests/arith/plus.cc | 81 +++++++++++++++++++++++++++++++++++----------------
8 files changed, 108 insertions(+), 35 deletions(-)
Index: trunk/milena/tests/arith/plus.cc
===================================================================
--- trunk/milena/tests/arith/plus.cc (revision 1513)
+++ trunk/milena/tests/arith/plus.cc (revision 1514)
@@ -31,18 +31,9 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/clone.hh>
-#include <mln/value/int_u8.hh>
-
+#include <mln/debug/iota.hh>
#include <mln/arith/plus.hh>
-#include <mln/arith/times.hh>
#include <mln/level/compare.hh>
-#include <mln/fun/v2v/cast.hh>
-
-#include <mln/debug/iota.hh>
-#include <mln/debug/println.hh>
-
-
int main()
{
@@ -51,29 +42,69 @@
// trace::quiet = false;
{
- image2d<int> ref(3,3);
- debug::iota(ref);
+ image2d<int> ima(3,3);
+ debug::iota(ima);
- image2d<int> ima_i = clone(ref);
- ima_i += ima_i;
- mln_assertion(ima_i == 2 * ref);
-
- debug::println(ima_i);
- ima_i += 1;
- debug::println(ima_i);
-
- image2d<float> ima_f(3,3);
- debug::iota(ima_f);
- debug::println(ima_i + ima_f);
+ int vs[3][3] = {
+ { 4, 5, 6},
+ { 7, 8, 9},
+ {10, 11, 12}
+ };
- point2d p(0, 0);
- std::cout << arith::plus<float>(ima_i, ima_i)(p) / 5 << std::endl;
+ ima += 2;
+ image2d<int> ref(make::image2d(vs));
+
+ mln_assertion (ima + 1 == ref);
}
}
+// #include <mln/core/image2d.hh>
+// #include <mln/core/clone.hh>
+// #include <mln/value/int_u8.hh>
+
+// #include <mln/arith/plus.hh>
+// #include <mln/arith/times.hh>
+// #include <mln/level/compare.hh>
+// #include <mln/fun/v2v/cast.hh>
+
+// #include <mln/debug/iota.hh>
+// #include <mln/debug/println.hh>
+
+
+
+// int main()
+// {
+// using namespace mln;
+
+// // trace::quiet = false;
+
+// {
+// image2d<int> ref(3,3);
+// debug::iota(ref);
+
+// image2d<int> ima_i = clone(ref);
+// ima_i += ima_i;
+// mln_assertion(ima_i == 2 * ref);
+
+// debug::println(ima_i);
+// ima_i += 1;
+// debug::println(ima_i);
+
+// image2d<float> ima_f(3,3);
+// debug::iota(ima_f);
+// debug::println(ima_i + ima_f);
+
+// point2d p(0, 0);
+// std::cout << arith::plus<float>(ima_i, ima_i)(p) / 5 << std::endl;
+// }
+
+// }
+
+
+
// Bench:
// {
Index: trunk/milena/mln/arith/times.hh
===================================================================
--- trunk/milena/mln/arith/times.hh (revision 1513)
+++ trunk/milena/mln/arith/times.hh (revision 1514)
@@ -221,35 +221,51 @@
template <typename L, typename R, typename O>
void times(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
{
+ trace::entering("arith::times");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_precondition(exact(output).domain() == exact(lhs).domain());
impl::times_(mln_trait_image_speed(L)(), exact(lhs),
mln_trait_image_speed(R)(), exact(rhs),
mln_trait_image_speed(O)(), exact(output));
+
+ trace::exiting("arith::times");
}
template <typename I, typename V, typename O>
void times_cst(const Image<I>& input, const V& val, Image<O>& output)
{
+ trace::entering("arith::times_cst");
+
mln_precondition(exact(output).domain() == exact(input).domain());
times(input, pw::cst(val) | exact(input).domain(), output);
// Calls the previous version.
+
+ trace::exiting("arith::times_cst");
}
template <typename L, typename R>
void times_inplace(Image<L>& lhs, const Image<R>& rhs)
{
+ trace::entering("arith::times_inplace");
+
mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
impl::times_inplace_(mln_trait_image_speed(L)(), exact(lhs),
mln_trait_image_speed(R)(), exact(rhs));
+
+ trace::exiting("arith::times_inplace");
}
template <typename I, typename V>
void times_cst_inplace(Image<I>& input, const V& val)
{
+ trace::entering("arith::times_cst_inplace");
+
mln_precondition(exact(input).has_data());
times_inplace(input, pw::cst(val) | exact(input).domain());
// Calls the previous version.
+
+ trace::exiting("arith::times_cst_inplace");
}
} // end of namespace mln::arith
Index: trunk/milena/mln/arith/plus.hh
===================================================================
--- trunk/milena/mln/arith/plus.hh (revision 1513)
+++ trunk/milena/mln/arith/plus.hh (revision 1514)
@@ -211,6 +211,7 @@
operator+(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("operator::plus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_trait_op_plus(L,R) output = arith::plus(lhs, rhs);
@@ -224,6 +225,7 @@
operator+=(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("operator::plus_eq");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
arith::plus_inplace(lhs, rhs);
@@ -238,6 +240,7 @@
operator+(const Image<I>& ima, const value::Scalar<S>& s)
{
trace::entering("operator::plus");
+
mln_precondition(exact(ima).has_data());
mln_trait_op_plus(I,S) output = arith::plus_cst(ima, exact(s));
@@ -251,6 +254,7 @@
operator+=(Image<I>& ima, const value::Scalar<S>& s)
{
trace::entering("operator::plus_eq");
+
mln_precondition(exact(ima).has_data());
arith::plus_cst_inplace(ima, exact(s));
@@ -337,6 +341,7 @@
plus(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::plus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_trait_op_plus(L, R) output;
@@ -354,6 +359,7 @@
plus(const Image<L>& lhs, const Image<R>& rhs, const Function_v2v<F>& f)
{
trace::entering("arith::plus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_ch_value(L, mln_result(F)) output;
@@ -371,6 +377,7 @@
plus(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::plus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
// Calls the previous version.
@@ -387,6 +394,7 @@
plus_cst(const Image<I>& input, const V& val)
{
trace::entering("arith::plus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -403,6 +411,7 @@
plus_cst(const Image<I>& input, const V& val, const Function_v2v<F>& f)
{
trace::entering("arith::plus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -420,6 +429,7 @@
plus_cst(const Image<I>& input, const V& val)
{
trace::entering("arith::plus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -436,6 +446,7 @@
plus_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::plus_inplace");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
impl::plus_inplace_(mln_trait_image_speed(L)(), exact(lhs),
@@ -450,6 +461,7 @@
plus_cst_inplace(Image<I>& input, const V& val)
{
trace::entering("arith::plus_cst_inplace");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
Index: trunk/milena/mln/arith/min.hh
===================================================================
--- trunk/milena/mln/arith/min.hh (revision 1513)
+++ trunk/milena/mln/arith/min.hh (revision 1514)
@@ -127,8 +127,8 @@
void min_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::min_inplace");
- mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
impl::min_inplace_(mln_trait_image_speed(L)(), exact(lhs),
mln_trait_image_speed(R)(), exact(rhs));
Index: trunk/milena/mln/arith/revert.hh
===================================================================
--- trunk/milena/mln/arith/revert.hh (revision 1513)
+++ trunk/milena/mln/arith/revert.hh (revision 1514)
@@ -113,6 +113,7 @@
mln_concrete(I) revert(const Image<I>& input)
{
trace::entering("arith::revert");
+
mln_precondition(exact(input).has_data());
mln_concrete(I) output;
@@ -127,6 +128,7 @@
void revert_inplace(Image<I>& input)
{
trace::entering("arith::revert_inplace");
+
mln_precondition(exact(input).has_data());
impl::revert_(mln_trait_image_speed(I)(), exact(input), exact(input));
Index: trunk/milena/mln/arith/all.hh
===================================================================
--- trunk/milena/mln/arith/all.hh (revision 1513)
+++ trunk/milena/mln/arith/all.hh (revision 1514)
@@ -41,18 +41,24 @@
namespace arith
{
/// Implementation namespace of arith namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of arith namespace.
+ namespace generic {
+
}
}
+ }
-# include <mln/arith/plus.hh>
-# include <mln/arith/minus.hh>
-# include <mln/arith/times.hh>
+}
# include <mln/arith/min.hh>
+# include <mln/arith/minus.hh>
+# include <mln/arith/plus.hh>
# include <mln/arith/revert.hh>
+# include <mln/arith/times.hh>
#endif // ! MLN_ARITH_ALL_HH
Index: trunk/milena/mln/arith/min.spe.hh
===================================================================
--- trunk/milena/mln/arith/min.spe.hh (revision 1513)
+++ trunk/milena/mln/arith/min.spe.hh (revision 1514)
@@ -53,7 +53,6 @@
template <typename L, typename R>
void min_inplace_(L& lhs, const R& rhs);
-
}
template <typename L, typename R, typename O>
Index: trunk/milena/mln/arith/minus.hh
===================================================================
--- trunk/milena/mln/arith/minus.hh (revision 1513)
+++ trunk/milena/mln/arith/minus.hh (revision 1514)
@@ -197,8 +197,8 @@
operator-(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("operator::minus");
- mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_trait_op_minus(L,R) output = arith::minus(lhs, rhs);
trace::exiting("operator::minus");
@@ -210,8 +210,8 @@
operator-=(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("operator::minus_eq");
- mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
arith::minus_inplace(lhs, rhs);
trace::exiting("operator::minus_eq");
@@ -224,8 +224,8 @@
operator-(const Image<I>& ima, const value::Scalar<S>& s)
{
trace::entering("operator::minus");
- mln_precondition(exact(ima).has_data());
+ mln_precondition(exact(ima).has_data());
mln_trait_op_minus(I,S) output = arith::minus_cst(ima, exact(s));
trace::exiting("operator::minus");
@@ -237,8 +237,8 @@
operator-=(Image<I>& ima, const value::Scalar<S>& s)
{
trace::entering("operator::minus_eq");
- mln_precondition(exact(ima).has_data());
+ mln_precondition(exact(ima).has_data());
arith::minus_cst_inplace(ima, exact(s));
trace::exiting("operator::minus_eq");
@@ -323,6 +323,7 @@
minus(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::minus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_trait_op_minus(L, R) output;
@@ -340,6 +341,7 @@
minus(const Image<L>& lhs, const Image<R>& rhs, const Function_v2v<F>& f)
{
trace::entering("arith::minus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_ch_value(L, mln_result(F)) output;
@@ -357,6 +359,7 @@
minus(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::minus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
// Calls the previous version.
@@ -373,6 +376,7 @@
minus_cst(const Image<I>& input, const V& val)
{
trace::entering("arith::minus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -389,6 +393,7 @@
minus_cst(const Image<I>& input, const V& val, const Function_v2v<F>& f)
{
trace::entering("arith::minus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -406,6 +411,7 @@
minus_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::minus_inplace");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
impl::minus_inplace_(mln_trait_image_speed(L)(), exact(lhs),
@@ -420,6 +426,7 @@
minus_cst_inplace(Image<I>& input, const V& val)
{
trace::entering("arith::minus_cst_inplace");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Review seeds2tiling and fix chamfer.
* mln/geom/seeds2tiling.hh: Add doc and tracing, fix typo and
update code.
* mln/geom/seeds2tiling_with_chamfer.hh: Remove ...
* mln/geom/seeds2tiling_roundness.hh: ... rename it and like
seeds2tiling.
* mln/geom/chamfer.hh,
* mln/canvas/chamfer.hh: Fix headers.
Tests
* tests/seed2tiling.cc: Update tests.
* tests/geom/seed2tiling.cc,
* tests/geom/seed2tiling_roundness.cc: New unit tests for these
algorithms.
---
mln/geom/chamfer.hh | 4 -
mln/geom/seeds2tiling.hh | 30 +++++++
mln/geom/seeds2tiling_roundness.hh | 144 ++++++++++++++++++++++++++++++++++++
tests/geom/seed2tiling.cc | 85 +++++++++++++++++++++
tests/geom/seed2tiling_roundness.cc | 90 ++++++++++++++++++++++
tests/seed2tiling.cc | 6 -
6 files changed, 355 insertions(+), 4 deletions(-)
Index: trunk/milena/tests/geom/seed2tiling_roundness.cc
===================================================================
--- trunk/milena/tests/geom/seed2tiling_roundness.cc (revision 0)
+++ trunk/milena/tests/geom/seed2tiling_roundness.cc (revision 1513)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/geom/seed2tiling_roundness.cc
+ *
+ * \brief Tests on mln::geom::seed2tiling_roundness.
+ */
+
+# include <mln/core/image2d.hh>
+# include <mln/core/neighb2d.hh>
+# include <mln/core/w_window2d_int.hh>
+# include <mln/make/win_chamfer.hh>
+# include <mln/geom/seeds2tiling_roundness.hh>
+# include <mln/level/compare.hh>
+# include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+ unsigned max = 2048;
+ const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2,3> ();
+
+ unsigned vs [16][16] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ };
+
+ unsigned ws [16][16] = {
+ {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}
+ };
+
+ image2d<unsigned> ima (make::image2d(vs));
+ image2d<unsigned> out = geom::seeds2tiling_roundness(ima, w_win, max, c4());
+ image2d<unsigned> ref (make::image2d(ws));
+
+ mln_assertion (ref == out);
+}
Index: trunk/milena/tests/geom/seed2tiling.cc
===================================================================
--- trunk/milena/tests/geom/seed2tiling.cc (revision 0)
+++ trunk/milena/tests/geom/seed2tiling.cc (revision 1513)
@@ -0,0 +1,85 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/geom/seed2tiling.cc
+ *
+ * \brief Tests on mln::geom::seed2tiling.
+ */
+
+
+# include <mln/core/image2d.hh>
+# include <mln/core/neighb2d.hh>
+# include <mln/geom/seeds2tiling.hh>
+# include <mln/level/compare.hh>
+
+int main()
+{
+ using namespace mln;
+
+ unsigned vs [16][16] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ };
+
+ unsigned ws [16][16] = {
+ {1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3}
+ };
+
+ image2d<unsigned> ima (make::image2d(vs));
+ image2d<unsigned> out = geom::seeds2tiling(ima, c4());
+ image2d<unsigned> ref (make::image2d(ws));
+ mln_assertion (ref == out);
+}
Index: trunk/milena/tests/seed2tiling.cc
===================================================================
--- trunk/milena/tests/seed2tiling.cc (revision 1512)
+++ trunk/milena/tests/seed2tiling.cc (revision 1513)
@@ -44,7 +44,7 @@
# include <mln/debug/println.hh>
# include <mln/draw/mesh.hh>
# include <mln/geom/seeds2tiling.hh>
-# include <mln/geom/seeds2tiling_with_chamfer.hh>
+# include <mln/geom/seeds2tiling_roundness.hh>
# include <mln/make/voronoi.hh>
#include <mln/core/image2d.hh>
@@ -85,13 +85,13 @@
std::cout << "ima1 generate with seeds2tiling"
<< std::endl;
- inte = geom::seeds2tiling_with_chamfer(lab, w_win, max, c4 ());
+ inte = geom::seeds2tiling_roundness(lab, w_win, max, c4 ());
border::fill(inte, 0);
level::stretch(inte, inte2);
io::pgm::save(inte2, "ima2.pgm");
- std::cout << "ima2 generate with seeds2tiling_with_chamfer"
+ std::cout << "ima2 generate with seeds2tiling_roundness"
<< std::endl;
}
Index: trunk/milena/mln/geom/seeds2tiling_with_chamfer.hh (deleted)
===================================================================
Index: trunk/milena/mln/geom/seeds2tiling_roundness.hh
===================================================================
--- trunk/milena/mln/geom/seeds2tiling_roundness.hh (revision 0)
+++ trunk/milena/mln/geom/seeds2tiling_roundness.hh (revision 1513)
@@ -0,0 +1,144 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH
+# define MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH
+
+/*! \file mln/geom/seeds2tiling_roundness.hh
+ *
+ * \brief seeds2tiling with a method which makes tiles more roundness.
+ */
+
+# include <map>
+
+
+# include <mln/core/p_priority_queue_fast.hh>
+# include <mln/core/clone.hh>
+# include <mln/accu/mean.hh>
+# include <mln/estim/min_max.hh>
+# include <mln/metal/vec.hh>
+# include <mln/geom/chamfer.hh>
+
+
+namespace mln
+{
+ namespace geom
+ {
+
+
+ /*! Take a labeled image \p ima_ with seeds and extend them until
+ * creating tiles nore roundness that the primary version.
+ *
+ * \param[in,out] ima The labeled image with seed.
+ * \param[in] win_w The weight window using by geom::chamfer to compute distance.
+ * \param[in] max Unsigned using by geom::chamfer to compute distance.
+ * \param[in] nbh The neighborhood to use on this algorithm.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ */
+ template <typename I, typename N>
+ I
+ seeds2tiling_roundness (Image<I>& ima_, const w_window2d_int& w_win, unsigned max,
+ const Neighborhood<N>& nbh);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I, typename N>
+ I
+ seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, unsigned max,
+ const Neighborhood<N>& nbh)
+ {
+ trace::entering("geom::impl::seed2tiling_roundness");
+
+ I& ima = exact(ima_);
+ image2d<unsigned> dist = geom::chamfer(ima, w_win, max);
+ I out = clone(ima_);
+ p_priority_queue_fast<mln_psite(I), unsigned> q;
+
+ // Init.
+ {
+ mln_piter(I) p(ima.domain());
+
+ for_all(p)
+ q.push_force(p, max - dist(p));
+ }
+
+
+ // Body: alternative version.
+ {
+ while (! q.is_empty())
+ {
+ mln_psite(I) p = q.front();
+ q.pop();
+ if (out(p) != 0) // p has already been processed so ignore
+ continue;
+ mln_niter(N) n(nbh, p);
+
+ for_all(n) if (ima.has(n))
+ if (out(n) != 0)
+ out(p) = out(n);
+ }
+ }
+
+ trace::exiting("geom::impl::seed2tiling_roundness");
+ return out;
+ }
+
+ } // end of namespace mln::geom::impl
+
+
+ /// Facade
+ template <typename I, typename N>
+ I
+ seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, unsigned max,
+ const Neighborhood<N>& nbh)
+ {
+ trace::entering("geom::seed2tiling_roundness");
+
+ mln_precondition(exact(ima_).has_data());
+ I output = impl::seeds2tiling_roundness(ima_, w_win, max, nbh);
+
+ trace::exiting("geom::seed2tiling_roundness");
+ return output;
+ }
+
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH
Index: trunk/milena/mln/geom/seeds2tiling.hh
===================================================================
--- trunk/milena/mln/geom/seeds2tiling.hh (revision 1512)
+++ trunk/milena/mln/geom/seeds2tiling.hh (revision 1513)
@@ -47,17 +47,30 @@
namespace geom
{
+ /*! Take a labeled image \p ima_ with seeds and extend them
+ * until creating tiles.
+ *
+ * \param[in,out] ima The labeled image with seed.
+ * \param[in] nbh The neighborhood to use on this algorithm.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ */
template <typename I, typename N>
I seeds2tiling (Image<I>& ima_, const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
template <typename I, typename N>
I
seeds2tiling (Image<I>& ima_,
const Neighborhood<N>& nbh)
{
+ trace::entering("geom::impl::seed2tiling");
+
I& ima = exact(ima_);
I out = clone(ima_);
p_queue<mln_psite(I)> q;
@@ -94,9 +107,26 @@
}
}
+ trace::exiting("geom::impl::seed2tiling");
return out;
}
+ } // end of namespace mln::geom::impl
+
+
+ /// Facade
+ template <typename I, typename N>
+ I seeds2tiling(Image<I>& ima_, const Neighborhood<N>& nbh)
+ {
+ trace::entering("geom::seed2tiling");
+
+ mln_precondition(exact(ima_).has_data());
+ I output = impl::seeds2tiling(ima_, nbh);
+
+ trace::exiting("geom::seed2tiling");
+ return output;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/geom/chamfer.hh
===================================================================
--- trunk/milena/mln/geom/chamfer.hh (revision 1512)
+++ trunk/milena/mln/geom/chamfer.hh (revision 1513)
@@ -36,7 +36,9 @@
# include <mln/level/fill.hh>
# include <mln/core/w_window2d_int.hh>
# include <mln/core/w_window2d_float.hh>
-
+# include <mln/core/sub_image.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/inplace.hh>
# include <mln/canvas/chamfer.hh>
namespace mln
Index: trunk/milena/mln/canvas/chamfer.hh
===================================================================
1
0
22 Nov '07
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Get rid of the former property mechanism for value types.
Start cleaning the histogram-related test.
* tests/histo_compute.cc: Rename as...
* tests/histo/compute.cc: ...this.
Activate the test with int_s<5>.
* tests/accu_all.cc: Inactivate tests on
"median< value::set<bool> >" and
"min_h< value::set<bool> >" since traits for bool are not
equiped with min() and max().
* tests/Makefile.am (SUBDIRS): Sort,
Add histo.
(histo_compute_SOURCES): Remove.
* tests/io_pbm.cc: Simplify.
* tests/histo/Makefile.am (check_PROGRAMS): New.
(compute_SOURCES, TESTS): New.
Preparing to get rid of former property mechanism for value types.
* mln/value/props.hh (mln_card_): Move...
* mln/trait/value_.hh: ...here and rename as...
(mln_card): ...this.
* mln/value/props.hh
(mln_value_sum, mln_value_kind, mln_value_card_): Remove.
(mln_is_lowq): Remove.
(mln_min, mln_max): Move...
* mln/trait/value_.hh: ...here.
* mln/trait/value_.hh (mln_trait_value_card): Rename as...
(mln_card): ...this.
(mln_value_quant_from_card): Rename as...
(mln_value_quant_from_): ...this.
(mln_value_card_from_): New macro.
(mln_nbits, mln_epsilon): New.
* mln/trait/value/nature.hh (matrix): New.
Now get rid of value "props".
* mln/value/props.hh: Remove.
(convert_): Move into...
* mln/value/internal/convert.hh: ...this new file.
(convert_<bool>): New specialization.
Propagate changes.
* tests/value_bool.cc,
* mln/trait/images.hh,
* mln/trait/value/print.hh,
* mln/core/macros.hh,
* mln/math/round_sat.hh,
* mln/metal/mat.hh,
* mln/metal/vec.hh,
* mln/arith/revert.hh,
* mln/arith/revert.spe.hh,
* mln/level/sort_points.hh,
* mln/level/transform.spe.hh,
* mln/level/transform.hh,
* mln/level/stretch.hh,
* mln/accu/min.hh,
* mln/accu/max.hh,
* mln/accu/min_max.hh,
* mln/accu/sum.hh,
* mln/value/proxy.hh,
* mln/value/graylevel.hh,
* mln/value/lut_vec.hh,
* mln/value/ops.hh,
* mln/value/gray.hh,
* mln/value/float01_.hh,
* mln/value/all.hh,
* mln/value/quat.hh,
* mln/value/int_s.hh,
* mln/value/int_u.hh,
* mln/value/int_u_sat.hh,
* mln/value/set.hh,
* mln/value/float01.hh,
* mln/value/builtin/symbolics.hh,
* mln/value/builtin/floatings.hh,
* mln/value/builtin/integers.hh,
* mln/value/rgb.hh,
* mln/value/float01_f.hh,
* mln/value/label.hh,
* mln/fun/v2v/saturate.hh,
* mln/morpho/Rd.hh,
* mln/norm/l1.hh,
* mln/norm/l2.hh: Update.
Misc.
* mln/metal/math/pow.hh (mlc_pow, mlc_pow_int): New macros.
* mln/value/internal/iterable_set.hh: .
* mln/io/pnm/save_header.hh (save_max_val): New specialization
for bool.
* mln/io/pnm/load.hh: Fix.
* mln/io/pbm/save.hh: Fix.
mln/accu/max.hh | 2
mln/accu/min.hh | 2
mln/accu/min_max.hh | 2
mln/accu/sum.hh | 2
mln/arith/revert.hh | 2
mln/arith/revert.spe.hh | 2
mln/core/macros.hh | 3 -
mln/fun/v2v/saturate.hh | 2
mln/io/pbm/save.hh | 35 ++++++------
mln/io/pnm/load.hh | 4 -
mln/io/pnm/save_header.hh | 10 +++
mln/level/sort_points.hh | 16 +++--
mln/level/stretch.hh | 2
mln/level/transform.hh | 2
mln/level/transform.spe.hh | 4 -
mln/math/round_sat.hh | 2
mln/metal/mat.hh | 46 ++++++++++------
mln/metal/math/pow.hh | 5 +
mln/metal/vec.hh | 48 +++++++++-------
mln/morpho/Rd.hh | 2
mln/norm/l1.hh | 24 ++++----
mln/norm/l2.hh | 24 ++++----
mln/trait/images.hh | 7 +-
mln/trait/value/nature.hh | 1
mln/trait/value/print.hh | 4 +
mln/trait/value_.hh | 49 ++++++++++++++---
mln/value/all.hh | 2
mln/value/builtin/floatings.hh | 50 ++++++++++++++++-
mln/value/builtin/integers.hh | 54 +++++++++----------
mln/value/builtin/symbolics.hh | 7 +-
mln/value/float01.hh | 2
mln/value/float01_.hh | 57 +++++++++++++-------
mln/value/float01_f.hh | 52 ++++++++++++------
mln/value/gray.hh | 65 ++++++++++++++++++++++
mln/value/graylevel.hh | 41 +++++++++-----
mln/value/int_s.hh | 41 ++++++++------
mln/value/int_u.hh | 37 +++++++------
mln/value/int_u_sat.hh | 2
mln/value/internal/convert.hh | 105 +++++++++++++++++++++++++++++++++++++
mln/value/internal/iterable_set.hh | 5 -
mln/value/label.hh | 65 +++++++++++++---------
mln/value/lut_vec.hh | 2
mln/value/ops.hh | 6 +-
mln/value/proxy.hh | 37 +++++++++----
mln/value/quat.hh | 31 +++++++++-
mln/value/rgb.hh | 39 +++++++++----
mln/value/set.hh | 11 ++-
tests/Makefile.am | 16 ++---
tests/accu_all.cc | 4 -
tests/histo/Makefile.am | 7 ++
tests/histo/compute.cc | 104 ++++++++++++++++++++++++++++++++++++
tests/io_pbm.cc | 48 ++++------------
tests/value_bool.cc | 4 -
53 files changed, 848 insertions(+), 348 deletions(-)
Index: tests/accu_all.cc
--- tests/accu_all.cc (revision 1511)
+++ tests/accu_all.cc (working copy)
@@ -46,9 +46,9 @@
histo< value::set<bool> > h;
max_<int> ma;
mean_<int> me;
- median< value::set<bool> > med;
+ // median< value::set<bool> > med; // FIXME: bool has no min so workaround!
min_<int> mi;
- min_h< value::set<bool> > mh;
+ // min_h< value::set<bool> > mh; // OK: do not work since bool has no min/max :)
min_max_<int> mm;
nil n;
pair_< min_<int>, max_<int> > p;
Index: tests/Makefile.am
--- tests/Makefile.am (revision 1511)
+++ tests/Makefile.am (working copy)
@@ -2,15 +2,17 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = norm \
- level \
+SUBDIRS = \
arith \
- logical \
- draw \
border \
canvas \
- win \
- set
+ draw \
+ histo \
+ level \
+ logical \
+ norm \
+ set \
+ win
check_PROGRAMS = \
accu_all \
@@ -57,7 +59,6 @@
fun_x2x_translation \
\
hexa \
- histo_compute \
histo_to_image1d \
h_vec \
\
@@ -210,7 +211,6 @@
fun_x2x_translation_SOURCES = fun_x2x_translation.cc
hexa_SOURCES = hexa.cc
-histo_compute_SOURCES = histo_compute.cc
histo_to_image1d_SOURCES = histo_to_image1d.cc
h_vec_SOURCES = h_vec.cc
Index: tests/io_pbm.cc
--- tests/io_pbm.cc (revision 1511)
+++ tests/io_pbm.cc (working copy)
@@ -27,53 +27,29 @@
/*! \file tests/io_pbm.cc
*
- * \brief Test on mln::io::pbm::load and mln::io::pbm::save.
+ * \brief Test on mln::io::pbm::.
*/
#include <mln/core/image2d.hh>
-
-#include <mln/value/int_u8.hh>
-#include <mln/pw/all.hh>
-
-#include <mln/io/pgm/load.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/pbm/save.hh>
-#include <mln/level/compare.hh>
-#include <mln/level/fill.hh>
-
-#include <mln/display/show.hh>
-#include <mln/display/save.hh>
-
-#include <mln/border/thickness.hh>
int main()
{
using namespace mln;
- using typename value::int_u8;
-
- typedef image2d< bool > I;
-
- border::thickness = 0;
- image2d< int_u8 >
- lena = io::pgm::load("../img/lena.pgm");
-
- I out(lena.domain());
- level::fill(out, pw::value(lena) > pw::cst(127));
- io::pbm::save(out, "out.pbm");
-
- {
- I lena = io::pbm::load("out.pbm");
- image2d<bool> out(lena.domain());
-
- io::pbm::save(lena, "out2.pbm");
+ image2d<bool> pic = io::pbm::load("../img/picasso.pbm");
+ io::pbm::save(pic, "pic.pbm");
+}
- I lena2 = io::pbm::load("out2.pbm");
- io::pbm::save(lena2, "out3.pbm");
+// sample binary image to test with xv, imview, and display
+// to bring into the fore the binary image bug with raw pbm.
- mln_assertion(lena.domain() = lena2.domain());
- mln_assertion(lena = lena2);
- }
-}
+// | | | | -
+// | | - - -
+// | - - - -
+// - - - - -
+// - - - - -
+// - - - - -
Index: tests/histo/compute.cc
--- tests/histo/compute.cc (revision 0)
+++ tests/histo/compute.cc (revision 0)
@@ -0,0 +1,104 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/histo/compute.cc
+ *
+ * \brief Tests on mln::accu::histo and mln::histo::data.
+ */
+
+#include <iterator>
+#include <sstream>
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_s.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/accu/histo.hh>
+#include <mln/histo/compute.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+// // Test on 'bool'.
+// {
+// accu::histo< value::set<bool> > h;
+
+// for (unsigned i = 0; i < 5; ++i)
+// h.take(false);
+// for (unsigned i = 0; i < 2; ++i)
+// h.take(true);
+// h.untake(true);
+
+// mln_assertion(h[0] * 10 + h[1] = 51);
+// mln_assertion(h(false) * 10 + h(true) = 51);
+// }
+
+// // Test on 'int_u8'.
+// {
+// image2d<int_u8> ima(3, 3);
+// debug::iota(ima);
+// ima.at(0,0) = 2;
+
+// histo::data< value::set<int_u8> > h = histo::compute(ima);
+// std::ostringstream oss;
+// oss << h;
+// mln_assertion(oss.str() = "2:2 3:1 4:1 5:1 6:1 7:1 8:1 9:1 ");
+
+// int_u8 i = 2;
+// mln_assertion(h(i) = 2);
+// }
+
+ // Test on 'int_s5'.
+ {
+ typedef value::int_s<5> int_s5;
+ image2d<int_s5> ima(3, 3);
+ debug::iota(ima);
+ ima.at(0,0) = 2;
+
+ std::cout << "int_s5: "
+ << value::props< int_s5 >::min() << ' '
+ << value::props< int_s5 >::max() << ' '
+ << value::props< int_s5 >::card_ << std::endl;
+
+ debug::println(ima);
+
+
+ histo::data< value::set<int_s5> > h = histo::compute(ima);
+ std::cout << "nvalues = " << h.vset().nvalues() << std::endl;
+ std::cout << h << std::endl;
+
+ for (unsigned i = 0; i < h.vset().nvalues(); ++i)
+ std::cout << i << ':' << h[i] << ' ';
+ std::cout << std::endl;
+ }
+
+}
Index: tests/histo/Makefile.am
--- tests/histo/Makefile.am (revision 1511)
+++ tests/histo/Makefile.am (working copy)
@@ -1,3 +1,10 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ compute
+
+compute_SOURCES = compute.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/value_bool.cc
--- tests/value_bool.cc (revision 1511)
+++ tests/value_bool.cc (working copy)
@@ -30,7 +30,7 @@
* \brief Tests on mln::value::set.
*/
-#include <mln/value/props.hh>
+#include <mln/trait/value_.hh>
#include <mln/value/set.hh>
@@ -38,7 +38,7 @@
{
using namespace mln;
- mln_assertion(mln::trait::value_<bool>::card::value = 2);
+ mln_assertion(mln_card(bool) = 2);
value::set<bool> B;
std::cout << B << std::endl;
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 1511)
+++ mln/trait/images.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/trait/undef.hh>
# include <mln/trait/image/props.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/bexpr.hh>
# include <mln/metal/equal.hh>
@@ -148,9 +148,10 @@
struct default_image_ : undefined_image_<I>
{
private:
- typedef metal::bool_<( mln_value_card_(T) = 0 )> is_high_quant_;
+ typedef mlc_equal(mln_trait_value_quant(T),
+ trait::value::quant::high) is_high_quant_;
public:
- typedef mln_value_kind(T) kind;
+ typedef mln_trait_value_kind(T) kind;
typedef mlc_if( is_high_quant_,
trait::image::quant::high,
trait::image::quant::low ) quant;
Index: mln/trait/value_.hh
--- mln/trait/value_.hh (revision 1511)
+++ mln/trait/value_.hh (working copy)
@@ -41,19 +41,38 @@
# include <mln/metal/if.hh>
# include <mln/trait/value/all.hh>
+# include <mln/metal/math/pow.hh>
# define mln_trait_value_nature(V) typename mln::trait::value_< V >::nature
# define mln_trait_value_kind(V) typename mln::trait::value_< V >::kind
# define mln_trait_value_quant(V) typename mln::trait::value_< V >::quant
-# define mln_trait_value_card(V) typename mln::trait::value_< V >::card
-# define mln_value_quant_from_card(C) \
- mlc_if(mln::metal::bool_<( C::value > 65536 || C::value = 0 )>, \
+# define mln_nbits(V) mln::trait::value_< V >::nbits
+# define mln_card(V) mln::trait::value_< V >::card
+# define mln_min(V) mln::trait::value_< V >::min()
+# define mln_max(V) mln::trait::value_< V >::max()
+# define mln_epsilon(V) mln::trait::value_< V >::epsilon()
+
+
+/// Give the summation type for values of type \c T.
+# define mln_trait_value_sum(V) typename mln::trait::value_< V >::sum
+# define mln_sum(V) mln_trait_value_sum(V)
+
+
+
+# define mln_value_quant_from_(C) \
+ mlc_if(mln::metal::bool_<( C > 65536 || C = 0 )>, \
mln::trait::value::quant::high, \
mln::trait::value::quant::low)
+# define mln_value_card_from_(N) \
+ N <= 16 \
+ ? mlc_pow_int((N <= 16 ? 2 : 1), \
+ (N <= 16 ? N : 1)) \
+ : 0
+
namespace mln
@@ -68,24 +87,38 @@
typedef undef nature;
typedef undef kind;
typedef undef quant;
- typedef undef card;
+
+ /*
+ * enum {
+ * nbits = ?,
+ * card = ?
+ * };
+ *
+ * static const E min();
+ * static const E max();
+ * static const E epsilon();
+ */
+
typedef undef sum;
// FIXME: signed or not, with zero or not, centered or not, etc.
};
- struct default_value_
+ struct default_value_ : undefined_value_
{
+ enum {
+ nbits = 0,
+ card = 0
+ };
+
typedef trait::value::nature::unknown nature;
typedef trait::value::kind::data kind;
typedef trait::value::quant::high quant;
- typedef metal::int_<0> card;
- typedef undef sum;
};
template <typename V>
- struct value_ : undefined_value_
+ struct value_ : default_value_
{
};
Index: mln/trait/value/print.hh
--- mln/trait/value/print.hh (revision 1511)
+++ mln/trait/value/print.hh (working copy)
@@ -70,7 +70,9 @@
<< typename the::nature().name() << ", "
<< typename the::kind() .name() << ", "
<< typename the::quant() .name() << ", "
- << typename the::card() .name() << " }" << std::endl;
+ << "nbits=" << the::nbits << ", "
+ << "card=" << the::card << ", "
+ << " }" << std::endl;
}
template <typename V>
Index: mln/trait/value/nature.hh
--- mln/trait/value/nature.hh (revision 1511)
+++ mln/trait/value/nature.hh (working copy)
@@ -54,6 +54,7 @@
struct floating : scalar { std::string name() const { return "nature::floating"; } };
struct vectorial : any { std::string name() const { return "nature::vectorial"; } };
+ struct matrix : any { std::string name() const { return "nature::matrix"; } };
struct symbolic : any { std::string name() const { return "nature::symbolic"; } };
struct structured : any { std::string name() const { return "nature::structured"; } };
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 1511)
+++ mln/core/macros.hh (working copy)
@@ -173,9 +173,6 @@
# define mln_value(T) typename T::value
# define mln_value_(T) T::value
-/// Shortcut to test if the values of an image with type \c I are lowly quantifized.
-# define mln_is_value_lowq(I) mln_is_lowq( mln_value(I) )
-
/// Shortcut to access the type of value set (vset) associated to T.
# define mln_vset(T) typename T::vset
Index: mln/math/round_sat.hh
--- mln/math/round_sat.hh (revision 1511)
+++ mln/math/round_sat.hh (working copy)
@@ -36,7 +36,7 @@
# include <cmath>
# include <mln/core/concept/function.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
Index: mln/metal/mat.hh
--- mln/metal/mat.hh (revision 1511)
+++ mln/metal/mat.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/core/concept/function.hh>
# include <mln/core/contract.hh>
# include <mln/trait/all.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/vec.hh>
@@ -51,6 +51,35 @@
namespace mln
{
+
+ // Fwd decl.
+ namespace metal {
+ template <unsigned n, unsigned m, typename T> class mat;
+ }
+
+
+ namespace trait
+ {
+
+ template <unsigned n, unsigned m, typename T>
+ struct value_< metal::mat<n,m,T> >
+ {
+ typedef trait::value::nature::matrix nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = n * m * mln_nbits(T),
+ card = n * m * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::mat<n, m, mln_sum(T)> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+
namespace metal
{
@@ -166,21 +195,6 @@
- namespace value
- {
-
- template <unsigned n, unsigned m, typename T>
- struct props< metal::mat<n,m,T> >
- {
- typedef trait::value::kind::data kind;
- static const std::size_t card_ = n * m * mln_card_(T);
- typedef metal::mat<n,m, mln_value_sum(T)> sum;
- };
-
- } // end of namespace mln::value
-
-
-
namespace metal
{
Index: mln/metal/math/pow.hh
--- mln/metal/math/pow.hh (revision 1511)
+++ mln/metal/math/pow.hh (working copy)
@@ -37,6 +37,11 @@
# include <mln/metal/int.hh>
+# define mlc_pow(X, N) typename mln::metal::math::pow< X, N >::ret
+# define mlc_pow_int(x, n) mln::metal::math::pow_int< x, n >::value
+
+
+
namespace mln
{
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1511)
+++ mln/metal/vec.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/core/concept/object.hh>
# include <mln/trait/all.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/fun/i2v/all_to.hh>
# include <mln/debug/format.hh>
@@ -54,18 +54,41 @@
{
// Fwd decls.
- namespace literal { struct zero_t; }
+ namespace metal {
+ template <unsigned n, typename T> class vec;
+ }
+ namespace literal {
+ struct zero_t;
+ }
template <unsigned d, typename C> struct h_vec;
- namespace metal
+ namespace trait
{
- // Fwd decl.
- template <unsigned n, typename T> class vec;
+ template <unsigned n, typename T>
+ struct value_< mln::metal::vec<n,T> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = n * mln_nbits(T),
+ card = n * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::vec<n, mln_sum(T)> sum;
+ };
+
+ } // end of namespace mln::trait
+
+ namespace metal
+ {
+
namespace internal
{
@@ -253,21 +276,6 @@
- namespace value
- {
-
- template <unsigned n, typename T>
- struct props< metal::vec<n,T> >
- {
- typedef trait::value::kind::data kind;
- static const std::size_t card_ = n * mln_card_(T);
- typedef metal::vec<n, mln_value_sum(T)> sum;
- };
-
- } // end of namespace mln::value
-
-
-
namespace metal
{
Index: mln/arith/revert.hh
--- mln/arith/revert.hh (revision 1511)
+++ mln/arith/revert.hh (working copy)
@@ -36,7 +36,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
// Specializations are in:
# include <mln/arith/revert.spe.hh>
Index: mln/arith/revert.spe.hh
--- mln/arith/revert.spe.hh (revision 1511)
+++ mln/arith/revert.spe.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# ifndef MLN_INCLUDE_ONLY
Index: mln/level/sort_points.hh
--- mln/level/sort_points.hh (revision 1511)
+++ mln/level/sort_points.hh (working copy)
@@ -107,7 +107,8 @@
template <typename I>
p_array<mln_point(I)>
- sort_points_increasing_(metal::false_, const I& input) // general case
+ sort_points_increasing_(trait::image::quant::any, // general case
+ const I& input)
{
p_array<mln_point(I)> v = convert::to_p_array(input.domain());
std::sort(v.hook_().begin(), v.hook_().end(),
@@ -117,7 +118,8 @@
template <typename I>
p_array<mln_point(I)>
- sort_points_increasing_(metal::true_, const I& input) // low quantization
+ sort_points_increasing_(trait::image::quant::low, // low quantization
+ const I& input)
{
typedef mln_vset(I) S;
const S& vset = input.values();
@@ -148,7 +150,8 @@
template <typename I>
p_array<mln_point(I)>
- sort_points_decreasing_(metal::false_, const I& input) // general case
+ sort_points_decreasing_(trait::image::quant::any, // general case
+ const I& input)
{
p_array<mln_point(I)> v = convert::to_p_array(input.domain());
std::sort(v.hook_().begin(), v.hook_().end(),
@@ -158,7 +161,8 @@
template <typename I>
p_array<mln_point(I)>
- sort_points_decreasing_(metal::true_, const I& input) // low quantization
+ sort_points_decreasing_(trait::image::quant::low, // low quantization
+ const I& input)
{
typedef mln_vset(I) S;
const S& vset = input.values();
@@ -195,7 +199,7 @@
sort_points_increasing(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- return impl::sort_points_increasing_(mln_is_value_lowq(I)(), exact(input));
+ return impl::sort_points_increasing_(mln_trait_image_quant(I)(), exact(input));
}
template <typename I>
@@ -203,7 +207,7 @@
sort_points_decreasing(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- return impl::sort_points_decreasing_(mln_is_value_lowq(I)(), exact(input));
+ return impl::sort_points_decreasing_(mln_trait_image_quant(I)(), exact(input));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/level/transform.spe.hh
--- mln/level/transform.spe.hh (revision 1511)
+++ mln/level/transform.spe.hh (working copy)
@@ -62,7 +62,7 @@
}
template <typename I, typename F, typename O>
- void transform_(metal::false_, // general case
+ void transform_(mln::trait::image::quant::any, // general case
const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
{
generic::transform_(input_, f_, output_);
@@ -70,7 +70,7 @@
template <typename I, typename F, typename O>
- void transform_(metal::true_, // low quantization
+ void transform_(mln::trait::image::quant::low, // low quantization
const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
{
trace::entering("level::impl::transform");
Index: mln/level/transform.hh
--- mln/level/transform.hh (revision 1511)
+++ mln/level/transform.hh (working copy)
@@ -110,7 +110,7 @@
trace::entering("level::transform");
mln_precondition(exact(output).domain() >= exact(input).domain());
- impl::transform_(mln_is_value_lowq(I)(),
+ impl::transform_(mln_trait_image_quant(I)(),
exact(input), exact(f), exact(output));
trace::exiting("level::transform");
Index: mln/level/stretch.hh
--- mln/level/stretch.hh (revision 1511)
+++ mln/level/stretch.hh (working copy)
@@ -73,7 +73,7 @@
if (max_ = min_)
return; // FIXME
float min = float(min_), max = float(max_);
- const float epsilon = value::props<float>::epsilon();
+ const float epsilon = mln_epsilon(float);
float m = 0.0f - 0.5f + epsilon;
float M = mln_max(value::int_u<n>) + 0.5f - epsilon;
float a = (M - m) / (max - min);
Index: mln/accu/min.hh
--- mln/accu/min.hh (revision 1511)
+++ mln/accu/min.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/util/pix.hh>
Index: mln/accu/max.hh
--- mln/accu/max.hh (revision 1511)
+++ mln/accu/max.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/core/concept/meta_accumulator.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/util/pix.hh>
Index: mln/accu/min_max.hh
--- mln/accu/min_max.hh (revision 1511)
+++ mln/accu/min_max.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/accu/pair.hh>
# include <mln/accu/min.hh>
# include <mln/accu/max.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/util/pix.hh>
Index: mln/accu/sum.hh
--- mln/accu/sum.hh (revision 1511)
+++ mln/accu/sum.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/meta_accumulator.hh>
# include <mln/accu/internal/base.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/util/pix.hh>
# include <mln/literal/zero.hh>
Index: mln/value/proxy.hh
--- mln/value/proxy.hh (revision 1511)
+++ mln/value/proxy.hh (working copy)
@@ -34,16 +34,41 @@
*/
# include <mln/core/concept/value.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/unconst.hh>
namespace mln
{
- namespace value
+ // Fwd decl.
+ namespace value {
+ template <typename I> class proxy;
+ }
+
+
+ namespace trait
+ {
+
+ template <typename I>
+ struct value_< mln::value::proxy<I> >
+ :
+ value_< mln_value(I) >
+ {
+ };
+
+ template <typename I>
+ struct value_< mln::value::proxy<const I> >
+ :
+ value_< mln_value(I) >
{
+ };
+
+ } // end of namespace trait
+
+ namespace value
+ {
/*! \brief Generic proxy class for an image pixel value.
*
@@ -156,14 +181,6 @@
- template <typename I>
- struct props< proxy<I> > : public props< mln_value(I) >
- {
- // Contents is inherited.
- };
-
-
-
/*! \brief Print a value proxy \p x into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
Index: mln/value/graylevel.hh
--- mln/value/graylevel.hh (revision 1511)
+++ mln/value/graylevel.hh (working copy)
@@ -44,7 +44,7 @@
# include <mln/value/int_u.hh>
# include <mln/value/gray.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
@@ -144,6 +144,33 @@
mln::value::scalar_<S>) ret;
};
+
+ // 'graylevel<n>' as a value.
+
+ template <unsigned n>
+ struct value_< mln::value::graylevel<n> >
+ {
+ private:
+ typedef mln::value::graylevel<n> self_;
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
+
+ typedef trait::value::nature::integer nature; // FIXME: Or scalar?
+ typedef trait::value::kind::gray kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ min() { return 0; }
+ static const self_ max() { return card - 1; }
+ static const self_ epsilon() { return 0; }
+
+ typedef float sum;
+ };
+
+
} // end of namespace mln::trait
@@ -219,18 +246,6 @@
};
- template <unsigned n>
- struct props< graylevel<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const graylevel<n> min() { return 0; }
- static const graylevel<n> max() { return card_ - 1; }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- typedef int interop;
- };
-
/// Op<<.
template <unsigned n>
Index: mln/value/lut_vec.hh
--- mln/value/lut_vec.hh (revision 1511)
+++ mln/value/lut_vec.hh (working copy)
@@ -37,7 +37,7 @@
# include <mln/core/concept/value_set.hh>
# include <mln/core/concept/function.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
Index: mln/value/ops.hh
--- mln/value/ops.hh (revision 1511)
+++ mln/value/ops.hh (working copy)
@@ -37,14 +37,16 @@
# include <mln/value/builtin/all.hh>
# include <mln/value/concept/all.hh>
# include <mln/value/equiv.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/literal/zero.hh>
# include <mln/literal/one.hh>
# include <mln/literal/ops.hh>
# include <mln/metal/ret.hh>
-# define mln_sum_x(T, U) typename mln::value::props< mln_trait_op_times(T,U) >::sum
+# define mln_trait_value_sum_x(T, U) typename mln::trait::value_< mln_trait_op_times(T,U) >::sum
+
+# define mln_sum_x(T, U) mln_trait_value_sum_x(T, U)
Index: mln/value/gray.hh
--- mln/value/gray.hh (revision 1511)
+++ mln/value/gray.hh (working copy)
@@ -69,9 +69,36 @@
typedef mln::value::gray ret;
};
+
+ // 'gray' as a value.
+
+ template <>
+ struct value_< mln::value::gray >
+ {
+ private:
+ typedef mln::value::gray self_;
+ public:
+
+ enum {
+ nbits = 8 * (sizeof(unsigned) + sizeof(long)),
+ card = 0
+ };
+
+ typedef trait::value::nature::integer nature; // FIXME: Or scalar?
+ typedef trait::value::kind::gray kind;
+ typedef trait::value::quant::high quant;
+
+ static const self_ min();
+ static const self_ max();
+ static const self_ epsilon();
+
+ typedef self_ sum; // FIXME: OK?
+ };
+
} // end of namespace mln::trait
+
namespace value
{
@@ -131,7 +158,7 @@
unsigned nbits_;
/// Value.
- long val_;
+ long val_; // FIXME: Why not int?
};
@@ -151,10 +178,15 @@
gray operator/(const gray& lhs, int s);
+ } // end of namespace mln::value
+
# ifndef MLN_INCLUDE_ONLY
+ namespace value
+ {
+
// Gray.
gray::gray()
@@ -513,10 +545,39 @@
return internal::helper_gray_op_<ret>::div(lhs, rhs);
}
-# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
+
+
+ namespace trait
+ {
+
+ // 'gray' as a value.
+
+ const mln::value::gray
+ value_< mln::value::gray >::min()
+ {
+ return mln::value::gray(1, 0);
+ }
+
+ const mln::value::gray
+ value_< mln::value::gray >::max()
+ {
+ return mln::value::gray(1, 1);
+ }
+
+ const mln::value::gray
+ value_< mln::value::gray >::epsilon()
+ {
+ return mln::value::gray(1, 0); // Means '0'.
+ }
+
+ } // end of namespace mln::trait
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln
Index: mln/value/float01_.hh
--- mln/value/float01_.hh (revision 1511)
+++ mln/value/float01_.hh (working copy)
@@ -40,20 +40,49 @@
# include <mln/value/int_u.hh>
# include <mln/value/concept/floating.hh>
+# include <mln/value/internal/convert.hh>
# include <mln/value/float01.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
{
- namespace value
+ // Fwd decls.
+ namespace value {
+ class float01;
+ template <unsigned n> struct float01_;
+ }
+
+
+ namespace trait
{
- /// Fwd decl.
- class float01;
+ template <unsigned n>
+ struct value_< mln::value::float01_<n> >
+ {
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(nbits)
+ };
+ typedef trait::value::nature::floating nature;
+ typedef trait::value::kind::data kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const float min() { return 0.f; }
+ static const float max() { return 1.f; }
+ static const float epsilon() { return 0.f; }
+
+ typedef float sum;
+ };
+
+ } // end of namespace trait
+
+
+ namespace value
+ {
/// General class for the interval [0,1] of |R made discrete (quantized with n bits).
template <unsigned n>
@@ -106,18 +135,6 @@
};
}
- template <unsigned n>
- struct props< float01_<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const float min() { return 0.f; }
- static const float max() { return 1.f; }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- typedef float interop;
- };
-
/// Op<<.
template <unsigned n>
@@ -146,14 +163,14 @@
{
mln_precondition(val >= 0);
mln_precondition(val <= 1);
- this->v_ = int(val * (mln_card_(float01_<n>) - 1)); // FIXME
+ this->v_ = int(val * (mln_card(float01_<n>) - 1)); // FIXME
}
template <unsigned n>
float
float01_<n>::value() const
{
- return float(this->v_) / (mln_card_(float01_<n>) - 1); // FIXME
+ return float(this->v_) / (mln_card(float01_<n>) - 1); // FIXME
}
template <unsigned n>
@@ -169,14 +186,14 @@
{
mln_precondition(val >= 0);
mln_precondition(val <= 1);
- this->v_ = int(val * (mln_card_(float01_<n>) - 1)); // FIXME
+ this->v_ = int(val * (mln_card(float01_<n>) - 1)); // FIXME
return *this;
}
template <unsigned n>
float01_<n>::operator float() const
{
- return float(this->v_) / (mln_card_(float01_<n>) - 1);
+ return float(this->v_) / (mln_card(float01_<n>) - 1);
}
Index: mln/value/all.hh
--- mln/value/all.hh (revision 1511)
+++ mln/value/all.hh (working copy)
@@ -49,7 +49,7 @@
# include <mln/value/aliases.hh>
# include <mln/value/label.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/value/proxy.hh>
# include <mln/value/interval.hh>
Index: mln/value/quat.hh
--- mln/value/quat.hh (revision 1511)
+++ mln/value/quat.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/value/concept/vectorial.hh>
# include <mln/value/internal/value_like.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/vec.hh>
# include <mln/norm/l2.hh>
@@ -90,6 +90,26 @@
typedef mln::value::quat ret;
};
+
+ // 'quat' as a value.
+
+
+ template <>
+ struct value_< mln::value::quat >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+ typedef trait::value::quant::high quant;
+
+ enum {
+ nbits = 4 * sizeof(float),
+ card = 0
+ };
+
+ typedef mln::value::quat sum;
+ };
+
+
} // end of namespace mln::trait
@@ -376,8 +396,8 @@
{
static const float pi = 3.14159265358979323846;
- mln_precondition(theta > - pi - props<float>::epsilon()
- && theta < pi + props<float>::epsilon());
+ mln_precondition(theta > - pi - mln_epsilon(float)
+ && theta < pi + mln_epsilon(float));
mln_precondition(about_equal(norm::l2(uv), 1.f));
this->v_[0] = cos(theta);
@@ -496,9 +516,10 @@
template <typename T>
bool about_equal(const T& f, const T& q)
{
+ // FIXME: Use abs!
if (f > q)
- return (f - q ) < props<T>::epsilon();
- return (q - f) < props<T>::epsilon();
+ return (f - q ) < mln_epsilon(T);
+ return (q - f) < mln_epsilon(T);
}
bool about_equal(const quat& p, const quat& q)
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1511)
+++ mln/value/int_s.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/trait/all.hh>
# include <mln/debug/format.hh>
@@ -69,8 +69,26 @@
{
template <unsigned n>
- struct value_< mln::value::int_s<n> > : mln::trait::value_integer_<n>
+ struct value_< mln::value::int_s<n> >
{
+ private:
+ typedef mln::value::int_s<n> self_;
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
+
+ typedef trait::value::nature::integer nature;
+ typedef trait::value::kind::data kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ max() { return card / 2 - 1; }
+ static const self_ min() { return - max(); }
+ static const self_ epsilon() { return 0; }
+
+ typedef float sum;
};
} // end of namespace mln::trait
@@ -88,8 +106,10 @@
template <unsigned n>
struct int_s
:
- public Integer< int_s<n> >,
-
+ private metal::bool_<(n <= 32)>::check_t
+ ,
+ public Integer< int_s<n> >
+ ,
public internal::value_like_< int, // Equivalent.
typename internal::encoding_signed_<n>::ret, // Enc.
int, // Interoperation.
@@ -129,19 +149,6 @@
- template <unsigned n>
- struct props< int_s<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value - 1;
- static const int_s<n> max() { return metal::math::pow_int<2, n-1>::value - 1; }
- static const int_s<n> min() { return - max(); }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- };
-
-
-
/*! \brief Print an signed integer \p i into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1511)
+++ mln/value/int_u.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/value/internal/value_like.hh>
# include <mln/value/internal/encoding.hh>
# include <mln/value/concept/integer.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/trait/all.hh> // FIXME!
# include <mln/trait/value_.hh>
# include <mln/debug/format.hh>
@@ -74,9 +74,28 @@
typedef int ret;
};
+
template <unsigned n>
- struct value_< mln::value::int_u<n> > : mln::trait::value_integer_<n>
+ struct value_< mln::value::int_u<n> >
{
+ private:
+ typedef mln::value::int_u<n> self_;
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
+
+ typedef trait::value::nature::integer nature;
+ typedef trait::value::kind::data kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ min() { return 0; }
+ static const self_ max() { return card - 1; }
+ static const self_ epsilon() { return 0; }
+
+ typedef float sum;
};
} // end of namespace mln::trait
@@ -136,20 +155,6 @@
- template <unsigned n>
- struct props< int_u<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const int_u<n> min() { return 0; }
- static const int_u<n> max() { return card_ - 1; }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- typedef int interop;
- };
-
-
-
/*! \brief Print an unsigned integer \p i into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
Index: mln/value/internal/iterable_set.hh
--- mln/value/internal/iterable_set.hh (revision 1511)
+++ mln/value/internal/iterable_set.hh (working copy)
@@ -34,9 +34,9 @@
*/
# include <mln/core/concept/value_set.hh>
-# include <mln/value/props.hh>
# include <mln/trait/value_.hh>
# include <mln/value/builtin/all.hh>
+# include <mln/value/internal/convert.hh>
namespace mln
@@ -112,8 +112,7 @@
unsigned
iterable_set<T,E>::nvalues() const
{
- typedef mln_trait_value_card(T) card_;
- return card_::value;
+ return mln_card(T);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/value/internal/convert.hh
--- mln/value/internal/convert.hh (revision 0)
+++ mln/value/internal/convert.hh (revision 0)
@@ -0,0 +1,105 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_VALUE_INTERNAL_CONVERT_HH
+# define MLN_VALUE_INTERNAL_CONVERT_HH
+
+/*! \file mln/value/internal/convert.hh
+ *
+ * \brief Define a conversion between an index and an iterable value.
+ */
+
+# include <mln/trait/value_.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct convert_
+ {
+ // FIXME: Check that we have a type T compatible with 'int'.
+
+ static T value_at_index(unsigned i);
+ static unsigned index_of_value(const T& v);
+ };
+
+ template <>
+ struct convert_<bool>
+ {
+ static bool value_at_index(unsigned i);
+ static unsigned index_of_value(bool v);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ T
+ convert_<T>::value_at_index(unsigned i)
+ {
+ return T( int(mln_min(T)) + int(i) );
+ }
+
+ template <typename T>
+ unsigned
+ convert_<T>::index_of_value(const T& v)
+ {
+ return unsigned( int(v) - int(mln_min(T)) );
+ }
+
+ // Case of 'bool'.
+
+ bool
+ convert_<bool>::value_at_index(unsigned i)
+ {
+ mln_precondition(i < 2);
+ return i = 1 ? true : false;
+ }
+
+ unsigned
+ convert_<bool>::index_of_value(bool v)
+ {
+ return v ? 1 : 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value::internal
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_INTERNAL_CONVERT_HH
Index: mln/value/int_u_sat.hh
--- mln/value/int_u_sat.hh (revision 1511)
+++ mln/value/int_u_sat.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/debug/format.hh>
Index: mln/value/set.hh
--- mln/value/set.hh (revision 1511)
+++ mln/value/set.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/value/internal/iterable_set.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
@@ -46,12 +46,12 @@
namespace internal
{
- template <typename T, typename E, typename is_lowq = metal::false_>
+ template <typename T, typename E, bool is_lowq = false>
struct set_selector_ // no inheritance
{};
template <typename T, typename E>
- struct set_selector_< T, E, metal::true_ > // lowq so iterable
+ struct set_selector_< T, E, true > // lowq so iterable
:
public iterable_set< T, E >
{};
@@ -65,7 +65,10 @@
* This is the exhaustive set of values obtainable from type \c T.
*/
template <typename T>
- struct set : public internal::set_selector_< T, set<T>, mln_is_lowq(T) >
+ struct set : public internal::set_selector_< T, set<T>,
+ mlc_equal( mln_trait_value_quant(T),
+ mln::trait::value::quant::low )::value
+ >
{
/// Return a singleton.
static const set<T>& the();
Index: mln/value/float01.hh
--- mln/value/float01.hh (revision 1511)
+++ mln/value/float01.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/core/concept/value.hh>
# include <mln/value/float01_.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/trait/all.hh> // FIXME!
# include <mln/trait/value_.hh>
Index: mln/value/builtin/symbolics.hh
--- mln/value/builtin/symbolics.hh (revision 1511)
+++ mln/value/builtin/symbolics.hh (working copy)
@@ -56,11 +56,14 @@
template <>
struct value_< bool>
{
- typedef metal::int_<1> nbits;
typedef value::nature::symbolic nature;
typedef value::kind::binary kind;
+
+ enum {
+ nbits = 1,
+ card = 2
+ };
typedef value::quant::low quant;
- typedef metal::int_<2> card;
};
} // end of namespace mln::trait
Index: mln/value/builtin/floatings.hh
--- mln/value/builtin/floatings.hh (revision 1511)
+++ mln/value/builtin/floatings.hh (working copy)
@@ -33,6 +33,8 @@
* \brief Some definitions about built-in floating types.
*/
+# include <limits>
+
# include <mln/value/concept/built_in.hh>
# include <mln/value/concept/floating.hh>
# include <mln/trait/value_.hh>
@@ -63,22 +65,62 @@
template <>
struct value_< float >
{
- typedef metal::int_<8*sizeof(float)> nbits;
+ enum {
+ nbits = 8 * sizeof(float),
+ card = 0
+ };
+
typedef value::nature::floating nature;
typedef value::kind::data kind;
- typedef metal::int_<0> card;
typedef value::quant::high quant;
+
+ static const float min()
+ {
+ static const float min_ = std::numeric_limits<float>::min();
+ return min_;
+ }
+ static const float max()
+ {
+ static const float max_ = std::numeric_limits<float>::max();
+ return max_;
+ }
+ static const float epsilon()
+ {
+ static const float epsilon_ = std::numeric_limits<float>::epsilon();
+ return epsilon_;
+ }
+
typedef float sum;
};
template <>
struct value_< double >
{
- typedef metal::int_<8*sizeof(double)> nbits;
+ enum {
+ nbits = 8 * sizeof(double),
+ card = 0
+ };
+
typedef value::nature::floating nature;
typedef value::kind::data kind;
- typedef metal::int_<0> card;
typedef value::quant::high quant;
+
+ static const double min()
+ {
+ static const double min_ = std::numeric_limits<double>::min();
+ return min_;
+ }
+ static const double max()
+ {
+ static const double max_ = std::numeric_limits<double>::max();
+ return max_;
+ }
+ static const double epsilon()
+ {
+ static const double epsilon_ = std::numeric_limits<double>::epsilon();
+ return epsilon_;
+ }
+
typedef double sum;
};
Index: mln/value/builtin/integers.hh
--- mln/value/builtin/integers.hh (revision 1511)
+++ mln/value/builtin/integers.hh (working copy)
@@ -33,6 +33,8 @@
* \brief Some definitions about built-in integer types.
*/
+# include <limits>
+
# include <mln/value/concept/built_in.hh>
# include <mln/value/concept/integer.hh>
# include <mln/trait/value_.hh>
@@ -63,43 +65,39 @@
namespace internal
{
- template < bool small_n /* = true */, unsigned n_bits >
- struct helper_card_
- {
- typedef metal::math::pow_int<2, n_bits> pow_;
- typedef metal::int_<pow_::value> card;
- };
-
- template < unsigned n_bits >
- struct helper_card_< false, n_bits >
- {
- typedef metal::int_<0> card;
- };
-
- } // end of namespace mln::trait::internal
-
-
- template <unsigned n_bits>
+ template <typename E>
struct value_integer_
{
- typedef typename internal::helper_card_<(n_bits <= 16), n_bits>::card card;
+ private:
+ enum { n = 8 * sizeof(E) };
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
- typedef metal::int_<n_bits> nbits;
typedef trait::value::nature::integer nature;
typedef trait::value::kind::data kind;
- typedef mln_value_quant_from_card(card) quant;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const E min() { return std::numeric_limits<E>::min(); }
+ static const E max() { return std::numeric_limits<E>::max(); }
+
typedef float sum;
};
+ } // end of namespace mln::trait::internal
+
- template <> struct value_< unsigned char > : value_integer_< 8 * sizeof(unsigned char) > {};
- template <> struct value_< signed char > : value_integer_< 8 * sizeof( signed char) > {};
- template <> struct value_< unsigned short > : value_integer_< 8 * sizeof(unsigned short) > {};
- template <> struct value_< signed short > : value_integer_< 8 * sizeof( signed short) > {};
- template <> struct value_< unsigned int > : value_integer_< 8 * sizeof(unsigned int) > {};
- template <> struct value_< signed int > : value_integer_< 8 * sizeof( signed int) > {};
- template <> struct value_< unsigned long > : value_integer_< 8 * sizeof(unsigned long) > {};
- template <> struct value_< signed long > : value_integer_< 8 * sizeof( signed long) > {};
+ template <> struct value_< unsigned char > : internal::value_integer_< unsigned char > {};
+ template <> struct value_< signed char > : internal::value_integer_< signed char > {};
+ template <> struct value_< unsigned short > : internal::value_integer_< unsigned short > {};
+ template <> struct value_< signed short > : internal::value_integer_< signed short > {};
+ template <> struct value_< unsigned int > : internal::value_integer_< unsigned int > {};
+ template <> struct value_< signed int > : internal::value_integer_< signed int > {};
+ template <> struct value_< unsigned long > : internal::value_integer_< unsigned long > {};
+ template <> struct value_< signed long > : internal::value_integer_< signed long > {};
} // end of namespace mln::trait
Index: mln/value/rgb.hh
--- mln/value/rgb.hh (revision 1511)
+++ mln/value/rgb.hh (working copy)
@@ -57,6 +57,34 @@
}
+ // Fwd decl.
+ namespace value {
+ template <unsigned n> struct rgb;
+ }
+
+
+ namespace trait
+ {
+
+ template <unsigned n>
+ struct value_< mln::value::rgb<n> >
+ {
+ enum {
+ nbits = 3 * n,
+ card = mln_value_card_from_(nbits)
+ };
+
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::color kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::vec<3, float> sum;
+ };
+
+ } // end of namespace trait
+
+
+
namespace value
{
@@ -129,17 +157,6 @@
- template <unsigned n>
- struct props< rgb<n> >
- {
- static const unsigned nbits = 3 * n;
- static const std::size_t card_ = 0; // FIXME: was: metal::math::pow_int<2, nbits>::value;
- typedef trait::value::kind::color kind;
- typedef metal::vec<3, float> sum;
- typedef metal::vec<3, int> interop;
- };
-
-
/*! \brief Print an rgb \p c into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
Index: mln/value/float01_f.hh
--- mln/value/float01_f.hh (revision 1511)
+++ mln/value/float01_f.hh (working copy)
@@ -36,18 +36,49 @@
# include <iostream>
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/floating.hh>
-# include <mln/value/props.hh>
+# include <mln/value/builtin/floatings.hh>
+# include <mln/trait/value_.hh>
+
namespace mln
{
- namespace value
+ // Fwd decls.
+ namespace value {
+ struct float01;
+ struct float01_f;
+ }
+
+
+ namespace trait
{
- /// Fwd decl.
- struct float01;
+ template <>
+ struct value_< mln::value::float01_f >
+ {
+ typedef trait::value::nature::floating nature;
+ typedef trait::value::kind::data kind;
+ typedef trait::value::quant::high quant;
+
+ enum {
+ nbits = 8 * sizeof(float),
+ card = 0
+ };
+
+ static const float min() { return 0; }
+ static const float max() { return 1; }
+ static const float epsilon() { return mln_epsilon(float); }
+
+ typedef float sum;
+ };
+
+ } // end of namespace trait
+
+ namespace value
+ {
+
/// Class for floating values restricted to the interval [0..1].
struct float01_f
:
@@ -75,19 +106,6 @@
};
- template <>
- struct props< float01_f >
- {
- static const std::size_t card_ = 0;
- static const float min() { return 0; }
- static const float max() { return 1; }
- //static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- typedef float interop;
- };
-
-
# ifndef MLN_INCLUDE_ONLY
// Float01_F.
Index: mln/value/label.hh
--- mln/value/label.hh (revision 1511)
+++ mln/value/label.hh (working copy)
@@ -34,19 +34,53 @@
*/
# include <mln/metal/math/pow.hh>
-# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/symbolic.hh>
+# include <mln/value/internal/value_like.hh>
+# include <mln/value/internal/convert.hh>
# include <mln/value/internal/encoding.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
{
- namespace value
+ // Fwd decl.
+ namespace value {
+ template <unsigned n> struct label;
+ }
+
+
+
+ namespace trait
+ {
+
+ template <unsigned n>
+ struct value_< mln::value::label<n> >
{
+ private:
+ typedef mln::value::label<n> self_;
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
+
+ typedef trait::value::nature::symbolic nature;
+ typedef trait::value::kind::label kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ min() { return 0; }
+ static const self_ max() { return card - 1; }
+ };
+
+ } // end of namespace trait
+
+ namespace value
+ {
+
/*! \brief Label value class.
*
@@ -125,23 +159,6 @@
-
- template <unsigned n>
- struct props< label<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const label<n> min; // = 0
- static const label<n> max; // = card_ - 1
- static const unsigned nbits = n;
- typedef trait::value::kind::label kind;
- };
-
-
-
-
-
-
-
/*! \brief Print a label \p l into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
@@ -217,14 +234,6 @@
}
template <unsigned n>
- const label<n>
- props< label<n> >::min = 0;
-
- template <unsigned n>
- const label<n>
- props< label<n> >::max = metal::math::pow_int<2, n>::value - 1;
-
- template <unsigned n>
std::ostream& operator<<(std::ostream& ostr, const label<n>& i)
{
return ostr << i.to_enc();
Index: mln/fun/v2v/saturate.hh
--- mln/fun/v2v/saturate.hh (revision 1511)
+++ mln/fun/v2v/saturate.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/core/concept/function.hh>
# include <mln/metal/converts_to.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
Index: mln/morpho/Rd.hh
--- mln/morpho/Rd.hh (revision 1511)
+++ mln/morpho/Rd.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/level/fill.hh>
# include <mln/level/compare.hh>
Index: mln/io/pnm/save_header.hh
--- mln/io/pnm/save_header.hh (revision 1511)
+++ mln/io/pnm/save_header.hh (working copy)
@@ -61,6 +61,10 @@
file << unsigned(mln_max(V)) << std::endl;
}
+ void save_max_val(bool&, std::ofstream& file)
+ {
+ }
+
template <unsigned int n>
void save_max_val(value::rgb<n>&, std::ofstream& file)
{
@@ -80,7 +84,11 @@
abort();
}
file << "P" << type << std::endl;
- file << "# milena" << std::endl;
+ file << "# Generated by milena 1.0 http://olena.lrde.epita.fr" << std::endl;
+ file << "# EPITA Research and Development Laboratory (LRDE)" << std::endl;
+ // We have a two-line comment because xv is buggy for some
+ // tiny binary images and their workaround is to have such a
+ // two-line comment...
file << geom::ncols(ima) << ' ' << geom::nrows(ima) << std::endl;
mln_value(I) i;
Index: mln/io/pnm/load.hh
--- mln/io/pnm/load.hh (revision 1511)
+++ mln/io/pnm/load.hh (working copy)
@@ -189,9 +189,9 @@
read_header(type_ - 3, type_, file, type,
nrows, ncols, maxval);
- if (value::props< mln_value(I) >::max() != maxval)
+ if (mln_max(mln_value(I)) != maxval)
{
- std::cerr << "max ref : " << value::props< mln_value(I) >::max()
+ std::cerr << "max ref : " << mln_max(mln_value(I))
<< "max image : " << maxval
<< std::endl;
Index: mln/io/pbm/save.hh
--- mln/io/pbm/save.hh (revision 1511)
+++ mln/io/pbm/save.hh (working copy)
@@ -80,29 +80,30 @@
io::pnm::save_header(PBM, ima, filename, file);
- const int
- min_row = geom::min_row(ima),
- max_row = geom::max_row(ima),
- min_col = geom::min_col(ima),
- max_col = geom::max_col(ima);
- point2d p;
-
+ int ncols = geom::ncols(ima);
+ int col = 0;
+ int stride = 0;
unsigned char c = 0;
- int i = 0;
- mln_piter(I) it(ima.domain());
- for_all(it)
+ mln_fwd_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ c <<= 1;
+ c += (ima(p) = true ? 1 : 0); // FIXME: Swap.
+ if (++col >= ncols)
{
- if (i && (i = 8))
+ c <<= (8 - stride - 1);
+ file << c;
+ c = col = stride = 0;
+ }
+ else
+ if (++stride >= 8)
{
- file.write((char*)(&c), 1);
- i = 0;
+ file << c;
+ c = stride = 0;
}
- c = c * 2;
- c += ima(it);
- ++i;
}
- file.write((char*)(&c), 1);
+ mln_postcondition(stride = 0);
}
} // end of namespace mln::io::impl
Index: mln/norm/l1.hh
--- mln/norm/l1.hh (revision 1511)
+++ mln/norm/l1.hh (working copy)
@@ -47,19 +47,19 @@
/// L1-norm of a vector \a vec.
/// \{
template <unsigned n, typename C>
- mln_value_sum(C) l1(const C (&vec)[n]);
+ mln_sum(C) l1(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_value_sum(C) l1(const metal::vec<n,C>& vec);
+ mln_sum(C) l1(const metal::vec<n,C>& vec);
/// \}
/// L1-norm distance between vectors \a vec1 and \a vec2.
/// \{
template <unsigned n, typename C>
- mln_value_sum(C) l1_distance(const C (&vec1)[n], const C (&vec2)[n]);
+ mln_sum(C) l1_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- mln_value_sum(C) l1_distance(const metal::vec<n,C>& vec1,
+ mln_sum(C) l1_distance(const metal::vec<n,C>& vec1,
const metal::vec<n,C>& vec2);
/// \}
@@ -69,20 +69,20 @@
namespace impl
{
template <unsigned n, typename C, typename V>
- mln_value_sum(C)
+ mln_sum(C)
l1_(const V& vec)
{
- mln_value_sum(C) m = 0;
+ mln_sum(C) m = 0;
for (unsigned i = 0; i < n; ++i)
m += mln::math::abs (vec[i]);
return m;
}
template <unsigned n, typename C, typename V>
- mln_value_sum(C)
+ mln_sum(C)
l1_distance_(const V& vec1, const V& vec2)
{
- mln_value_sum(C) d = 0;
+ mln_sum(C) d = 0;
for (unsigned i = 0; i < n; ++i)
d += mln::math::abs (vec1[i] - vec2[i]);
return d;
@@ -96,28 +96,28 @@
`----------*/
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l1(const C (&vec)[n])
{
return impl::l1_<n, C>(vec);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l1(const metal::vec<n,C>& vec)
{
return impl::l1_<n, C>(vec);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l1_distance(const C (&vec1)[n], const C (&vec2)[n])
{
return impl::l1_distance_<n, C>(vec1, vec2);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l1_distance(const metal::vec<n,C>& vec1, const metal::vec<n,C>& vec2)
{
return impl::l1_distance_<n, C>(vec1, vec2);
Index: mln/norm/l2.hh
--- mln/norm/l2.hh (revision 1511)
+++ mln/norm/l2.hh (working copy)
@@ -48,19 +48,19 @@
/// L2-norm of a vector \a vec.
/// \{
template <unsigned n, typename C>
- mln_value_sum(C) l2(const C (&vec)[n]);
+ mln_sum(C) l2(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_value_sum(C) l2(const metal::vec<n,C>& vec);
+ mln_sum(C) l2(const metal::vec<n,C>& vec);
/// \}
/// L2-norm distance between vectors \a vec1 and \p vec2.
/// \{
template <unsigned n, typename C>
- mln_value_sum(C) l2_distance(const C (&vec1)[n], const C (&vec2)[n]);
+ mln_sum(C) l2_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- mln_value_sum(C) l2_distance(const metal::vec<n,C>& vec1,
+ mln_sum(C) l2_distance(const metal::vec<n,C>& vec1,
const metal::vec<n,C>& vec2);
/// \}
@@ -71,20 +71,20 @@
{
template <unsigned n, typename C, typename V>
- mln_value_sum(C)
+ mln_sum(C)
l2_(const V& vec)
{
- mln_value_sum(C) m = 0;
+ mln_sum(C) m = 0;
for (unsigned i = 0; i < n; ++i)
m += mln::math::sqr(vec[i]);
return mln::math::sqrt(m);
}
template <unsigned n, typename C, typename V>
- mln_value_sum(C)
+ mln_sum(C)
l2_distance_(const V& vec1, const V& vec2)
{
- mln_value_sum(C) d = 0;
+ mln_sum(C) d = 0;
for (unsigned i = 0; i < n; ++i)
d += mln::math::sqr(vec1[i] - vec2[i]);
return mln::math::sqrt(d);
@@ -98,28 +98,28 @@
`----------*/
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l2(const C (&vec)[n])
{
return impl::l2_<n, C>(vec);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l2(const metal::vec<n,C>& vec)
{
return impl::l2_<n, C>(vec);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l2_distance(const C (&vec1)[n], const C (&vec2)[n])
{
return impl::l2_distance_<n, C>(vec1, vec2);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l2_distance(const metal::vec<n,C>& vec1, const metal::vec<n,C>& vec2)
{
return impl::l2_distance_<n, C>(vec1, vec2);
1
0
22 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Review the set directory and add tests.
* mln/set/all.hh,
* mln/set/diff.hh,
* mln/set/inter.hh,
* mln/set/is_subset_of.hh,
* mln/set/sym_diff.hh,
* mln/set/uni.hh: Review.
* tests/Makefile.am,
* tests/set/Makefile.am,
* tests/set/diff.cc,
* tests/set/inter.cc,
* tests/set/is_subset_of.cc,
* tests/set/sym_diff.cc,
* tests/set/uni.cc: Add tests.
* mln/make/pix.hh: Doc.
---
mln/make/pix.hh | 8 +++
mln/set/all.hh | 1
mln/set/diff.hh | 15 +++++--
mln/set/inter.hh | 4 +
mln/set/is_subset_of.hh | 13 ++++++
mln/set/sym_diff.hh | 14 +++++-
mln/set/uni.hh | 4 +
tests/Makefile.am | 3 -
tests/set/Makefile.am | 15 +++++++
tests/set/diff.cc | 93 +++++++++++++++++++++++++++++++++++++++++++++
tests/set/inter.cc | 94 ++++++++++++++++++++++++++++++++++++++++++++++
tests/set/is_subset_of.cc | 79 ++++++++++++++++++++++++++++++++++++++
tests/set/sym_diff.cc | 93 +++++++++++++++++++++++++++++++++++++++++++++
tests/set/uni.cc | 93 +++++++++++++++++++++++++++++++++++++++++++++
14 files changed, 522 insertions(+), 7 deletions(-)
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1510)
+++ trunk/milena/tests/Makefile.am (revision 1511)
@@ -9,7 +9,8 @@
draw \
border \
canvas \
- win
+ win \
+ set
check_PROGRAMS = \
accu_all \
Index: trunk/milena/tests/set/uni.cc
===================================================================
--- trunk/milena/tests/set/uni.cc (revision 0)
+++ trunk/milena/tests/set/uni.cc (revision 1511)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/uni.cc
+ *
+ * \brief Tests on mln::set::uni.
+ */
+
+#include <mln/set/uni.hh>
+#include <mln/core/dpoint2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ window<dpoint2d> win1;
+ win1
+ .insert( 2, 7)
+ .insert( 2, 1)
+ .insert(-4, 0)
+ .insert( 0, 0)
+ .insert( 1, 1)
+ .insert( 6, 5);
+ window<dpoint2d> win2;
+ win2
+ .insert( 2, 7)
+ .insert(-2, 1)
+ .insert(-4, 0)
+ .insert( 1,-1)
+ .insert( 6, 5);
+ window<dpoint2d> win3 = set::uni(win1, win2);
+ mln_assertion(win3.has(dpoint2d( 2, 1)));
+ mln_assertion(win3.has(dpoint2d( 0, 0)));
+ mln_assertion(win3.has(dpoint2d( 1, 1)));
+ mln_assertion(win3.has(dpoint2d( 2, 7)));
+ mln_assertion(win3.has(dpoint2d(-2, 1)));
+ mln_assertion(win3.has(dpoint2d(-4, 0)));
+ mln_assertion(win3.has(dpoint2d( 1,-1)));
+ mln_assertion(win3.has(dpoint2d( 6, 5)));
+ }
+
+ {
+ p_set<point2d> pst1;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst2;
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst3 = set::uni(pst1, pst2);
+ mln_assertion(pst3.has(point2d( 2, 1)));
+ mln_assertion(pst3.has(point2d( 0, 0)));
+ mln_assertion(pst3.has(point2d( 1, 1)));
+ mln_assertion(pst3.has(point2d( 2, 7)));
+ mln_assertion(pst3.has(point2d(-2, 1)));
+ mln_assertion(pst3.has(point2d(-4, 0)));
+ mln_assertion(pst3.has(point2d( 1,-1)));
+ mln_assertion(pst3.has(point2d( 6, 5)));
+ }
+}
Index: trunk/milena/tests/set/sym_diff.cc
===================================================================
--- trunk/milena/tests/set/sym_diff.cc (revision 0)
+++ trunk/milena/tests/set/sym_diff.cc (revision 1511)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/sym_diff.cc
+ *
+ * \brief Tests on mln::set::sym_diff.
+ */
+
+#include <mln/set/sym_diff.hh>
+#include <mln/core/dpoint2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ window<dpoint2d> win1;
+ win1
+ .insert( 2, 7)
+ .insert( 2, 1)
+ .insert(-4, 0)
+ .insert( 0, 0)
+ .insert( 1, 1)
+ .insert( 6, 5);
+ window<dpoint2d> win2;
+ win2
+ .insert( 2, 7)
+ .insert(-2, 1)
+ .insert(-4, 0)
+ .insert( 1,-1)
+ .insert( 6, 5);
+ window<dpoint2d> win3 = set::sym_diff(win1, win2);
+ mln_assertion(win3.has(dpoint2d( 2, 1)));
+ mln_assertion(win3.has(dpoint2d( 0, 0)));
+ mln_assertion(win3.has(dpoint2d( 1, 1)));
+ mln_assertion(!win3.has(dpoint2d( 2, 7)));
+ mln_assertion(win3.has(dpoint2d(-2, 1)));
+ mln_assertion(!win3.has(dpoint2d(-4, 0)));
+ mln_assertion(win3.has(dpoint2d( 1,-1)));
+ mln_assertion(!win3.has(dpoint2d( 6, 5)));
+ }
+
+ {
+ p_set<point2d> pst1;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst2;
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst3 = set::sym_diff(pst1, pst2);
+ mln_assertion(pst3.has(point2d( 2, 1)));
+ mln_assertion(pst3.has(point2d( 0, 0)));
+ mln_assertion(pst3.has(point2d( 1, 1)));
+ mln_assertion(!pst3.has(point2d( 2, 7)));
+ mln_assertion(pst3.has(point2d(-2, 1)));
+ mln_assertion(!pst3.has(point2d(-4, 0)));
+ mln_assertion(pst3.has(point2d( 1,-1)));
+ mln_assertion(!pst3.has(point2d( 6, 5)));
+ }
+}
Index: trunk/milena/tests/set/inter.cc
===================================================================
--- trunk/milena/tests/set/inter.cc (revision 0)
+++ trunk/milena/tests/set/inter.cc (revision 1511)
@@ -0,0 +1,94 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/inter.cc
+ *
+ * \brief Tests on mln::set::inter.
+ */
+
+#include <mln/set/inter.hh>
+#include <mln/core/dpoint2d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ window<dpoint2d> win1;
+ win1
+ .insert( 2, 7)
+ .insert( 2, 1)
+ .insert(-4, 0)
+ .insert( 0, 0)
+ .insert( 1, 1)
+ .insert( 6, 5);
+ window<dpoint2d> win2;
+ win2
+ .insert( 2, 7)
+ .insert(-2, 1)
+ .insert(-4, 0)
+ .insert( 1,-1)
+ .insert( 6, 5);
+ window<dpoint2d> win3 = set::inter(win1, win2);
+ mln_assertion(!win3.has(dpoint2d( 2, 1)));
+ mln_assertion(!win3.has(dpoint2d( 0, 0)));
+ mln_assertion(!win3.has(dpoint2d( 1, 1)));
+ mln_assertion(win3.has(dpoint2d( 2, 7)));
+ mln_assertion(!win3.has(dpoint2d(-2, 1)));
+ mln_assertion(win3.has(dpoint2d(-4, 0)));
+ mln_assertion(!win3.has(dpoint2d( 1,-1)));
+ mln_assertion(win3.has(dpoint2d( 6, 5)));
+ }
+
+ {
+ p_set<point2d> pst1;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst2;
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst3 = set::inter(pst1, pst2);
+ mln_assertion(!pst3.has(point2d( 2, 1)));
+ mln_assertion(!pst3.has(point2d( 0, 0)));
+ mln_assertion(!pst3.has(point2d( 1, 1)));
+ mln_assertion(pst3.has(point2d( 2, 7)));
+ mln_assertion(!pst3.has(point2d(-2, 1)));
+ mln_assertion(pst3.has(point2d(-4, 0)));
+ mln_assertion(!pst3.has(point2d( 1,-1)));
+ mln_assertion(pst3.has(point2d( 6, 5)));
+ }
+}
Index: trunk/milena/tests/set/is_subset_of.cc
===================================================================
--- trunk/milena/tests/set/is_subset_of.cc (revision 0)
+++ trunk/milena/tests/set/is_subset_of.cc (revision 1511)
@@ -0,0 +1,79 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/is_subset_of.cc
+ *
+ * \brief Tests on mln::set::is_subset_of.
+ */
+
+#include <mln/set/is_subset_of.hh>
+#include <mln/core/p_set.hh>
+#include <mln/core/point2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ p_set<point2d> pst1;
+ p_set<point2d> pst2;
+ p_set<point2d> pst3;
+ p_set<point2d> pst4;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ pst3
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5))
+ .insert(point2d(-2, 1))
+ .insert(point2d( 1,-1));
+
+ mln_assertion(set::is_subset_of(pst1, pst3));
+ mln_assertion(set::is_subset_of(pst2, pst3));
+ mln_assertion(!set::is_subset_of(pst3, pst1));
+ mln_assertion(!set::is_subset_of(pst3, pst2));
+ mln_assertion(set::is_subset_of(pst3, pst3));
+ mln_assertion(set::is_subset_of(pst4, pst1));
+ mln_assertion(set::is_subset_of(pst4, pst2));
+ mln_assertion(set::is_subset_of(pst4, pst3));
+ mln_assertion(set::is_subset_of(pst4, pst4));
+ }
+}
Index: trunk/milena/tests/set/Makefile.am
===================================================================
--- trunk/milena/tests/set/Makefile.am (revision 1510)
+++ trunk/milena/tests/set/Makefile.am (revision 1511)
@@ -1,3 +1,18 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ diff \
+ inter \
+ is_subset_of \
+ sym_diff \
+ uni
+
+diff_SOURCES = diff.cc
+inter_SOURCES = inter.cc
+is_subset_SOURCES = is_subset.cc
+sym_diff_SOURCES = sym_diff.cc
+uni_SOURCES = uni.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/set/diff.cc
===================================================================
--- trunk/milena/tests/set/diff.cc (revision 0)
+++ trunk/milena/tests/set/diff.cc (revision 1511)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/diff.cc
+ *
+ * \brief Tests on mln::set::diff.
+ */
+
+#include <mln/set/diff.hh>
+#include <mln/core/dpoint2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ window<dpoint2d> win1;
+ win1
+ .insert( 2, 7)
+ .insert( 2, 1)
+ .insert(-4, 0)
+ .insert( 0, 0)
+ .insert( 1, 1)
+ .insert( 6, 5);
+ window<dpoint2d> win2;
+ win2
+ .insert( 2, 7)
+ .insert(-2, 1)
+ .insert(-4, 0)
+ .insert( 1,-1)
+ .insert( 6, 5);
+ window<dpoint2d> win3 = set::diff(win1, win2);
+ mln_assertion(win3.has(dpoint2d( 2, 1)));
+ mln_assertion(win3.has(dpoint2d( 0, 0)));
+ mln_assertion(win3.has(dpoint2d( 1, 1)));
+ mln_assertion(!win3.has(dpoint2d( 2, 7)));
+ mln_assertion(!win3.has(dpoint2d(-2, 1)));
+ mln_assertion(!win3.has(dpoint2d(-4, 0)));
+ mln_assertion(!win3.has(dpoint2d( 1,-1)));
+ mln_assertion(!win3.has(dpoint2d( 6, 5)));
+ }
+
+ {
+ p_set<point2d> pst1;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst2;
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst3 = set::diff(pst1, pst2);
+ mln_assertion(pst3.has(point2d( 2, 1)));
+ mln_assertion(pst3.has(point2d( 0, 0)));
+ mln_assertion(pst3.has(point2d( 1, 1)));
+ mln_assertion(!pst3.has(point2d( 2, 7)));
+ mln_assertion(!pst3.has(point2d(-2, 1)));
+ mln_assertion(!pst3.has(point2d(-4, 0)));
+ mln_assertion(!pst3.has(point2d( 1,-1)));
+ mln_assertion(!pst3.has(point2d( 6, 5)));
+ }
+}
Index: trunk/milena/mln/make/pix.hh
===================================================================
--- trunk/milena/mln/make/pix.hh (revision 1510)
+++ trunk/milena/mln/make/pix.hh (revision 1511)
@@ -42,7 +42,13 @@
namespace make
{
- /// Create an mln::pix from an image \p ima and a psite \p p.
+ /*! \brief Create an mln::util::pix from an image \p ima and a psite \p p.
+ *
+ * \param[in] ima The input image.
+ * \param[in] p The point site.
+ *
+ * \return An mln::util::pix.
+ */
template <typename I>
mln::util::pix<I> pix(const Image<I>& ima, const mln_psite(I)& p);
Index: trunk/milena/mln/set/inter.hh
===================================================================
--- trunk/milena/mln/set/inter.hh (revision 1510)
+++ trunk/milena/mln/set/inter.hh (revision 1511)
@@ -69,6 +69,7 @@
window<mln_dpoint(Wl)>
inter(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
+ trace::entering("set::inter");
mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
typedef mln_dpoint(Wl) D;
std::set<D>
@@ -79,12 +80,14 @@
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
return convert::to_window(s);
+ trace::exiting("set::inter");
}
template <typename Wl, typename Wr>
p_set<mln_point(Wl)>
inter(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs)
{
+ trace::entering("set::inter");
mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
typedef mln_point(Wl) P;
std::set<P>
@@ -95,6 +98,7 @@
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
return convert::to_p_set(s);
+ trace::exiting("set::inter");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/set/is_subset_of.hh
===================================================================
--- trunk/milena/mln/set/is_subset_of.hh (revision 1510)
+++ trunk/milena/mln/set/is_subset_of.hh (revision 1511)
@@ -28,6 +28,11 @@
#ifndef MLN_SET_IS_SUBSET_OF_HH
# define MLN_SET_IS_SUBSET_OF_HH
+/*! \file mln/set/is_subset_of.hh
+ *
+ * \brief Routine to test if a set is a subset of another.
+ */
+
# include <mln/core/concept/point_set.hh>
namespace mln
@@ -49,18 +54,26 @@
bool
is_subset_of(const Point_Set<Pl>& lhs_, const Point_Set<Pr>& rhs_)
{
+ trace::entering("set::is_subset_of");
Pl lhs = exact(lhs_);
Pr rhs = exact(rhs_);
if (lhs.npoints() > rhs.npoints())
+ {
+ trace::exiting("set::is_subset_of");
return false;
+ }
mln_piter(Pl) p(lhs);
for_all(p)
{
if (!rhs.has(p))
+ {
+ trace::exiting("set::is_subset_of");
return false;
}
+ }
+ trace::exiting("set::is_subset_of");
return true;
}
Index: trunk/milena/mln/set/all.hh
===================================================================
--- trunk/milena/mln/set/all.hh (revision 1510)
+++ trunk/milena/mln/set/all.hh (revision 1511)
@@ -44,6 +44,7 @@
# include <mln/set/diff.hh>
# include <mln/set/inter.hh>
+# include <mln/set/is_subset_of.hh>
# include <mln/set/sym_diff.hh>
# include <mln/set/union.hh>
Index: trunk/milena/mln/set/diff.hh
===================================================================
--- trunk/milena/mln/set/diff.hh (revision 1510)
+++ trunk/milena/mln/set/diff.hh (revision 1511)
@@ -49,12 +49,18 @@
namespace set
{
- /// Set theoretic difference of \p lhs and \p rhs.
+ /*! \brief Set theoretic difference of \p lhs and \p rhs.
+ *
+ * \relates mln::Window
+ */
template <typename Wl, typename Wr>
window<mln_dpoint(Wl)>
diff(const Window<Wl>& lhs, const Window<Wr>& rhs);
- /// Set theoretic difference of \p lhs and \p rhs.
+ /*! \brief Set theoretic difference of \p lhs and \p rhs.
+ *
+ * \relates mln::Point_Set
+ */
template <typename Wl, typename Wr>
p_set<mln_point(Wl)>
diff(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs);
@@ -66,6 +72,7 @@
window<mln_dpoint(Wl)>
diff(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
+ trace::entering("set::diff");
mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
typedef mln_dpoint(Wl) D;
std::set<D>
@@ -75,14 +82,15 @@
std::set_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::diff");
return convert::to_window(s);
}
- /// Set theoretic difference of \p lhs and \p rhs.
template <typename Wl, typename Wr>
p_set<mln_point(Wl)>
diff(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs)
{
+ trace::entering("set::diff");
mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
typedef mln_point(Wl) P;
std::set<P>
@@ -92,6 +100,7 @@
std::set_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::diff");
return convert::to_p_set(s);
}
Index: trunk/milena/mln/set/uni.hh
===================================================================
--- trunk/milena/mln/set/uni.hh (revision 1510)
+++ trunk/milena/mln/set/uni.hh (revision 1511)
@@ -69,6 +69,7 @@
window<mln_dpoint(Wl)>
uni(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
+ trace::entering("set::uni");
mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
typedef mln_dpoint(Wl) D;
std::set<D>
@@ -78,6 +79,7 @@
std::set_union(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::uni");
return convert::to_window(s);
}
@@ -85,6 +87,7 @@
p_set<mln_point(Wl)>
uni(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs)
{
+ trace::entering("set::uni");
mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
typedef mln_point(Wl) P;
std::set<P>
@@ -94,6 +97,7 @@
std::set_union(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::uni");
return convert::to_p_set(s);
}
Index: trunk/milena/mln/set/sym_diff.hh
===================================================================
--- trunk/milena/mln/set/sym_diff.hh (revision 1510)
+++ trunk/milena/mln/set/sym_diff.hh (revision 1511)
@@ -46,12 +46,18 @@
namespace set
{
- /// Set theoretic symmetrical difference of \p lhs and \p rhs.
+ /*! \brief Set theoretic symmetrical difference of \p lhs and \p rhs.
+ *
+ * \relates mln::Window
+ */
template <typename Wl, typename Wr>
window<mln_dpoint(Wl)>
sym_diff(const Window<Wl>& lhs, const Window<Wr>& rhs);
- /// Set theoretic symmetrical difference of \p lhs and \p rhs.
+ /*! \brief Set theoretic symmetrical difference of \p lhs and \p rhs.
+ *
+ * \relates mln::Point_Set
+ */
template <typename Wl, typename Wr>
p_set<mln_point(Wl)>
sym_diff(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs);
@@ -62,6 +68,7 @@
window<mln_dpoint(Wl)>
sym_diff(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
+ trace::entering("set::sym_diff");
mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
typedef mln_dpoint(Wl) D;
std::set<D>
@@ -71,6 +78,7 @@
std::set_symmetric_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::sym_diff");
return convert::to_window(s);
}
@@ -78,6 +86,7 @@
p_set<mln_point(Wl)>
sym_diff(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs)
{
+ trace::entering("set::sym_diff");
mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
typedef mln_point(Wl) P;
std::set<P>
@@ -87,6 +96,7 @@
std::set_symmetric_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::sym_diff");
return convert::to_p_set(s);
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Replace the default viewer by "display".
* mln/display/save_and_show.hh,
* mln/display/show.hh,
* tests/display/save_and_show.cc,
* tests/display/show.cc: Replace "xv" by "display" for the
default viewer.
---
mln/display/save_and_show.hh | 6 +++---
mln/display/show.hh | 8 ++++----
tests/display/save_and_show.cc | 4 ++--
tests/display/show.cc | 4 ++--
4 files changed, 11 insertions(+), 11 deletions(-)
Index: trunk/milena/tests/display/show.cc
===================================================================
--- trunk/milena/tests/display/show.cc (revision 1509)
+++ trunk/milena/tests/display/show.cc (revision 1510)
@@ -69,7 +69,7 @@
{
image_if_value<image2d<unsigned> > t = inplace (tmp | i);
display::save (t);
- display::show (t, "xv", 1);
+ display::show (t, "display", 1);
}
// image2d<value::rgb8> color_image (16, 16);
@@ -77,7 +77,7 @@
// for (int j = 0; j < 16; ++j)
// color_image(point2d(i, j)) = value::rgb8(0,0,255);
// display::save (color_image);
-// display::show (color_image, "xv");
+// display::show (color_image, "display");
display::remove ();
}
Index: trunk/milena/tests/display/save_and_show.cc
===================================================================
--- trunk/milena/tests/display/save_and_show.cc (revision 1509)
+++ trunk/milena/tests/display/save_and_show.cc (revision 1510)
@@ -65,11 +65,11 @@
for (unsigned i = 2; i < 6; i += 2)
{
image_if_value<image2d<unsigned> > t = inplace (tmp | i);
- display::save_and_show (t, "xv", 1);
+ display::save_and_show (t, "display", 1);
}
/// FIXME: Uncomment this ASAP
// image2d<value::rgb8> ima (100, 100);
// level::fill(ima, value::rgb8 (0, 0, 255));
-// display::save_and_show (ima, "xv", 1);
+// display::save_and_show (ima, "display", 1);
}
Index: trunk/milena/mln/display/save_and_show.hh
===================================================================
--- trunk/milena/mln/display/save_and_show.hh (revision 1509)
+++ trunk/milena/mln/display/save_and_show.hh (revision 1510)
@@ -49,7 +49,7 @@
* \param[in] input_ the image to show.
* \param[in] cmd The string which contains the programm of the
* viewer which the user want to display with. By default its
- * value is "xv".
+ * value is "display".
* \param[in] time The number of second of
* display, 0 display permanently. By default the value is 0.
*
@@ -58,7 +58,7 @@
*/
template <typename I>
void
- save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
+ save_and_show(const Image<I>& input_, std::string cmd = "display", int time = 0);
# ifndef MLN_INCLUDE_ONLY
@@ -82,7 +82,7 @@
/// Facade.
template <typename I>
void
- save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
+ save_and_show(const Image<I>& input_, std::string cmd = "display", int time = 0)
{
trace::entering("display::save_and_show");
Index: trunk/milena/mln/display/show.hh
===================================================================
--- trunk/milena/mln/display/show.hh (revision 1509)
+++ trunk/milena/mln/display/show.hh (revision 1510)
@@ -31,7 +31,7 @@
/*! \file mln/display/show.hh
*
* \brief Display the temporary image which has just been saved with
- * given viewer (default xv).
+ * given viewer (default display).
*/
# include <mln/trait/image_from_mesh.hh>
@@ -53,7 +53,7 @@
* \param[in] input_ the image to show.
* \param[in] cmd The string which contains the programm of the
* viewer which the user want to display with. By default its
- * value is "xv".
+ * value is "display".
* \param[in] time The number of second of
* display, 0 display permanently. By default the value is 0.
*
@@ -62,7 +62,7 @@
*/
template <typename I>
void
- show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
+ show(const Image<I>& input_, std::string cmd = "display", int time = 0);
# ifndef MLN_INCLUDE_ONLY
@@ -114,7 +114,7 @@
/// Facade.
template <typename I>
void
- show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
+ show(const Image<I>& input_, std::string cmd = "display", int time = 0)
{
trace::entering("display::show");
1
0