URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-15 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Update tests/level.
* tests/level/fill.cc: Update.
* tests/level/take.cc: New simple test for level:take.
* tests/level/approx_median.cc: Rename this file into ...
* tests/level/approx/median.cc: ... this.
---
approx/median.cc | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
fill.cc | 28 +++++++++++++++---------
take.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 136 insertions(+), 11 deletions(-)
Index: trunk/milena/tests/level/approx_median.cc (deleted)
===================================================================
Index: trunk/milena/tests/level/take.cc
===================================================================
--- trunk/milena/tests/level/take.cc (revision 0)
+++ trunk/milena/tests/level/take.cc (revision 1488)
@@ -0,0 +1,57 @@
+// 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/level/take.cc
+ *
+ * \brief Tests on mln::level::take.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/level/take.hh>
+#include <mln/level/compare.hh>
+#include <mln/debug/iota.hh>
+#include <mln/accu/min.hh>
+#include <mln/accu/max.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 200;
+ image2d<int> ima(size, size);
+ accu::min_<int> acu_min;
+ accu::max_<int> acu_max;
+
+ debug::iota(ima);
+ level::take(ima, acu_min);
+ level::take(ima, acu_max);
+
+ mln_assertion(acu_min.to_result() == 1);
+ mln_assertion(acu_max.to_result() == 40000);
+
+}
Index: trunk/milena/tests/level/approx/median.cc
===================================================================
--- trunk/milena/tests/level/approx/median.cc (revision 0)
+++ trunk/milena/tests/level/approx/median.cc (revision 1488)
@@ -0,0 +1,62 @@
+// 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/level/approx/median.cc
+ *
+ * \brief Test on mln::level::approx::median.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/win/octagon2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/approx/median.hh>
+
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ win::rectangle2d rect(51, 51);
+ win::octagon2d oct(13);
+ border::thickness = 52;
+
+ image2d<int_u8>
+ lena = io::pgm::load("../../../img/lena.pgm"),
+ out(lena.domain());
+
+// level::approx::median(lena, rect, out);
+ level::approx::median(lena, oct, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/tests/level/fill.cc
===================================================================
--- trunk/milena/tests/level/fill.cc (revision 1487)
+++ trunk/milena/tests/level/fill.cc (revision 1488)
@@ -47,21 +47,27 @@
unsigned char uc = u;
mln_assertion(uc == 44);
-// {
-// const unsigned size = 3;
-// image2d<unsigned> ima(size, size);
-// level::fill(ima, u);
-// debug::println(ima);
-// }
-
{
- const unsigned size = 10000;
- image2d<unsigned char> ima(size, size);
- for (unsigned i = 0; i < 5; ++i)
- level::fill(ima, uc);
+ const unsigned size = 3;
+ image2d<unsigned> ima(size, size);
+ level::fill(ima, u);
+ box_fwd_piter_<point2d> p(ima.domain());
+ for_all (p)
+ mln_assertion (ima(p) == u);
+
}
// {
+// const unsigned size = 10000;
+// image2d<unsigned char> ima(size, size);
+// for (unsigned i = 0; i < 5; ++i)
+// level::fill(ima, uc);
+// box_fwd_piter_<point2d> p(ima.domain());
+// for_all (p)
+// mln_assertion (ima(p) == uc);
+// }
+
+// {
// // do *not* compile so that's great since ima is not mutable
// sub_image< const image2d<int>, box2d > ima;
// level::fill(ima, 0);
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-15 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Review the debug namespace.
* mln/debug/format.hh: Fix style.
* mln/debug/iota.hh: Move spezialisations to iota.spe.hh.
* mln/debug/iota.spe.hh: New, specializations of iota.
* mln/debug/println.hh: Move spezialisations to println.spe.hh.
* mln/debug/println.spe.hh: New, specializations of println.
* mln/debug/println_with_border.hh: Move spezialisations to
println_with_border.spe.hh.
* mln/debug/println_with_border.spe.hh: New, specializations of
println.
* tests/debug_iota.cc: New, add a test for iota.
---
mln/debug/format.hh | 12 +-
mln/debug/iota.hh | 30 +++---
mln/debug/iota.spe.hh | 71 +++++++++++++++
mln/debug/println.hh | 106 +----------------------
mln/debug/println.spe.hh | 160 +++++++++++++++++++++++++++++++++++
mln/debug/println_with_border.hh | 56 +-----------
mln/debug/println_with_border.spe.hh | 113 ++++++++++++++++++++++++
tests/debug_iota.cc | 49 ++++++++++
8 files changed, 434 insertions(+), 163 deletions(-)
Index: trunk/milena/tests/debug_iota.cc
===================================================================
--- trunk/milena/tests/debug_iota.cc (revision 0)
+++ trunk/milena/tests/debug_iota.cc (revision 1487)
@@ -0,0 +1,49 @@
+// 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/debug_iota.cc
+ *
+ * \brief Tests on mln::debug::iota.
+ */
+
+#include <mln/core/image2d.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> in(32, 32);
+
+ debug::iota(in);
+ debug::println(in);
+}
Index: trunk/milena/mln/debug/iota.spe.hh
===================================================================
--- trunk/milena/mln/debug/iota.spe.hh (revision 0)
+++ trunk/milena/mln/debug/iota.spe.hh (revision 1487)
@@ -0,0 +1,71 @@
+// 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_DEBUG_IOTA_SPE_HH
+# define MLN_DEBUG_IOTA_SPE_HH
+
+/*! \file mln/debug/iota.spe.hh
+ *
+ * \brief Specializations for mln::debug::iota.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace debug
+ {
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I>
+ void
+ iota(trait::image::speed::fastest, I& input)
+ {
+ unsigned i = 0;
+ mln_pixter(I) p(input);
+ for_all(p)
+ // FIXME : remove the convertion when the bug will be
+ // resolved.
+ p.val() = ++i % int(mln_max(mln_value(I)));
+ }
+
+ } // end of namespace mln::debug::impl
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::debug
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DEBUG_IOTA_SPE_HH
Index: trunk/milena/mln/debug/println_with_border.spe.hh
===================================================================
--- trunk/milena/mln/debug/println_with_border.spe.hh (revision 0)
+++ trunk/milena/mln/debug/println_with_border.spe.hh (revision 1487)
@@ -0,0 +1,113 @@
+// 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_DEBUG_PRINTLN_WITH_BORDER_SPE_HH
+# define MLN_DEBUG_PRINTLN_WITH_BORDER_SPE_HH
+
+/*! \file mln/debug/println_with_border_spe.hh
+ *
+ * \brief Specializations for mln::debug::println_with_border.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/debug/format.hh>
+
+namespace mln
+{
+
+ namespace debug
+ {
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+# ifdef MLN_CORE_BOX2D_HH
+
+ // 2D version.
+ template <typename I>
+ void
+ println_with_border(const box2d& b, const I& input)
+ {
+ const std::size_t ncols = b.ncols() + 2 * input.border();
+ for (size_t i = 0; i < input.ncells(); i++)
+ {
+ std::cout << format(input.buffer()[i]) << ' ';
+ if (((i + 1) % ncols) == 0)
+ std::cout << std::endl;
+ }
+ std::cout << std::endl;
+ }
+# endif // MLN_CORE_BOX2D_HH
+
+
+# ifdef MLN_CORE_BOX3D_HH
+
+ // 3D version.
+ template <typename I>
+ void
+ println_with_border(const box3d& b, const I& input)
+ {
+ typedef mln_point(I) P;
+
+ std::size_t len_s = b.len(P::dim - 3);
+ std::size_t len_r = b.len(P::dim - 2);
+ std::size_t len_c = b.len(P::dim - 1);
+
+ std::size_t border = input.border();
+ std::size_t real_len_s = len_s + 2 * border;
+ std::size_t real_len_c = len_c + 2 * border;
+ std::size_t real_len_r = len_r + 2 * border;
+
+ for (std::size_t k = 0; k < real_len_s; ++k)
+ {
+ for (std::size_t j = 0; j < real_len_r; ++j)
+ {
+ for (std::size_t i = 0; i < real_len_c; ++i)
+ std::cout << format(input[k * (real_len_r * real_len_c) + j * real_len_c + i])
+ << ' ';
+ std::cout << std::endl;
+ }
+ std::cout << std::endl;
+ }
+ std::cout << std::endl;
+ }
+
+# endif // MLN_CORE_BOX3D_HH
+
+ } // end of namespace mln::debug::impl
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::debug
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DEBUG_PRINTLN_WITH_BORDER_SPE_HH
Index: trunk/milena/mln/debug/println.hh
===================================================================
--- trunk/milena/mln/debug/println.hh (revision 1486)
+++ trunk/milena/mln/debug/println.hh (revision 1487)
@@ -37,6 +37,8 @@
# include <mln/core/concept/window.hh>
# include <mln/debug/format.hh>
+// Specializations are in:
+# include <mln/debug/println.spe.hh>
namespace mln
{
@@ -54,9 +56,10 @@
namespace impl
{
- // generic version
+ // Generic version.
template <typename S, typename I>
- void println(const S&, const Image<I>& input_)
+ void
+ println(const S&, const Image<I>& input_)
{
const I& input = exact(input_);
mln_piter(I) p(input.domain());
@@ -65,108 +68,13 @@
std::cout << std::endl;
}
-# ifdef MLN_CORE_BOX2D_HH
-
- // 2D version
- template <typename I>
- void println(const box2d& b, const I& input)
- {
- point2d p;
- int& row = p.row();
- int& col = p.col();
- const int
- max_row = b.max_row(),
- max_col = b.max_col();
-
- for (row = b.min_row(); row <= max_row; ++row)
- {
- for (col = b.min_col(); col <= max_col; ++col)
- if (input.has(p))
- std::cout << format( input(p) ) << ' ';
- else
- std::cout << " ";
- std::cout << std::endl;
- }
- std::cout << std::endl;
- }
-
-# endif // MLN_CORE_BOX2D_HH
-
-# ifdef MLN_CORE_IMAGE2D_H_HH
-
- // Hexa version
- template <typename I>
- void println(const box2d_h& b, const hexa<I>& input)
- {
- typename hexa<I>::fwd_piter p(input.domain());
-
- int c = 1;
- int r = 1;
- int row_len = 1 + (b.max_col() - b.min_col()) / 2;
-
- for_all(p)
- {
- if (input.has(p))
- std::cout << format(input(p)) << " ";
- else
- std::cout << " ";
-
- if (c >= row_len)
- {
- std::cout << std::endl;
- if (r % 2)
- std::cout << " ";
- c = 0;
- r++;
- }
- c++;
- }
- std::cout << std::endl;
- }
-
-# endif // MLN_CORE_IMAGE2D_H_HH
-
-
-# ifdef MLN_CORE_BOX3D_HH
-
- template <typename I>
- void println(const box3d& b, const I& input)
- {
- point3d p;
- int& sli = p.sli();
- int& row = p.row();
- int& col = p.col();
- const int
- max_row = b.max_row(),
- max_sli = b.max_sli(),
- max_col = b.max_col();
-
- for (sli = b.min_sli(); sli <= max_sli; ++sli)
- {
- for (row = b.min_row(); row <= max_row; ++row)
- {
- for (int i = max_row; i >= row; --i)
- std::cout << ' ';
- for (col = b.min_col(); col <= max_col; ++col)
- if (input.has(p))
- std::cout << format( input(p) ) << ' ';
- else
- std::cout << " ";
- std::cout << std::endl;
- }
- std::cout << std::endl;
- }
- }
-
-# endif // MLN_CORE_BOX3D_HH
-
} // end of namespace mln::debug::impl
// Facade.
-
template <typename I>
- void println(const Image<I>& input)
+ void
+ println(const Image<I>& input)
{
impl::println(exact(input).bbox(), exact(input));
}
Index: trunk/milena/mln/debug/format.hh
===================================================================
--- trunk/milena/mln/debug/format.hh (revision 1486)
+++ trunk/milena/mln/debug/format.hh (revision 1487)
@@ -61,22 +61,26 @@
# ifndef MLN_INCLUDE_ONLY
template <typename T>
- const T& format(const T& v)
+ const T&
+ format(const T& v)
{
return v;
}
- char format(bool v)
+ char
+ format(bool v)
{
return v ? '|' : '-';
}
- signed short format(signed char v)
+ signed short
+ format(signed char v)
{
return v;
}
- unsigned short format(unsigned char v)
+ unsigned short
+ format(unsigned char v)
{
return v;
}
Index: trunk/milena/mln/debug/iota.hh
===================================================================
--- trunk/milena/mln/debug/iota.hh (revision 1486)
+++ trunk/milena/mln/debug/iota.hh (revision 1487)
@@ -35,6 +35,9 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/debug/iota.spe.hh>
+
namespace mln
{
@@ -42,7 +45,11 @@
namespace debug
{
- /// FIXME
+ /*! Fill the image \p input with successive values.
+ *
+ * \param[in,out] destination The image in which values are
+ * assigned.
+ */
template <typename I>
void iota(Image<I>& input);
@@ -53,31 +60,28 @@
{
template <typename I>
- void iota(trait::image::speed::any, I& input)
+ void
+ iota(trait::image::speed::any, I& input)
{
unsigned i = 0;
mln_piter(I) p(input.domain());
for_all(p)
- input(p) = ++i;
- }
-
- template <typename I>
- void iota(trait::image::speed::fastest, I& input)
- {
- unsigned i = 0;
- mln_pixter(I) p(input);
- for_all(p)
- p.val() = ++i;
+ // FIXME : remove the convertion when the bug will be
+ // resolved.
+ input(p) = ++i % int(mln_max(mln_value(I)));
}
} // end of namespace mln::debug::impl
template <typename I>
- void iota(Image<I>& input)
+ void
+ iota(Image<I>& input)
{
+ trace::entering("debug::iota");
mln_precondition(exact(input).has_data());
impl::iota(mln_trait_image_speed(I)(), exact(input));
+ trace::exiting("debug::iota");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/debug/println.spe.hh
===================================================================
--- trunk/milena/mln/debug/println.spe.hh (revision 0)
+++ trunk/milena/mln/debug/println.spe.hh (revision 1487)
@@ -0,0 +1,160 @@
+// 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_DEBUG_PRINTLN_SPE_HH
+# define MLN_DEBUG_PRINTLN_SPE_HH
+
+/*! \file mln/debug/println.spe.hh
+ *
+ * \brief Specializations for mln::debug::println.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/debug/format.hh>
+
+
+namespace mln
+{
+
+ namespace debug
+ {
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+# ifdef MLN_CORE_BOX2D_HH
+
+ // 2D version.
+ template <typename I>
+ void
+ println(const box2d& b, const I& input)
+ {
+ point2d p;
+ int& row = p.row();
+ int& col = p.col();
+ const int
+ max_row = b.max_row(),
+ max_col = b.max_col();
+
+ for (row = b.min_row(); row <= max_row; ++row)
+ {
+ for (col = b.min_col(); col <= max_col; ++col)
+ if (input.has(p))
+ std::cout << format(input(p)) << ' ';
+ else
+ std::cout << " ";
+ std::cout << std::endl;
+ }
+ std::cout << std::endl;
+ }
+
+# endif // MLN_CORE_BOX2D_HH
+
+# ifdef MLN_CORE_IMAGE2D_H_HH
+
+ // Hexa version.
+ template <typename I>
+ void
+ println(const box2d_h& b, const hexa<I>& input)
+ {
+ typename hexa<I>::fwd_piter p(input.domain());
+
+ int c = 1;
+ int r = 1;
+ int row_len = 1 + (b.max_col() - b.min_col()) / 2;
+
+ for_all(p)
+ {
+ if (input.has(p))
+ std::cout << format(input(p)) << " ";
+ else
+ std::cout << " ";
+
+ if (c >= row_len)
+ {
+ std::cout << std::endl;
+ if (r % 2)
+ std::cout << " ";
+ c = 0;
+ r++;
+ }
+ c++;
+ }
+ std::cout << std::endl;
+ }
+
+# endif // MLN_CORE_IMAGE2D_H_HH
+
+
+# ifdef MLN_CORE_BOX3D_HH
+
+ // 3D version.
+ template <typename I>
+ void
+ println(const box3d& b, const I& input)
+ {
+ point3d p;
+ int& sli = p.sli();
+ int& row = p.row();
+ int& col = p.col();
+ const int
+ max_row = b.max_row(),
+ max_sli = b.max_sli(),
+ max_col = b.max_col();
+
+ for (sli = b.min_sli(); sli <= max_sli; ++sli)
+ {
+ for (row = b.min_row(); row <= max_row; ++row)
+ {
+ for (int i = max_row; i >= row; --i)
+ std::cout << ' ';
+ for (col = b.min_col(); col <= max_col; ++col)
+ if (input.has(p))
+ std::cout << format(input(p)) << ' ';
+ else
+ std::cout << " ";
+ std::cout << std::endl;
+ }
+ std::cout << std::endl;
+ }
+ }
+
+# endif // MLN_CORE_BOX3D_HH
+
+ } // end of namespace mln::debug::impl
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::debug
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DEBUG_PRINTLN_SPE_HH
Index: trunk/milena/mln/debug/println_with_border.hh
===================================================================
--- trunk/milena/mln/debug/println_with_border.hh (revision 1486)
+++ trunk/milena/mln/debug/println_with_border.hh (revision 1487)
@@ -40,6 +40,9 @@
# include <mln/core/box2d.hh>
# include <mln/core/box3d.hh>
+// Specializations are in:
+# include <mln/debug/println_with_border.spe.hh>
+
namespace mln
{
@@ -56,64 +59,23 @@
namespace impl
{
- // generic version
+ // Generic version.
template <typename S, typename I>
- void println_with_border(const S&, const I& input)
- {
- for (size_t i = 0; i < input.ncells(); i++)
- std::cout << format( input.buffer()[i] ) << ' ';
- std::cout << std::endl;
- }
-
- // 2D version
- template <typename I>
- void println_with_border(const box2d& b, const I& input)
+ void
+ println_with_border(const S&, const I& input)
{
- const std::size_t ncols = b.ncols() + 2 * input.border();
for (size_t i = 0; i < input.ncells(); i++)
- {
std::cout << format( input.buffer()[i] ) << ' ';
- if (((i+1) % ncols) == 0)
std::cout << std::endl;
}
- std::cout << std::endl;
- }
-
- // 3D version
- template <typename I>
- void println_with_border(const box3d& b, const I& input)
- {
- typedef mln_point(I) P;
-
- std::size_t len_s = b.len(P::dim - 3);
- std::size_t len_r = b.len(P::dim - 2);
- std::size_t len_c = b.len(P::dim - 1);
-
- std::size_t border = input.border ();
- std::size_t real_len_s = len_s + 2 * border;
- std::size_t real_len_c = len_c + 2 * border;
- std::size_t real_len_r = len_r + 2 * border;
- for (std::size_t k = 0; k < real_len_s; ++k)
- {
- for (std::size_t j = 0; j < real_len_r; ++j)
- {
- for (std::size_t i = 0; i < real_len_c; ++i)
- std::cout << format(input[k * (real_len_r * real_len_c) + j * real_len_c + i])
- << ' ';
- std::cout << std::endl;
- }
- std::cout << std::endl;
- }
- std::cout << std::endl;
- }
} // end of namespace mln::debug::impl
-
- // facade
+ // Facade.
template <typename I>
- void println_with_border(const Image<I>& input)
+ void
+ println_with_border(const Image<I>& input)
{
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-15 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Move level test in level tests repertory.
* tests/level/abs.cc: New.
* tests/level/apply.cc: New.
* tests/level/approx: New.
* tests/level/approx_median.cc: New.
* tests/level/assign.cc: New.
* tests/level/fill.cc: New.
* tests/level/median.cc: New.
* tests/level/median_dir.cc: New.
* tests/level/median_fast.cc: New.
* tests/level/median_hline2d.cc: New.
* tests/level/memcpy_.cc: New.
* tests/level/memset_.cc: New.
* tests/level/naive/median.cc: New.
* tests/level/naive: New.
* tests/level/paste.cc: New.
* tests/level/transform.cc: New.
* tests/level: New.
* tests/level_approx_median.cc: Remove.
* tests/level_assign.cc: Remove.
* tests/level_fill.cc: Remove.
* tests/level_median.cc: Remove.
* tests/level_median_dir.cc: Remove.
* tests/level_median_fast.cc: Remove.
* tests/level_median_hline2d.cc: Remove.
* tests/level_memcpy_.cc: Remove.
* tests/level_memset_.cc: Remove.
* tests/level_naive_median.cc: Remove.
* tests/level_paste.cc: Remove.
* tests/level_transform.cc: Remove.
---
abs.cc | 60 +++++++++++++++++++++++++++++++
apply.cc | 57 +++++++++++++++++++++++++++++
approx_median.cc | 62 ++++++++++++++++++++++++++++++++
assign.cc | 48 ++++++++++++++++++++++++
fill.cc | 70 ++++++++++++++++++++++++++++++++++++
median.cc | 59 ++++++++++++++++++++++++++++++
median_dir.cc | 55 ++++++++++++++++++++++++++++
median_fast.cc | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
median_hline2d.cc | 64 +++++++++++++++++++++++++++++++++
memcpy_.cc | 58 ++++++++++++++++++++++++++++++
memset_.cc | 53 +++++++++++++++++++++++++++
naive/median.cc | 58 ++++++++++++++++++++++++++++++
paste.cc | 62 ++++++++++++++++++++++++++++++++
transform.cc | 66 ++++++++++++++++++++++++++++++++++
14 files changed, 876 insertions(+)
Index: trunk/milena/tests/level_naive_median.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_median_hline2d.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_transform.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_memcpy_.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_median.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_median_dir.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_fill.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_median_fast.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_approx_median.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_paste.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_assign.cc (deleted)
===================================================================
Index: trunk/milena/tests/level_memset_.cc (deleted)
===================================================================
Index: trunk/milena/tests/level/transform.cc
===================================================================
--- trunk/milena/tests/level/transform.cc (revision 0)
+++ trunk/milena/tests/level/transform.cc (revision 1485)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/level/transform.cc
+ *
+ * \brief Tests on mln::level::transform
+ */
+
+#include <cmath>
+
+#include <mln/core/image2d.hh>
+#include <mln/level/transform.hh>
+#include <mln/debug/iota.hh>
+
+
+struct mysqrt : mln::Function_v2v<mysqrt>
+{
+ typedef unsigned short result;
+ result operator()(unsigned short c) const
+ {
+ return result( std::sqrt(float(c)) );
+ }
+};
+
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 10000;
+ image2d<unsigned short>
+ ima(size, size);
+
+ (std::cout << "iota... ").flush();
+ debug::iota(ima);
+ std::cout << "done" << std::endl;
+
+ (std::cout << "transform... ").flush();
+ level::transform(ima, mysqrt(), ima);
+ std::cout << "done" << std::endl;
+}
Index: trunk/milena/tests/level/median_dir.cc
===================================================================
--- trunk/milena/tests/level/median_dir.cc (revision 0)
+++ trunk/milena/tests/level/median_dir.cc (revision 1485)
@@ -0,0 +1,55 @@
+// 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/level/median_dir.cc
+ *
+ * \brief Test on mln::level::median.
+ */
+
+#include <mln/core/image2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/median.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ border::thickness = 7;
+
+ image2d<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain());
+
+ level::median_dir(lena, 1, 15, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/tests/level/paste.cc
===================================================================
--- trunk/milena/tests/level/paste.cc (revision 0)
+++ trunk/milena/tests/level/paste.cc (revision 1485)
@@ -0,0 +1,62 @@
+// 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/level/paste.cc
+ *
+ * \brief Tests on mln::level::paste.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/level/fill.hh>
+#include <mln/level/paste.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ box2d b(make::point2d(1,2), make::point2d(2,4));
+ image2d<int> ima(b, 2);
+ debug::iota(ima);
+ debug::println(ima);
+
+
+ box2d b2(make::point2d(-1,-2), make::point2d(3,6));
+ image2d<int> ima2(b2, 0);
+ debug::iota(ima2);
+ debug::println(ima2);
+
+ trace::quiet = false;
+
+ level::paste(ima, ima2); // Fast version.
+ debug::println(ima2);
+
+ level::impl::generic::paste_(ima, ima2); // Not so fast version...
+}
Index: trunk/milena/tests/level/median.cc
===================================================================
--- trunk/milena/tests/level/median.cc (revision 0)
+++ trunk/milena/tests/level/median.cc (revision 1485)
@@ -0,0 +1,59 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/level/median.cc
+ *
+ * \brief Test on mln::level::median.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/median.hh>
+
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ win::rectangle2d rect(51, 51);
+ border::thickness = 52;
+
+ image2d<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain());
+
+ level::median(lena, rect, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/tests/level/naive/median.cc
===================================================================
--- trunk/milena/tests/level/naive/median.cc (revision 0)
+++ trunk/milena/tests/level/naive/median.cc (revision 1485)
@@ -0,0 +1,58 @@
+// 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/level/naive/median.cc
+ *
+ * \brief Test on mln::level::naive::median.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/naive/median.hh>
+
+
+using namespace mln;
+using namespace mln::value;
+
+
+int main()
+{
+ win::rectangle2d rec(51, 51);
+ border::thickness = 52;
+
+ image2d<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain());
+
+ level::naive::median(lena, rec, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/tests/level/median_hline2d.cc
===================================================================
--- trunk/milena/tests/level/median_hline2d.cc (revision 0)
+++ trunk/milena/tests/level/median_hline2d.cc (revision 1485)
@@ -0,0 +1,64 @@
+// 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/level/median_hline2d.cc
+ *
+ * \brief Test on the hline2d version of mln::level::median.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/median.hh>
+#include <mln/level/compare.hh>
+
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ border::thickness = 0;
+
+ image2d<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain()),
+ ref(lena.domain());
+
+ level::median(lena, win::rectangle2d(1, 101), ref);
+
+ level::median(lena, win::hline2d(101), out);
+ io::pgm::save(out, "out.pgm");
+
+ // FIXME: mln_assertion(out == ref);
+}
Index: trunk/milena/tests/level/assign.cc
===================================================================
--- trunk/milena/tests/level/assign.cc (revision 0)
+++ trunk/milena/tests/level/assign.cc (revision 1485)
@@ -0,0 +1,48 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/level/assign.cc
+ *
+ * \brief Tests on mln::level::assign.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/level/assign.hh>
+#include <mln/level/compare.hh>
+#include <mln/debug/iota.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 1000;
+ image2d<int> rhs(size, size), lhs(rhs.domain());
+ debug::iota(rhs);
+ level::assign(lhs, rhs);
+ mln_assertion(lhs == rhs);
+}
Index: trunk/milena/tests/level/apply.cc
===================================================================
--- trunk/milena/tests/level/apply.cc (revision 0)
+++ trunk/milena/tests/level/apply.cc (revision 1485)
@@ -0,0 +1,57 @@
+// 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/level/apply.cc
+ *
+ * \brief Tests on mln::level::apply.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/level/apply.hh>
+#include <mln/debug/iota.hh>
+#include <mln/fun/v2v/saturate.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 1000;
+ image2d<int> ima(3, 3);
+ int vs[3][3] = {
+ { 2, 2, 3 },
+ { 4, 5, 6 },
+ { 6, 6, 6 }
+ };
+
+ image2d<int> ref(make::image2d(vs));
+ debug::iota(ima);
+ level::apply(ima, fun::v2v::saturate<int>(2, 6));
+ box_fwd_piter_<point2d> p(ima.domain());
+ for_all(p)
+ mln_assertion(ima(p) == ref(p));
+}
Index: trunk/milena/tests/level/abs.cc
===================================================================
--- trunk/milena/tests/level/abs.cc (revision 0)
+++ trunk/milena/tests/level/abs.cc (revision 1485)
@@ -0,0 +1,60 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/level/abs.cc
+ *
+ * \brief Tests on mln::level::abs.
+ */
+
+# include <mln/core/image2d.hh>
+# include <mln/level/abs.hh>
+
+int main()
+{
+
+ using namespace mln;
+
+ typedef image2d<int> I;
+
+ int vs[6][5] = {
+
+ { -3, -3, -4, -4, -4 },
+ { -2, -1, -1, -1, -1 },
+ { -1, -4, -4, -4, -1 },
+ { -1, -4, -3, -4, -1 },
+ { -1, -4, -5, -3, -1 },
+ { -1, -1, -1, -1, -1 }
+
+ };
+
+ image2d<int> ima(make::image2d(vs));
+ image2d<int> out(ima.domain());
+ level::abs(ima, out);
+ box_fwd_piter_<point2d> p(ima.domain());
+ for_all (p)
+ mln_assertion (out(p) >= 0);
+}
Index: trunk/milena/tests/level/approx_median.cc
===================================================================
--- trunk/milena/tests/level/approx_median.cc (revision 0)
+++ trunk/milena/tests/level/approx_median.cc (revision 1485)
@@ -0,0 +1,62 @@
+// 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/level/approx/median.cc
+ *
+ * \brief Test on mln::level::approx::median.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/win/octagon2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/approx/median.hh>
+
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ win::rectangle2d rect(51, 51);
+ win::octagon2d oct(13);
+ border::thickness = 52;
+
+ image2d<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain());
+
+// level::approx::median(lena, rect, out);
+ level::approx::median(lena, oct, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/tests/level/fill.cc
===================================================================
--- trunk/milena/tests/level/fill.cc (revision 0)
+++ trunk/milena/tests/level/fill.cc (revision 1485)
@@ -0,0 +1,70 @@
+// 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/level/fill.cc
+ *
+ * \brief Tests on mln::level::fill
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/level/fill.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/value/props.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+
+ unsigned u = 300;
+ unsigned char uc = u;
+ mln_assertion(uc == 44);
+
+// {
+// const unsigned size = 3;
+// image2d<unsigned> ima(size, size);
+// level::fill(ima, u);
+// debug::println(ima);
+// }
+
+ {
+ const unsigned size = 10000;
+ image2d<unsigned char> ima(size, size);
+ for (unsigned i = 0; i < 5; ++i)
+ level::fill(ima, uc);
+ }
+
+// {
+// // do *not* compile so that's great since ima is not mutable
+// sub_image< const image2d<int>, box2d > ima;
+// level::fill(ima, 0);
+// }
+
+}
Index: trunk/milena/tests/level/memcpy_.cc
===================================================================
--- trunk/milena/tests/level/memcpy_.cc (revision 0)
+++ trunk/milena/tests/level/memcpy_.cc (revision 1485)
@@ -0,0 +1,58 @@
+// 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/level/memcpy_.cc
+ *
+ * \brief Tests on mln::level::memcpy_.
+ *
+ * \todo Make this test not dummy!
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/inplace.hh>
+#include <mln/debug/iota.hh>
+#include <mln/level/memcpy_.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+ I ima(3, 3);
+ debug::iota(ima);
+
+ point2d
+ src = make::point2d(0, 2),
+ dest = make::point2d(1, 2);
+
+ level::memcpy_(inplace(make::pixel(ima, dest)),
+ make::pixel(ima, src),
+ 2 + 2 * ima.border());
+
+ mln_assertion(ima(dest) == ima(src));
+}
Index: trunk/milena/tests/level/memset_.cc
===================================================================
--- trunk/milena/tests/level/memset_.cc (revision 0)
+++ trunk/milena/tests/level/memset_.cc (revision 1485)
@@ -0,0 +1,53 @@
+// 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/level/memset_.cc
+ *
+ * \brief Tests on mln::level::memset_.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/geom/ncols.hh>
+#include <mln/level/fill.hh>
+#include <mln/level/memset_.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(3, 3);
+ level::fill(ima, 0);
+ int X = 9;
+ level::memset_(ima, make::point2d(0,0),
+ X,
+ geom::ncols(ima) + 2 * ima.border() + 1);
+ // ^
+ // |
+ mln_assertion(ima.at(1,0) == X); // <----------------+
+ mln_assertion(ima.at(1,1) != X);
+}
Index: trunk/milena/tests/level/median_fast.cc
===================================================================
--- trunk/milena/tests/level/median_fast.cc (revision 0)
+++ trunk/milena/tests/level/median_fast.cc (revision 1485)
@@ -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/level/median_fast.cc
+ *
+ * \brief Test on mln::level::fast_median.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/level/fast_median.hh>
+
+#include <mln/core/dpoints_pixter.hh>
+#include <mln/core/pixel.hh>
+
+
+namespace mln
+{
+
+ template <typename I, typename W>
+ void test(I& input, const W& win)
+ {
+ mln_point(I) p;
+ p.row() = p.col() = 1;
+
+ {
+ mln_qixter(I, W) qix(input, win, p);
+ for_all(qix)
+ std::cout << qix.val() << ' ';
+ std::cout << " : " << qix.center_val() << std::endl;
+ }
+
+ {
+ pixel<I> pix(input, p);
+ mln_qixter(I, W) qix(input, win, pix);
+ for_all(qix)
+ std::cout << qix.val() << ' ';
+ std::cout << " : " << qix.center_val() << std::endl;
+ }
+ }
+
+}
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+// {
+// win::rectangle2d rect(3, 3);
+// border::thickness = 4;
+// image2d<int_u8> ima(3, 3);
+// debug::iota(ima);
+// debug::println(ima);
+// test(ima, rect);
+// }
+
+
+ {
+ win::rectangle2d rect(51, 51);
+ border::thickness = 52;
+
+ image2d<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain());
+
+ level::fast_median(lena, rect, out);
+ io::pgm::save(out, "out.pgm");
+ }
+
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-15 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Review the mln/literal directory.
* mln/literal/black.hh,
* mln/literal/colors.hh,
* mln/literal/grays.hh,
* mln/literal/one.hh,
* mln/literal/origin.hh,
* mln/literal/white.hh,
* tests/literal/black.cc: Use extern const ref, not static. Move
impl. within MLN_INCLUDE_ONLY.
Move/add some unit tests.
* tests/literal/literal_medium_gray.cc: Rename as...
* tests/literal/medium_gray.cc: ...this.
* tests/literal/literal_zero.cc: Rename as...
* tests/literal/zero.cc: ...this.
* tests/literal/one.cc: New.
* tests/literal/white.cc: New.
---
mln/literal/black.hh | 9 +++++-
mln/literal/colors.hh | 14 ++++++++--
mln/literal/grays.hh | 9 +++++-
mln/literal/one.hh | 4 ++
mln/literal/origin.hh | 9 +++++-
mln/literal/white.hh | 9 +++++-
tests/literal/black.cc | 52 ++++++++++++++++++++++++++++++++++++++
tests/literal/medium_gray.cc | 57 ++++++++++++++++++++++++++++++++++++++++++
tests/literal/one.cc | 58 +++++++++++++++++++++++++++++++++++++++++++
tests/literal/white.cc | 53 +++++++++++++++++++++++++++++++++++++++
tests/literal/zero.cc | 58 +++++++++++++++++++++++++++++++++++++++++++
11 files changed, 323 insertions(+), 9 deletions(-)
Index: trunk/milena/tests/literal/literal_zero.cc (deleted)
===================================================================
Index: trunk/milena/tests/literal/literal_medium_gray.cc (deleted)
===================================================================
Index: trunk/milena/tests/literal/black.cc
===================================================================
--- trunk/milena/tests/literal/black.cc (revision 0)
+++ trunk/milena/tests/literal/black.cc (revision 1484)
@@ -0,0 +1,52 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/literal/black.cc
+ *
+ * \brief Tests on mln::literal::black.
+ */
+
+#include <mln/value/rgb8.hh>
+#include <mln/literal/black.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::rgb8;
+ using literal::black;
+
+ {
+ rgb8 c(0, 0, 0);
+
+ c.green() = 254;
+ mln_assertion(c != black);
+
+ c = black;
+ mln_assertion(c == black);
+ }
+}
Index: trunk/milena/tests/literal/zero.cc
===================================================================
--- trunk/milena/tests/literal/zero.cc (revision 0)
+++ trunk/milena/tests/literal/zero.cc (revision 1484)
@@ -0,0 +1,58 @@
+// 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/literal/zero.cc
+ *
+ * \brief Tests on mln::literal::zero.
+ */
+
+#include <mln/literal/zero.hh>
+#include <mln/literal/one.hh>
+#include <mln/literal/ops.hh>
+#include <mln/value/int_u8.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned char c;
+ c = literal::zero;
+ mln_assertion(c == 0);
+
+ double d;
+ d = literal::zero;
+ mln_assertion(d == 0);
+
+ mln_assertion(literal::zero != literal::one);
+
+ value::int_u8 u(literal::zero), uu;
+ uu = literal::zero;
+
+ mln_assertion(u == 0 && 0 == u);
+}
Index: trunk/milena/tests/literal/white.cc
===================================================================
--- trunk/milena/tests/literal/white.cc (revision 0)
+++ trunk/milena/tests/literal/white.cc (revision 1484)
@@ -0,0 +1,53 @@
+// 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/literal/white.cc
+ *
+ * \brief Tests on mln::literal::white.
+ */
+
+#include <mln/value/rgb8.hh>
+#include <mln/literal/white.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::rgb8;
+ using literal::white;
+
+ {
+ rgb8 c(255, 255, 255);
+
+
+ c.green() = 254;
+ mln_assertion(c != white);
+
+ c = white;
+ mln_assertion(c == white);
+ }
+}
Index: trunk/milena/tests/literal/one.cc
===================================================================
--- trunk/milena/tests/literal/one.cc (revision 0)
+++ trunk/milena/tests/literal/one.cc (revision 1484)
@@ -0,0 +1,58 @@
+// 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/literal/one.cc
+ *
+ * \brief Tests on mln::literal::one.
+ */
+
+#include <mln/literal/one.hh>
+#include <mln/literal/zero.hh>
+#include <mln/literal/ops.hh>
+#include <mln/value/int_u8.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned char c;
+ c = literal::one;
+ mln_assertion(c == 1);
+
+ double d;
+ d = literal::one;
+ mln_assertion(d == 1);
+
+ mln_assertion(literal::one != literal::zero);
+
+ value::int_u8 u(literal::one), uu;
+ uu = literal::one;
+
+ mln_assertion(u == 1 && 1 == u);
+}
Index: trunk/milena/tests/literal/medium_gray.cc
===================================================================
--- trunk/milena/tests/literal/medium_gray.cc (revision 0)
+++ trunk/milena/tests/literal/medium_gray.cc (revision 1484)
@@ -0,0 +1,57 @@
+// 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/literal/medium_gray.cc
+ *
+ * \brief Tests on mln::literal::medium_gray.
+ */
+
+#include <mln/literal/grays.hh>
+#include <mln/value/graylevel.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ using literal::medium_gray;
+ using value::gl8;
+ using value::gl16;
+
+ gl8 a;
+ gl16 b;
+
+ a = medium_gray;
+
+ std::cout << int(a.value()) << std::endl;
+
+ b = a;
+ std::cout << int(b.value()) << std::endl;
+
+ b = medium_gray;
+ std::cout << int(b.value()) << std::endl;
+}
Index: trunk/milena/mln/literal/colors.hh
===================================================================
--- trunk/milena/mln/literal/colors.hh (revision 1483)
+++ trunk/milena/mln/literal/colors.hh (revision 1484)
@@ -58,13 +58,21 @@
/// Literal red.
- static red_t red = red_t();
+ extern const red_t& red;
/// Literal green.
- static green_t green = green_t();
+ extern const green_t& green;
/// Literal blue.
- static blue_t blue = blue_t();
+ extern const blue_t& blue;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const red_t& red = red_t();
+ const green_t& green = green_t();
+ const blue_t& blue = blue_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/one.hh
===================================================================
--- trunk/milena/mln/literal/one.hh (revision 1483)
+++ trunk/milena/mln/literal/one.hh (revision 1484)
@@ -54,7 +54,7 @@
/// Literal one.
- static one_t one = one_t();
+ extern const one_t& one;
# ifndef MLN_INCLUDE_ONLY
@@ -66,6 +66,8 @@
return 1;
}
+ const one_t& one = one_t();
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/grays.hh
===================================================================
--- trunk/milena/mln/literal/grays.hh (revision 1483)
+++ trunk/milena/mln/literal/grays.hh (revision 1484)
@@ -47,7 +47,14 @@
};
/// Literal medium_gray.
- static medium_gray_t medium_gray = medium_gray_t();
+ extern const medium_gray_t& medium_gray;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const medium_gray_t& medium_gray = medium_gray_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/origin.hh
===================================================================
--- trunk/milena/mln/literal/origin.hh (revision 1483)
+++ trunk/milena/mln/literal/origin.hh (revision 1484)
@@ -47,9 +47,14 @@
{
};
-
/// Literal origin.
- static origin_t origin = origin_t();
+ extern const origin_t& origin;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const origin_t& origin = origin_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/black.hh
===================================================================
--- trunk/milena/mln/literal/black.hh (revision 1483)
+++ trunk/milena/mln/literal/black.hh (revision 1484)
@@ -48,7 +48,14 @@
/// Literal black.
- static black_t black = black_t();
+ extern const black_t& black;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const black_t& black = black_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/white.hh
===================================================================
--- trunk/milena/mln/literal/white.hh (revision 1483)
+++ trunk/milena/mln/literal/white.hh (revision 1484)
@@ -48,7 +48,14 @@
/// Literal white.
- static white_t white = white_t();
+ extern const white_t& white;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const white_t& white = white_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-15 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Move literals tests into tests/literal directory.
* tests/literal: New.
* tests/literal_medium_gray.cc: Rename as...
* tests/literal/literal_medium_gray.cc: ...this.
* tests/literal_zero.cc: Rename as...
* tests/literal/literal_zero.cc: ...this.
---
literal_medium_gray.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++++++
literal_zero.cc | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 115 insertions(+)
Index: trunk/milena/tests/literal_zero.cc (deleted)
===================================================================
Index: trunk/milena/tests/literal_medium_gray.cc (deleted)
===================================================================
Index: trunk/milena/tests/literal/literal_zero.cc
===================================================================
--- trunk/milena/tests/literal/literal_zero.cc (revision 0)
+++ trunk/milena/tests/literal/literal_zero.cc (revision 1483)
@@ -0,0 +1,58 @@
+// 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/literal_zero.cc
+ *
+ * \brief Tests on mln::literal::zero.
+ */
+
+#include <mln/literal/zero.hh>
+#include <mln/literal/one.hh>
+#include <mln/literal/ops.hh>
+#include <mln/value/int_u8.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned char c;
+ c = literal::zero;
+ mln_assertion(c == 0);
+
+ double d;
+ d = literal::zero;
+ mln_assertion(d == 0);
+
+ mln_assertion(literal::zero != literal::one);
+
+ value::int_u8 u(literal::zero), uu;
+ uu = literal::zero;
+
+ mln_assertion(u == 0 && 0 == u);
+}
Index: trunk/milena/tests/literal/literal_medium_gray.cc
===================================================================
--- trunk/milena/tests/literal/literal_medium_gray.cc (revision 0)
+++ trunk/milena/tests/literal/literal_medium_gray.cc (revision 1483)
@@ -0,0 +1,57 @@
+// 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/literal_medium_gray.cc
+ *
+ * \brief Tests on mln::literal::medium_gray.
+ */
+
+#include <mln/literal/grays.hh>
+#include <mln/value/graylevel.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ using literal::medium_gray;
+ using value::gl8;
+ using value::gl16;
+
+ gl8 a;
+ gl16 b;
+
+ a = medium_gray;
+
+ std::cout << int(a.value()) << std::endl;
+
+ b = a;
+ std::cout << int(b.value()) << std::endl;
+
+ b = medium_gray;
+ std::cout << int(b.value()) << std::endl;
+}