URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-19 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Review arith subdirectory and add tests.
* mln/arith/min.hh,
* mln/arith/revert.hh,
* mln/arith/times.hh: Add tracing, and remove specializations.
* mln/arith/min.spe.hh,
* mln/arith/revert.spe.hh,
* mln/arith/times.spe.hh: New specializations file for arith
algorithms.
* tests/Makefile.am,
* tests/arith/Makefile.am: New Makefile for checking tests.
* tests/arith: New subdirectory for arith tests.
* tests/arith_plus.cc: Remove ...
* tests/arith/plus.cc: ... and replace here.
* tests/arith/minus.cc,
* tests/arith/revert.cc,
* tests/arith/times.cc: New tests for arith.
---
mln/arith/min.hh | 39 ++++++----------
mln/arith/min.spe.hh | 112 +++++++++++++++++++++++++++++++++++++++++++++++
mln/arith/revert.hh | 24 +++++-----
mln/arith/revert.spe.hh | 86 ++++++++++++++++++++++++++++++++++++
mln/arith/times.hh | 41 ++++++-----------
mln/arith/times.spe.hh | 114 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 1
tests/arith/Makefile.am | 16 ++++++
tests/arith/minus.cc | 60 +++++++++++++++++++++++++
tests/arith/plus.cc | 104 +++++++++++++++++++++++++++++++++++++++++++
tests/arith/revert.cc | 62 ++++++++++++++++++++++++++
tests/arith/times.cc | 60 +++++++++++++++++++++++++
12 files changed, 659 insertions(+), 60 deletions(-)
Index: trunk/milena/tests/arith_plus.cc (deleted)
===================================================================
Index: trunk/milena/tests/arith/minus.cc
===================================================================
--- trunk/milena/tests/arith/minus.cc (revision 0)
+++ trunk/milena/tests/arith/minus.cc (revision 1498)
@@ -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/arith/minus.cc
+ *
+ * \brief Tests on mln::arith::minus.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/arith/minus.hh>
+#include <mln/level/compare.hh>
+
+int main()
+{
+ using namespace mln;
+
+ // trace::quiet = false;
+
+ {
+ image2d<int> ima(3,3);
+ debug::iota(ima);
+
+ int vs[3][3] = {
+ {0, 1, 2},
+ {3, 4, 5},
+ {6, 7, 8}
+ };
+
+ image2d<int> ref(make::image2d(vs));
+
+ mln_assertion (ima - 1 == ref);
+ }
+
+}
+
Index: trunk/milena/tests/arith/times.cc
===================================================================
--- trunk/milena/tests/arith/times.cc (revision 0)
+++ trunk/milena/tests/arith/times.cc (revision 1498)
@@ -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/arith/times.cc
+ *
+ * \brief Tests on mln::arith::times.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/arith/times.hh>
+#include <mln/level/compare.hh>
+
+int main()
+{
+ using namespace mln;
+
+ // trace::quiet = false;
+
+ {
+ image2d<int> ima(3,3);
+ debug::iota(ima);
+
+ int vs[3][3] = {
+ { 2, 4, 6},
+ { 8, 10, 12},
+ {14, 16, 18}
+ };
+
+ image2d<int> ref(make::image2d(vs));
+
+ mln_assertion (ima * 2 == ref);
+ }
+
+}
+
Index: trunk/milena/tests/arith/plus.cc
===================================================================
--- trunk/milena/tests/arith/plus.cc (revision 0)
+++ trunk/milena/tests/arith/plus.cc (revision 1498)
@@ -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/arith/plus.cc
+ *
+ * \brief Tests on mln::arith::plus.
+ */
+
+#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:
+
+// {
+// unsigned size = 5000;
+// image2d<unsigned char> ima_uc(size, size);
+// image2d<unsigned> ima_u;
+// ima_u = 2u + ima_uc;
+// }
+// {
+// unsigned size = 5000;
+// image2d<value::int_u8> ima_uc(size, size);
+// image2d<unsigned> ima_u;
+// ima_u = 2u + ima_uc;
+// }
+
+// {
+// unsigned size = 5000;
+// image2d<unsigned char> ima_uc(size, size);
+// image2d<unsigned> ima_u;
+// ima_u = ima_uc + ima_uc;
+// }
+// {
+// unsigned size = 5000;
+// image2d<value::int_u8> ima_u8(size, size);
+// image2d<unsigned> ima_u;
+// ima_u = ima_u8 + ima_u8;
+// }
+
Index: trunk/milena/tests/arith/Makefile.am
===================================================================
--- trunk/milena/tests/arith/Makefile.am (revision 0)
+++ trunk/milena/tests/arith/Makefile.am (revision 1498)
@@ -0,0 +1,16 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ minus \
+ plus \
+ revert \
+ times
+
+minus_SOURCES = minus.cc
+plus_SOURCES = plus.cc
+revert_SOURCES = revert.cc
+times_SOURCES = times.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/arith/revert.cc
===================================================================
--- trunk/milena/tests/arith/revert.cc (revision 0)
+++ trunk/milena/tests/arith/revert.cc (revision 1498)
@@ -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/arith/revert.cc
+ *
+ * \brief Tests on mln::arith::revert.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/arith/revert.hh>
+#include <mln/level/compare.hh>
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ // trace::quiet = false;
+
+ {
+ image2d<int> ima(3,3);
+ debug::iota(ima);
+
+ int vs[3][3] = {
+ { -2, -3, -4},
+ { -5, -6, -7},
+ { -8, -9, -10}
+ };
+
+ image2d<int> ref(make::image2d(vs));
+ arith::revert_inplace(ima);
+
+ mln_assertion (ima == ref);
+ }
+
+}
+
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1497)
+++ trunk/milena/tests/Makefile.am (revision 1498)
@@ -4,6 +4,7 @@
SUBDIRS = norm \
level \
+ arith \
border
check_PROGRAMS = \
Index: trunk/milena/mln/arith/times.hh
===================================================================
--- trunk/milena/mln/arith/times.hh (revision 1497)
+++ trunk/milena/mln/arith/times.hh (revision 1498)
@@ -38,6 +38,9 @@
# include <mln/arith/includes.hh>
+// Specializations are in:
+# include <mln/arith/times.spe.hh>
+
namespace mln
{
@@ -181,47 +184,35 @@
namespace impl
{
+ namespace generic
+ {
+
template <typename L, typename R, typename O>
- void times_(trait::image::speed::any, const L& lhs,
- trait::image::speed::any, const R& rhs,
- trait::image::speed::any, O& output)
+ void times_(const L& lhs, const R& rhs, O& output)
{
+ trace::entering("arith::impl::generic::times_");
+
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) * rhs(p);
- }
- template <typename L, typename R, typename O>
- void times_(trait::image::speed::fastest, const L& lhs,
- trait::image::speed::fastest, const R& rhs,
- trait::image::speed::fastest, O& output)
- {
- mln_pixter(const L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- mln_pixter(O) op(output);
- for_all_3(lp, rp, op)
- op.val() = lp.val() * rp.val();
+ trace::exiting("arith::impl::generic::times_");
}
template <typename L, typename R>
- void times_inplace_(trait::image::speed::any, L& lhs,
- trait::image::speed::any, const R& rhs)
+ void times_inplace_(L& lhs, const R& rhs)
{
+ trace::entering("arith::impl::generic::times_inplace_");
+
mln_piter(R) p(rhs.domain());
for_all(p)
lhs(p) *= rhs(p);
- }
- template <typename L, typename R>
- void times_inplace_(trait::image::speed::fastest, L& lhs,
- trait::image::speed::fastest, const R& rhs)
- {
- mln_pixter(L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- for_all_2(rp, lp)
- lp.val() *= rp.val();
+ trace::exiting("arith::impl::generic::times_inplace_");
}
+ } // end of namespace mln::arith::impl::generic
+
} // end of namespace mln::arith::impl
Index: trunk/milena/mln/arith/min.hh
===================================================================
--- trunk/milena/mln/arith/min.hh (revision 1497)
+++ trunk/milena/mln/arith/min.hh (revision 1498)
@@ -36,6 +36,9 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/arith/min.spe.hh>
+
namespace mln
{
@@ -71,47 +74,35 @@
namespace impl
{
+ namespace generic
+ {
template <typename L, typename R, typename O>
- void min_(trait::image::speed::any, const L& lhs,
- trait::image::speed::any, const R& rhs, O& output)
+ void min_(const L& lhs, const R& rhs, O& output)
{
+ trace::entering("level::arith::generic::min_");
+
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) < rhs(p) ? lhs(p) : rhs(p);
- }
- template <typename L, typename R, typename O>
- void min_(trait::image::speed::fastest, const L& lhs,
- trait::image::speed::fastest, const R& rhs, O& output)
- {
- mln_pixter(const L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- mln_pixter(O) op(output);
- for_all_3(lp, rp, op)
- op.val() = lp.val() < rp.val() ? lp.val() : rp.val();
+ trace::entering("level::arith::generic::min_");
}
template <typename L, typename R>
- void min_inplace_(trait::image::speed::any, L& lhs,
- trait::image::speed::any, const R& rhs)
+ void min_inplace_(L& lhs, const R& rhs)
{
+ trace::entering("level::arith::generic::min_inplace_");
+
mln_piter(L) p(lhs.domain());
for_all(p)
if (rhs(p) < lhs(p))
lhs(p) = rhs(p);
- }
- template <typename L, typename R>
- void min_inplace_(trait::image::speed::fastest, L& lhs,
- trait::image::speed::fastest, const R& rhs)
- {
- mln_pixter(L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- for_all_2(lp, rp)
- if (rp.val() < lp.val())
- lp.val() = rp.val();
+ trace::exiting("level::arith::generic::min_inplace_");
}
+ } // end of namespace mln::arith::impl::generic
+
} // end of namespace mln::arith::impl
Index: trunk/milena/mln/arith/times.spe.hh
===================================================================
--- trunk/milena/mln/arith/times.spe.hh (revision 0)
+++ trunk/milena/mln/arith/times.spe.hh (revision 1498)
@@ -0,0 +1,114 @@
+// 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_ARITH_TIMES_SPE_HH
+# define MLN_ARITH_TIMES_SPE_HH
+
+/*! \file mln/arith/times.spe.hh
+ *
+ * \brief Specializations for mln::arith::times.
+ *
+ */
+
+# include <mln/arith/includes.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace arith
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void times_(const L& lhs, const R& rhs, O& output);
+
+ template <typename L, typename R>
+ void times_inplace_(L& lhs, const R& rhs);
+
+ }
+
+ template <typename L, typename R, typename O>
+ void times_(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs,
+ trait::image::speed::any, O& output)
+ {
+ generic::times_(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ void times_(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs,
+ trait::image::speed::fastest, O& output)
+ {
+ trace::entering("arith::impl::times_");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() * rp.val();
+
+ trace::exiting("arith::impl::times_");
+ }
+
+ template <typename L, typename R>
+ void times_inplace_(trait::image::speed::any, L& lhs,
+ trait::image::speed::any, const R& rhs)
+ {
+ generic::times_inplace_(lhs, rhs);
+ }
+
+ template <typename L, typename R>
+ void times_inplace_(trait::image::speed::fastest, L& lhs,
+ trait::image::speed::fastest, const R& rhs)
+ {
+ trace::entering("arith::impl::times_inplace_");
+
+ mln_pixter(L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ for_all_2(rp, lp)
+ lp.val() *= rp.val();
+
+ trace::exiting("arith::impl::times_inplace_");
+ }
+
+ } // end of namespace mln::arith::impl
+
+ } // end of namespace mln::arith
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_ARITH_TIMES_SPE_HH
Index: trunk/milena/mln/arith/revert.hh
===================================================================
--- trunk/milena/mln/arith/revert.hh (revision 1497)
+++ trunk/milena/mln/arith/revert.hh (revision 1498)
@@ -38,11 +38,14 @@
# include <mln/core/concept/image.hh>
# include <mln/value/props.hh>
+// Specializations are in:
+# include <mln/arith/revert.spe.hh>
+
+
// FIXME: Rely instead on mln/fun/v2v/revert.hh.
// FIXME: Revert on int value 0 does not give 0 (since min != - max; idem for float etc.)
-
namespace mln
{
@@ -83,25 +86,24 @@
namespace impl
{
+ namespace generic
+ {
+
template <typename I, typename O>
- void revert_(trait::image::speed::any, const I& input, O& output)
+ void revert_(const I& input, O& output)
{
+ trace::entering("arith::impl::generic::revert_");
+
typedef mln_value(I) V;
mln_piter(I) p(input.domain());
for_all(p)
output(p) = mln_min(V) + (mln_max(V) - input(p));
- }
- template <typename I, typename O>
- void revert_(trait::image::speed::fastest, const I& input, O& output)
- {
- typedef mln_value(I) V;
- mln_pixter(const I) ip(input);
- mln_pixter(O) op(output);
- for_all_2(ip, op)
- op.val() = mln_min(V) + (mln_max(V) - ip.val());
+ trace::exiting("arith::impl::generic::revert_");
}
+ } // end of namespace mln::arith::impl::generic
+
} // end of namespace mln::arith::impl
Index: trunk/milena/mln/arith/min.spe.hh
===================================================================
--- trunk/milena/mln/arith/min.spe.hh (revision 0)
+++ trunk/milena/mln/arith/min.spe.hh (revision 1498)
@@ -0,0 +1,112 @@
+// 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_ARITH_MIN_SPE_HH
+# define MLN_ARITH_MIN_SPE_HH
+
+/*! \file mln/arith/min.spe.hh
+ *
+ * \brief Specializations for mln::arith::min.
+ */
+
+# include <mln/core/concept/image.hh>
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace arith
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void min_(const L& lhs, const R& rhs, O& output);
+
+ template <typename L, typename R>
+ void min_inplace_(L& lhs, const R& rhs);
+
+ }
+
+ template <typename L, typename R, typename O>
+ void min_(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs, O& output)
+ {
+ generic::min_(lhs, rhs, output);
+ }
+
+
+ template <typename L, typename R, typename O>
+ void min_(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs, O& output)
+ {
+ trace::entering("level::arith::min_");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() < rp.val() ? lp.val() : rp.val();
+
+ trace::exiting("level::arith::min_");
+ }
+
+ template <typename L, typename R>
+ void min_inplace_(trait::image::speed::any, L& lhs,
+ trait::image::speed::any, const R& rhs)
+ {
+ generic::min_inplace_(lhs, rhs);
+ }
+
+ template <typename L, typename R>
+ void min_inplace_(trait::image::speed::fastest, L& lhs,
+ trait::image::speed::fastest, const R& rhs)
+ {
+ trace::entering("level::arith::min_inplace_");
+
+ mln_pixter(L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ for_all_2(lp, rp)
+ if (rp.val() < lp.val())
+ lp.val() = rp.val();
+
+ trace::exiting("level::arith::min_inplace_");
+ }
+
+ } // end of namespace mln::arith::impl
+
+ } // end of namespace mln::arith
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_ARITH_MIN_SPE_HH
Index: trunk/milena/mln/arith/revert.spe.hh
===================================================================
--- trunk/milena/mln/arith/revert.spe.hh (revision 0)
+++ trunk/milena/mln/arith/revert.spe.hh (revision 1498)
@@ -0,0 +1,86 @@
+// 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_ARITH_REVERT_SPE_HH
+# define MLN_ARITH_REVERT_SPE_HH
+
+/*! \file mln/arith/revert.spe.hh
+ *
+ * \brief Specializations for mln::arith::revert.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/value/props.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace arith
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename I, typename O>
+ void revert_(const I& input, O& output);
+ }
+
+ template <typename I, typename O>
+ void revert_(trait::image::speed::any, const I& input, O& output)
+ {
+ generic::revert_(input, output);
+ }
+
+ template <typename I, typename O>
+ void revert_(trait::image::speed::fastest, const I& input, O& output)
+ {
+ trace::entering("arith::impl::revert_");
+
+ typedef mln_value(I) V;
+ mln_pixter(const I) ip(input);
+ mln_pixter(O) op(output);
+ for_all_2(ip, op)
+ op.val() = mln_min(V) + (mln_max(V) - ip.val());
+
+ trace::entering("arith::impl::revert_");
+ }
+
+ } // end of namespace mln::arith::impl
+
+ } // end of namespace mln::arith
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_ARITH_REVERT_SPE_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-19 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Update level tree test.
* tests/border/adjust.cc: New file to test adjsut.
* tests/border/find.cc: New.
Update
* tests/border/get.cc,
* tests/border/resize.cc: Update these tests.
---
adjust.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
find.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
get.cc | 2 +-
resize.cc | 30 +++++-------------------------
4 files changed, 104 insertions(+), 26 deletions(-)
Index: trunk/milena/tests/border/get.cc
===================================================================
--- trunk/milena/tests/border/get.cc (revision 1496)
+++ trunk/milena/tests/border/get.cc (revision 1497)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/border_get.cc
+/*! \file tests/border/get.cc
*
* \brief Tests on mln::border::get.
*/
Index: trunk/milena/tests/border/find.cc
===================================================================
--- trunk/milena/tests/border/find.cc (revision 0)
+++ trunk/milena/tests/border/find.cc (revision 1497)
@@ -0,0 +1,50 @@
+// 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/find.cc
+ *
+ * \brief Tests on mln::border::find.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/sub_image.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/border/find.hh>
+#include <mln/core/clone.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+ image2d<int> ima(3, 3, 51);
+ debug::iota(ima);
+
+ box2d b = make::box2d(2,2);
+ mln_assertion(border::find( clone(ima | b)) == 51);
+}
Index: trunk/milena/tests/border/resize.cc
===================================================================
--- trunk/milena/tests/border/resize.cc (revision 1496)
+++ trunk/milena/tests/border/resize.cc (revision 1497)
@@ -32,11 +32,9 @@
#include <mln/core/image2d.hh>
-#include <mln/debug/iota.hh>
#include <mln/value/int_u8.hh>
#include <mln/border/resize.hh>
-#include <mln/debug/println_with_border.hh>
-#include <mln/border/fill.hh>
+#include <mln/border/get.hh>
using namespace mln;
@@ -46,28 +44,10 @@
unsigned border = 1;
unsigned new_border = 3;
- std::cout << std::endl
- << "Test 2d resize"
- << std::endl
- << std::endl;
image2d<value::int_u8> ima(3, 2, border);
- debug::iota(ima);
- border::fill(ima, 8);
-
- std::cout << "before resize ("
- << border
- << ")"
- << std::endl;
- debug::println_with_border(ima);
- std::cout << std::endl;
-
-
+ mln_assertion(border::get(ima) == border);
border::resize (ima, new_border);
- std::cout << "after resize ("
- << new_border
- << ")"
- << std::endl;
- debug::println_with_border(ima);
- std::cout << std::endl;
-
+ mln_assertion(border::get(ima) == new_border);
+ border::resize (ima, border);
+ mln_assertion(border::get(ima) == border);
}
Index: trunk/milena/tests/border/adjust.cc
===================================================================
--- trunk/milena/tests/border/adjust.cc (revision 0)
+++ trunk/milena/tests/border/adjust.cc (revision 1497)
@@ -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/border/adjust.cc
+ *
+ * \brief Tests on mln::border::adjust.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/border/get.hh>
+#include <mln/border/adjust.hh>
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+
+ I ima(3,3, 51);
+ border::adjust(ima, 51);
+ mln_assertion(border::get(ima) == 51);
+ border::adjust(ima, 2);
+ mln_assertion(border::get(ima) == 51);
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-16 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add border subdirectory in test and add/update test.
* tests/border: New subdirectory for border test.
* tests/Makefile.am: Add border subdirectory.
* tests/border/duplicate.cc: New test for duplicate.
* tests/border/fill.cc: New test for duplicate.
* tests/border_get.cc: Remove ...
* tests/border/get.cc: ... and replace here.
* tests/border/resize.cc: Move test for resize.
* tests/level/median_dir.cc,
* tests/level/median_fast.cc,
* tests/level/median_hline2d.cc: Fix path for image.
---
Makefile.am | 3 +
border/duplicate.cc | 75 +++++++++++++++++++++++++++++++++++++++++++
border/fill.cc | 64 +++++++++++++++++++++++++++++++++++++
border/get.cc | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
border/resize.cc | 73 ++++++++++++++++++++++++++++++++++++++++++
level/median_dir.cc | 2 -
level/median_fast.cc | 2 -
level/median_hline2d.cc | 2 -
8 files changed, 299 insertions(+), 4 deletions(-)
Index: trunk/milena/tests/border_get.cc (deleted)
===================================================================
Index: trunk/milena/tests/level/median_dir.cc
===================================================================
--- trunk/milena/tests/level/median_dir.cc (revision 1495)
+++ trunk/milena/tests/level/median_dir.cc (revision 1496)
@@ -47,7 +47,7 @@
border::thickness = 7;
image2d<int_u8>
- lena = io::pgm::load("../img/lena.pgm"),
+ lena = io::pgm::load("../../img/lena.pgm"),
out(lena.domain());
level::median_dir(lena, 1, 15, out);
Index: trunk/milena/tests/level/median_hline2d.cc
===================================================================
--- trunk/milena/tests/level/median_hline2d.cc (revision 1495)
+++ trunk/milena/tests/level/median_hline2d.cc (revision 1496)
@@ -51,7 +51,7 @@
border::thickness = 0;
image2d<int_u8>
- lena = io::pgm::load("../img/lena.pgm"),
+ lena = io::pgm::load("../../img/lena.pgm"),
out(lena.domain()),
ref(lena.domain());
Index: trunk/milena/tests/level/median_fast.cc
===================================================================
--- trunk/milena/tests/level/median_fast.cc (revision 1495)
+++ trunk/milena/tests/level/median_fast.cc (revision 1496)
@@ -94,7 +94,7 @@
border::thickness = 52;
image2d<int_u8>
- lena = io::pgm::load("../img/lena.pgm"),
+ lena = io::pgm::load("../../img/lena.pgm"),
out(lena.domain());
level::fast_median(lena, rect, out);
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1495)
+++ trunk/milena/tests/Makefile.am (revision 1496)
@@ -3,7 +3,8 @@
include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = norm \
- level
+ level \
+ border
check_PROGRAMS = \
accu_all \
Index: trunk/milena/tests/border/get.cc
===================================================================
--- trunk/milena/tests/border/get.cc (revision 0)
+++ trunk/milena/tests/border/get.cc (revision 1496)
@@ -0,0 +1,82 @@
+// 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_get.cc
+ *
+ * \brief Tests on mln::border::get.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/image_if.hh>
+#include <mln/fun/p2b/chess.hh>
+
+#include <mln/border/get.hh>
+#include <mln/literal/origin.hh>
+
+
+struct f_box2d_t : mln::Function_p2b< f_box2d_t >
+{
+ f_box2d_t(const mln::box2d& b)
+ : b_(b)
+ {
+ }
+ mln::box2d b_;
+ bool operator()(const mln::point2d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+
+ box2d b(literal::origin, point2d(1,1));
+ f_box2d_t f_b(b);
+
+ I ima(3,3, 51);
+
+ mln_assertion(border::get(ima) == 51);
+ mln_assertion( ima.has(point2d(2,2)) == true );
+
+ sub_image<I, box2d> sub(ima, b);
+ mln_assertion( sub.has (point2d(2,2)) == false &&
+ sub.owns_(point2d(2,2)) == false );
+ mln_assertion(border::get(sub) == 0);
+
+ image_if<I, f_box2d_t> imaif(ima, f_b);
+ mln_assertion( imaif.has (point2d(2,2)) == false &&
+ imaif.owns_(point2d(2,2)) == true );
+ mln_assertion(border::get(imaif) == 51);
+
+ mln_assertion(border::get( (ima | b) | f_b ) == 0);
+}
Index: trunk/milena/tests/border/resize.cc
===================================================================
--- trunk/milena/tests/border/resize.cc (revision 0)
+++ trunk/milena/tests/border/resize.cc (revision 1496)
@@ -0,0 +1,73 @@
+// 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_resize_image2d_1.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 1;
+ unsigned new_border = 3;
+
+ std::cout << std::endl
+ << "Test 2d resize"
+ << std::endl
+ << std::endl;
+ image2d<value::int_u8> ima(3, 2, border);
+ debug::iota(ima);
+ border::fill(ima, 8);
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+}
Index: trunk/milena/tests/border/fill.cc
===================================================================
--- trunk/milena/tests/border/fill.cc (revision 0)
+++ trunk/milena/tests/border/fill.cc (revision 1496)
@@ -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/border_fill/test_border_fill_image2d_1.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/fill.hh>
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+
+int
+check(int size, int border)
+{
+ int w = size + 2 * border;
+ int ww = w *w;
+
+ image2d<value::int_u8> ima(size, size, border);
+ border::fill (ima, 42);
+ for(int i = 0; i < ww; ++i)
+ if ((i / w < border) || (i / w > border + size))
+ mln_assertion (ima[i] == 42);
+ else
+ if ((i % w < border) &&
+ (border + size <= i % w))
+ mln_assertion (ima[i] == 42);
+}
+
+int
+main (void)
+{
+ for (int i = 1; i < 42; ++i)
+ for (int j = 1; j < 42; ++j)
+ check(i, j);
+}
Index: trunk/milena/tests/border/duplicate.cc
===================================================================
--- trunk/milena/tests/border/duplicate.cc (revision 0)
+++ trunk/milena/tests/border/duplicate.cc (revision 1496)
@@ -0,0 +1,75 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \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/duplicate.hh>
+
+
+using namespace mln;
+
+int
+main (void)
+{
+ image2d<int> ima(3, 3, 1);
+
+ debug::iota (ima);
+ border::duplicate (ima);
+
+ mln_assertion(ima[ 0] == 1);
+ mln_assertion(ima[ 1] == 1);
+ mln_assertion(ima[ 2] == 2);
+ mln_assertion(ima[ 3] == 3);
+ mln_assertion(ima[ 4] == 3);
+ mln_assertion(ima[ 5] == 1);
+ mln_assertion(ima[ 6] == 1);
+ mln_assertion(ima[ 7] == 2);
+ mln_assertion(ima[ 8] == 3);
+ mln_assertion(ima[ 9] == 3);
+ mln_assertion(ima[10] == 4);
+ mln_assertion(ima[11] == 4);
+ mln_assertion(ima[12] == 5);
+ mln_assertion(ima[13] == 6);
+ mln_assertion(ima[14] == 6);
+ mln_assertion(ima[15] == 7);
+ mln_assertion(ima[16] == 7);
+ mln_assertion(ima[17] == 8);
+ mln_assertion(ima[18] == 9);
+ mln_assertion(ima[19] == 9);
+ mln_assertion(ima[20] == 7);
+ mln_assertion(ima[21] == 7);
+ mln_assertion(ima[22] == 8);
+ mln_assertion(ima[23] == 9);
+ mln_assertion(ima[24] == 9);
+
+}
+
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-16 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Review the mln/canvas/browsing directory.
* mln/canvas/browsing/dir_ricard51.hh: Rename as...
* mln/canvas/browsing/dir_struct_elt_incr_update.hh: ...this, Document.
* mln/canvas/browsing/directional.hh: Document.
* mln/canvas/browsing/fwd.hh: Document.
* mln/canvas/browsing/snake_fwd.hh: Document.
* tests/canvas/browsing/dir_struct_elt_incr_update.cc: New.
* tests/canvas/browsing/directional.cc: New.
* tests/canvas/browsing/fwd.cc: New.
* tests/canvas/browsing/snake_fwd.cc: New.
* tests/canvas/browsing: New.
* tests/canvas: New.
* tests/canvas_browsing_fwd.cc: Remove.
---
mln/canvas/browsing/dir_struct_elt_incr_update.hh | 227 ++++++++++++++++++++
mln/canvas/browsing/directional.hh | 27 ++
mln/canvas/browsing/fwd.hh | 23 +-
mln/canvas/browsing/snake_fwd.hh | 39 +++
tests/canvas/browsing/dir_struct_elt_incr_update.cc | 37 +++
tests/canvas/browsing/directional.cc | 120 ++++++++++
tests/canvas/browsing/fwd.cc | 93 ++++++++
tests/canvas/browsing/snake_fwd.cc | 96 ++++++++
8 files changed, 653 insertions(+), 9 deletions(-)
Index: trunk/milena/tests/canvas_browsing_fwd.cc (deleted)
===================================================================
Index: trunk/milena/tests/canvas/browsing/directional.cc
===================================================================
--- trunk/milena/tests/canvas/browsing/directional.cc (revision 0)
+++ trunk/milena/tests/canvas/browsing/directional.cc (revision 1495)
@@ -0,0 +1,120 @@
+// 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/canvas/browsing/directional.cc
+ *
+ * \brief Tests on mln::canvas::browsing::directional.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/canvas/browsing/directional.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/level/fill.hh>
+
+// FIXME: Move code below into mln/canvas/browsing/iota.hh.
+
+
+template <typename I_, typename F>
+struct assign_browsing_functor
+{
+ typedef I_ I;
+ enum { dim = I::point::dim };
+
+
+ I input;
+ F f;
+ int dir;
+
+ assign_browsing_functor(I& input, F f = F(), int dir_ = 0)
+ : input(input),
+ f(f),
+ dir(dir_)
+ {}
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+ mln_assertion(p[dir] == 0);
+ }
+ void fwd() { next(); }
+ void bkd() { next(); }
+ void down() { next(); }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_,
+ int dir = 0)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f, dir);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image2d<unsigned> ima2(3, 3);
+ image3d<unsigned> ima3(3, 3, 3);
+
+ level::fill(ima2, 0);
+ my_test(ima2, fun::p2v::iota, canvas::browsing::directional, 0);
+ debug::println(ima2);
+
+ level::fill(ima2, 0);
+ my_test(ima2, fun::p2v::iota, canvas::browsing::directional, 1);
+ debug::println(ima2);
+
+
+ level::fill(ima3, 0);
+ my_test(ima3, fun::p2v::iota, canvas::browsing::directional, 0);
+ debug::println(ima3);
+
+ level::fill(ima3, 0);
+ my_test(ima3, fun::p2v::iota, canvas::browsing::directional, 1);
+ debug::println(ima3);
+
+ level::fill(ima3, 0);
+ my_test(ima3, fun::p2v::iota, canvas::browsing::directional, 2);
+ debug::println(ima3);
+}
Index: trunk/milena/tests/canvas/browsing/fwd.cc
===================================================================
--- trunk/milena/tests/canvas/browsing/fwd.cc (revision 0)
+++ trunk/milena/tests/canvas/browsing/fwd.cc (revision 1495)
@@ -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/canvas/browsing/fwd.cc
+ *
+ * \brief Tests on mln::canvas::browsing::fwd.hh
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/canvas/browsing/fwd.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/debug/println.hh>
+
+// FIXME: Move code below into mln/canvas/browsing/iota.hh.
+
+
+template <typename I_, typename F>
+struct assign_browsing_functor
+{
+ typedef I_ I;
+ enum { dim = I::point::dim };
+
+
+ I input;
+ F f;
+
+ assign_browsing_functor(I& input, F f = F())
+ : input(input),
+ f(f)
+ {}
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+ mln_assertion(input(p) - 1 == p[0] * input.domain().ncols() + p[1]);
+ }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image2d<unsigned> ima2(3, 3);
+
+ my_test(ima2, fun::p2v::iota, canvas::browsing::fwd);
+ debug::println(ima2);
+}
Index: trunk/milena/tests/canvas/browsing/snake_fwd.cc
===================================================================
--- trunk/milena/tests/canvas/browsing/snake_fwd.cc (revision 0)
+++ trunk/milena/tests/canvas/browsing/snake_fwd.cc (revision 1495)
@@ -0,0 +1,96 @@
+// 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/canvas/browsing/snake_fwd.cc
+ *
+ * \brief Tests on mln::canvas::browsing::snake_fwd.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/canvas/browsing/snake_fwd.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/debug/println.hh>
+
+// FIXME: Move code below into mln/canvas/browsing/iota.hh.
+
+
+template <typename I, typename F>
+struct assign_browsing_functor
+{
+ enum { dim = I::point::dim };
+
+
+ I input;
+ F f;
+
+ assign_browsing_functor(I& input, F f = F())
+ : input(input),
+ f(f)
+ {}
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+ mln_assertion(input(p) - 1 == p[0] * input.domain().ncols()
+ + ( (p[0] % 2) ? input.domain().ncols() - 1 - p[1] : p[1]));
+ }
+ void fwd() { next(); }
+ void bkd() { next(); }
+ void down() { next(); }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image2d<unsigned> ima2(3, 3);
+
+ my_test(ima2, fun::p2v::iota, canvas::browsing::snake_fwd);
+ debug::println(ima2);
+}
Index: trunk/milena/tests/canvas/browsing/dir_struct_elt_incr_update.cc
===================================================================
--- trunk/milena/tests/canvas/browsing/dir_struct_elt_incr_update.cc (revision 0)
+++ trunk/milena/tests/canvas/browsing/dir_struct_elt_incr_update.cc (revision 1495)
@@ -0,0 +1,37 @@
+// 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/canvas/browsing/dir_struct_elt_incr_update.cc
+ *
+ * \brief Tests on mln::canvas::browsing::dir_struct_elt_incr_update
+ */
+
+
+int main()
+{
+ //FIXME: Make a more relevant test.
+}
Index: trunk/milena/mln/canvas/browsing/dir_ricard51.hh (deleted)
===================================================================
Index: trunk/milena/mln/canvas/browsing/snake_fwd.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/snake_fwd.hh (revision 1494)
+++ trunk/milena/mln/canvas/browsing/snake_fwd.hh (revision 1495)
@@ -34,7 +34,6 @@
*/
# include <mln/core/concept/browsing.hh>
-# include <mln/core/dpoint2d.hh> // for "up"
# include <mln/geom/size2d.hh>
@@ -47,8 +46,29 @@
namespace browsing
{
- /*! FIXME: Doc!
+ /*!
+ * \brief Browsing in a snake-way, forward.
*
+ * This canvas browse all the point of an image 'input' like
+ * this :
+ *
+ * ------->
+ * <------'
+ * '------>
+ *
+ * The fonctor should provide (In addition to 'input') four
+ * methods :
+ *
+ * - init() : Will be called at the beginning.
+ * - down() : Will be called after each moving down. (will
+ * also be called once at the first point).
+ * - fwd() : Will be called after each moving right.
+ * - bwd() : Will ba called after each moving left.
+ *
+ * This methods should acces to the current working point 'p'
+ * also provided by the functor.
+ *
+ * Warning: This canvas works only on 2D.
*
* F shall feature: \n
* { \n
@@ -73,49 +93,62 @@
snake_fwd;
+
# ifndef MLN_INCLUDE_ONLY
template <typename F>
void
snake_fwd_t::operator()(F& f) const
{
+ // FIXME: Check the dimension (2D) or generalize.
+ trace::entering("canvas::browsing::snake_fwd");
mln_precondition(f.input.has_data());
int
min_row = geom::min_row(f.input), max_row = geom::max_row(f.input),
min_col = geom::min_col(f.input), max_col = geom::max_col(f.input);
// p
- f.p = f.input.bbox().pmin() + up;
+ f.p = f.input.bbox().pmin();
int& row = f.p.row();
int& col = f.p.col();
// initialization
+ trace::entering("canvas::browsing::snake_fwd::init");
f.init();
+ trace::exiting("canvas::browsing::snake_fwd::init");
bool fwd = true;
for (row = min_row; row <= max_row; ++row)
+ // FIXME: Add "if (f.input.has(p))"?
{
// go down
+ trace::entering("canvas::browsing::snake_fwd::init");
f.down();
+ trace::exiting("canvas::browsing::snake_fwd::init");
if (fwd)
// browse line fwd
while (col < max_col)
{
++col;
+ trace::entering("canvas::browsing::snake_fwd::fwd");
f.fwd();
+ trace::exiting("canvas::browsing::snake_fwd::fwd");
}
else
// browse line bkd
while (col > min_col)
{
--col;
+ trace::entering("canvas::browsing::snake_fwd");
f.bkd();
+ trace::exiting("canvas::browsing::snake_fwd");
}
// change browsing
fwd = ! fwd;
}
+ trace::exiting("canvas::browsing::snake_fwd");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/canvas/browsing/dir_struct_elt_incr_update.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/dir_struct_elt_incr_update.hh (revision 0)
+++ trunk/milena/mln/canvas/browsing/dir_struct_elt_incr_update.hh (revision 1495)
@@ -0,0 +1,227 @@
+// 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_CANVAS_BROWSING_DIR_STRUCT_ELT_INCR_UPDATE_HH
+# define MLN_CANVAS_BROWSING_DIR_STRUCT_ELT_INCR_UPDATE_HH
+
+/*! \file mln/canvas/browsing/dir_struct_elt_incr_update.hh
+ *
+ * \brief Directional browsing of an image with structuring element.
+ */
+
+# include <mln/core/concept/browsing.hh>
+# include <mln/core/concept/image.hh>
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ namespace browsing
+ {
+
+ /*!
+ * \brief Browsing in a certain direction with a segment.
+ *
+ * This canvas browse all the point of an image 'input' of type
+ * 'I', of dimension 'dim' in the direction 'dir' with
+ * considering weigh the 'length' nearest points.
+ *
+ * The functor should provide (In addition to 'input', 'I',
+ * 'dim', 'dir' and 'length') six methods :
+ *
+ * - init() : Will be called at the beginning.
+ * - init_line() : Will be called at the beginning of each
+ * line.
+ * - add_point(q) : Will be called for taking the new point
+ * 'q' into account.
+ * - remove_point(q): Will be called for untaking the new point
+ * 'q' into account.
+ * - next() : Will be called at each point 'p' (also
+ * provided by the functor).
+ * - final() : Will be called at the end.
+ *
+ * F shall features : \n
+ * { \n
+ * --- as types: \n
+ * I; \n
+ * --- as attributes: \n
+ * dim; \n
+ * dir; // and test dir < dim \n
+ * input; \n
+ * p; \n
+ * length; \n
+ * --- as methods: \n
+ * void init(); \n
+ * void init_line(); \n
+ * void add_point(q) \n
+ * void remove_point(q) \n
+ * void next(); \n
+ * void final(); \n
+ * } \n
+ *
+ */
+ struct dir_struct_elt_incr_update_t : public Browsing< dir_struct_elt_incr_update_t >
+ {
+ template <typename F>
+ void operator()(F& f) const;
+ }
+
+ dir_struct_elt_incr_update;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F>
+ void
+ dir_struct_elt_incr_update_t::operator()(F& f) const
+ {
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update");
+ mln_precondition(f.dir < f.dim);
+ typedef typename F::I I;
+
+ const mln_point(I)
+ pmin = f.input.domain().pmin(),
+ pmax = f.input.domain().pmax();
+
+ const mln_coord(I)
+ pmin_dir = pmin[f.dir],
+ pmax_dir = pmax[f.dir],
+ pmin_dir_plus_half_length = pmin_dir + f.length / 2,
+ pmax_dir_minus_half_length = pmax_dir - f.length / 2;
+
+ mln_point(I) pt, pu;
+
+ typedef mln_coord(I)& coord_ref;
+ coord_ref
+ ct = pt[f.dir],
+ cu = pu[f.dir],
+ p_dir = f.p[f.dir];
+
+ f.p = pmin;
+
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::init");
+ f.init();
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::init");
+
+ do
+ {
+ pt = f.p;
+ pu = f.p;
+
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::init_line");
+ f.init_line();
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::init_line");
+
+ // initialization (before first point of the line)
+ for (ct = pmin_dir; ct < pmin_dir_plus_half_length; ++ ct)
+ if (f.input.has(pt))
+ {
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::add_point");
+ f.add_point(pt);
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::add_point");
+ }
+
+ // left columns (just take new points)
+ for (p_dir = pmin_dir; p_dir <= pmin_dir_plus_half_length; ++p_dir, ++ct)
+ {
+ if (f.input.has(pt))
+ {
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::add_point");
+ f.add_point(pt);
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::add_point");
+ }
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::next");
+ f.next();
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::next");
+ }
+
+ // middle columns (both take and untake)
+ cu = pmin_dir;
+ for (; p_dir <= pmax_dir_minus_half_length; ++cu, ++p_dir, ++ct)
+ {
+ if (f.input.has(pt))
+ {
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::add_point");
+ f.add_point(pt);
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::add_point");
+ }
+ if (f.input.has(pu))
+ {
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::remove_point");
+ f.remove_point(pu);
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::remove_point");
+ }
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::next");
+ f.next();
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::next");
+ }
+
+ // right columns (now just untake old points)
+ for (; p_dir <= pmax_dir; ++cu, ++p_dir)
+ {
+ if (f.input.has(pu))
+ {
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::remove_point");
+ f.remove_point(pu);
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::remove_point");
+ }
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::next");
+ f.next();
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::next");
+ }
+
+ p_dir = pmin_dir;
+
+ for (int c = F::dim - 1; c >= 0; --c)
+ {
+ if (c == int(f.dir))
+ continue;
+ if (f.p[c] != pmax[c])
+ {
+ ++f.p[c];
+ break;
+ }
+ f.p[c] = pmin[c];
+ }
+ } while (f.p != pmin);
+
+ trace::entering("canvas::browsing::dir_struct_elt_incr_update::final");
+ f.final();
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update::final");
+ trace::exiting("canvas::browsing::dir_struct_elt_incr_update");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas::browsing
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+#endif // ! MLN_CANVAS_BROWSING_DIR_STRUCT_ELT_INCR_UPDATE_HH
Index: trunk/milena/mln/canvas/browsing/directional.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/directional.hh (revision 1494)
+++ trunk/milena/mln/canvas/browsing/directional.hh (revision 1495)
@@ -45,7 +45,20 @@
namespace browsing
{
- /*! FIXME : DOC
+ /*!
+ * \brief Browsing in a certain direction.
+ *
+ * This canvas browse all the point of an image 'input' of type
+ * 'I' and of dimension 'dim' in the direction 'dir'.
+ *
+ * The functor should provide (In addition to 'input', 'I',
+ * 'dim' and 'dir') three methods :
+ *
+ * - init() : Will be called at the beginning.
+ * - next() : Will be called at each point 'p' (also provided by
+ * the fonctor).
+ * - final(): Will be called at the end.
+ *
* F shall features : \n
* { \n
* --- as types: \n
@@ -57,8 +70,8 @@
* p; \n
* --- as methods: \n
* void init(); \n
- * void next() \n
- * void final() \n
+ * void next(); \n
+ * void final(); \n
* } \n
*
*/
@@ -76,6 +89,7 @@
void
directional_t::operator()(F& f) const
{
+ trace::entering("canvas::browsing::directional");
mln_precondition(f.dir < f.dim);
typedef typename F::I I;
@@ -85,11 +99,15 @@
f.p = pmin;
+ trace::entering("canvas::browsing::directional::init");
f.init();
+ trace::exiting("canvas::browsing::directional::init");
do
{
+ trace::entering("canvas::browsing::directional::next");
f.next();
+ trace::exiting("canvas::browsing::directional::next");
for (int c = F::dim - 1; c >= 0; --c)
{
@@ -104,7 +122,10 @@
}
} while (f.p != pmin);
+ trace::entering("canvas::browsing::directional::final");
f.final();
+ trace::exiting("canvas::browsing::directional::final");
+ trace::exiting("canvas::browsing::directional");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/canvas/browsing/fwd.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/fwd.hh (revision 1494)
+++ trunk/milena/mln/canvas/browsing/fwd.hh (revision 1495)
@@ -30,7 +30,7 @@
/*! \file mln/canvas/browsing/fwd.hh
*
- * \brief Canvas for browsing forward.
+ * \brief Canvas for forward browsing.
*/
# include <mln/core/concept/browsing.hh>
@@ -46,8 +46,18 @@
namespace browsing
{
- /*! FIXME: Doc!
+ /*!
+ * \brief Canvas for forward browsing
*
+ * This canvas browse all the points of an image 'input' of type
+ * 'I' from left to right and from top to bottom
+ *
+ * The fonctor should provide (In addition of 'I' and 'input')
+ * three methods :
+ * - init() : Will be called at the beginning.
+ * - next() : Will be called at each point 'p' (also provided by
+ * the functor).
+ * - final(): Will be called at the end.
*
* F shall feature: \n
* { \n
@@ -63,7 +73,6 @@
* } \n
*
*/
-
struct fwd_t : public Browsing< fwd_t >
{
template <typename F>
@@ -79,16 +88,24 @@
void
fwd_t::operator()(F& f) const
{
+ trace::entering("canvas::browsing::fwd");
mln_precondition(f.input.has_data());
typedef typename F::I I;
mln_fwd_piter(I) p(f.input.domain());
+ trace::entering("canvas::browsing::fwd::init");
f.init();
+ trace::exiting("canvas::browsing::fwd::init");
for_all(p)
{
f.p = p;
+ trace::entering("canvas::browsing::fwd::next");
f.next();
+ trace::exiting("canvas::browsing::fwd::next");
}
+ trace::entering("canvas::browsing::fwd::final");
f.final();
+ trace::exiting("canvas::browsing::fwd::final");
+ trace::exiting("canvas::browsing::fwd");
}
# endif // ! MLN_INCLUDE_ONLY
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-16 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add simple tests for level.
* tests/level/compare.cc,
* tests/level/compute.cc,
* tests/level/saturate.cc,
* tests/level/sort_points.cc,
* tests/level/stretch.cc: New test for level.
* tests/level/median.cc,
* tests/level/paste.cc,
* tests/level/transform.cc: Upadate test.
---
compare.cc | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
compute.cc | 53 ++++++++++++++++++++++++++++++
median.cc | 2 -
paste.cc | 6 ---
saturate.cc | 57 +++++++++++++++++++++++++++++++++
sort_points.cc | 61 +++++++++++++++++++++++++++++++++++
stretch.cc | 65 +++++++++++++++++++++++++++++++++++++
transform.cc | 12 +++++-
8 files changed, 345 insertions(+), 9 deletions(-)
Index: trunk/milena/tests/level/median.cc
===================================================================
--- trunk/milena/tests/level/median.cc (revision 1490)
+++ trunk/milena/tests/level/median.cc (revision 1491)
@@ -51,7 +51,7 @@
border::thickness = 52;
image2d<int_u8>
- lena = io::pgm::load("../img/lena.pgm"),
+ lena = io::pgm::load("../../img/lena.pgm"),
out(lena.domain());
level::median(lena, rect, out);
Index: trunk/milena/tests/level/transform.cc
===================================================================
--- trunk/milena/tests/level/transform.cc (revision 1490)
+++ trunk/milena/tests/level/transform.cc (revision 1491)
@@ -52,15 +52,23 @@
{
using namespace mln;
- const unsigned size = 10000;
+ const unsigned size = 1000;
image2d<unsigned short>
ima(size, size);
+ image2d<unsigned short>
+ out(size, size);
(std::cout << "iota... ").flush();
debug::iota(ima);
std::cout << "done" << std::endl;
(std::cout << "transform... ").flush();
- level::transform(ima, mysqrt(), ima);
+ level::transform(ima, mysqrt(), out);
+ std::cout << "done" << std::endl;
+
+ (std::cout << "checking... ").flush();
+ box_fwd_piter_<point2d> p(out.domain());
+ for_all(p)
+ mln_assertion((unsigned short)std::sqrt(ima(p)) == out(p));
std::cout << "done" << std::endl;
}
Index: trunk/milena/tests/level/stretch.cc
===================================================================
--- trunk/milena/tests/level/stretch.cc (revision 0)
+++ trunk/milena/tests/level/stretch.cc (revision 1491)
@@ -0,0 +1,65 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/level/stretch.cc
+ *
+ * \brief Tests on mln::level::stretch.
+ */
+
+
+#include <mln/core/image2d.hh>
+#include <mln/level/stretch.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ int vs[3][3] = {
+ { 1000, 2000, 3000 },
+ { 1000, 2000, 3000 },
+ { 1000, 2000, 3000 }
+ };
+ image2d<int> ima(make::image2d(vs));
+
+ image2d<int_u8> out(3, 3);
+
+ int_u8 ws[3][3] = {
+ { 0, 127, 255 },
+ { 0, 127, 255 },
+ { 0, 127, 255 }
+ };
+
+ image2d<int_u8> ref(make::image2d(ws));
+ level::stretch(ima, out);
+ box_fwd_piter_<point2d> p(out.domain());
+ for_all(p)
+ mln_assertion(out(p) == ref(p));
+}
Index: trunk/milena/tests/level/compute.cc
===================================================================
--- trunk/milena/tests/level/compute.cc (revision 0)
+++ trunk/milena/tests/level/compute.cc (revision 1491)
@@ -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/compute.cc
+ *
+ * \brief Tests on mln::level::compute.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/level/compute.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);
+ int min = level::compute(ima, acu_min);
+ int max = level::compute(ima, acu_max);
+ mln_assertion(min == 1);
+ mln_assertion(max == 40000);
+}
Index: trunk/milena/tests/level/paste.cc
===================================================================
--- trunk/milena/tests/level/paste.cc (revision 1490)
+++ trunk/milena/tests/level/paste.cc (revision 1491)
@@ -45,18 +45,12 @@
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/sort_points.cc
===================================================================
--- trunk/milena/tests/level/sort_points.cc (revision 0)
+++ trunk/milena/tests/level/sort_points.cc (revision 1491)
@@ -0,0 +1,61 @@
+// 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/sort_points.cc
+ *
+ * \brief Tests on mln::level::sort_points.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/level/sort_points.hh>
+#include <mln/core/p_array.hh>
+
+
+int main ()
+{
+ using namespace mln;
+
+ image2d<int> ima(3, 3);
+ debug::iota (ima);
+ p_array<point2d> array_inc = level::sort_points_increasing(ima);
+ p_array<point2d> array_dec = level::sort_points_decreasing(ima);
+
+ p_array<point2d> array_inc_ref;
+ p_array<point2d> array_dec_ref;
+
+ for (int i = 0; i < 3; ++i)
+ for (int j = 0; j < 3; ++j)
+ array_inc_ref.append(point2d(i, j));
+
+ for (int i = 2; i >= 0; --i)
+ for (int j = 2; j >= 0; --j)
+ array_dec_ref.append(point2d(i, j));
+
+ mln_assertion(array_inc == array_inc_ref);
+ mln_assertion(array_dec == array_dec_ref);
+}
Index: trunk/milena/tests/level/compare.cc
===================================================================
--- trunk/milena/tests/level/compare.cc (revision 0)
+++ trunk/milena/tests/level/compare.cc (revision 1491)
@@ -0,0 +1,98 @@
+// 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/compare.cc
+ *
+ * \brief Tests on mln::level::compare.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/debug/iota.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 3;
+ image2d<int> rhs(size, size), lhs(rhs.domain());
+ debug::iota(rhs);
+ debug::iota(lhs);
+ mln_assertion( (lhs == rhs));
+ mln_assertion( (lhs <= rhs));
+ mln_assertion(! (lhs < rhs));
+ mln_assertion( (lhs >= rhs));
+ mln_assertion(! (lhs > rhs));
+
+ int vs[3][3] = {
+
+ { 2, 3, 4 },
+ { 5, 6, 7 },
+ { 8, 9, 10 },
+
+ };
+
+ rhs = make::image2d(vs);
+
+ mln_assertion(! (lhs == rhs));
+ mln_assertion( (lhs <= rhs));
+ mln_assertion( (lhs < rhs));
+ mln_assertion(! (lhs >= rhs));
+ mln_assertion(! (lhs > rhs));
+
+ mln_assertion(! (rhs == lhs));
+ mln_assertion(! (rhs <= lhs));
+ mln_assertion(! (rhs < lhs));
+ mln_assertion( (rhs >= lhs));
+ mln_assertion( (rhs > lhs));
+
+
+ int ws[3][3] = {
+
+ { 1, 3, 4 },
+ { 4, 6, 7 },
+ { 7, 9, 10 },
+
+ };
+
+ rhs = make::image2d(ws);
+
+ mln_assertion(! (lhs == rhs));
+ mln_assertion( (lhs <= rhs));
+ mln_assertion(! (lhs < rhs));
+ mln_assertion(! (lhs >= rhs));
+ mln_assertion(! (lhs > rhs));
+
+ mln_assertion(! (rhs == lhs));
+ mln_assertion(! (rhs <= lhs));
+ mln_assertion(! (rhs < lhs));
+ mln_assertion( (rhs >= lhs));
+ mln_assertion(! (rhs > lhs));
+
+
+}
Index: trunk/milena/tests/level/saturate.cc
===================================================================
--- trunk/milena/tests/level/saturate.cc (revision 0)
+++ trunk/milena/tests/level/saturate.cc (revision 1491)
@@ -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/saturate.cc
+ *
+ * \brief Tests on mln::level::saturate.
+ */
+
+
+#include <mln/core/image2d.hh>
+#include <mln/level/saturate.hh>
+#include <mln/debug/iota.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::saturate_inplace(ima, 2, 6);
+ box_fwd_piter_<point2d> p(ima.domain());
+ for_all(p)
+ mln_assertion(ima(p) == ref(p));
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-16 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Review the mln/geom directory.
* mln/geom/seeds2tiling.hh: Clean dead code, update doc. Fixme for
guillaume : Review the documentation.
* mln/geom/seeds2tiling_with_chamfer.hh: likewise.
Add unit tests.
* tests/geom/bbox.cc: New.
* tests/geom/max_col.cc: New.
* tests/geom/max_ind.cc: New.
* tests/geom/max_row.cc: New.
* tests/geom/max_sli.cc: New.
* tests/geom/min_col.cc: New.
* tests/geom/min_ind.cc: New.
* tests/geom/min_row.cc: New.
* tests/geom/min_sli.cc: New.
* tests/geom/ncols.cc: New.
* tests/geom/ninds.cc: New.
* tests/geom/nrows.cc: New.
* tests/geom/nslis.cc: New.
* tests/geom/pmin_pmax.cc: New.
* tests/geom/shift.cc: New.
* tests/geom/sym.cc: New.
* tests/geom: New.
---
mln/geom/seeds2tiling.hh | 23 +-------------
mln/geom/seeds2tiling_with_chamfer.hh | 2 -
tests/geom/bbox.cc | 45 ++++++++++++++++++++++++++++
tests/geom/max_col.cc | 39 ++++++++++++++++++++++++
tests/geom/max_ind.cc | 39 ++++++++++++++++++++++++
tests/geom/max_row.cc | 39 ++++++++++++++++++++++++
tests/geom/max_sli.cc | 39 ++++++++++++++++++++++++
tests/geom/min_col.cc | 39 ++++++++++++++++++++++++
tests/geom/min_ind.cc | 39 ++++++++++++++++++++++++
tests/geom/min_row.cc | 39 ++++++++++++++++++++++++
tests/geom/min_sli.cc | 39 ++++++++++++++++++++++++
tests/geom/ncols.cc | 39 ++++++++++++++++++++++++
tests/geom/ninds.cc | 39 ++++++++++++++++++++++++
tests/geom/nrows.cc | 39 ++++++++++++++++++++++++
tests/geom/nslis.cc | 39 ++++++++++++++++++++++++
tests/geom/pmin_pmax.cc | 50 +++++++++++++++++++++++++++++++
tests/geom/shift.cc | 54 ++++++++++++++++++++++++++++++++++
tests/geom/sym.cc | 54 ++++++++++++++++++++++++++++++++++
18 files changed, 674 insertions(+), 22 deletions(-)
Index: trunk/milena/tests/geom/max_sli.cc
===================================================================
--- trunk/milena/tests/geom/max_sli.cc (revision 0)
+++ trunk/milena/tests/geom/max_sli.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image3d.hh>
+
+#include <mln/geom/max_sli.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image3d<int> ima(3,4,5);
+
+ mln_assertion(geom::max_sli(ima) == 2);
+}
Index: trunk/milena/tests/geom/nrows.cc
===================================================================
--- trunk/milena/tests/geom/nrows.cc (revision 0)
+++ trunk/milena/tests/geom/nrows.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image2d.hh>
+
+#include <mln/geom/nrows.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(make::box2d(-1,-4,2,6));
+
+ mln_assertion(geom::nrows(ima) == 4);
+}
Index: trunk/milena/tests/geom/sym.cc
===================================================================
--- trunk/milena/tests/geom/sym.cc (revision 0)
+++ trunk/milena/tests/geom/sym.cc (revision 1490)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#include <mln/core/window2d.hh>
+#include <mln/core/dpoint2d.hh>
+
+#include <mln/geom/sym.hh>
+
+int main()
+{
+ using namespace mln;
+
+ dpoint2d dp(2, 2);
+
+ window2d win, win2;
+
+ win.insert(make::dpoint2d(0,0));
+ win.insert(make::dpoint2d(1,2));
+ win.insert(make::dpoint2d(3,4));
+ win.insert(make::dpoint2d(5,6));
+ win.insert(make::dpoint2d(7,8));
+
+ win2.insert(make::dpoint2d(0,0));
+ win2.insert(make::dpoint2d(-1,-2));
+ win2.insert(make::dpoint2d(-3,-4));
+ win2.insert(make::dpoint2d(-5,-6));
+ win2.insert(make::dpoint2d(-7,-8));
+
+ mln_assertion(geom::sym(win) == win2);
+}
Index: trunk/milena/tests/geom/min_row.cc
===================================================================
--- trunk/milena/tests/geom/min_row.cc (revision 0)
+++ trunk/milena/tests/geom/min_row.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image2d.hh>
+
+#include <mln/geom/min_row.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(make::box2d(-1,-4,2,6));
+
+ mln_assertion(geom::min_row(ima) == -1);
+}
Index: trunk/milena/tests/geom/ninds.cc
===================================================================
--- trunk/milena/tests/geom/ninds.cc (revision 0)
+++ trunk/milena/tests/geom/ninds.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image1d.hh>
+
+#include <mln/geom/ninds.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image1d<int> ima(make::box1d(-1,8));
+
+ mln_assertion(geom::ninds(ima) == 10);
+}
Index: trunk/milena/tests/geom/max_row.cc
===================================================================
--- trunk/milena/tests/geom/max_row.cc (revision 0)
+++ trunk/milena/tests/geom/max_row.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image2d.hh>
+
+#include <mln/geom/max_row.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(make::box2d(-1,-4,2,6));
+
+ mln_assertion(geom::max_row(ima) == 2);
+}
Index: trunk/milena/tests/geom/shift.cc
===================================================================
--- trunk/milena/tests/geom/shift.cc (revision 0)
+++ trunk/milena/tests/geom/shift.cc (revision 1490)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#include <mln/core/window2d.hh>
+#include <mln/core/dpoint2d.hh>
+
+#include <mln/geom/shift.hh>
+
+int main()
+{
+ using namespace mln;
+
+ dpoint2d dp(2, 2);
+
+ window2d win, win2;
+
+ win.insert(make::dpoint2d(0,0));
+ win.insert(make::dpoint2d(1,2));
+ win.insert(make::dpoint2d(3,4));
+ win.insert(make::dpoint2d(5,6));
+ win.insert(make::dpoint2d(7,8));
+
+ win2.insert(make::dpoint2d(2,2));
+ win2.insert(make::dpoint2d(3,4));
+ win2.insert(make::dpoint2d(5,6));
+ win2.insert(make::dpoint2d(7,8));
+ win2.insert(make::dpoint2d(9,10));
+
+ mln_assertion(geom::shift(win, dp) == win2);
+}
Index: trunk/milena/tests/geom/min_ind.cc
===================================================================
--- trunk/milena/tests/geom/min_ind.cc (revision 0)
+++ trunk/milena/tests/geom/min_ind.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image1d.hh>
+
+#include <mln/geom/min_ind.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image1d<int> ima(make::box1d(-1,8));
+
+ mln_assertion(geom::min_ind(ima) == -1);
+}
Index: trunk/milena/tests/geom/ncols.cc
===================================================================
--- trunk/milena/tests/geom/ncols.cc (revision 0)
+++ trunk/milena/tests/geom/ncols.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image2d.hh>
+
+#include <mln/geom/ncols.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(make::box2d(-1,-4,2,6));
+
+ mln_assertion(geom::ncols(ima) == 11);
+}
Index: trunk/milena/tests/geom/max_ind.cc
===================================================================
--- trunk/milena/tests/geom/max_ind.cc (revision 0)
+++ trunk/milena/tests/geom/max_ind.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image1d.hh>
+
+#include <mln/geom/max_ind.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image1d<int> ima(make::box1d(-1,8));
+
+ mln_assertion(geom::max_ind(ima) == 8);
+}
Index: trunk/milena/tests/geom/min_col.cc
===================================================================
--- trunk/milena/tests/geom/min_col.cc (revision 0)
+++ trunk/milena/tests/geom/min_col.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image2d.hh>
+
+#include <mln/geom/min_col.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(make::box2d(-1,-4,2,6));
+
+ mln_assertion(geom::min_col(ima) == -4);
+}
Index: trunk/milena/tests/geom/max_col.cc
===================================================================
--- trunk/milena/tests/geom/max_col.cc (revision 0)
+++ trunk/milena/tests/geom/max_col.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image2d.hh>
+
+#include <mln/geom/max_col.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(make::box2d(-1,-4,2,6));
+
+ mln_assertion(geom::max_col(ima) == 6);
+}
Index: trunk/milena/tests/geom/pmin_pmax.cc
===================================================================
--- trunk/milena/tests/geom/pmin_pmax.cc (revision 0)
+++ trunk/milena/tests/geom/pmin_pmax.cc (revision 1490)
@@ -0,0 +1,50 @@
+// 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.
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_set.hh>
+
+#include <mln/geom/pmin_pmax.hh>
+
+int main()
+{
+ using namespace mln;
+
+ p_set<point2d> p;
+ point2d min, max;
+
+ p.insert(make::point2d(0,0));
+ p.insert(make::point2d(-1,2));
+ p.insert(make::point2d(-3,4));
+ p.insert(make::point2d(7,6));
+ p.insert(make::point2d(5,8));
+
+ geom::pmin_pmax(p, min, max);
+
+ mln_assertion(min == (make::point2d(-3 ,0)));
+ mln_assertion(max == (make::point2d( 7 ,8)));
+}
Index: trunk/milena/tests/geom/nslis.cc
===================================================================
--- trunk/milena/tests/geom/nslis.cc (revision 0)
+++ trunk/milena/tests/geom/nslis.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image3d.hh>
+
+#include <mln/geom/nslis.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image3d<int> ima(3,4,5);
+
+ mln_assertion(geom::nslis(ima) == 3);
+}
Index: trunk/milena/tests/geom/bbox.cc
===================================================================
--- trunk/milena/tests/geom/bbox.cc (revision 0)
+++ trunk/milena/tests/geom/bbox.cc (revision 1490)
@@ -0,0 +1,45 @@
+// 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.
+
+#include <mln/core/p_set.hh>
+#include <mln/core/point2d.hh>
+#include <mln/core/box2d.hh>
+
+#include <mln/geom/bbox.hh>
+
+int main()
+{
+ using namespace mln;
+ p_set<point2d> s;
+
+ s.insert(make::point2d(0,0));
+ s.insert(make::point2d(0,5));
+ s.insert(make::point2d(5,0));
+ s.insert(make::point2d(5,5));
+
+ mln_assertion(geom::bbox(s) == make::box2d(0,0,5,5));
+}
Index: trunk/milena/tests/geom/min_sli.cc
===================================================================
--- trunk/milena/tests/geom/min_sli.cc (revision 0)
+++ trunk/milena/tests/geom/min_sli.cc (revision 1490)
@@ -0,0 +1,39 @@
+// 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.
+
+#include <mln/core/image3d.hh>
+
+#include <mln/geom/min_sli.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image3d<int> ima(3,4,5);
+
+ mln_assertion(geom::min_sli(ima) == 0);
+}
Index: trunk/milena/mln/geom/seeds2tiling.hh
===================================================================
--- trunk/milena/mln/geom/seeds2tiling.hh (revision 1489)
+++ trunk/milena/mln/geom/seeds2tiling.hh (revision 1490)
@@ -30,8 +30,7 @@
/*! \file mln/geom/seeds2tiling.hh
*
- * \brief Definition of a function which takes a labeled image and
- * returns an image which has blew up its labeled values.
+ * \brief Convert a binary image with seeds into a labeled image.
*/
# include <map>
@@ -76,25 +75,7 @@
}
}
-// // Body.
-// {
-// while (! q.is_empty())
-// {
-// mln_psite(I) p = q.front();
-// q.pop();
-// mln_invariant(ima(p) == 0);
-
-// mln_niter(N) n(nbh, p);
-// for_all(n) if (ima.has(n))
-// if (out(n) != 0)
-// out(p) = out(n);
-// else
-// if (! q.has(n))
-// q.push(n);
-// }
-// }
-
- // Body: alternative version.
+ // Body.
{
while (! q.is_empty())
{
Index: trunk/milena/mln/geom/seeds2tiling_with_chamfer.hh
===================================================================
--- trunk/milena/mln/geom/seeds2tiling_with_chamfer.hh (revision 1489)
+++ trunk/milena/mln/geom/seeds2tiling_with_chamfer.hh (revision 1490)
@@ -30,7 +30,7 @@
/*! \file mln/geom/seeds2tiling_with_chamfer.hh
*
- * \brief FIXME.
+ * \brief seeds2tiling with chamfer method.
*/
# include <map>
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-15 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Update level and add specialization for algorithm.
* mln/level/assign.hh,
* mln/level/fill.hh,
* mln/level/take.hh,
* mln/level/apply.hh: Remove specialization stuff and add
generic namespace.
Specialization files
* mln/level/assign.spe.hh,
* mln/level/fill.spe.hh,
* mln/level/take.spe.hh,
* mln/level/apply.spe.hh: New file for specialization.
Update
* mln/level/abs.hh,
* mln/level/all.hh,
* mln/level/compare.hh,
* mln/level/sort_points.hh: Update.
---
abs.hh | 4 ++
all.hh | 1
apply.hh | 24 +++++++++-----
apply.spe.hh | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
assign.hh | 32 ++++++++++++-------
assign.spe.hh | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fill.hh | 38 ++++++++++++++++++-----
fill.spe.hh | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
take.hh | 24 +++++++++-----
take.spe.hh | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 440 insertions(+), 39 deletions(-)
Index: trunk/milena/mln/level/sort_points.hh
===================================================================
Index: trunk/milena/mln/level/take.hh
===================================================================
--- trunk/milena/mln/level/take.hh (revision 1488)
+++ trunk/milena/mln/level/take.hh (revision 1489)
@@ -36,6 +36,8 @@
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/level/take.spe.hh>
namespace mln
{
@@ -62,22 +64,22 @@
namespace impl
{
+ namespace generic
+ {
template <typename A, typename I>
- void take(trait::image::speed::any, const I& input, A& a)
+ void take_(const I& input, A& a)
{
+ trace::entering("level::impl::generic::take");
+
mln_piter(I) p(input.domain());
for_all(p)
a.take(input(p));
- }
- template <typename A, typename I>
- void take(trait::image::speed::fastest, const I& input, A& a)
- {
- mln_pixter(const I) pxl(input);
- for_all(pxl)
- a.take(pxl.val());
+ trace::exiting("level::impl::generic::take");
}
+ } // end of namespace mln::level::impl::generic
+
} // end of namespace mln::level::impl
@@ -86,9 +88,13 @@
template <typename A, typename I>
void take(const Image<I>& input, Accumulator<A>& a)
{
+ trace::entering("level::take");
+
mln_precondition(exact(input).has_data());
- impl::take(mln_trait_image_speed(I)(), exact(input),
+ impl::take_(mln_trait_image_speed(I)(), exact(input),
exact(a));
+
+ trace::exiting("level::take");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/assign.hh
===================================================================
--- trunk/milena/mln/level/assign.hh (revision 1488)
+++ trunk/milena/mln/level/assign.hh (revision 1489)
@@ -38,6 +38,11 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/level/assign.spe.hh>
+
+
+
namespace mln
{
@@ -64,34 +69,37 @@
namespace impl
{
+ namespace generic
+ {
template <typename L, typename R>
- void assign(trait::image::speed::any, L& target,
- trait::image::speed::any, const R& data)
+ void assign_(L& target, const R& data)
{
+ trace::entering("level::impl::generic::assign_");
+
mln_piter(L) p(target.domain());
for_all(p)
target(p) = data(p);
- }
- template <typename L, typename R>
- void assign(trait::image::speed::fastest, L& target,
- trait::image::speed::fastest, const R& data)
- {
- mln_pixter(L) lhs(target);
- mln_pixter(const R) rhs(data);
- for_all_2(lhs, rhs)
- lhs.val() = rhs.val();
+ trace::exiting("level::impl::generic::assign_");
}
+ } // end of namespace mln::level::impl::generic
+
} // end of namespace mln::level::impl
+ // Facade.
+
template <typename L, typename R>
void assign(Image<L>& target, const Image<R>& data)
{
+ trace::entering("level::assign");
+
mln_precondition(exact(data).domain() == exact(target).domain());
- impl::assign(mln_trait_image_speed(L)(), exact(target),
+ impl::assign_(mln_trait_image_speed(L)(), exact(target),
mln_trait_image_speed(R)(), exact(data));
+
+ trace::exiting("level::assign");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/apply.hh
===================================================================
--- trunk/milena/mln/level/apply.hh (revision 1488)
+++ trunk/milena/mln/level/apply.hh (revision 1489)
@@ -36,6 +36,9 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/function.hh>
+// Specializations are in:
+# include <mln/level/apply.spe.hh>
+
namespace mln
{
@@ -66,22 +69,23 @@
namespace impl
{
+ namespace generic
+ {
+
template <typename I, typename F>
- void apply_(trait::image::speed::any, I& input, const F& f)
+ void apply_(I& input, const F& f)
{
+ trace::entering("level::impl::generic::apply_");
+
mln_piter(I) p(input.domain());
for_all(p)
input(p) = f(input(p));
- }
- template <typename I, typename F>
- void apply_(trait::image::speed::fastest, I& input, const F& f)
- {
- mln_pixter(I) pxl(input);
- for_all(pxl)
- pxl.val() = f(pxl.val());
+ trace::exiting("level::impl::generic::apply_");
}
+ } // end of namespace mln::level::impl::generic
+
} // end of namespace mln::level::impl
@@ -90,9 +94,13 @@
template <typename I, typename F>
void apply(Image<I>& input, const Function_v2v<F>& f)
{
+ trace::entering("level::apply");
+
mln_precondition(exact(input).has_data());
impl::apply_(mln_trait_image_speed(I)(), exact(input),
exact(f));
+
+ trace::exiting("level::apply");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/compare.hh
===================================================================
Index: trunk/milena/mln/level/fill.hh
===================================================================
--- trunk/milena/mln/level/fill.hh (revision 1488)
+++ trunk/milena/mln/level/fill.hh (revision 1489)
@@ -43,6 +43,9 @@
# include <mln/level/memset_.hh>
+// Specializations are in:
+# include <mln/level/fill.spe.hh>
+
namespace mln
{
@@ -132,25 +135,22 @@
namespace impl
{
-
- // fill_with_value
-
+ namespace generic
+ {
template <typename I>
void fill_with_value(trait::image::speed::any, I& ima,
const mln_value(I)& value)
{
+ trace::entering("level::impl::generic::fill_with_value");
+
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = value;
- }
- template <typename I>
- void fill_with_value(trait::image::speed::fastest, I& ima,
- const mln_value(I)& value)
- {
- level::memset_(ima, ima.point_at_offset(0), value, ima.ncells());
+ trace::exiting("level::impl::generic::fill_with_value");
}
+ } // end if namespace mln::level::impl::generic
} // end of namespace mln::level::impl
@@ -161,10 +161,14 @@
template <typename I>
void fill(Image<I>& ima, const mln_value(I)& value)
{
+ trace::entering("level::fill");
+
mlc_is(mln_trait_image_io(I), trait::image::io::write)::check(); // FIXME: Only the upcoming general facade!!!
mln_precondition(exact(ima).has_data());
impl::fill_with_value(mln_trait_image_speed(I)(), exact(ima),
value);
+
+ trace::exiting("level::fill");
}
@@ -173,12 +177,16 @@
template <typename I, typename F>
void fill(Image<I>& ima_, const Function_p2v<F>& f_)
{
+ trace::entering("level::fill");
+
I& ima = exact(ima_);
mln_precondition(ima.has_data());
const F& f = exact(f_);
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = f(p);
+
+ trace::exiting("level::fill");
}
@@ -188,12 +196,16 @@
void fill_f(Image<I>& ima_,
mln_value(I) (*f)(const mln_point(I)& p))
{
+ trace::entering("level::fill_f");
+
mln_precondition(f != 0);
I& ima = exact(ima_);
mln_precondition(ima.has_data());
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = f(p);
+
+ trace::exiting("level::fill_f");
}
@@ -202,6 +214,8 @@
template <typename I, unsigned N>
void fill(Image<I>& ima_, mln_value(I) (&arr)[N])
{
+ trace::entering("level::fill");
+
I& ima = exact(ima_);
mln_precondition(ima.has_data());
mln_precondition(N == ima.npoints());
@@ -209,6 +223,8 @@
unsigned i = 0;
for_all(p)
ima(p) = arr[i++];
+
+ trace::exiting("level::fill");
}
@@ -217,6 +233,8 @@
template <typename I, typename J>
void fill(Image<I>& ima_, const Image<J>& data_)
{
+ trace::entering("level::fill");
+
I& ima = exact(ima_);
const J& data = exact(data_);
mln_precondition(ima.domain() <= data.domain());
@@ -224,6 +242,8 @@
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = data(p);
+
+ trace::exiting("level::fill");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/abs.hh
===================================================================
--- trunk/milena/mln/level/abs.hh (revision 1488)
+++ trunk/milena/mln/level/abs.hh (revision 1489)
@@ -68,15 +68,19 @@
template <typename I, typename O>
void abs(const Image<I>& input, Image<O>& output)
{
+ trace::entering("level::abs");
mln_precondition(exact(input).domain() == exact(output).domain());
level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
+ trace::exiting("level::abs");
}
template <typename I>
void abs_inplace(Image<I>& input)
{
+ trace::entering("level::abs_inplace");
mln_precondition(exact(input).has_data());
level::apply(input, fun::v2v::abs<mln_value(I)>());
+ trace::exiting("level::abs_inplace");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/all.hh
===================================================================
--- trunk/milena/mln/level/all.hh (revision 1488)
+++ trunk/milena/mln/level/all.hh (revision 1489)
@@ -47,7 +47,6 @@
}
# include <mln/level/abs.hh>
-# include <mln/level/all.hh>
# include <mln/level/apply.hh>
# include <mln/level/approx/all.hh>
# include <mln/level/assign.hh>
Index: trunk/milena/mln/level/assign.spe.hh
===================================================================
--- trunk/milena/mln/level/assign.spe.hh (revision 0)
+++ trunk/milena/mln/level/assign.spe.hh (revision 1489)
@@ -0,0 +1,92 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_LEVEL_ASSIGN_SPE_HH
+# define MLN_LEVEL_ASSIGN_SPE_HH
+
+/*! \file mln/level/assign.spe.hh
+ *
+ * \brief Specializations for mln::level::assign.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R>
+ void assign_(L& target, const R& data);
+ }
+
+
+ // Disjunction.
+
+
+ template <typename L, typename R>
+ void assign_(trait::image::speed::any, L& target,
+ trait::image::speed::any, const R& data)
+ {
+ generic::assign_(target, data);
+ }
+
+ template <typename L, typename R>
+ void assign_(trait::image::speed::fastest, L& target,
+ trait::image::speed::fastest, const R& data)
+ {
+ trace::entering("level::impl::assign_");
+
+ mln_pixter(L) lhs(target);
+ mln_pixter(const R) rhs(data);
+ for_all_2(lhs, rhs)
+ lhs.val() = rhs.val();
+
+ trace::exiting("level::impl::assign_");
+ }
+
+
+ } // end of namespace mln::level::impl
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LEVEL_ASSIGN_SPE_HH
Index: trunk/milena/mln/level/take.spe.hh
===================================================================
--- trunk/milena/mln/level/take.spe.hh (revision 0)
+++ trunk/milena/mln/level/take.spe.hh (revision 1489)
@@ -0,0 +1,82 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_LEVEL_TAKE_SPE_HH
+# define MLN_LEVEL_TAKE_SPE_HH
+
+/*! \file mln/level/take.spe.hh
+ *
+ * \brief Specializations for mln::level::take.
+ */
+
+# include <mln/core/concept/accumulator.hh>
+# include <mln/core/concept/image.hh>
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename A, typename I>
+ void take_(const I& input, A& a);
+ }
+
+ template <typename A, typename I>
+ void take_(trait::image::speed::any, const I& input, A& a)
+ {
+ generic::take_(input, a);
+ }
+
+ template <typename A, typename I>
+ void take_(trait::image::speed::fastest, const I& input, A& a)
+ {
+ trace::entering("level::impl::take");
+
+ mln_pixter(const I) pxl(input);
+ for_all(pxl)
+ a.take(pxl.val());
+
+ trace::exiting("level::impl::take");
+ }
+
+ } // end of namespace mln::level::impl
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LEVEL_TAKE_HH
Index: trunk/milena/mln/level/apply.spe.hh
===================================================================
--- trunk/milena/mln/level/apply.spe.hh (revision 0)
+++ trunk/milena/mln/level/apply.spe.hh (revision 1489)
@@ -0,0 +1,89 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_LEVEL_APPLY_SPE_HH
+# define MLN_LEVEL_APPLY_SPE_HH
+
+/*! \file mln/level/apply.spe.hh
+ *
+ * \brief Specializations for mln::level::apply.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename I, typename F>
+ void apply_(I& input, const F& f);
+ }
+
+
+ // Disjunction.
+
+ template <typename I, typename F>
+ void apply_(trait::image::speed::any, I& input, const F& f)
+ {
+ generic::apply_(input, f);
+ }
+
+ template <typename I, typename F>
+ void apply_(trait::image::speed::fastest, I& input, const F& f)
+ {
+ trace::entering("level::impl::apply_");
+
+ mln_pixter(I) pxl(input);
+ for_all(pxl)
+ pxl.val() = f(pxl.val());
+
+ trace::exiting("level::impl::apply_");
+ }
+
+
+ } // end of namespace mln::level::impl
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+#endif // ! MLN_LEVEL_APPLY_HH
Index: trunk/milena/mln/level/fill.spe.hh
===================================================================
--- trunk/milena/mln/level/fill.spe.hh (revision 0)
+++ trunk/milena/mln/level/fill.spe.hh (revision 1489)
@@ -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.
+
+#ifndef MLN_LEVEL_FILL_SPE_HH
+# define MLN_LEVEL_FILL_SPE_HH
+
+/*! \file mln/level/fill.spe.hh
+ *
+ * \brief Specializations for mln::level::fill.
+ *
+ */
+
+# include <cstring>
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/inplace.hh>
+# include <mln/level/memset_.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename I>
+ void fill_with_value(I& ima, const mln_value(I)& value);
+ }
+
+
+ // Disjunction.
+
+
+ template <typename I>
+ void fill_with_value(trait::image::speed::any, I& ima,
+ const mln_value(I)& value)
+ {
+ generic::fill_with_value(ima, value);
+ }
+
+ template <typename I>
+ void fill_with_value(trait::image::speed::fastest, I& ima,
+ const mln_value(I)& value)
+ {
+ trace::entering("level::impl::fill_with_value");
+
+ level::memset_(ima, ima.point_at_offset(0), value, ima.ncells());
+
+ trace::exiting("level::impl::fill_with_value");
+ }
+
+
+ } // end of namespace mln::level::impl
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LEVEL_FILL_SPE_HH