URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-29 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add full tests for border.
* tests/border/equalize_full.cc,
* tests/border/find_full.cc,
* tests/border/resize_full.cc: New full tests.
* tests/border/resize.cc: Fix typo.
---
equalize_full.cc | 84 ++++++++++++++++++++++++++++
find_full.cc | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
resize.cc | 2
resize_full.cc | 135 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 380 insertions(+), 1 deletion(-)
Index: trunk/milena/tests/border/resize.cc
===================================================================
--- trunk/milena/tests/border/resize.cc (revision 1570)
+++ trunk/milena/tests/border/resize.cc (revision 1571)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/border_resize_image2d_1.cc
+/*! \file tests/border/resize.cc
*
* \brief Tests on mln::border::resize.
*/
Index: trunk/milena/tests/border/equalize_full.cc
===================================================================
--- trunk/milena/tests/border/equalize_full.cc (revision 0)
+++ trunk/milena/tests/border/equalize_full.cc (revision 1571)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/border/equalize_full.cc
+ *
+ * \brief Tests on mln::border::equalize.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/border/get.hh>
+#include <mln/border/equalize.hh>
+
+int main()
+{
+ using namespace mln;
+ unsigned sli = 5;
+ unsigned row = 10;
+ unsigned col = 20;
+ unsigned border1 = 42;
+ unsigned border2 = 36;
+ unsigned new_border = 51;
+
+
+
+ {
+ typedef image1d<int> I;
+ (std::cerr << "Tests border::equalize in 1d ... ").flush ();
+ I ima1(col, border1);
+ I ima2(col, border2);
+ border::equalize(ima1, ima2, new_border);
+ mln_assertion(border::get(ima1) == new_border);
+ mln_assertion(border::get(ima2) == new_border);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ typedef image2d<int> I;
+ (std::cerr << "Tests border::equalize in 2d ... ").flush ();
+ I ima1(row, col, border1);
+ I ima2(row, col, border2);
+ border::equalize(ima1, ima2, new_border);
+ mln_assertion(border::get(ima1) == new_border);
+ mln_assertion(border::get(ima2) == new_border);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ typedef image3d<int> I;
+ (std::cerr << "Tests border::equalize in 3d ... ").flush ();
+ I ima1(sli, row, col, border1);
+ I ima2(sli, row, col, border2);
+ border::equalize(ima1, ima2, new_border);
+ mln_assertion(border::get(ima1) == new_border);
+ mln_assertion(border::get(ima2) == new_border);
+ std::cerr << "OK" << std::endl;
+ }
+
+}
Index: trunk/milena/tests/border/find_full.cc
===================================================================
--- trunk/milena/tests/border/find_full.cc (revision 0)
+++ trunk/milena/tests/border/find_full.cc (revision 1571)
@@ -0,0 +1,160 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/border/find_full.cc
+ *
+ * \brief Tests on mln::border::find.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/core/sub_image.hh>
+
+#include <mln/core/image_if.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/border/find.hh>
+#include <mln/literal/origin.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
+
+#include <mln/debug/iota.hh>
+#include <mln/border/find.hh>
+#include <mln/core/clone.hh>
+
+
+struct f_box1d_t : mln::Function_p2b< f_box1d_t >
+{
+ f_box1d_t(const mln::box1d& b)
+ : b_(b)
+ {
+ }
+ mln::box1d b_;
+ bool operator()(const mln::point1d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+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);
+ }
+};
+
+struct f_box3d_t : mln::Function_p2b< f_box3d_t >
+{
+ f_box3d_t(const mln::box3d& b)
+ : b_(b)
+ {
+ }
+ mln::box3d b_;
+ bool operator()(const mln::point3d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+
+int main()
+{
+ using namespace mln;
+
+ box1d b1(literal::origin, point1d(1));
+ box2d b2(literal::origin, point2d(1,1));
+ box3d b3(literal::origin, point3d(1,1,1));
+ f_box1d_t f_b1(b1);
+ f_box2d_t f_b2(b2);
+ f_box3d_t f_b3(b3);
+ mln::fun::p2b::chess_t c_b;
+
+ {
+ typedef image1d<int> I;
+ (std::cerr << "Tests border::find on int in 1d ... ").flush ();
+ I ima(3, 51);
+ debug::iota(ima);
+ mln_assertion(border::find(ima) == 51);
+ sub_image<I, box1d> sub(ima, b1);
+ mln_assertion(border::find(sub) == 51);
+
+ image_if<I, f_box1d_t> imaif(ima, f_b1);
+ mln_assertion(border::find(imaif) == 51);
+
+ mln_assertion(border::find( (ima | b1) ) == 51);
+ mln_assertion(border::find( (ima | b1) | f_b1 ) == 51);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ typedef image2d<value::int_u8> I;
+ (std::cerr << "Tests border::find on int_u8 in 2d ... ").flush ();
+ I ima(10, 10, 42);
+ debug::iota(ima);
+ mln_assertion(border::find(ima) == 42);
+ sub_image<I, box2d> sub(ima, b2);
+ mln_assertion(border::find(sub) == 42);
+
+ image_if<I, f_box2d_t > imaif(ima, f_b2);
+ mln_assertion(border::find(imaif) == 42);
+
+ image_if<I, fun::p2b::chess_t > imaif_chess(ima, c_b);
+ mln_assertion(border::find(imaif_chess) == 42);
+
+
+ mln_assertion(border::find( (ima | b2) ) == 42);
+ mln_assertion(border::find( (ima | b2) | f_b2 ) == 42);
+ mln_assertion(border::find( (ima | b2) | c_b ) == 42);
+ mln_assertion(border::find( (ima | b2) | c_b | f_b2 ) == 42);
+ mln_assertion(border::find( (ima | b2) | f_b2 | c_b ) == 42);
+
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ typedef image3d<value::rgb8> I;
+ (std::cerr << "Tests border::find on rgb8 in 3d ... ").flush ();
+ I ima(10, 10, 10, 36);
+ mln_assertion(border::find(ima) == 36);
+ mln_assertion( ima.has(point3d(2,2,2)) == true );
+ sub_image<I, box3d> sub(ima, b3);
+ mln_assertion(border::find(sub) == 36);
+
+ image_if<I, f_box3d_t> imaif(ima, f_b3);
+ mln_assertion(border::find(imaif) == 36);
+ mln_assertion(border::find( (ima | b3) ) == 36);
+ mln_assertion(border::find( (ima | b3) | f_b3 ) == 36);
+ std::cerr << "OK" << std::endl;
+ }
+}
Index: trunk/milena/tests/border/resize_full.cc
===================================================================
--- trunk/milena/tests/border/resize_full.cc (revision 0)
+++ trunk/milena/tests/border/resize_full.cc (revision 1571)
@@ -0,0 +1,135 @@
+// 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_full.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/border/get.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned sli = 51;
+ unsigned row = 42;
+ unsigned col = 100;
+
+
+
+ unsigned border1 = 1;
+ unsigned border2 = 3;
+ unsigned border3 = 42;
+ unsigned border4 = 51;
+ unsigned border5 = 36;
+ unsigned border6 = 2;
+ unsigned border7 = 0;
+ unsigned border8 = 8;
+ unsigned border9 = 1;
+
+
+ {
+ (std::cerr << "Test border::resize in 1d ... ").flush ();
+ image1d<value::int_u8> ima(col, border1);
+
+ mln_assertion(border::get(ima) == border1);
+ border::resize (ima, border2);
+ mln_assertion(border::get(ima) == border2);
+ border::resize (ima, border3);
+ mln_assertion(border::get(ima) == border3);
+ border::resize (ima, border4);
+ mln_assertion(border::get(ima) == border4);
+ border::resize (ima, border5);
+ mln_assertion(border::get(ima) == border5);
+ border::resize (ima, border6);
+ mln_assertion(border::get(ima) == border6);
+ border::resize (ima, border7);
+ mln_assertion(border::get(ima) == border7);
+ border::resize (ima, border8);
+ mln_assertion(border::get(ima) == border8);
+ border::resize (ima, border9);
+ mln_assertion(border::get(ima) == border9);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ (std::cerr << "Test border::resize in 2d ... ").flush ();
+ image2d<value::int_u8> ima(row, col, border1);
+
+ mln_assertion(border::get(ima) == border1);
+ border::resize (ima, border2);
+ mln_assertion(border::get(ima) == border2);
+ border::resize (ima, border3);
+ mln_assertion(border::get(ima) == border3);
+ border::resize (ima, border4);
+ mln_assertion(border::get(ima) == border4);
+ border::resize (ima, border5);
+ mln_assertion(border::get(ima) == border5);
+ border::resize (ima, border6);
+ mln_assertion(border::get(ima) == border6);
+ border::resize (ima, border7);
+ mln_assertion(border::get(ima) == border7);
+ border::resize (ima, border8);
+ mln_assertion(border::get(ima) == border8);
+ border::resize (ima, border9);
+ mln_assertion(border::get(ima) == border9);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ (std::cerr << "Test border::resize in 3d ... ").flush ();
+ image3d<value::int_u8> ima(sli, row, col, border1);
+
+ mln_assertion(border::get(ima) == border1);
+ border::resize (ima, border2);
+ mln_assertion(border::get(ima) == border2);
+ border::resize (ima, border3);
+ mln_assertion(border::get(ima) == border3);
+ border::resize (ima, border4);
+ mln_assertion(border::get(ima) == border4);
+ border::resize (ima, border5);
+ mln_assertion(border::get(ima) == border5);
+ border::resize (ima, border6);
+ mln_assertion(border::get(ima) == border6);
+ border::resize (ima, border7);
+ mln_assertion(border::get(ima) == border7);
+ border::resize (ima, border8);
+ mln_assertion(border::get(ima) == border8);
+ border::resize (ima, border9);
+ mln_assertion(border::get(ima) == border9);
+ std::cerr << "OK" << std::endl;
+ }
+
+}