Roland> + // FIXME: Exercize more image types.
Compromise, exercise, surprise.
Je n'ai pas retenu s'il y avait une règle, je me souviens juste
que je fais souvent l'erreur d'écrire ces trois là avec -ize
alors qu'il ne faut pas. Bienvenu au club :)
--
Alexandre Duret-Lutz
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-01-07 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add resize function for fast 2d image in mln::geom.
* mln/geom/resize.hh: New function for resize fast iamge.
* tests/geom/resize.cc: Test this function.
* tests/geom/Makefile.am: And add this test in the Makefile.
* mln/core/concept/object.hh: Update copyright.
---
mln/core/concept/object.hh | 4 -
mln/geom/resize.hh | 174 +++++++++++++++++++++++++++++++++++++++++++++
tests/geom/Makefile.am | 2
tests/geom/resize.cc | 68 +++++++++++++++++
4 files changed, 246 insertions(+), 2 deletions(-)
Index: trunk/milena/tests/geom/resize.cc
===================================================================
--- trunk/milena/tests/geom/resize.cc (revision 0)
+++ trunk/milena/tests/geom/resize.cc (revision 1633)
@@ -0,0 +1,68 @@
+// Copyright (C) 2007, 2008 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/geom/resize.cc
+ *
+ * \brief Tests on mln::geom::resize.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/geom/resize.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/level/compare.hh>
+
+int
+main ()
+{
+ using namespace mln;
+
+ {
+ image2d<int> ima (8, 16);
+
+ debug::iota(ima);
+
+ image2d<int> out = geom::resize(ima, 0.5);
+
+ int ws[4][8] =
+ {
+ { 9, 11, 13, 15, 17, 19, 21, 23},
+ { 41, 43, 45, 47, 49, 51, 53, 55},
+ { 73, 75, 77, 79, 81, 83, 85, 87},
+ {105, 107, 109, 111, 113, 115, 117, 119}
+ };
+
+ image2d<int> ref(make::image2d(ws));
+
+ mln_assertion (out == ref);
+ }
+
+}
Index: trunk/milena/tests/geom/Makefile.am
===================================================================
--- trunk/milena/tests/geom/Makefile.am (revision 1632)
+++ trunk/milena/tests/geom/Makefile.am (revision 1633)
@@ -17,6 +17,7 @@
nrows \
nslis \
pmin_pmax \
+resize \
seed2tiling \
seed2tiling_roundness \
shift \
@@ -36,6 +37,7 @@
nrows_SOURCES = nrows.cc
nslis_SOURCES = nslis.cc
pmin_pmax_SOURCES = pmin_pmax.cc
+resize_SOURCES = resize.cc
seed2tiling_SOURCES = seed2tiling.cc
seed2tiling_roundness_SOURCES = seed2tiling_roundness.cc
shift_SOURCES = shift.cc
Index: trunk/milena/mln/core/concept/object.hh
===================================================================
--- trunk/milena/mln/core/concept/object.hh (revision 1632)
+++ trunk/milena/mln/core/concept/object.hh (revision 1633)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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
@@ -93,7 +93,7 @@
* <LI> \ref mln::win
*
* \section copyright Copyright and License.
- * Copyright (C) 2007 EPITA Research and Development Laboratory
+ * Copyright (C) 2007, 2008 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
Index: trunk/milena/mln/geom/resize.hh
===================================================================
--- trunk/milena/mln/geom/resize.hh (revision 0)
+++ trunk/milena/mln/geom/resize.hh (revision 1633)
@@ -0,0 +1,174 @@
+// Copyright (C) 2007, 2008 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.
+
+#ifndef MLN_GEOM_RESIZE_HH
+# define MLN_GEOM_RESIZE_HH
+
+/*! \file mln/geom/resize.hh
+ *
+ * \brief Resize an image.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/clone.hh>
+# include <mln/make/w_window1d.hh>
+# include <mln/accu/mean.hh>
+# include <mln/border/resize.hh>
+# include <mln/border/fill.hh>
+# include <mln/debug/println.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /*!
+ * \brief Resize an image \p input_ with \p ratio.
+ *
+ * \param[in] input_ The image to resize.
+ * \param[in] ratio The ratio of the resize image.
+ *
+ * \precondition \p input_ has to be initialized.
+ * \precondition \p ratio <= 1.
+ *
+ * \return The resized image.
+ */
+ template <typename I>
+ I
+ resize(const Image<I>& input_, const float ratio);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+
+ template <typename I>
+ I
+ resize_1d_(const I& input, const float ratio)
+ {
+ trace::entering("mln::geom::impl::resize_1d_");
+ typedef mln_value(I) V;
+
+ std::size_t cols = input.bbox().len(0);
+ std::size_t new_cols = (std::size_t)(ratio * cols);
+
+ std::size_t n = (std::size_t)(1 / ratio);
+
+ I output (new_cols);
+ level::fill(output, 0);
+
+ for (std::size_t j = 0; j < cols; ++j)
+ {
+ output(point1d(j / n)) += input(point1d(j));
+ if (!((j + 1) % n))
+ output(point1d(j / n)) /= n;
+ }
+
+ trace::exiting("mln::geom::impl::resize_1d_");
+ return output;
+ }
+
+ template <typename I>
+ I
+ resize_2d_(const I& input, const float ratio)
+ {
+ trace::entering("mln::geom::impl::resize_2d_");
+ typedef mln_value(I) V;
+
+ std::size_t rows = input.bbox().len(0);
+ std::size_t cols = input.bbox().len(1);
+ std::size_t new_rows = (std::size_t)(ratio * rows);
+ std::size_t new_cols = (std::size_t)(ratio * cols);
+
+ std::size_t n = (std::size_t)(1 / ratio);
+ std::size_t nn = n * n;
+
+ I output (new_rows, new_cols);
+ std::vector<V> v (new_cols);
+
+ for (std::size_t i = 0; i < rows; ++i)
+ {
+ std::size_t in = i / n;
+
+ if (!(i % n))
+ for (std::size_t j = 0; j < new_cols; ++j)
+ v[j] = 0;
+
+ for (std::size_t j = 0; j < cols; ++j)
+ v[j / n] += input(point2d(i, j));
+
+ if (!((i + 1) % n))
+ for (std::size_t j = 0; j < cols; ++j)
+ output(point2d(in, j / n)) = v[j / n] / nn;
+ }
+
+ trace::exiting("mln::geom::impl::resize_2d_");
+ return output;
+ }
+
+ } // end of namespace mln::geom::impl
+
+
+ template <typename I>
+ I
+ resize(const Image<I>& input_, const float ratio)
+ {
+ trace::entering("mln::geom::resize");
+
+ const I input = exact (input_);
+ mln_precondition(input.has_data());
+ mln_precondition(ratio <= 1.0f);
+ mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
+
+ I output;
+ typedef mln_point(I) P;
+
+ /// FIXME : Find a better way for the disjunction.
+
+// if (P::dim == 1)
+// output = impl::resize_1d_(input, ratio);
+
+ if (P::dim == 2)
+ output = impl::resize_2d_(input, ratio);
+
+ trace::exiting("mln::geom::resize");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_RESIZE_HH
Happy New Year!
I wanted to recall that as of today, files altered by patches in the
Olena Project must mention the year 2008 in their copyright header.
Thanks in advance!
Roland
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Roland Levillain <roland(a)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;