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);
+
+}
+