milena r1485: Move level test in level tests repertory

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-11-15 Guillaume Duhamel <guillaume.duhamel@lrde.epita.fr> Move level test in level tests repertory. * tests/level/abs.cc: New. * tests/level/apply.cc: New. * tests/level/approx: New. * tests/level/approx_median.cc: New. * tests/level/assign.cc: New. * tests/level/fill.cc: New. * tests/level/median.cc: New. * tests/level/median_dir.cc: New. * tests/level/median_fast.cc: New. * tests/level/median_hline2d.cc: New. * tests/level/memcpy_.cc: New. * tests/level/memset_.cc: New. * tests/level/naive/median.cc: New. * tests/level/naive: New. * tests/level/paste.cc: New. * tests/level/transform.cc: New. * tests/level: New. * tests/level_approx_median.cc: Remove. * tests/level_assign.cc: Remove. * tests/level_fill.cc: Remove. * tests/level_median.cc: Remove. * tests/level_median_dir.cc: Remove. * tests/level_median_fast.cc: Remove. * tests/level_median_hline2d.cc: Remove. * tests/level_memcpy_.cc: Remove. * tests/level_memset_.cc: Remove. * tests/level_naive_median.cc: Remove. * tests/level_paste.cc: Remove. * tests/level_transform.cc: Remove. --- abs.cc | 60 +++++++++++++++++++++++++++++++ apply.cc | 57 +++++++++++++++++++++++++++++ approx_median.cc | 62 ++++++++++++++++++++++++++++++++ assign.cc | 48 ++++++++++++++++++++++++ fill.cc | 70 ++++++++++++++++++++++++++++++++++++ median.cc | 59 ++++++++++++++++++++++++++++++ median_dir.cc | 55 ++++++++++++++++++++++++++++ median_fast.cc | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ median_hline2d.cc | 64 +++++++++++++++++++++++++++++++++ memcpy_.cc | 58 ++++++++++++++++++++++++++++++ memset_.cc | 53 +++++++++++++++++++++++++++ naive/median.cc | 58 ++++++++++++++++++++++++++++++ paste.cc | 62 ++++++++++++++++++++++++++++++++ transform.cc | 66 ++++++++++++++++++++++++++++++++++ 14 files changed, 876 insertions(+) Index: trunk/milena/tests/level_naive_median.cc (deleted) =================================================================== Index: trunk/milena/tests/level_median_hline2d.cc (deleted) =================================================================== Index: trunk/milena/tests/level_transform.cc (deleted) =================================================================== Index: trunk/milena/tests/level_memcpy_.cc (deleted) =================================================================== Index: trunk/milena/tests/level_median.cc (deleted) =================================================================== Index: trunk/milena/tests/level_median_dir.cc (deleted) =================================================================== Index: trunk/milena/tests/level_fill.cc (deleted) =================================================================== Index: trunk/milena/tests/level_median_fast.cc (deleted) =================================================================== Index: trunk/milena/tests/level_approx_median.cc (deleted) =================================================================== Index: trunk/milena/tests/level_paste.cc (deleted) =================================================================== Index: trunk/milena/tests/level_assign.cc (deleted) =================================================================== Index: trunk/milena/tests/level_memset_.cc (deleted) =================================================================== Index: trunk/milena/tests/level/transform.cc =================================================================== --- trunk/milena/tests/level/transform.cc (revision 0) +++ trunk/milena/tests/level/transform.cc (revision 1485) @@ -0,0 +1,66 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/transform.cc + * + * \brief Tests on mln::level::transform + */ + +#include <cmath> + +#include <mln/core/image2d.hh> +#include <mln/level/transform.hh> +#include <mln/debug/iota.hh> + + +struct mysqrt : mln::Function_v2v<mysqrt> +{ + typedef unsigned short result; + result operator()(unsigned short c) const + { + return result( std::sqrt(float(c)) ); + } +}; + + + +int main() +{ + using namespace mln; + + const unsigned size = 10000; + image2d<unsigned short> + ima(size, size); + + (std::cout << "iota... ").flush(); + debug::iota(ima); + std::cout << "done" << std::endl; + + (std::cout << "transform... ").flush(); + level::transform(ima, mysqrt(), ima); + std::cout << "done" << std::endl; +} Index: trunk/milena/tests/level/median_dir.cc =================================================================== --- trunk/milena/tests/level/median_dir.cc (revision 0) +++ trunk/milena/tests/level/median_dir.cc (revision 1485) @@ -0,0 +1,55 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/median_dir.cc + * + * \brief Test on mln::level::median. + */ + +#include <mln/core/image2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/level/median.hh> + + +int main() +{ + using namespace mln; + using value::int_u8; + + border::thickness = 7; + + image2d<int_u8> + lena = io::pgm::load("../img/lena.pgm"), + out(lena.domain()); + + level::median_dir(lena, 1, 15, out); + io::pgm::save(out, "out.pgm"); +} Index: trunk/milena/tests/level/paste.cc =================================================================== --- trunk/milena/tests/level/paste.cc (revision 0) +++ trunk/milena/tests/level/paste.cc (revision 1485) @@ -0,0 +1,62 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/paste.cc + * + * \brief Tests on mln::level::paste. + */ + +#include <mln/core/image2d.hh> +#include <mln/level/fill.hh> +#include <mln/level/paste.hh> + +#include <mln/debug/iota.hh> +#include <mln/debug/println.hh> + + +int main() +{ + using namespace mln; + + box2d b(make::point2d(1,2), make::point2d(2,4)); + image2d<int> ima(b, 2); + debug::iota(ima); + debug::println(ima); + + + box2d b2(make::point2d(-1,-2), make::point2d(3,6)); + image2d<int> ima2(b2, 0); + debug::iota(ima2); + debug::println(ima2); + + trace::quiet = false; + + level::paste(ima, ima2); // Fast version. + debug::println(ima2); + + level::impl::generic::paste_(ima, ima2); // Not so fast version... +} Index: trunk/milena/tests/level/median.cc =================================================================== --- trunk/milena/tests/level/median.cc (revision 0) +++ trunk/milena/tests/level/median.cc (revision 1485) @@ -0,0 +1,59 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/median.cc + * + * \brief Test on mln::level::median. + */ + +#include <mln/core/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/level/median.hh> + + + + +int main() +{ + using namespace mln; + using value::int_u8; + + win::rectangle2d rect(51, 51); + border::thickness = 52; + + image2d<int_u8> + lena = io::pgm::load("../img/lena.pgm"), + out(lena.domain()); + + level::median(lena, rect, out); + io::pgm::save(out, "out.pgm"); +} Index: trunk/milena/tests/level/naive/median.cc =================================================================== --- trunk/milena/tests/level/naive/median.cc (revision 0) +++ trunk/milena/tests/level/naive/median.cc (revision 1485) @@ -0,0 +1,58 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/naive/median.cc + * + * \brief Test on mln::level::naive::median. + */ + +#include <mln/core/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/level/naive/median.hh> + + +using namespace mln; +using namespace mln::value; + + +int main() +{ + win::rectangle2d rec(51, 51); + border::thickness = 52; + + image2d<int_u8> + lena = io::pgm::load("../img/lena.pgm"), + out(lena.domain()); + + level::naive::median(lena, rec, out); + io::pgm::save(out, "out.pgm"); +} Index: trunk/milena/tests/level/median_hline2d.cc =================================================================== --- trunk/milena/tests/level/median_hline2d.cc (revision 0) +++ trunk/milena/tests/level/median_hline2d.cc (revision 1485) @@ -0,0 +1,64 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/median_hline2d.cc + * + * \brief Test on the hline2d version of mln::level::median. + */ + +#include <mln/core/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/level/median.hh> +#include <mln/level/compare.hh> + + + + +int main() +{ + using namespace mln; + using value::int_u8; + + border::thickness = 0; + + image2d<int_u8> + lena = io::pgm::load("../img/lena.pgm"), + out(lena.domain()), + ref(lena.domain()); + + level::median(lena, win::rectangle2d(1, 101), ref); + + level::median(lena, win::hline2d(101), out); + io::pgm::save(out, "out.pgm"); + + // FIXME: mln_assertion(out == ref); +} Index: trunk/milena/tests/level/assign.cc =================================================================== --- trunk/milena/tests/level/assign.cc (revision 0) +++ trunk/milena/tests/level/assign.cc (revision 1485) @@ -0,0 +1,48 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/assign.cc + * + * \brief Tests on mln::level::assign. + */ + +#include <mln/core/image2d.hh> +#include <mln/level/assign.hh> +#include <mln/level/compare.hh> +#include <mln/debug/iota.hh> + + +int main() +{ + using namespace mln; + + const unsigned size = 1000; + image2d<int> rhs(size, size), lhs(rhs.domain()); + debug::iota(rhs); + level::assign(lhs, rhs); + mln_assertion(lhs == rhs); +} Index: trunk/milena/tests/level/apply.cc =================================================================== --- trunk/milena/tests/level/apply.cc (revision 0) +++ trunk/milena/tests/level/apply.cc (revision 1485) @@ -0,0 +1,57 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/apply.cc + * + * \brief Tests on mln::level::apply. + */ + +#include <mln/core/image2d.hh> +#include <mln/level/apply.hh> +#include <mln/debug/iota.hh> +#include <mln/fun/v2v/saturate.hh> + + +int main() +{ + using namespace mln; + + const unsigned size = 1000; + image2d<int> ima(3, 3); + int vs[3][3] = { + { 2, 2, 3 }, + { 4, 5, 6 }, + { 6, 6, 6 } + }; + + image2d<int> ref(make::image2d(vs)); + debug::iota(ima); + level::apply(ima, fun::v2v::saturate<int>(2, 6)); + box_fwd_piter_<point2d> p(ima.domain()); + for_all(p) + mln_assertion(ima(p) == ref(p)); +} Index: trunk/milena/tests/level/abs.cc =================================================================== --- trunk/milena/tests/level/abs.cc (revision 0) +++ trunk/milena/tests/level/abs.cc (revision 1485) @@ -0,0 +1,60 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/abs.cc + * + * \brief Tests on mln::level::abs. + */ + +# include <mln/core/image2d.hh> +# include <mln/level/abs.hh> + +int main() +{ + + using namespace mln; + + typedef image2d<int> I; + + int vs[6][5] = { + + { -3, -3, -4, -4, -4 }, + { -2, -1, -1, -1, -1 }, + { -1, -4, -4, -4, -1 }, + { -1, -4, -3, -4, -1 }, + { -1, -4, -5, -3, -1 }, + { -1, -1, -1, -1, -1 } + + }; + + image2d<int> ima(make::image2d(vs)); + image2d<int> out(ima.domain()); + level::abs(ima, out); + box_fwd_piter_<point2d> p(ima.domain()); + for_all (p) + mln_assertion (out(p) >= 0); +} Index: trunk/milena/tests/level/approx_median.cc =================================================================== --- trunk/milena/tests/level/approx_median.cc (revision 0) +++ trunk/milena/tests/level/approx_median.cc (revision 1485) @@ -0,0 +1,62 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/approx/median.cc + * + * \brief Test on mln::level::approx::median. + */ + +#include <mln/core/image2d.hh> +#include <mln/win/rectangle2d.hh> +#include <mln/win/octagon2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/level/approx/median.hh> + + + + +int main() +{ + using namespace mln; + using value::int_u8; + + win::rectangle2d rect(51, 51); + win::octagon2d oct(13); + border::thickness = 52; + + image2d<int_u8> + lena = io::pgm::load("../img/lena.pgm"), + out(lena.domain()); + +// level::approx::median(lena, rect, out); + level::approx::median(lena, oct, out); + io::pgm::save(out, "out.pgm"); +} Index: trunk/milena/tests/level/fill.cc =================================================================== --- trunk/milena/tests/level/fill.cc (revision 0) +++ trunk/milena/tests/level/fill.cc (revision 1485) @@ -0,0 +1,70 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/fill.cc + * + * \brief Tests on mln::level::fill + */ + +#include <mln/core/image2d.hh> +#include <mln/core/sub_image.hh> +#include <mln/level/fill.hh> + +#include <mln/debug/println.hh> +#include <mln/value/props.hh> + + +int main() +{ + using namespace mln; + + + unsigned u = 300; + unsigned char uc = u; + mln_assertion(uc == 44); + +// { +// const unsigned size = 3; +// image2d<unsigned> ima(size, size); +// level::fill(ima, u); +// debug::println(ima); +// } + + { + const unsigned size = 10000; + image2d<unsigned char> ima(size, size); + for (unsigned i = 0; i < 5; ++i) + level::fill(ima, uc); + } + +// { +// // do *not* compile so that's great since ima is not mutable +// sub_image< const image2d<int>, box2d > ima; +// level::fill(ima, 0); +// } + +} Index: trunk/milena/tests/level/memcpy_.cc =================================================================== --- trunk/milena/tests/level/memcpy_.cc (revision 0) +++ trunk/milena/tests/level/memcpy_.cc (revision 1485) @@ -0,0 +1,58 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/memcpy_.cc + * + * \brief Tests on mln::level::memcpy_. + * + * \todo Make this test not dummy! + */ + +#include <mln/core/image2d.hh> +#include <mln/core/inplace.hh> +#include <mln/debug/iota.hh> +#include <mln/level/memcpy_.hh> + + +int main() +{ + using namespace mln; + + typedef image2d<int> I; + I ima(3, 3); + debug::iota(ima); + + point2d + src = make::point2d(0, 2), + dest = make::point2d(1, 2); + + level::memcpy_(inplace(make::pixel(ima, dest)), + make::pixel(ima, src), + 2 + 2 * ima.border()); + + mln_assertion(ima(dest) == ima(src)); +} Index: trunk/milena/tests/level/memset_.cc =================================================================== --- trunk/milena/tests/level/memset_.cc (revision 0) +++ trunk/milena/tests/level/memset_.cc (revision 1485) @@ -0,0 +1,53 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/memset_.cc + * + * \brief Tests on mln::level::memset_. + */ + +#include <mln/core/image2d.hh> +#include <mln/geom/ncols.hh> +#include <mln/level/fill.hh> +#include <mln/level/memset_.hh> + + +int main() +{ + using namespace mln; + + image2d<int> ima(3, 3); + level::fill(ima, 0); + int X = 9; + level::memset_(ima, make::point2d(0,0), + X, + geom::ncols(ima) + 2 * ima.border() + 1); + // ^ + // | + mln_assertion(ima.at(1,0) == X); // <----------------+ + mln_assertion(ima.at(1,1) != X); +} Index: trunk/milena/tests/level/median_fast.cc =================================================================== --- trunk/milena/tests/level/median_fast.cc (revision 0) +++ trunk/milena/tests/level/median_fast.cc (revision 1485) @@ -0,0 +1,104 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/level/median_fast.cc + * + * \brief Test on mln::level::fast_median. + */ + +#include <mln/core/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/debug/iota.hh> +#include <mln/debug/println.hh> +#include <mln/level/fast_median.hh> + +#include <mln/core/dpoints_pixter.hh> +#include <mln/core/pixel.hh> + + +namespace mln +{ + + template <typename I, typename W> + void test(I& input, const W& win) + { + mln_point(I) p; + p.row() = p.col() = 1; + + { + mln_qixter(I, W) qix(input, win, p); + for_all(qix) + std::cout << qix.val() << ' '; + std::cout << " : " << qix.center_val() << std::endl; + } + + { + pixel<I> pix(input, p); + mln_qixter(I, W) qix(input, win, pix); + for_all(qix) + std::cout << qix.val() << ' '; + std::cout << " : " << qix.center_val() << std::endl; + } + } + +} + + + +int main() +{ + using namespace mln; + using value::int_u8; + +// { +// win::rectangle2d rect(3, 3); +// border::thickness = 4; +// image2d<int_u8> ima(3, 3); +// debug::iota(ima); +// debug::println(ima); +// test(ima, rect); +// } + + + { + win::rectangle2d rect(51, 51); + border::thickness = 52; + + image2d<int_u8> + lena = io::pgm::load("../img/lena.pgm"), + out(lena.domain()); + + level::fast_median(lena, rect, out); + io::pgm::save(out, "out.pgm"); + } + +}
participants (1)
-
Guillaume Duhamel