https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make operations on windows more explicit.
* mln/convert/to_std_set.hh: New.
* mln/geom/sym.hh: New.
* mln/geom/shift.hh: New.
* mln/set: New directory.
* mln/set/inter.hh: New.
* mln/set/diff.hh: New.
* mln/set/union.hh: New.
* mln/set/sym_diff.hh: New.
* mln/convert/to_image.hh: Typo.
* mln/convert/to_window.hh (to_window): New overload.
* mln/convert/to_dpoint.hh: Typo.
* mln/core/w_window.hh (sym_): Rename as...
(sym): ...this and update.
* mln/core/window.hh: Likewise.
(operator-): Remove the unary version.
(operator+, operator-): Remove; now handle by...
* mln/geom/shift.hh (shift): ...this.
* mln/core/concept/weighted_window.hh: Update.
(operator-): Remove.
* mln/core/concept/window.hh: Likewise.
* mln/core/concept/doc/weighted_window.hh,
* mln/core/concept/doc/window.hh,
* mln/core/win/vline2d.hh,
* mln/core/win/hline2d.hh,
* mln/core/win/rectangle2d.hh,
* mln/morpho/includes.hh,
* mln/morpho/closing.hh,
* mln/morpho/opening.hh,
* mln/level/was.median.hh,
* mln/level/median.hh,
* mln/level/fast_median.hh,
* tests/rectangle2d.cc: Update.
* mln/core/concept/value.hh: Fix warning.
mln/convert/to_dpoint.hh | 2
mln/convert/to_image.hh | 2
mln/convert/to_std_set.hh | 75 ++++++++++++++++++++++++++++
mln/convert/to_window.hh | 19 +++++++
mln/core/concept/doc/weighted_window.hh | 4 -
mln/core/concept/doc/window.hh | 4 -
mln/core/concept/value.hh | 2
mln/core/concept/weighted_window.hh | 10 ---
mln/core/concept/window.hh | 24 ++-------
mln/core/w_window.hh | 14 +++--
mln/core/win/hline2d.hh | 6 +-
mln/core/win/rectangle2d.hh | 6 +-
mln/core/win/vline2d.hh | 6 +-
mln/core/window.hh | 70 +++-----------------------
mln/geom/shift.hh | 73 ++++++++++++++++++++++++++++
mln/geom/sym.hh | 68 ++++++++++++++++++++++++++
mln/level/fast_median.hh | 14 +++--
mln/level/median.hh | 14 +++--
mln/level/was.median.hh | 12 ++--
mln/morpho/closing.hh | 2
mln/morpho/includes.hh | 2
mln/morpho/opening.hh | 2
mln/set/diff.hh | 80 ++++++++++++++++++++++++++++++
mln/set/inter.hh | 83 ++++++++++++++++++++++++++++++++
mln/set/sym_diff.hh | 79 ++++++++++++++++++++++++++++++
mln/set/union.hh | 82 +++++++++++++++++++++++++++++++
tests/rectangle2d.cc | 3 -
27 files changed, 630 insertions(+), 128 deletions(-)
Index: tests/rectangle2d.cc
--- tests/rectangle2d.cc (revision 1061)
+++ tests/rectangle2d.cc (working copy)
@@ -31,6 +31,7 @@
*/
#include <mln/core/win/rectangle2d.hh>
+#include <mln/geom/sym.hh>
@@ -43,7 +44,7 @@
mln_assertion(rec.is_centered());
mln_assertion(rec.is_symmetric());
- mln_assertion(rec = -rec);
+ mln_assertion(rec = geom::sym(rec));
mln_assertion(rec.ndpoints() = h * w);
}
Index: mln/convert/to_image.hh
--- mln/convert/to_image.hh (revision 1061)
+++ mln/convert/to_image.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/convert/to_image.hh
*
- * \brief Convertions to mln::Image.
+ * \brief Conversions to mln::Image.
*/
# include <mln/core/image2d_b.hh>
Index: mln/convert/to_std_set.hh
--- mln/convert/to_std_set.hh (revision 0)
+++ mln/convert/to_std_set.hh (revision 0)
@@ -0,0 +1,75 @@
+// 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.
+
+#ifndef MLN_CONVERT_TO_STD_SET_HH
+# define MLN_CONVERT_TO_STD_SET_HH
+
+/*! \file mln/convert/to_std_set.hh
+ *
+ * \brief Conversions to std::set.
+ */
+
+# include <set>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/window.hh>
+
+
+namespace mln
+{
+
+ namespace convert
+ {
+
+ /// Convert a window \p win into a std::set of delta-points.
+ template <typename W>
+ std::set<mln_dpoint(W)> to_std_set(const Window<W>& win);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename W>
+ std::set<mln_dpoint(W)> to_std_set(const Window<W>& win)
+ {
+ typedef mln_dpoint(W) D;
+ typedef mln_point(D) P;
+ std::set<D> s;
+ mln_qiter(W) q(exact(win), P::zero);
+ for_all(q)
+ s.insert(q - P::zero);
+ return s;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CONVERT_TO_STD_SET_HH
Index: mln/convert/to_window.hh
--- mln/convert/to_window.hh (revision 1061)
+++ mln/convert/to_window.hh (working copy)
@@ -33,10 +33,14 @@
* \brief Conversions to mln::window.
*/
+# include <set>
+
+# include <mln/core/concept/dpoint.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/window.hh>
# include <mln/pw/image.hh>
# include <mln/pw/cst.hh>
+# include <mln/metal/is_a.hh>
namespace mln
@@ -57,6 +61,10 @@
template <typename S, typename F>
window<mln_dpoint(S)> to_window(const Point_Set<S>& pset);
+ /// Convert an std::set \p s of delta-points into a window.
+ template <typename D>
+ window<D> to_window(const std::set<D>& s);
+
# ifndef MLN_INCLUDE_ONLY
@@ -95,6 +103,17 @@
return to_window(pw::cst(true) | pset);
}
+ template <typename D>
+ window<D> to_window(const std::set<D>& s)
+ {
+ mln::metal::is_a<D, Dpoint>::check();
+ window<D> win;
+ for (typename std::set<D>::const_iterator i = s.begin();
+ i != s.end(); ++i)
+ win.insert(*i);
+ return win;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::convert
Index: mln/convert/to_dpoint.hh
--- mln/convert/to_dpoint.hh (revision 1061)
+++ mln/convert/to_dpoint.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/convert/to_dpoint.hh
*
- * \brief Convertions to mln::Dpoint.
+ * \brief Conversions to mln::Dpoint.
*/
# include <mln/core/concept/generalized_point.hh>
Index: mln/geom/sym.hh
--- mln/geom/sym.hh (revision 0)
+++ mln/geom/sym.hh (revision 0)
@@ -0,0 +1,68 @@
+// 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.
+
+#ifndef MLN_GEOM_SYM_HH
+# define MLN_GEOM_SYM_HH
+
+/*! \file mln/geom/sym.hh
+ *
+ * \brief Give the symmetrical object.
+ */
+
+# include <mln/core/concept/window.hh>
+
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /*! \brief Give the symmetrical window of \p win.
+ */
+ template <typename W>
+ W sym(const Window<W>& win);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename W>
+ W sym(const Window<W>& win)
+ {
+ W tmp = exact(win);
+ return tmp.sym();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_SYM_HH
Index: mln/geom/shift.hh
--- mln/geom/shift.hh (revision 0)
+++ mln/geom/shift.hh (revision 0)
@@ -0,0 +1,73 @@
+// 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.
+
+#ifndef MLN_GEOM_SHIFT_HH
+# define MLN_GEOM_SHIFT_HH
+
+/*! \file mln/geom/shift.hh
+ *
+ * \brief Shift.
+ */
+
+# include <mln/core/window.hh>
+
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Shift a window \p win with a delta-point \p dp.
+ template <typename W>
+ window<mln_dpoint(W)>
+ shift(const Window<W>& win, const mln_dpoint(W)& dp);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename W>
+ window<mln_dpoint(W)>
+ shift(const Window<W>& win, const mln_dpoint(W)& dp)
+ {
+ typedef mln_point(W) P;
+ window<mln_dpoint(W)> tmp;
+ mln_qiter(W) q(win, P::zero);
+ for_all(q)
+ tmp.insert(convert::to_dpoint(q) + dp);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_SHIFT_HH
Index: mln/core/w_window.hh
--- mln/core/w_window.hh (revision 1061)
+++ mln/core/w_window.hh (working copy)
@@ -104,8 +104,8 @@
const mln::window<D>& win() const;
- /// Give the symmetrical w_window.
- w_window<D,W> sym_() const;
+ /// Apply a central symmetry to the target window.
+ w_window<D,W>& sym();
protected:
@@ -252,11 +252,13 @@
}
template <typename D, typename W>
- w_window<D,W>
- w_window<D,W>::sym_() const
+ w_window<D,W>&
+ w_window<D,W>::sym()
{
- w_window<D,W> tmp(*this);
- tmp.win_ = - this->win_;
+ w_window<D,W> tmp;
+ for (unsigned i = 0; i < this->ndpoints(); ++i)
+ tmp.insert(this->w(i), this->dp(i));
+ *this = tmp;
return *this;
}
Index: mln/core/window.hh
--- mln/core/window.hh (revision 1061)
+++ mln/core/window.hh (working copy)
@@ -40,6 +40,7 @@
# include <mln/core/box.hh>
# include <mln/convert/to_dpoint.hh>
+# include <mln/geom/sym.hh>
namespace mln
@@ -87,8 +88,8 @@
/// Insert a delta-point \p dp.
window<D>& insert(const D& dp);
- /// Give the symmetrical window.
- window<D> sym_() const;
+ /// Apply a central symmetry to the target window.
+ window<D>& sym();
protected:
@@ -96,24 +97,6 @@
};
- // FIXME: Move both ops below to mln/core/concept/window.hh
-
- /// Shift a window \p win with a delta-point \p dp.
- template <typename W>
- window<mln_dpoint(W)> operator+(const Window<W>& win,
- const mln_dpoint(W)& dp);
-
- /// Shift a window \p win with the delta-point (-\p dp).
- template <typename W>
- window<mln_dpoint(W)> operator-(const Window<W>& win,
- const mln_dpoint(W)& dp);
-
- /// Substract \p rhs from \p lhs.
- // FIXME: Give details!
- template <typename Wl, typename Wr>
- window<mln_dpoint(Wl)> operator-(const Window<Wl>& lhs,
- const Window<Wr>& rhs);
-
# ifndef MLN_INCLUDE_ONLY
@@ -128,7 +111,7 @@
template <typename D>
bool window<D>::is_symmetric() const
{
- return this->sym_() = *this;
+ return geom::sym(*this) = *this;
}
template <typename D>
@@ -141,52 +124,15 @@
}
template <typename D>
- window<D>
- window<D>::sym_() const
+ window<D>&
+ window<D>::sym()
{
window<D> tmp;
const unsigned n = this->ndpoints();
for (unsigned i = 0; i < n; ++i)
tmp.insert(- this->dp(i));
- return tmp;
- }
-
-
- // operators
-
- template <typename W>
- window<mln_dpoint(W)> operator+(const Window<W>& win,
- const mln_dpoint(W)& dp)
- {
- typedef mln_point(W) P;
- window<mln_dpoint(W)> tmp;
- mln_qiter(W) q(win, P::zero);
- for_all(q)
- tmp.insert(convert::to_dpoint(q) + dp);
- return tmp;
- }
-
- template <typename W>
- window<mln_dpoint(W)> operator-(const Window<W>& win,
- const mln_dpoint(W)& dp)
- {
- return win + (-dp);
- }
-
- template <typename W, typename Wr>
- window<mln_dpoint(W)> operator-(const Window<W>& lhs,
- const Window<Wr>& rhs)
- {
- typedef mln_point(W) P;
- window<mln_dpoint(W)> tmp;
- mln_qiter(W) q(lhs, P::zero);
- for_all(q)
- {
- mln_dpoint(W) dp = convert::to_dpoint(q);
- if (! exact(rhs).has(dp))
- tmp.insert(dp);
- }
- return tmp;
+ *this = tmp;
+ return *this;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/weighted_window.hh
--- mln/core/concept/weighted_window.hh (revision 1061)
+++ mln/core/concept/weighted_window.hh (working copy)
@@ -58,7 +58,7 @@
typedef weight;
typedef window;
- E sym_() const;
+ E& sym();
*/
/// Test if the weighted window is empty; final method.
@@ -107,19 +107,13 @@
typedef mln_fwd_qiter(E) fwd_qiter;
typedef mln_bkd_qiter(E) bkd_qiter;
- E (E::*m1)() const = & E::sym_;
+ E& (E::*m1)() = & E::sym;
m1 = 0;
const window& (E::*m2)() const = & E::win;
m2 = 0;
}
- template <typename W>
- W operator-(const Weighted_Window<W>& rhs)
- {
- return exact(rhs).sym_();
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/concept/window.hh
--- mln/core/concept/window.hh (revision 1061)
+++ mln/core/concept/window.hh (working copy)
@@ -39,6 +39,7 @@
namespace mln
{
+
/*! \brief Base class for implementation classes that are windows.
*
* \see mln::doc::Window for a complete documentation of this class
@@ -61,7 +62,7 @@
unsigned delta() const;
- E sym_() const;
+ E& sym();
*/
protected:
@@ -69,22 +70,17 @@
};
- /*! \brief Compute the symmetrical window of \p rhs.
- *
- * \relates mln::Window
- */
- template <typename W>
- W operator-(const Window<W>& rhs);
-
-
/*! \brief Equality comparison between windows \p lhs and \p rhs.
*
* \relates mln::Window
+ *
+ * \todo Move into mln/set/compare.hh and delegate to replace this special impl.
*/
template <typename Wl, typename Wr>
bool operator=(const Window<Wl>& lhs, const Window<Wr>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
template <typename E>
@@ -105,14 +101,8 @@
m3 = 0;
unsigned (E::*m4)() const = & E::delta;
m4 = 0;
- E (E::*m_)() const = & E::sym_;
- m_ = 0;
- }
-
- template <typename W>
- W operator-(const Window<W>& rhs)
- {
- return exact(rhs).sym_();
+ E& (E::*m5)() = & E::sym;
+ m5 = 0;
}
template <typename Wl, typename Wr>
Index: mln/core/concept/doc/weighted_window.hh
--- mln/core/concept/doc/weighted_window.hh (revision 1061)
+++ mln/core/concept/doc/weighted_window.hh (working copy)
@@ -89,9 +89,9 @@
*/
const window& win() const;
- /*! \brief Give the symmetrical weighted_window.
+ /*! \brief Apply a central symmetry to the target weighted window.
*/
- E sym_() const;
+ E& sym();
};
} // end of namespace mln::doc
Index: mln/core/concept/doc/window.hh
--- mln/core/concept/doc/window.hh (revision 1061)
+++ mln/core/concept/doc/window.hh (working copy)
@@ -81,9 +81,9 @@
*/
unsigned delta() const;
- /*! \brief Give the symmetrical window.
+ /*! \brief Apply a central symmetry to the target window.
*/
- E sym_() const;
+ E& sym();
};
} // end of namespace mln::doc
Index: mln/core/concept/value.hh
--- mln/core/concept/value.hh (revision 1061)
+++ mln/core/concept/value.hh (working copy)
@@ -115,7 +115,7 @@
template <typename T, typename S>
typename S::equiv
- cast_(const T& dummy, const Value<S>& src)
+ cast_(const T&, const Value<S>& src)
{
return exact(src);
}
Index: mln/core/win/vline2d.hh
--- mln/core/win/vline2d.hh (revision 1061)
+++ mln/core/win/vline2d.hh (working copy)
@@ -108,8 +108,8 @@
*/
unsigned delta() const;
- /// Get the symmetrical window.
- vline2d sym_() const;
+ /// Apply a central symmetry to the target window.
+ vline2d& sym();
protected:
unsigned length_;
@@ -161,7 +161,7 @@
return length_ / 2;
}
- vline2d vline2d::sym_() const
+ vline2d& vline2d::sym()
{
return *this;
}
Index: mln/core/win/hline2d.hh
--- mln/core/win/hline2d.hh (revision 1061)
+++ mln/core/win/hline2d.hh (working copy)
@@ -106,8 +106,8 @@
*/
unsigned delta() const;
- /// Get the symmetrical window.
- hline2d sym_() const;
+ /// Apply a central symmetry to the target window.
+ hline2d& sym();
protected:
unsigned length_;
@@ -159,7 +159,7 @@
return length_ / 2;
}
- hline2d hline2d::sym_() const
+ hline2d& hline2d::sym()
{
return *this;
}
Index: mln/core/win/rectangle2d.hh
--- mln/core/win/rectangle2d.hh (revision 1061)
+++ mln/core/win/rectangle2d.hh (working copy)
@@ -111,8 +111,8 @@
*/
unsigned delta() const;
- /// Get the symmetrical window.
- rectangle2d sym_() const;
+ /// Apply a central symmetry to the target window.
+ rectangle2d& sym();
protected:
unsigned height_, width_;
@@ -171,7 +171,7 @@
return width_ > height_ ? width_ / 2 : height_ / 2;
}
- rectangle2d rectangle2d::sym_() const
+ rectangle2d& rectangle2d::sym()
{
return *this;
}
Index: mln/set/inter.hh
--- mln/set/inter.hh (revision 0)
+++ mln/set/inter.hh (revision 0)
@@ -0,0 +1,83 @@
+// 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.
+
+#ifndef MLN_SET_INTER_HH
+# define MLN_SET_INTER_HH
+
+/*! \file mln/set/inter.hh
+ *
+ * \brief Several routines to compute the intersection between a
+ * couple of sets.
+ */
+
+# include <mln/convert/to_std_set.hh>
+# include <mln/convert/to_window.hh>
+# include <mln/metal/equal.hh>
+
+
+
+namespace mln
+{
+
+ namespace set
+ {
+
+ /*! \brief Intersection between a couple of windows.
+ *
+ * \relates mln::Window
+ */
+ template <typename Wl, typename Wr>
+ window<mln_dpoint(Wl)>
+ inter(const Window<Wl>& lhs, const Window<Wr>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename Wl, typename Wr>
+ window<mln_dpoint(Wl)>
+ inter(const Window<Wl>& lhs, const Window<Wr>& rhs)
+ {
+ mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
+ typedef mln_dpoint(Wl) D;
+ std::set<D>
+ sl = convert::to_std_set(lhs),
+ sr = convert::to_std_set(rhs),
+ s;
+ std::set_intersection(sl.begin(), sl.end(),
+ sr.begin(), sr.end(),
+ std::inserter(s, s.begin()));
+ return convert::to_window(s);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::set
+
+} // end of namespace mln
+
+
+#endif // ! MLN_SET_INTER_HH
Index: mln/set/diff.hh
--- mln/set/diff.hh (revision 0)
+++ mln/set/diff.hh (revision 0)
@@ -0,0 +1,80 @@
+// 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.
+
+#ifndef MLN_SET_DIFF_HH
+# define MLN_SET_DIFF_HH
+
+/*! \file mln/set/diff.hh
+ *
+ * \brief Set theoretic difference (non-symmetrical) of a couple of
+ * sets.
+ */
+
+# include <mln/convert/to_std_set.hh>
+# include <mln/convert/to_window.hh>
+# include <mln/metal/equal.hh>
+
+
+
+namespace mln
+{
+
+ namespace set
+ {
+
+ /// Set theoretic difference of \p lhs and \p rhs.
+ template <typename Wl, typename Wr>
+ window<mln_dpoint(Wl)>
+ diff(const Window<Wl>& lhs, const Window<Wr>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename Wl, typename Wr>
+ window<mln_dpoint(Wl)>
+ diff(const Window<Wl>& lhs, const Window<Wr>& rhs)
+ {
+ mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
+ typedef mln_dpoint(Wl) D;
+ std::set<D>
+ sl = convert::to_std_set(lhs),
+ sr = convert::to_std_set(rhs),
+ s;
+ std::set_difference(sl.begin(), sl.end(),
+ sr.begin(), sr.end(),
+ std::inserter(s, s.begin()));
+ return convert::to_window(s);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::set
+
+} // end of namespace mln
+
+
+#endif // ! MLN_SET_DIFF_HH
Index: mln/set/union.hh
--- mln/set/union.hh (revision 0)
+++ mln/set/union.hh (revision 0)
@@ -0,0 +1,82 @@
+// 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.
+
+#ifndef MLN_SET_UNION_HH
+# define MLN_SET_UNION_HH
+
+/*! \file mln/set/union.hh
+ *
+ * \brief Several routines to compute the union of a couple of sets.
+ */
+
+# include <mln/convert/to_std_set.hh>
+# include <mln/convert/to_window.hh>
+# include <mln/metal/equal.hh>
+
+
+
+namespace mln
+{
+
+ namespace set
+ {
+
+ /*! \brief Union of a couple of windows.
+ *
+ * \relates mln::Window
+ */
+ template <typename Wl, typename Wr>
+ window<mln_dpoint(Wl)>
+ union(const Window<Wl>& lhs, const Window<Wr>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename Wl, typename Wr>
+ window<mln_dpoint(Wl)>
+ union(const Window<Wl>& lhs, const Window<Wr>& rhs)
+ {
+ mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
+ typedef mln_dpoint(Wl) D;
+ std::set<D>
+ sl = convert::to_std_set(lhs),
+ sr = convert::to_std_set(rhs),
+ s;
+ std::set_union(sl.begin(), sl.end(),
+ sr.begin(), sr.end(),
+ std::inserter(s, s.begin()));
+ return convert::to_window(s);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::set
+
+} // end of namespace mln
+
+
+#endif // ! MLN_SET_UNION_HH
Index: mln/set/sym_diff.hh
--- mln/set/sym_diff.hh (revision 0)
+++ mln/set/sym_diff.hh (revision 0)
@@ -0,0 +1,79 @@
+// 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.
+
+#ifndef MLN_SET_SYM_DIFF_HH
+# define MLN_SET_SYM_DIFF_HH
+
+/*! \file mln/set/sym_diff.hh
+ *
+ * \brief Set theoretic symmetrical difference of a couple of sets.
+ */
+
+# include <mln/convert/to_std_set.hh>
+# include <mln/convert/to_window.hh>
+# include <mln/metal/equal.hh>
+
+
+
+namespace mln
+{
+
+ namespace set
+ {
+
+ /// Set theoretic symmetrical difference of \p lhs and \p rhs.
+ template <typename Wl, typename Wr>
+ window<mln_dpoint(Wl)>
+ sym_diff(const Window<Wl>& lhs, const Window<Wr>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename Wl, typename Wr>
+ window<mln_dpoint(Wl)>
+ sym_diff(const Window<Wl>& lhs, const Window<Wr>& rhs)
+ {
+ mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
+ typedef mln_dpoint(Wl) D;
+ std::set<D>
+ sl = convert::to_std_set(lhs),
+ sr = convert::to_std_set(rhs),
+ s;
+ std::set_symmetric_difference(sl.begin(), sl.end(),
+ sr.begin(), sr.end(),
+ std::inserter(s, s.begin()));
+ return convert::to_window(s);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::set
+
+} // end of namespace mln
+
+
+#endif // ! MLN_SET_SYM_DIFF_HH
Index: mln/morpho/includes.hh
--- mln/morpho/includes.hh (revision 1061)
+++ mln/morpho/includes.hh (working copy)
@@ -48,6 +48,8 @@
# include <mln/border/resize.hh>
# include <mln/border/fill.hh>
+# include <mln/geom/sym.hh>
+
# include <mln/morpho/dilation.hh>
# include <mln/morpho/erosion.hh>
Index: mln/morpho/closing.hh
--- mln/morpho/closing.hh (revision 1061)
+++ mln/morpho/closing.hh (working copy)
@@ -64,7 +64,7 @@
O temp(input.domain());
dilation(input, win, temp);
- erosion(temp, -win, output);
+ erosion(temp, geom::sym(win), output);
mln_postcondition(output >= input);
}
Index: mln/morpho/opening.hh
--- mln/morpho/opening.hh (revision 1061)
+++ mln/morpho/opening.hh (working copy)
@@ -64,7 +64,7 @@
O temp(input.domain());
erosion(input, win, temp);
- dilation(temp, -win, output);
+ dilation(temp, geom::sym(win), output);
mln_postcondition(output <= input);
}
Index: mln/level/was.median.hh
--- mln/level/was.median.hh (revision 1061)
+++ mln/level/was.median.hh (working copy)
@@ -59,12 +59,12 @@
min_col = geom::min_col(input), max_col = geom::max_col(input);
window2d
- win_fwd_plus = win - (win + left),
- win_fwd_minus = (win + left) - win,
- win_bkd_plus = win - (win + right),
- win_bkd_minus = (win + right) - win,
- win_bot = win - (win + up),
- win_top = (win + up) - win;
+ win_fwd_plus = set::diff(win, geom::shift(win, left)),
+ win_fwd_minus = set::diff(geom::shift(win, left), win),
+ win_bkd_plus = set::diff(win, geom::shift(win, right)),
+ win_bkd_minus = set::diff(geom::shift(win, right), win),
+ win_bot = set::diff(win, geom::shift(win, up)),
+ win_top = set::diff(geom::shift(win, up), win);
point2d p;
mln_qiter(W)
Index: mln/level/median.hh
--- mln/level/median.hh (revision 1061)
+++ mln/level/median.hh (working copy)
@@ -38,11 +38,14 @@
# include <mln/core/window2d.hh>
# include <mln/core/win/hline2d.hh>
-
# include <mln/core/t_image.hh>
+
# include <mln/accu/median.hh>
# include <mln/canvas/sbrowsing.hh>
+# include <mln/geom/shift.hh>
+# include <mln/set/diff.hh>
+
namespace mln
{
@@ -98,9 +101,12 @@
// aux data
med(input.values()),
p(),
- win_fp(win - (win + left)), win_fm((win + left) - win),
- win_bp(win - (win + right)), win_bm((win + right) - win),
- win_dp(win - (win + up)), win_dm((win + up) - win),
+ win_fp(set::diff(win, geom::shift(win, left))),
+ win_fm(set::diff(geom::shift(win, left), win)),
+ win_bp(set::diff(win, geom::shift(win, right))),
+ win_bm(set::diff(geom::shift(win, right), win)),
+ win_dp(set::diff(win, geom::shift(win, up))),
+ win_dm(set::diff(geom::shift(win, up), win)),
q_fp(win_fp, p), q_fm(win_fm, p),
q_bp(win_bp, p), q_bm(win_bm, p),
q_dp(win_dp, p), q_dm(win_dm, p)
Index: mln/level/fast_median.hh
--- mln/level/fast_median.hh (revision 1061)
+++ mln/level/fast_median.hh (working copy)
@@ -36,6 +36,8 @@
# include <mln/core/concept/image.hh>
# include <mln/core/window2d.hh>
# include <mln/accu/median.hh>
+# include <mln/geom/shift.hh>
+# include <mln/set/diff.hh>
namespace mln
@@ -77,12 +79,12 @@
min_col = geom::min_col(input), max_col = geom::max_col(input);
window2d
- win_fwd_plus = win - (win + left),
- win_fwd_minus = (win + left) - win,
- win_bkd_plus = win - (win + right),
- win_bkd_minus = (win + right) - win,
- win_bot = win - (win + up),
- win_top = (win + up) - win;
+ win_fwd_plus = set::diff(win, geom::shift(win, left)),
+ win_fwd_minus = set::diff(geom::shift(win, left), win),
+ win_bkd_plus = set::diff(win, geom::shift(win, right)),
+ win_bkd_minus = set::diff(geom::shift(win, right), win),
+ win_bot = set::diff(win, geom::shift(win, up)),
+ win_top = set::diff(geom::shift(win, up), win);
accu::median<mln_vset(I)> med(input.values());