milena r1147: Add tests for duplicate border and debug print with border for 3d.

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-09-20 Guillaume Duhamel <guillaume.duhamel@lrde.epita.fr> Add tests for duplicate border and debug print with border for 3d. Tests for duplicate. * test_border_duplicate_image1d_1.cc, * test_border_duplicate_image1d_2.cc, * test_border_duplicate_image1d_3.cc, * test_border_duplicate_image1d_4.cc, * test_border_duplicate_image1d_5.cc, * test_border_duplicate_image2d_1.cc, * test_border_duplicate_image2d_2.cc, * test_border_duplicate_image2d_3.cc, * test_border_duplicate_image2d_4.cc, * test_border_duplicate_image3d_1.cc, * test_border_duplicate_image3d_2.cc, * test_border_duplicate_image3d_3.cc, * test_border_duplicate_image3d_4.cc: New tests. New print for 3d with border. * debug_print_3d_with_border.hh: New. Update. * test_border_fill_image3d_2.cc, * test_border_fill_image3d_3.cc, * test_border_fill_image3d_4.cc, * test_border_fill_image3d_1.cc, * border_duplicate.hh: Update. New iota * test_debug_iota_3d.cc: New iota debug for 3d. --- border_duplicate.hh | 107 +++++-------------------------------- debug_print_3d_with_border.hh | 70 ++++++++++++++++++++++++ test_border_duplicate_image1d_1.cc | 54 ++++++++++++++++++ test_border_duplicate_image1d_2.cc | 53 ++++++++++++++++++ test_border_duplicate_image1d_3.cc | 57 +++++++++++++++++++ test_border_duplicate_image1d_4.cc | 56 +++++++++++++++++++ test_border_duplicate_image1d_5.cc | 56 +++++++++++++++++++ test_border_duplicate_image2d_1.cc | 54 ++++++++++++++++++ test_border_duplicate_image2d_2.cc | 53 ++++++++++++++++++ test_border_duplicate_image2d_3.cc | 54 ++++++++++++++++++ test_border_duplicate_image2d_4.cc | 56 +++++++++++++++++++ test_border_duplicate_image3d_1.cc | 53 ++++++++++++++++++ test_border_duplicate_image3d_2.cc | 52 +++++++++++++++++ test_border_duplicate_image3d_3.cc | 56 +++++++++++++++++++ test_border_duplicate_image3d_4.cc | 54 ++++++++++++++++++ test_border_fill_image3d_1.cc | 38 ------------- test_border_fill_image3d_2.cc | 37 ------------ test_border_fill_image3d_3.cc | 38 ------------- test_border_fill_image3d_4.cc | 39 ------------- test_debug_iota_3d.cc | 50 +++++++++++++++++ 20 files changed, 849 insertions(+), 238 deletions(-) Index: trunk/milena/sandbox/duhamel/test_border_fill_image3d_1.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_fill_image3d_1.cc (revision 1146) +++ trunk/milena/sandbox/duhamel/test_border_fill_image3d_1.cc (revision 1147) @@ -30,47 +30,11 @@ * \brief Tests on mln::border::fill. */ +#include "debug_print_3d_with_border.hh" #include "border_fill.hh" #include <mln/core/image3d_b.hh> #include <mln/value/int_u8.hh> -namespace mln -{ - - namespace debug - { - template <typename I> - void print_3d_with_border (const Fast_Image<I>& input_) - { - const I& ima = exact(input_); - mln_precondition(ima.has_data()); - - typedef mln_point(I) P; - - std::size_t len_s = exact(ima).bbox().len(P::dim - 3); - std::size_t len_r = exact(ima).bbox().len(P::dim - 1); - std::size_t len_c = exact(ima).bbox().len(P::dim - 2); - std::size_t border = ima.border (); - std::size_t real_len_s = len_s + 2 * border; - std::size_t real_len_r = len_r + 2 * border; - std::size_t real_len_c = len_c + 2 * border; - - for (std::size_t k = 0; k < real_len_s; ++k) - { - for (std::size_t j = 0; j < real_len_c; ++j) - { - for (std::size_t i = 0; i < real_len_r; ++i) - std::cout << ima[k * (real_len_r * real_len_c) + j * real_len_r + i] - << " "; - std::cout << std::endl; - } - std::cout << std::endl; - } - std::cout << std::endl; - } - } -} - using namespace mln; int Index: trunk/milena/sandbox/duhamel/test_border_fill_image3d_3.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_fill_image3d_3.cc (revision 1146) +++ trunk/milena/sandbox/duhamel/test_border_fill_image3d_3.cc (revision 1147) @@ -30,47 +30,11 @@ * \brief Tests on mln::border::fill. */ +#include "debug_print_3d_with_border.hh" #include "border_fill.hh" #include <mln/core/image3d_b.hh> #include <mln/value/int_u8.hh> -namespace mln -{ - - namespace debug - { - template <typename I> - void print_3d_with_border (const Fast_Image<I>& input_) - { - const I& ima = exact(input_); - mln_precondition(ima.has_data()); - - typedef mln_point(I) P; - - std::size_t len_s = exact(ima).bbox().len(P::dim - 3); - std::size_t len_r = exact(ima).bbox().len(P::dim - 1); - std::size_t len_c = exact(ima).bbox().len(P::dim - 2); - std::size_t border = ima.border (); - std::size_t real_len_s = len_s + 2 * border; - std::size_t real_len_r = len_r + 2 * border; - std::size_t real_len_c = len_c + 2 * border; - - for (std::size_t k = 0; k < real_len_s; ++k) - { - for (std::size_t j = 0; j < real_len_c; ++j) - { - for (std::size_t i = 0; i < real_len_r; ++i) - std::cout << ima[k * (real_len_r * real_len_c) + j * real_len_r + i] - << " "; - std::cout << std::endl; - } - std::cout << std::endl; - } - std::cout << std::endl; - } - } -} - using namespace mln; int Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_1.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_1.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_1.cc (revision 1147) @@ -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. + +/*! \file tests/test_border_duplicate_image1d_1.cc + * + * \brief Tests on mln::border::duplicate. + */ + +#include "border_duplicate.hh" +#include <mln/core/image1d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 1d size=5 with border=3 in value::int_u8" + << std::endl + << std::endl; + image1d_b<value::int_u8> ima(5); + debug::iota (ima); + border::duplicate (ima); + std::cout << std::endl; + debug::println_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_1.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_1.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_1.cc (revision 1147) @@ -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. + +/*! \file tests/test_border_duplicate_image2d_1.cc + * + * \brief Tests on mln::border::duplicate. + */ + +#include "border_duplicate.hh" +#include <mln/core/image2d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 2d size=5x2 with border=3 in value::int_u8" + << std::endl + << std::endl; + image2d_b<value::int_u8> ima(5, 2, 3); + debug::iota (ima); + border::duplicate (ima); + std::cout << std::endl; + debug::println_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_1.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_1.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_1.cc (revision 1147) @@ -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/border_fill.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "debug_print_3d_with_border.hh" +#include "border_duplicate.hh" +#include <mln/core/image3d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 3d size=2x3x1 in value::int_u8 with border=2" + << std::endl + << std::endl; + image3d_b<value::int_u8> ima(2, 3, 1, 2); + debug::iota (ima); + border::duplicate (ima); + debug::print_3d_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_3.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_3.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_3.cc (revision 1147) @@ -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/border_fill.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "border_duplicate.hh" +#include <mln/core/image1d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 1d size= box [2 .. 4] with border=6 in int" + << std::endl + << std::endl; + + box1d b(make::point1d(2), make::point1d(4)); + image1d_b<int> ima(b, 6); + debug::iota (ima); + border::duplicate (ima); + std::cout << std::endl; + debug::println_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_3.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_3.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_3.cc (revision 1147) @@ -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. + +/*! \file tests/border_fill.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "border_duplicate.hh" +#include <mln/core/image2d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 2d size=[(2,6) .. (3,8)] with border=3 in int" + << std::endl + << std::endl; + box2d b(make::point2d(2, 6), make::point2d(3, 8)); + image2d_b<int> ima(b, 3); + debug::iota (ima); + border::duplicate (ima); + debug::println_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/border_duplicate.hh =================================================================== --- trunk/milena/sandbox/duhamel/border_duplicate.hh (revision 1146) +++ trunk/milena/sandbox/duhamel/border_duplicate.hh (revision 1147) @@ -34,7 +34,6 @@ */ # include <mln/core/concept/image.hh> -# include <mln/core/internal/fixme.hh> # include <mln/level/memset_.hh> //# include <mln/core/line_piter.hh> #include <mln/geom/nrows.hh> @@ -69,71 +68,6 @@ { template <typename I> - void duplicate_(const Fast_Image<I>& ima_) - { - const I& ima = exact(ima_); - mln_precondition(ima.has_data()); - - // internal::fixme(); - // FIX - std::size_t border = ima.border (); - std::size_t nbrows = geom::max_row(ima) - geom::min_row(ima); - std::size_t nbcols = geom::max_col(ima) - geom::min_col(ima); - std::size_t real_nbcols = (nbcols + 1) + 2 * border; - std::size_t start = real_nbcols * border + border; - std::size_t s = start; - - // duplicate top left corner - for (std::size_t i = 0; i < border + 1; ++i) - for (std::size_t j = 0; j < border + 1; ++j) - const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + j] = ima[s]; - - // duplicate top border - s = start; - for (std::size_t i = 1; i <= nbcols - 1; ++i) - for (std::size_t j = 0; j <= border; ++j) - const_cast<I&>(ima)[s + i - (j * real_nbcols)] = ima[s + i]; - - // duplicate top left corner - s = start + nbcols; - for (std::size_t i = 0; i <= border; ++i) - for (std::size_t j = 0; j <= border; ++j) - const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + (nbcols + border + j)] = ima[s]; - - // duplicate left border - s = start; - for (std::size_t i = 1; i <= nbrows - 1; ++i) - for (std::size_t j = 1; j <= border; ++j) - const_cast<I&>(ima)[s - j + (i * real_nbcols)] = ima[s + (i * real_nbcols)]; - - // duplicate right border - s = start; - for (std::size_t i = 1; i <= nbrows - 1; ++i) - for (std::size_t j = 1; j <= border; ++j) - const_cast<I&>(ima)[s + (i * real_nbcols + nbcols) + j] = ima[s + (i * real_nbcols + nbcols)]; - - - // duplicate bottom left corner - s = start + (nbrows * real_nbcols); - for (std::size_t i = 0; i <= border; ++i) - for (std::size_t j = 0; j <= border; ++j) - const_cast<I&>(ima)[s - i + (j * (real_nbcols))] = ima[s]; - - // duplicate bottom border - s = start + (nbrows * real_nbcols); - for (std::size_t i = 1; i <= nbcols - 1; ++i) - for (std::size_t j = 0; j <= border; ++j) - const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s + i]; - - // duplicate bottom right corner - s = start + (nbrows * real_nbcols) + nbcols; - for (std::size_t i = 0; i <= border; ++i) - for (std::size_t j = 0; j <= border; ++j) - const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s]; - //END FIX - } - - template <typename I> void duplicate_1d_(const Fast_Image<I>& ima_) { const I& ima = exact(ima_); @@ -162,30 +96,10 @@ typename I::line_piter pl(ima.domain()); std::size_t border = ima.border (); std::size_t border_2x = 2 * ima.border (); - std::size_t len_c = exact(ima).bbox().len(P::dim - 1); - std::size_t len_r = exact(ima).bbox().len(P::dim - 2); + std::size_t len_c = exact(ima).bbox().len(1); + std::size_t len_r = exact(ima).bbox().len(0); std::size_t real_len_c = len_c + border_2x; - - - pl.start (); - - // Duplicate first line - std::size_t st = ima.offset_at (pl); - for (std::size_t i = 0; i < border; ++i) - const_cast<I&>(ima)[i] = ima[st]; - - std::size_t end = len_c + border; - for (std::size_t i = 0; i < len_c; ++i) - const_cast<I&>(ima)[border + i] = ima[st + i]; - - end = len_c + border * 2; - for (std::size_t i = len_c + border; i < end; ++i) - const_cast<I&>(ima)[i] = ima[len_c + border - 1]; - - // Duplicate n * border line - for (std::size_t k = 1; k < border; ++k) - for (std::size_t i = 0; i < real_len_c; ++i) - const_cast<I&>(ima)[k * real_len_c + i] = ima[i]; + std::size_t st; // Duplicate for_all (pl) @@ -198,6 +112,12 @@ const_cast<I&>(ima)[st + i] = ima[st]; } + // Duplicate n first * border line + st = real_len_c * border; + for (std::size_t k = 0; k < border; ++k) + for (std::size_t i = 0; i < real_len_c; ++i) + const_cast<I&>(ima)[k * real_len_c + i] = ima[st + i]; + // Duplicate n last * border line st = real_len_c * (border + len_r - 1); for (std::size_t k = 1; k <= border; ++k) @@ -216,8 +136,8 @@ std::size_t border = ima.border (); std::size_t border_2x = 2 * ima.border (); std::size_t len_c = exact(ima).bbox().len(P::dim - 1); - std::size_t len_r = exact(ima).bbox().len(P::dim - 2); - std::size_t len_s = exact(ima).bbox().len(P::dim - 3); + std::size_t len_r = exact(ima).bbox().len(1); + std::size_t len_s = exact(ima).bbox().len(0); std::size_t real_len_c = len_c + border_2x; std::size_t real_len_r = len_r + border_2x; std::size_t face = real_len_c * real_len_r; @@ -277,6 +197,11 @@ void duplicate(const Fast_Image<I>& ima_) { typedef mln_point(I) P; + const I& ima = exact(ima_); + mln_precondition(ima.has_data()); + + if (!ima.border ()) + return; if (P::dim == 1) impl::duplicate_1d_(ima_); if (P::dim == 2) Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_5.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_5.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_5.cc (revision 1147) @@ -0,0 +1,56 @@ +// 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.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "border_duplicate.hh" +#include <mln/core/image1d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 1d size= box [2 .. 4] with border=0 in int" + << std::endl + << std::endl; + + box1d b(make::point1d(2), make::point1d(4)); + image1d_b<int> ima(b, 0); + debug::iota (ima); + border::duplicate (ima); + std::cout << std::endl; + debug::println_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_3.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_3.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_3.cc (revision 1147) @@ -0,0 +1,56 @@ +// 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.cc + * + * \brief Tests on mln::border::fill. + */ + + +#include "debug_print_3d_with_border.hh" +#include "border_duplicate.hh" +#include <mln/core/image3d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 3d size=[(2,6,1) .. (3,8,3)] border=1 in value::int_u8" + << std::endl + << std::endl; + + box3d b(make::point3d(2, 6, 1), make::point3d(3, 8, 3)); + image3d_b<value::int_u8> ima(b, 1); + debug::iota (ima); + border::duplicate (ima); + debug::print_3d_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/debug_print_3d_with_border.hh =================================================================== --- trunk/milena/sandbox/duhamel/debug_print_3d_with_border.hh (revision 0) +++ trunk/milena/sandbox/duhamel/debug_print_3d_with_border.hh (revision 1147) @@ -0,0 +1,70 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file debug_print_3d_with_boder.cc + * + * + */ + +#include <mln/core/image3d_b.hh> + +namespace mln +{ + + namespace debug + { + template <typename I> + void print_3d_with_border (const Fast_Image<I>& input_) + { + const I& ima = exact(input_); + mln_precondition(ima.has_data()); + + typedef mln_point(I) P; + + std::size_t len_s = exact(ima).bbox().len(P::dim - 3); + std::size_t len_r = exact(ima).bbox().len(P::dim - 2); + std::size_t len_c = exact(ima).bbox().len(P::dim - 1); + std::size_t border = ima.border (); + std::size_t real_len_s = len_s + 2 * border; + std::size_t real_len_r = len_r + 2 * border; + std::size_t real_len_c = len_c + 2 * border; + + for (std::size_t k = 0; k < real_len_s; ++k) + { + for (std::size_t j = 0; j < real_len_r; ++j) + { + for (std::size_t i = 0; i < real_len_c; ++i) + std::cout << ima[k * (real_len_r * real_len_c) + j * real_len_c + i] + << " "; + std::cout << std::endl; + } + std::cout << std::endl; + } + std::cout << std::endl; + } + } +} Index: trunk/milena/sandbox/duhamel/test_border_fill_image3d_2.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_fill_image3d_2.cc (revision 1146) +++ trunk/milena/sandbox/duhamel/test_border_fill_image3d_2.cc (revision 1147) @@ -30,45 +30,10 @@ * \brief Tests on mln::border::fill. */ +#include "debug_print_3d_with_border.hh" #include "border_fill.hh" #include <mln/core/image3d_b.hh> -namespace mln -{ - - namespace debug - { - template <typename I> - void print_3d_with_border (const Fast_Image<I>& input_) - { - const I& ima = exact(input_); - mln_precondition(ima.has_data()); - - typedef mln_point(I) P; - - std::size_t len_s = exact(ima).bbox().len(P::dim - 3); - std::size_t len_r = exact(ima).bbox().len(P::dim - 1); - std::size_t len_c = exact(ima).bbox().len(P::dim - 2); - std::size_t border = ima.border (); - std::size_t real_len_s = len_s + 2 * border; - std::size_t real_len_r = len_r + 2 * border; - std::size_t real_len_c = len_c + 2 * border; - - for (std::size_t k = 0; k < real_len_s; ++k) - { - for (std::size_t j = 0; j < real_len_c; ++j) - { - for (std::size_t i = 0; i < real_len_r; ++i) - std::cout << ima[k * (real_len_r * real_len_c) + j * real_len_r + i] - << " "; - std::cout << std::endl; - } - std::cout << std::endl; - } - std::cout << std::endl; - } - } -} using namespace mln; Index: trunk/milena/sandbox/duhamel/test_border_fill_image3d_4.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_fill_image3d_4.cc (revision 1146) +++ trunk/milena/sandbox/duhamel/test_border_fill_image3d_4.cc (revision 1147) @@ -30,46 +30,11 @@ * \brief Tests on mln::border::fill. */ + +#include "debug_print_3d_with_border.hh" #include "border_fill.hh" #include <mln/core/image3d_b.hh> -namespace mln -{ - - namespace debug - { - template <typename I> - void print_3d_with_border (const Fast_Image<I>& input_) - { - const I& ima = exact(input_); - mln_precondition(ima.has_data()); - - typedef mln_point(I) P; - - std::size_t len_s = exact(ima).bbox().len(P::dim - 3); - std::size_t len_r = exact(ima).bbox().len(P::dim - 1); - std::size_t len_c = exact(ima).bbox().len(P::dim - 2); - std::size_t border = ima.border (); - std::size_t real_len_s = len_s + 2 * border; - std::size_t real_len_r = len_r + 2 * border; - std::size_t real_len_c = len_c + 2 * border; - - for (std::size_t k = 0; k < real_len_s; ++k) - { - for (std::size_t j = 0; j < real_len_c; ++j) - { - for (std::size_t i = 0; i < real_len_r; ++i) - std::cout << ima[k * (real_len_r * real_len_c) + j * real_len_r + i] - << " "; - std::cout << std::endl; - } - std::cout << std::endl; - } - std::cout << std::endl; - } - } -} - using namespace mln; int Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_2.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_2.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_2.cc (revision 1147) @@ -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/border_fill.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "border_duplicate.hh" +#include <mln/core/image1d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 1d size=8 with border=3 in int" + << std::endl + << std::endl; + image1d_b<int> ima(8, 3); + debug::iota (ima); + border::duplicate (ima); + debug::println_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_2.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_2.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_2.cc (revision 1147) @@ -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/border_fill.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "border_duplicate.hh" +#include <mln/core/image2d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 2d size=2x3 in int with border=2" + << std::endl + << std::endl; + image2d_b<int> i2(2, 3, 2); + debug::iota (i2); + border::duplicate (i2); + debug::println_with_border(i2); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_4.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_4.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image1d_4.cc (revision 1147) @@ -0,0 +1,56 @@ +// 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.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "border_duplicate.hh" +#include <mln/core/image1d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 1d size= box [-6 .. -3] with border=6 in value::int_u8" + << std::endl + << std::endl; + + box1d b(make::point1d(-6), make::point1d(-3)); + image1d_b<value::int_u8> ima(b, 6); + debug::iota (ima); + border::duplicate (ima); + std::cout << std::endl; + debug::println_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_2.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_2.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_2.cc (revision 1147) @@ -0,0 +1,52 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/border_fill.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "debug_print_3d_with_border.hh" +#include "border_duplicate.hh" +#include <mln/core/image3d_b.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 3d size=2x3x1 with border=1 in int" + << std::endl + << std::endl; + image3d_b<int> ima(2, 3, 1, 1); + debug::iota (ima); + border::duplicate (ima); + debug::print_3d_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_4.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_4.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image2d_4.cc (revision 1147) @@ -0,0 +1,56 @@ +// 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.cc + * + * \brief Tests on mln::border::fill. + */ + + +#include "border_duplicate.hh" +#include <mln/core/image2d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/println_with_border.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 2d size=[(-6,-3) .. (-2,-1)] with border=3 in value::int_u8" + << std::endl + << std::endl; + + box2d b(make::point2d(-6, -3), make::point2d(-2, -1)); + image2d_b<value::int_u8> ima(b, 3); + debug::iota (ima); + border::duplicate (ima); + debug::println_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_4.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_4.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_border_duplicate_image3d_4.cc (revision 1147) @@ -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. + +/*! \file tests/border_fill.cc + * + * \brief Tests on mln::border::fill. + */ + +#include "debug_print_3d_with_border.hh" +#include "border_duplicate.hh" +#include <mln/core/image3d_b.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + std::cout << std::endl + << "Test 3d size=[(-7,-8,-6) .. (-5,-4,-1 )] border=1 in int" + << std::endl + << std::endl; + + box3d b(make::point3d(-7, -8, -6), make::point3d(-5, -4, -1)); + image3d_b<int> ima(b, 1); + debug::iota (ima); + border::duplicate (ima); + debug::print_3d_with_border(ima); + std::cout << std::endl; +} Index: trunk/milena/sandbox/duhamel/test_debug_iota_3d.cc =================================================================== --- trunk/milena/sandbox/duhamel/test_debug_iota_3d.cc (revision 0) +++ trunk/milena/sandbox/duhamel/test_debug_iota_3d.cc (revision 1147) @@ -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_fill.cc + * + * \brief Tests on mln::border::fill. + */ + + +#include "debug_print_3d_with_border.hh" +#include <mln/core/image3d_b.hh> +#include <mln/value/int_u8.hh> +#include <mln/debug/iota.hh> + +using namespace mln; + +int +main (void) +{ + + box3d b(make::point3d(2, 6, 1), make::point3d(3, 8, 3)); + image3d_b<value::int_u8> ima(b, 1); + debug::iota (ima); + debug::print_3d_with_border(ima); + +}
participants (1)
-
Guillaume Duhamel