milena r1537: Moves the io's tests

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-11-26 Matthieu Garrigues <garrigues@lrde.epita.fr> Moves the io's tests. * tests/Makefile.am: Makefile update due to test moves. * tests/io/Makefile.am: Likewise. * tests/io/fits/Makefile.am: Likewise. * tests/io/pbm/Makefile.am: Likewise. * tests/io/pgm/Makefile.am: Likewise. * tests/io/ppm/Makefile.am: Likewise. * sandbox/garrigues/io_fits.cc: Remove. * tests/io/fits/io_fits.cc: New. * tests/io_pbm.cc: Rename as... * tests/io/pbm/pbm.cc: ...this. * tests/io_pgm.cc: Rename as... * tests/io/pgm/pgm.cc: ...this. * tests/io_pgm16.cc: Rename as... * tests/io/pgm/pgm16.cc: ...this. * tests/io_pgm19.cc: Rename as... * tests/io/pgm/pgm19.cc: ...this. * tests/io_pgm27.cc: Rename as... * tests/io/pgm/pgm27.cc: ...this. * tests/io_ppm.cc: Rename as... * tests/io/ppm/ppm.cc: ...this. * tests/io_ppm16.cc: Rename as... * tests/io/ppm/ppm16.cc: ...this. * tests/io_ppm23.cc: Rename as... * tests/io/ppm/ppm23.cc: ...this. * tests/new_io_pgm.cc: Remove, now into tests/io/pgm/pgm.cc. Fix style and doc. * mln/accu/compute.hh, * mln/io/ppm/load.hh: Fix. --- trunk/milena/mln/accu/compute.hh | 3 trunk/milena/tests/Makefile.am | 17 ----- trunk/milena/tests/io/Makefile.am | 8 ++ trunk/milena/tests/io/fits/Makefile.am | 7 ++ trunk/milena/tests/io/fits/io_fits.cc | 77 +++++++++++++++++++++++ trunk/milena/tests/io/pbm/Makefile.am | 7 ++ trunk/milena/tests/io/pbm/pbm.cc | 55 ++++++++++++++++ trunk/milena/tests/io/pgm/Makefile.am | 12 +++ trunk/milena/tests/io/pgm/pgm.cc | 62 ++++++++++++++++++ trunk/milena/tests/io/pgm/pgm16.cc | 95 ++++++++++++++++++++++++++++ trunk/milena/tests/io/pgm/pgm19.cc | 95 ++++++++++++++++++++++++++++ trunk/milena/tests/io/pgm/pgm27.cc | 95 ++++++++++++++++++++++++++++ trunk/milena/tests/io/ppm/Makefile.am | 12 +++ trunk/milena/tests/io/ppm/ppm.cc | 49 ++++++++++++++ trunk/milena/tests/io/ppm/ppm16.cc | 110 +++++++++++++++++++++++++++++++++ trunk/milena/tests/io/ppm/ppm23.cc | 110 +++++++++++++++++++++++++++++++++ 16 files changed, 796 insertions(+), 18 deletions(-) Index: trunk/milena/tests/io_pgm.cc (deleted) =================================================================== Index: trunk/milena/tests/io_pgm19.cc (deleted) =================================================================== Index: trunk/milena/tests/io_ppm23.cc (deleted) =================================================================== Index: trunk/milena/tests/new_io_pgm.cc (deleted) =================================================================== Index: trunk/milena/tests/io_pbm.cc (deleted) =================================================================== Index: trunk/milena/tests/io_ppm.cc (deleted) =================================================================== Index: trunk/milena/tests/io_ppm16.cc (deleted) =================================================================== Index: trunk/milena/tests/io_pgm27.cc (deleted) =================================================================== Index: trunk/milena/tests/io_pgm16.cc (deleted) =================================================================== Index: trunk/milena/tests/Makefile.am =================================================================== --- trunk/milena/tests/Makefile.am (revision 1536) +++ trunk/milena/tests/Makefile.am (revision 1537) @@ -68,13 +68,6 @@ image_if_value \ interpolated \ io_pbm \ - io_pgm16 \ - io_pgm19 \ - io_pgm27 \ - io_pgm \ - io_ppm16 \ - io_ppm23 \ - io_ppm \ \ labeling_algo \ labeling_estimate \ @@ -109,7 +102,6 @@ morpho_opening_area \ morpho_thinning \ \ - new_io_pgm \ norm_l2 \ \ pixel \ @@ -215,14 +207,6 @@ image_if_interval_SOURCES = image_if_interval.cc image_if_value_SOURCES = image_if_value.cc interpolated_SOURCES = interpolated.cc -io_pbm_SOURCES = io_pbm.cc -io_pgm16_SOURCES = io_pgm16.cc -io_pgm19_SOURCES = io_pgm19.cc -io_pgm27_SOURCES = io_pgm27.cc -io_pgm_SOURCES = io_pgm.cc -io_ppm16_SOURCES = io_ppm16.cc -io_ppm23_SOURCES = io_ppm23.cc -io_ppm_SOURCES = io_ppm.cc labeling_algo_SOURCES = labeling_algo.cc labeling_estimate_SOURCES = labeling_estimate.cc @@ -257,7 +241,6 @@ morpho_opening_area_SOURCES = morpho_opening_area.cc morpho_thinning_SOURCES = morpho_thinning.cc -new_io_pgm_SOURCES = new_io_pgm.cc norm_l2_SOURCES = norm_l2.cc pixel_SOURCES = pixel.cc Index: trunk/milena/tests/io/pgm/pgm27.cc =================================================================== --- trunk/milena/tests/io/pgm/pgm27.cc (revision 0) +++ trunk/milena/tests/io/pgm/pgm27.cc (revision 1537) @@ -0,0 +1,95 @@ +// 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/io_pgm27.cc + * + * \brief Test on mln::io::pgm::load and mln::io::pgm::save. + */ + + +#include <mln/core/image2d.hh> + +#include <mln/value/int_u8.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/level/transform.hh> +#include <mln/level/compare.hh> + + + using namespace mln; + +struct to27bits : mln::Function_v2v<to27bits> +{ + + typedef value::int_u<27> result; + result operator()(value::int_u8 v) const + { + result ret(v * 524288); + return ret; + } +}; + +struct to8bits : mln::Function_v2v<to8bits> +{ + + typedef value::int_u8 result; + result operator()(value::int_u<27> v) const + { + result ret(v / 524288); + return ret; + } +}; + +int main() +{ + using namespace mln; + using value::int_u8; + using value::int_u; + typedef value::int_u<27> int_u27; + + image2d<int_u8> + lena = io::pgm::load<int_u8>("../img/lena.pgm"); + image2d<int_u27> out(lena.domain()); + + level::transform(lena, to27bits(), out); + + io::pgm::save(out, "out27.pgm"); + + image2d<int_u27> lena2; + io::pgm::load(lena2, "out27.pgm"); + + image2d<int_u8> out2(lena.domain()); + + level::transform(lena2, to8bits(), out2); + + io::pgm::save(out2, "out8.pgm"); + + assert(out2 == lena); + +} Index: trunk/milena/tests/io/pgm/pgm19.cc =================================================================== --- trunk/milena/tests/io/pgm/pgm19.cc (revision 0) +++ trunk/milena/tests/io/pgm/pgm19.cc (revision 1537) @@ -0,0 +1,95 @@ +// 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/io_pgm19.cc + * + * \brief Test on mln::io::pgm::load and mln::io::pgm::save. + */ + +#include <mln/core/image2d.hh> + +#include <mln/value/int_u8.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/level/transform.hh> +#include <mln/level/compare.hh> + + + using namespace mln; + +struct to19bits : mln::Function_v2v<to19bits> +{ + + typedef value::int_u<19> result; + result operator()(value::int_u8 v) const + { + result ret(v * 524288); + return ret; + } +}; + +struct to8bits : mln::Function_v2v<to8bits> +{ + + typedef value::int_u8 result; + result operator()(value::int_u<19> v) const + { + result ret(v / 524288); + return ret; + } +}; + +int main() +{ + using namespace mln; + using value::int_u8; + using value::int_u; + typedef value::int_u<19> int_u19; + + border::thickness = 52; + + image2d<int_u8> + lena = io::pgm::load<int_u8>("../img/lena.pgm"); + image2d<int_u19> out(lena.domain()); + + level::transform(lena, to19bits(), out); + + io::pgm::save(out, "out19.pgm"); + + image2d<int_u19> + lena2 = io::pgm::load<int_u19>("out19.pgm"); + image2d<int_u8> out2(lena.domain()); + + level::transform(lena2, to8bits(), out2); + + io::pgm::save(out2, "out8.pgm"); + + assert(out2 == lena); + +} Index: trunk/milena/tests/io/pgm/pgm.cc =================================================================== --- trunk/milena/tests/io/pgm/pgm.cc (revision 0) +++ trunk/milena/tests/io/pgm/pgm.cc (revision 1537) @@ -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/io_pgm.cc + * + * \brief Test on mln::io::pgm::load and mln::io::pgm::save. + */ + + +#include <mln/core/image2d.hh> + +#include <mln/value/int_u8.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +int main() +{ + using namespace mln; + using value::int_u8; + + { + image2d<int_u8> + lena = io::pgm::load<int_u8>("../img/lena.pgm"); + + io::pgm::save(lena, "out.pgm"); + } + + + { + image2d< value::int_u<8> > + lena; + io::pgm::load(lena, "../img/lena.pgm"); + + io::pgm::save(lena, "out.pgm"); + } + +} Index: trunk/milena/tests/io/pgm/Makefile.am =================================================================== --- trunk/milena/tests/io/pgm/Makefile.am (revision 1536) +++ trunk/milena/tests/io/pgm/Makefile.am (revision 1537) @@ -1,3 +1,15 @@ ## Process this file through Automake to create Makefile.in -*- Makefile -*- include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + pgm16 \ + pgm19 \ + pgm27 \ + pgm + +pgm16_SOURCES = pgm16.cc +pgm19_SOURCES = pgm19.cc +pgm27_SOURCES = pgm27.cc +pgm_SOURCES = pgm.cc + Index: trunk/milena/tests/io/pgm/pgm16.cc =================================================================== --- trunk/milena/tests/io/pgm/pgm16.cc (revision 0) +++ trunk/milena/tests/io/pgm/pgm16.cc (revision 1537) @@ -0,0 +1,95 @@ +// 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/io_pgm16.cc + * + * \brief Test on mln::io::pgm::load and mln::io::pgm::save. + */ + +#include <mln/core/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/value/int_u8.hh> +#include <mln/value/int_u16.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/level/transform.hh> + + + using namespace mln; + +struct to16bits : mln::Function_v2v<to16bits> +{ + + typedef value::int_u16 result; + result operator()(value::int_u8 v) const + { + result ret(v * 256); + return ret; + } +}; + +struct to8bits : mln::Function_v2v<to8bits> +{ + + typedef value::int_u8 result; + result operator()(value::int_u16 v) const + { + result ret(v / 256); + return ret; + } +}; + +int main() +{ + using namespace mln; + using value::int_u8; + using value::int_u16; + + win::rectangle2d rect(51, 51); + border::thickness = 52; + + image2d<int_u8> + lena = io::pgm::load<int_u8>("../img/lena.pgm"); + image2d<int_u16> out(lena.domain()); + + level::transform(lena, to16bits(), out); + + io::pgm::save(out, "out16.pgm"); + + image2d<int_u16> + lena2 = io::pgm::load<int_u16>("out16.pgm"); + image2d<int_u8> out2(lena.domain()); + + level::transform(lena2, to8bits(), out2); + + io::pgm::save(out2, "out8.pgm"); + + +} Index: trunk/milena/tests/io/fits/io_fits.cc =================================================================== --- trunk/milena/tests/io/fits/io_fits.cc (revision 0) +++ trunk/milena/tests/io/fits/io_fits.cc (revision 1537) @@ -0,0 +1,77 @@ +// 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/fits_load.cc + * + * \brief Test on mln::io::fits::load. + */ + +#include <mln/core/image2d_b.hh> + +#include <mln/level/compare.hh> +#include <mln/debug/println.hh> + +#include <mln/io/fits/load.hh> +#include <mln/io/pfm/save.hh> +#include <mln/io/pfm/load.hh> + +int main() +{ + using namespace mln; + { + image2d_b<float> + fits_in = io::fits::load("../../img/test.fits"); + + debug::println(fits_in); + + io::pfm::save(fits_in, "out.pfm"); + + image2d_b<float> + pfm = io::pfm::load("out.pfm"); + + io::pfm::save(fits_in, "out2.pfm"); + + image2d_b<float> + pfm2 = io::pfm::load("out2.pfm"); + + image2d_b<float>::fwd_piter p(fits_in.domain()); + for_all(p) + if (fits_in(p) != pfm(p)) + std::cout << "at " << p + << " ref :" << fits_in(p) + << " pfm2 : " << pfm(p) << std::endl; + + mln_assertion(fits_in == pfm2); + + // } + // { + // image2d_b<int_u8> + // lena = io::fits::load<int_u8>("../img/lena.fits"); + + // io::fits::save(lena, "out.fits"); + } +} Index: trunk/milena/tests/io/fits/Makefile.am =================================================================== --- trunk/milena/tests/io/fits/Makefile.am (revision 1536) +++ trunk/milena/tests/io/fits/Makefile.am (revision 1537) @@ -1,3 +1,10 @@ ## Process this file through Automake to create Makefile.in -*- Makefile -*- include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + fits \ + +fits_SOURCES = fits.cc + +TESTS = $(check_PROGRAMS) Index: trunk/milena/tests/io/Makefile.am =================================================================== --- trunk/milena/tests/io/Makefile.am (revision 1536) +++ trunk/milena/tests/io/Makefile.am (revision 1537) @@ -1,3 +1,11 @@ ## Process this file through Automake to create Makefile.in -*- Makefile -*- include $(top_srcdir)/milena/tests/tests.mk + +SUBDIRS = \ + fits \ + pbm \ + pfm \ + pgm \ + pnm \ + ppm Index: trunk/milena/tests/io/ppm/ppm.cc =================================================================== --- trunk/milena/tests/io/ppm/ppm.cc (revision 0) +++ trunk/milena/tests/io/ppm/ppm.cc (revision 1537) @@ -0,0 +1,49 @@ +// 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/io_ppm.cc + * + * \brief Test on mln::io::ppm::load and mln::io::ppm::save. + */ + +#include <mln/core/image2d.hh> +#include <mln/value/rgb8.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/ppm/save.hh> + + + + +int main() +{ + using namespace mln; + using value::rgb8; + + image2d<rgb8> lena = io::ppm::load("../img/lena.ppm"); + io::ppm::save(lena, "out.ppm"); +} Index: trunk/milena/tests/io/ppm/ppm23.cc =================================================================== --- trunk/milena/tests/io/ppm/ppm23.cc (revision 0) +++ trunk/milena/tests/io/ppm/ppm23.cc (revision 1537) @@ -0,0 +1,110 @@ +// 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/io_ppm23.cc + * + * \brief Test on mln::io::ppm::load and mln::io::ppm::save. + */ + +#include <mln/core/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/value/rgb8.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/ppm/save.hh> + +#include <mln/level/compare.hh> + + +using namespace mln; + +typedef value::rgb<23> rgb23; + +struct to23bits : mln::Function_v2v<to23bits> +{ + + typedef rgb23 result; + result operator()(value::rgb8 v) const + { + result ret(v.red().to_enc() * 256, + v.green().to_enc() * 256, + v.blue().to_enc() * 256); + return ret; + } +}; + +struct to8bits : mln::Function_v2v<to8bits> +{ + + typedef value::rgb8 result; + result operator()(rgb23 v) const + { + result ret(v.red().to_enc() / 256, + v.green().to_enc() / 256, + v.blue().to_enc() / 256); + return ret; + } +}; + +int main() +{ + using namespace mln; + using value::rgb8; + + typedef image2d<rgb8> I; + + + // load a 8bits image A + image2d<rgb8> + a = io::ppm::load<rgb8>("../img/lena.ppm"); + image2d<rgb23> b(a.domain()); + + image2d<rgb8>::fwd_piter p(b.domain()); + + // save it as a 23bits ppm image B + to23bits f; + for_all(p) + b(p) = f(a(p)); + io::ppm::save(b, "out23.ppm"); + + // reload B into C + image2d<rgb23> + c = io::ppm::load<rgb23>("out23.ppm"); + image2d<rgb8> d(a.domain()); + + + // save C as a 8bits ppm image D + to8bits g; + for_all(p) + d(p) = g(c(p)); + io::ppm::save(d, "out8.ppm"); + + // D should equals A + mln_assertion(d == a); + +} Index: trunk/milena/tests/io/ppm/ppm16.cc =================================================================== --- trunk/milena/tests/io/ppm/ppm16.cc (revision 0) +++ trunk/milena/tests/io/ppm/ppm16.cc (revision 1537) @@ -0,0 +1,110 @@ +// 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/io_ppm16.cc + * + * \brief Test on mln::io::ppm::load and mln::io::ppm::save. + */ + +#include <mln/core/image2d.hh> +#include <mln/win/rectangle2d.hh> + +#include <mln/value/rgb8.hh> +#include <mln/value/rgb16.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/ppm/save.hh> + +#include <mln/level/compare.hh> + + +using namespace mln; + +struct to16bits : mln::Function_v2v<to16bits> +{ + + typedef value::rgb16 result; + result operator()(value::rgb8 v) const + { + result ret(v.red().to_enc() * 256, + v.green().to_enc() * 256, + v.blue().to_enc() * 256); + return ret; + } +}; + +struct to8bits : mln::Function_v2v<to8bits> +{ + + typedef value::rgb8 result; + result operator()(value::rgb16 v) const + { + result ret(v.red().to_enc() / 256, + v.green().to_enc() / 256, + v.blue().to_enc() / 256); + return ret; + } +}; + +int main() +{ + using namespace mln; + using value::rgb8; + using value::rgb16; + + typedef image2d<rgb8> I; + + + // load a 8bits image A + image2d<rgb8> + a = io::ppm::load<rgb8>("../img/lena.ppm"); + image2d<rgb16> b(a.domain()); + + image2d<rgb8>::fwd_piter p(b.domain()); + + // save it as a 16bits ppm image B + to16bits f; + for_all(p) + b(p) = f(a(p)); + io::ppm::save(b, "out16.ppm"); + + // reload B into C + image2d<rgb16> + c = io::ppm::load<rgb16>("out16.ppm"); + image2d<rgb8> d(a.domain()); + + + // save C as a 8bits ppm image D + to8bits g; + for_all(p) + d(p) = g(c(p)); + io::ppm::save(d, "out8.ppm"); + + // D should equals A + mln_assertion(d == a); + +} Index: trunk/milena/tests/io/ppm/Makefile.am =================================================================== --- trunk/milena/tests/io/ppm/Makefile.am (revision 1536) +++ trunk/milena/tests/io/ppm/Makefile.am (revision 1537) @@ -1,3 +1,15 @@ ## Process this file through Automake to create Makefile.in -*- Makefile -*- include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + ppm16 \ + ppm23 \ + ppm + +ppm16_SOURCES = ppm16.cc +ppm23_SOURCES = ppm23.cc +ppm_SOURCES = ppm.cc + + +TESTS = $(check_PROGRAMS) Index: trunk/milena/tests/io/pbm/pbm.cc =================================================================== --- trunk/milena/tests/io/pbm/pbm.cc (revision 0) +++ trunk/milena/tests/io/pbm/pbm.cc (revision 1537) @@ -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/io_pbm.cc + * + * \brief Test on mln::io::pbm::. + */ + +#include <mln/core/image2d.hh> +#include <mln/io/pbm/load.hh> +#include <mln/io/pbm/save.hh> + + +int main() +{ + using namespace mln; + + image2d<bool> pic = io::pbm::load("../img/picasso.pbm"); + io::pbm::save(pic, "pic.pbm"); +} + + +// sample binary image to test with xv, imview, and display +// to bring into the fore the binary image bug with raw pbm. + +// | | | | - +// | | - - - +// | - - - - +// - - - - - +// - - - - - +// - - - - - Index: trunk/milena/tests/io/pbm/Makefile.am =================================================================== --- trunk/milena/tests/io/pbm/Makefile.am (revision 1536) +++ trunk/milena/tests/io/pbm/Makefile.am (revision 1537) @@ -1,3 +1,10 @@ ## Process this file through Automake to create Makefile.in -*- Makefile -*- include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + pbm + +pbm_SOURCES = pbm.cc + +TESTS = $(check_PROGRAMS) Index: trunk/milena/mln/accu/compute.hh =================================================================== --- trunk/milena/mln/accu/compute.hh (revision 1536) +++ trunk/milena/mln/accu/compute.hh (revision 1537) @@ -51,7 +51,8 @@ * \param[in] input The input image. * * This routine runs: \n - * FIXME + * a.take(make::pix(input, p)); + * on all pixels on the images. * * \warning This routine does not perform a.init(). */ Index: trunk/milena/mln/io/ppm/load.hh =================================================================== Index: trunk/milena/sandbox/garrigues/io_fits.cc (deleted) ===================================================================
participants (1)
-
Matthieu Garrigues