
https://svn.lrde.epita.fr/svn/oln/trunk Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Fix the tests in tests/morpho. * mln/morpho/erosion.spe.hh (erosion_iterative_(kind::logic, speed::fastest, const I&, const W&)): Fix the assignment of the out pixter in the case of a non-centered window. * mln/value/int_u_sat.hh (mln::value::props< int_u_sat<n> >): Remove. Superseded by... (mln::trait::value_< mln::value::int_u_sat<n> >): ...this (new specialization). * mln/set/inter.hh (mln::set::inter): Fix uses of the tracing mechanism. * mln/value/int_u.hh: Don't use Doxygen comments to announce forward declarations. * tests/morpho/contrast.cc, * tests/morpho/dilation.cc, * tests/morpho/dilation_max_h.cc, * tests/morpho/erosion.cc, * tests/morpho/erosion_min_h.cc, * tests/morpho/gradient.cc, * tests/morpho/hit_or_miss.cc, * tests/morpho/laplacian.cc, * tests/morpho/opening_area.cc, * tests/morpho/thinning.cc: Catch up with the new I/O interface of Milena. mln/morpho/erosion.spe.hh | 13 +++++++++- mln/set/inter.hh | 6 ++-- mln/value/int_u.hh | 6 +--- mln/value/int_u_sat.hh | 50 +++++++++++++++++++++++++++-------------- tests/morpho/contrast.cc | 5 ++-- tests/morpho/dilation.cc | 5 ++-- tests/morpho/dilation_max_h.cc | 5 ++-- tests/morpho/erosion.cc | 5 ++-- tests/morpho/erosion_min_h.cc | 5 ++-- tests/morpho/gradient.cc | 5 ++-- tests/morpho/hit_or_miss.cc | 8 +++--- tests/morpho/laplacian.cc | 9 ++++--- tests/morpho/opening_area.cc | 8 +++--- tests/morpho/thinning.cc | 8 +++--- 14 files changed, 86 insertions(+), 52 deletions(-) Index: milena/tests/morpho/contrast.cc --- milena/tests/morpho/contrast.cc (revision 1626) +++ milena/tests/morpho/contrast.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -50,7 +50,8 @@ win::rectangle2d rect(5, 5); border::thickness = 2; - image2d<int_u8> lena = io::pgm::load("../img/tiny.pgm"); + image2d<int_u8> lena; + io::pgm::load(lena, "../img/lena.pgm"); image2d<int_u8> out = morpho::contrast(lena, rect); io::pgm::save(out, "out.pgm"); Index: milena/tests/morpho/gradient.cc --- milena/tests/morpho/gradient.cc (revision 1626) +++ milena/tests/morpho/gradient.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -49,7 +49,8 @@ win::rectangle2d rect(5, 5); border::thickness = 2; - image2d<int_u8> lena = io::pgm::load("../img/tiny.pgm"); + image2d<int_u8> lena; + io::pgm::load(lena, "../img/tiny.pgm"); io::pgm::save( morpho::gradient(lena, rect), "out.pgm" ); Index: milena/tests/morpho/erosion.cc --- milena/tests/morpho/erosion.cc (revision 1626) +++ milena/tests/morpho/erosion.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -74,7 +74,8 @@ // 11 29 1 // 25 66 15 - image2d<int_u8> lena = io::pgm::load("../img/lena.pgm"); + image2d<int_u8> lena; + io::pgm::load(lena, "../img/lena.pgm"); // trace::quiet = false; Index: milena/tests/morpho/thinning.cc --- milena/tests/morpho/thinning.cc (revision 1626) +++ milena/tests/morpho/thinning.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -62,9 +62,9 @@ border::thickness = 2; { - image2d<bool> pic = io::pbm::load("../img/picasso.pbm"); - io::pbm::save( morpho::thinning(pic, win_fg, win_bg), - "out.pbm" ); + image2d<bool> pic; + io::pbm::load(pic, "../img/picasso.pbm"); + io::pbm::save(morpho::thinning(pic, win_fg, win_bg), "out.pbm" ); } // { // image2d<int_u8> pic = io::pgm::load("../img/picasso.pgm"); Index: milena/tests/morpho/dilation_max_h.cc --- milena/tests/morpho/dilation_max_h.cc (revision 1626) +++ milena/tests/morpho/dilation_max_h.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -52,7 +52,8 @@ win::rectangle2d rec(21, 21); border::thickness = 66; - image2d<int_u8> lena = io::pgm::load("../img/lena.pgm"); + image2d<int_u8> lena; + io::pgm::load(lena, "../img/lena.pgm"); { p_array<point2d> vec = convert::to_p_array(rec, point2d::origin); Index: milena/tests/morpho/hit_or_miss.cc --- milena/tests/morpho/hit_or_miss.cc (revision 1626) +++ milena/tests/morpho/hit_or_miss.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -75,9 +75,9 @@ border::thickness = 2; - image2d<bool> - pic = io::pbm::load("../img/picasso.pbm"), - out = morpho::hit_or_miss(pic, win_hit, win_miss); + image2d<bool> pic; + io::pbm::load(pic, "../img/picasso.pbm"); + image2d<bool> out = morpho::hit_or_miss(pic, win_hit, win_miss); io::pbm::save(out, "out.pbm"); mln_postcondition(morpho::hit_or_miss(morpho::complementation(pic), Index: milena/tests/morpho/dilation.cc --- milena/tests/morpho/dilation.cc (revision 1626) +++ milena/tests/morpho/dilation.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -60,7 +60,8 @@ win::rectangle2d rec(21, 21); border::thickness = 66; - image2d<int_u8> lena = io::pgm::load("../img/lena.pgm"); + image2d<int_u8> lena; + io::pgm::load(lena, "../img/lena.pgm"); // { // image2d<int_u8> out(lena.domain()); Index: milena/tests/morpho/laplacian.cc --- milena/tests/morpho/laplacian.cc (revision 1626) +++ milena/tests/morpho/laplacian.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -53,9 +53,10 @@ win::rectangle2d rect(5, 5); border::thickness = 2; - image2d<int_u8> lena = io::pgm::load("../img/tiny.pgm"); - image2d<int> lap(lena.domain()); - morpho::laplacian(lena, rect, lap); + image2d<int_u8> tiny; + io::pgm::load(tiny, "../img/tiny.pgm"); + image2d<int> lap(tiny.domain()); + morpho::laplacian(tiny, rect, lap); io::pgm::save( arith::plus_cst< value::int_u_sat<8> >(lap, 128), "out.pgm" ); Index: milena/tests/morpho/opening_area.cc --- milena/tests/morpho/opening_area.cc (revision 1626) +++ milena/tests/morpho/opening_area.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -46,9 +46,9 @@ using namespace mln; using value::int_u8; - image2d<int_u8> - lena = io::pgm::load("../img/lena.pgm"), - out(lena.domain()); + image2d<int_u8> lena; + io::pgm::load(lena, "../img/lena.pgm"); + image2d<int_u8> out(lena.domain()); morpho::opening_area(lena, c4(), 510, out); io::pgm::save(out, "out.pgm"); Index: milena/tests/morpho/erosion_min_h.cc --- milena/tests/morpho/erosion_min_h.cc (revision 1626) +++ milena/tests/morpho/erosion_min_h.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -52,7 +52,8 @@ win::rectangle2d rec(21, 21); border::thickness = 66; - image2d<int_u8> lena = io::pgm::load("../img/lena.pgm"); + image2d<int_u8> lena; + io::pgm::load(lena, "../img/lena.pgm"); { p_array<point2d> vec = convert::to_p_array(rec, point2d::origin); Index: milena/mln/value/int_u.hh --- milena/mln/value/int_u.hh (revision 1626) +++ milena/mln/value/int_u.hh (working copy) @@ -51,17 +51,15 @@ namespace value { - /// \{ Fwd decls. + // Fwd decls. template <unsigned n> struct int_u; - /// \} } namespace literal { - /// \{ Fwd decls. + // Fwd decls. struct zero_t; struct one_t; - /// \} } Index: milena/mln/value/int_u_sat.hh --- milena/mln/value/int_u_sat.hh (revision 1626) +++ milena/mln/value/int_u_sat.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -47,6 +47,35 @@ namespace value { + // Fwd decls. + template <unsigned n> struct int_u_sat; + } + + namespace trait + { + + template <unsigned n> + struct value_< mln::value::int_u_sat<n> > + { + // FIXME: Overhaul these traits (see other value traits). + static const std::size_t card = metal::math::pow_int<2, n>::value; + static const mln::value::int_u_sat<n> min() { return 0; } + static const mln::value::int_u_sat<n> max() { return card - 1; } + static const unsigned nbits = n; + + typedef trait::value::nature::integer nature; + typedef trait::value::kind::data kind; + // FIXME: Is that right? + typedef mln_value_quant_from_(card) quant; + + typedef float sum; + }; + + } // end of namespace mln::trait + + + namespace value + { /*! \brief Unsigned integer value class with saturation behavior. @@ -90,24 +119,10 @@ // Safety. + // FIXME: We shouldn't have to do that. template <> struct int_u_sat<0>; template <> struct int_u_sat<1>; - - - template <unsigned n> - struct props< int_u_sat<n> > - { - static const std::size_t card_ = metal::math::pow_int<2, n>::value; - static const int_u_sat<n> min() { return 0; } - static const int_u_sat<n> max() { return card_ - 1; } - static const unsigned nbits = n; - typedef trait::value::kind::data kind; - typedef float sum; - }; - - - /*! \brief Print a saturated unsigned integer \p i into the output * stream \p ostr. * @@ -135,6 +150,9 @@ static const unsigned max_ = mln_max(int_u<n>); if (i < 0) this->v_ = 0; + // FIXME: This comparison triggers a warning between signed and + // unsigned values from the compiler. If it is valid, use a + // cast and leave a comment about it. else if (i > max_) this->v_ = max_; else Index: milena/mln/set/inter.hh --- milena/mln/set/inter.hh (revision 1626) +++ milena/mln/set/inter.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -80,8 +80,8 @@ std::set_intersection(sl.begin(), sl.end(), sr.begin(), sr.end(), std::inserter(s, s.begin())); - return convert::to_window(s); trace::exiting("set::inter"); + return convert::to_window(s); } template <typename Wl, typename Wr> @@ -99,8 +99,8 @@ std::set_intersection(sl.begin(), sl.end(), sr.begin(), sr.end(), std::inserter(s, s.begin())); - return convert::to_p_set(s); trace::exiting("set::inter"); + return convert::to_p_set(s); } # endif // ! MLN_INCLUDE_ONLY Index: milena/mln/morpho/erosion.spe.hh --- milena/mln/morpho/erosion.spe.hh (revision 1626) +++ milena/mln/morpho/erosion.spe.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -178,10 +178,14 @@ mln_pixter(O) p_out(output); for_all_2(p, p_out) + // Consider P only if its value is `true' (the erosion + // is anti-extensive). if (p.val()) for_all(q) if (! q.val()) { + // Assign `false' to the value of P_OUT as soon + // as a `false' value is found in its vicinity. p_out.val() = false; break; } @@ -194,10 +198,17 @@ mln_pixter(O) p_out(output); for_all_2(p, p_out) for_all(q) + { + // Stop as soon as a `false' value is found the + // window. if (! q.val()) break; + // If a `false' value was not found, then Q is now + // invalid (past the end of the window), and vice + // versa. Use this information to assign P_OUT. p_out.val() = ! q.is_valid(); } + } trace::exiting("morpho::impl::erosion_iterative_(kind::logic, speed::fastest)"); return output;