https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add morphological top-hats and contrast.
* tests/morpho_gradient.cc: Fix doc.
* mln/geom/pmin_pmax.hh (pmin_pmax): Overload for point set.
* mln/geom/bbox.hh: Update.
* mln/morpho/includes.hh (include): Add mln/test/positive.hh
and mln/arith/plus.hh.
* mln/morpho/gradient.hh: Add commentaries.
* tests/morpho_contrast.cc: New.
* mln/morpho/contrast.hh: New.
* mln/morpho/top_hat.hh: New.
mln/geom/bbox.hh | 3 -
mln/geom/pmin_pmax.hh | 91 ++++++++++++++++++++++++++----
mln/morpho/contrast.hh | 82 +++++++++++++++++++++++++++
mln/morpho/gradient.hh | 21 +++----
mln/morpho/includes.hh | 3 +
mln/morpho/top_hat.hh | 138 +++++++++++++++++++++++++++++++++++++++++++++++
tests/morpho_contrast.cc | 61 ++++++++++++++++++++
tests/morpho_gradient.cc | 4 -
8 files changed, 373 insertions(+), 30 deletions(-)
Index: tests/morpho_gradient.cc
--- tests/morpho_gradient.cc (revision 1058)
+++ tests/morpho_gradient.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/erosion.cc
+/*! \file tests/morpho_gradient.cc
*
- * \brief Test on mln::morpho::erosion.
+ * \brief Test on mln::morpho::gradient.
*/
#include <mln/core/image2d_b.hh>
Index: tests/morpho_contrast.cc
--- tests/morpho_contrast.cc (revision 0)
+++ tests/morpho_contrast.cc (revision 0)
@@ -0,0 +1,61 @@
+// 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/morpho_contrast.cc
+ *
+ * \brief Test on mln::morpho::contrast.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/win/rectangle2d.hh>
+
+#include <mln/io/load_pgm.hh>
+#include <mln/io/save_pgm.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/morpho/contrast.hh>
+#include <mln/level/saturate.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ win::rectangle2d rect(5, 5);
+ border::thickness = 2;
+
+ image2d_b<int_u8>
+ lena = io::load_pgm("../img/tiny.pgm"),
+ out(lena.domain());
+
+ image2d_b<int> tmp(lena.domain());
+ morpho::contrast(lena, rect, tmp);
+
+ level::saturate(tmp, out);
+ io::save_pgm(out, "out.pgm");
+}
Index: mln/geom/pmin_pmax.hh
--- mln/geom/pmin_pmax.hh (revision 1058)
+++ mln/geom/pmin_pmax.hh (working copy)
@@ -36,6 +36,10 @@
# include <utility>
+# include <mln/core/concept/point_set.hh>
+# include <mln/core/concept/box.hh>
+
+
namespace mln
{
@@ -44,6 +48,19 @@
{
+ /// Compute the minimum and maximum points of point set \p s.
+ template <typename S>
+ std::pair<mln_point(S), mln_point(S)>
+ pmin_pmax(const Point_Set<S>& s);
+
+
+ /// Compute the minimum and maximum points, \p pmin and \p max,
+ /// of point set \p s.
+ template <typename S>
+ void
+ pmin_pmax(const Point_Set<S>& s, mln_point(S)& pmin, mln_point(S)& pmax);
+
+
/// Compute the minimum and maximum points when browsing with
/// iterator \p p.
template <typename I>
@@ -61,40 +78,86 @@
# ifndef MLN_INCLUDE_ONLY
+
+ // Versions with point iterator.
+
template <typename I>
- std::pair<mln_point(I), mln_point(I)>
- pmin_pmax(Point_Iterator<I>& p_)
+ void
+ pmin_pmax(const Point_Iterator<I>& p_, mln_point(I)& pmin, mln_point(I)& pmax)
{
- I& p = exact(p_);
-
- typedef mln_point(I) P;
- std::pair<P, P> tmp;
- P& pmin = tmp.first;
- P& pmax = tmp.second;
+ I p = exact(p_); // a copy of p_
// init with first point
p.start();
+ mln_precondition(p.is_valid());
pmin = pmax = p;
// update with remaining points
+ typedef mln_point(I) P;
for_all_remaining(p)
for (unsigned i = 0; i < P::dim; ++i)
if (p[i] < pmin[i])
pmin[i] = p[i];
else if (p[i] > pmax[i])
pmax[i] = p[i];
+ }
+ template <typename I>
+ std::pair<mln_point(I), mln_point(I)>
+ pmin_pmax(const Point_Iterator<I>& p)
+ {
+ typedef mln_point(I) P;
+ std::pair<P, P> tmp;
+ pmin_pmax(p, tmp.first, tmp.second); // calls the previous version
return tmp;
}
- template <typename I>
+
+ // Versions with point set.
+
+ namespace impl
+ {
+
+ // General case.
+
+ template <typename S>
void
- pmin_pmax(const Point_Iterator<I>& p, mln_point(I)& pmin, mln_point(I)& pmax)
+ pmin_pmax_(const Point_Set<S>& s, mln_point(S)& pmin, mln_point(S)& pmax)
{
- typedef mln_point(I) P;
- std::pair<P, P> tmp = pmin_pmax(p);
- pmin = tmp.first;
- pmax = tmp.second;
+ mln_piter(S) it(exact(s));
+ pmin_pmax(it, pmin, pmax);
+ }
+
+ // Box.
+
+ template <typename B>
+ void
+ pmin_pmax_(const Box<B>& b, mln_point(B)& pmin, mln_point(B)& pmax)
+ {
+ pmin = exact(b).pmin();
+ pmax = exact(b).pmax();
+ }
+
+ } // end of namespace mln::geom::impl
+
+
+ template <typename S>
+ void
+ pmin_pmax(const Point_Set<S>& s, mln_point(S)& pmin, mln_point(S)& pmax)
+ {
+ mln_precondition(exact(s).npoints() != 0);
+ impl::pmin_pmax_(exact(s), pmin, pmax);
+ }
+
+ template <typename S>
+ std::pair<mln_point(S), mln_point(S)>
+ pmin_pmax(const Point_Set<S>& s)
+ {
+ mln_precondition(exact(s).npoints() != 0);
+ typedef mln_point(S) P;
+ std::pair<P, P> tmp;
+ pmin_pmax(p_, tmp.first, tmp.second); // calls the previous version
+ return tmp;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/geom/bbox.hh
--- mln/geom/bbox.hh (revision 1058)
+++ mln/geom/bbox.hh (working copy)
@@ -100,8 +100,7 @@
mln_precondition(pset.npoints() != 0);
typedef mln_point(S) P;
- mln_piter(S) p(pset);
- std::pair<P, P> pp = geom::pmin_pmax(p);
+ std::pair<P, P> pp = geom::pmin_pmax(pset);
box_<P> tmp(pp.first, pp.second);
// FIXME: mln_postcondition(tmp <= pset.bbox());
Index: mln/morpho/includes.hh
--- mln/morpho/includes.hh (revision 1058)
+++ mln/morpho/includes.hh (working copy)
@@ -40,11 +40,14 @@
# include <mln/accu/min.hh>
# include <mln/accu/max.hh>
+# include <mln/arith/plus.hh>
# include <mln/arith/minus.hh>
# include <mln/level/compare.hh>
# include <mln/level/fill.hh>
+# include <mln/test/positive.hh>
+
# include <mln/border/resize.hh>
# include <mln/border/fill.hh>
Index: mln/morpho/gradient.hh
--- mln/morpho/gradient.hh (revision 1058)
+++ mln/morpho/gradient.hh (working copy)
@@ -31,10 +31,11 @@
/*! \file mln/morpho/gradient.hh
*
* \brief Morphological gradient.
+ *
+ * \todo Save memory.
*/
# include <mln/morpho/includes.hh>
-# include <mln/test/positive.hh>
namespace mln
@@ -82,11 +83,10 @@
mln_precondition(output.domain() = input.domain());
mln_precondition(! win.is_empty());
+ dilation(input, win, output); // output = dilation
O temp(input.domain());
- erosion(input, win, temp);
-
- dilation(input, win, output);
- arith::minus_inplace(output, temp);
+ erosion(input, win, temp); // temp = erosion
+ arith::minus_inplace(output, temp); // now output = dilation - erosion
mln_postcondition(test::positive(output));
}
@@ -103,9 +103,8 @@
mln_precondition(! win.is_empty());
O temp(input.domain());
- erosion(input, win, temp);
-
- arith::minus(input, temp, output);
+ erosion(input, win, temp); // temp = erosion
+ arith::minus(input, temp, output); // output = input - erosion
mln_postcondition(test::positive(output));
}
@@ -121,10 +120,8 @@
mln_precondition(output.domain() = input.domain());
mln_precondition(! win.is_empty());
- O temp(input.domain());
- dilation(input, win, temp);
-
- arith::minus(temp, input, output);
+ dilation(input, win, output); // output = dilation
+ arith::minus_inplace(output, input); // now output = dilation - input
mln_postcondition(test::positive(output));
}
Index: mln/morpho/contrast.hh
--- mln/morpho/contrast.hh (revision 0)
+++ mln/morpho/contrast.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_MORPHO_CONTRAST_HH
+# define MLN_MORPHO_CONTRAST_HH
+
+/*! \file mln/morpho/contrast.hh
+ *
+ * \brief Morphological contrast operator (based on top-hats).
+ *
+ * \todo Save memory.
+ */
+
+# include <mln/morpho/top_hat.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /*! Morphological contrast operator (based on top-hats).
+ *
+ * This operator is Id + wth_B - bth_B.
+ */
+ template <typename I, typename W, typename O>
+ void contrast(const Image<I>& input, const Window<W>& win,
+ Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename W, typename O>
+ void contrast(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ top_hat_white(input, win, output); // output = wth
+ arith::plus_inplace(output, input); // now output = wth + input
+ O temp(input.domain());
+ top_hat_black(input, win, temp); // temp = bth
+ arith::minus_inplace(output, temp); // now output = wth + input - bth
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CONTRAST_HH
Index: mln/morpho/top_hat.hh
--- mln/morpho/top_hat.hh (revision 0)
+++ mln/morpho/top_hat.hh (revision 0)
@@ -0,0 +1,138 @@
+// 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_MORPHO_TOP_HAT_HH
+# define MLN_MORPHO_TOP_HAT_HH
+
+/*! \file mln/morpho/top_hat.hh
+ *
+ * \brief Morphological top-hats.
+ *
+ * \todo Save memory.
+ */
+
+# include <mln/morpho/opening.hh>
+# include <mln/morpho/closing.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /*! Morphological white top-hat (for object / light objects).
+ *
+ * This operator is Id - ope_B.
+ */
+ template <typename I, typename W, typename O>
+ void top_hat_white(const Image<I>& input, const Window<W>& win,
+ Image<O>& output);
+
+
+ /*! Morphological black top-hat (for background / dark objects).
+ *
+ * This operator is clo_B - Id.
+ */
+ template <typename I, typename W, typename O>
+ void top_hat_black(const Image<I>& input, const Window<W>& win,
+ Image<O>& output);
+
+
+ /*! Morphological self-complementary top-hat.
+ *
+ * This operator is \n
+ * = top_hat_white + top_hat_black \n
+ * = (input - opening) + (closing - input) \n
+ * = closing - opening. \n
+ */
+ template <typename I, typename W, typename O>
+ void top_hat_self_complementary(const Image<I>& input, const Window<W>& win,
+ Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename W, typename O>
+ void top_hat_white(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ O temp(input.domain());
+ opening(input, win, temp); // temp = opening
+ arith::minus(input, temp, output); // output = input - opening
+
+ mln_postcondition(test::positive(output));
+ }
+
+ template <typename I, typename W, typename O>
+ void top_hat_black(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ closing(input, win, output); // output = closing
+ arith::minus_inplace(output, input); // now output = closing - input
+
+ mln_postcondition(test::positive(output));
+ }
+
+ template <typename I, typename W, typename O>
+ void top_hat_self_complementary(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ closing(input, win, output); // output = closing
+ O temp(input.domain());
+ opening(input, win, temp); // temp = opening
+ arith::minus_inplace(output, temp); // now output = closing - opening
+
+ mln_postcondition(test::positive(output));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_TOP_HAT_HH
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Replace 2D specific methods in 2D images by routines.
* mln/geom/max_col.hh: New.
* mln/geom/nrows.hh: New.
* mln/geom/min_row.hh: New.
* mln/geom/max_row.hh: New.
* mln/geom/ncols.hh: New.
* mln/geom/size2d.hh: New.
* mln/geom/min_col.hh: New.
* mln/core/image2d_b.hh (image2d_b): Remove inheritance to
box_impl.
* tests/image2d_b.cc,
* mln/core/pixter2d_b.hh,
* mln/io/save_pgm.hh,
* mln/io/load_pgm.hh,
* mln/level/was.median.hh,
* mln/level/median.hh,
* mln/level/fast_median.hh,
* mln/canvas/sbrowsing.hh: Update.
mln/canvas/sbrowsing.hh | 7 ++--
mln/core/image2d_b.hh | 4 --
mln/core/pixter2d_b.hh | 5 ++-
mln/geom/max_col.hh | 66 ++++++++++++++++++++++++++++++++++++++++++++++
mln/geom/max_row.hh | 66 ++++++++++++++++++++++++++++++++++++++++++++++
mln/geom/min_col.hh | 66 ++++++++++++++++++++++++++++++++++++++++++++++
mln/geom/min_row.hh | 66 ++++++++++++++++++++++++++++++++++++++++++++++
mln/geom/ncols.hh | 67 +++++++++++++++++++++++++++++++++++++++++++++++
mln/geom/nrows.hh | 67 +++++++++++++++++++++++++++++++++++++++++++++++
mln/geom/size2d.hh | 40 ++++++++++++++++++++++++++++
mln/io/load_pgm.hh | 10 +++----
mln/io/save_pgm.hh | 17 +++++------
mln/level/fast_median.hh | 4 +-
mln/level/median.hh | 10 ++++---
mln/level/was.median.hh | 13 ++++-----
tests/image2d_b.cc | 3 +-
16 files changed, 475 insertions(+), 36 deletions(-)
Index: tests/image2d_b.cc
--- tests/image2d_b.cc (revision 1057)
+++ tests/image2d_b.cc (working copy)
@@ -31,6 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
+#include <mln/geom/size2d.hh>
int main()
@@ -43,6 +44,6 @@
image2d_b<int> f(nrows, ncols, border);
- mln_assertion(f.npoints() = f.nrows() * f.ncols());
+ mln_assertion(f.npoints() = geom::nrows(f) * geom::ncols(f));
mln_assertion(f.ncells() = (nrows + 2 * border) * (ncols + 2 * border));
}
Index: mln/geom/max_col.hh
--- mln/geom/max_col.hh (revision 0)
+++ mln/geom/max_col.hh (revision 0)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_MAX_COL_HH
+# define MLN_GEOM_MAX_COL_HH
+
+/*! \file mln/geom/max_col.hh
+ *
+ * \brief Give the maximum column of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the maximum column of an image.
+ template <typename I>
+ mln_coord(I) max_col(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_coord(I) max_col(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return exact(ima).bbox().pmax().col();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_MAX_COL_HH
Index: mln/geom/nrows.hh
--- mln/geom/nrows.hh (revision 0)
+++ mln/geom/nrows.hh (revision 0)
@@ -0,0 +1,67 @@
+// 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_NROWS_HH
+# define MLN_GEOM_NROWS_HH
+
+/*! \file mln/geom/nrows.hh
+ *
+ * \brief Give the number of rows of an image.
+ */
+
+# include <mln/geom/min_row.hh>
+# include <mln/geom/max_row.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the number of rows of an image.
+ template <typename I>
+ unsigned nrows(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ unsigned nrows(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return geom::max_row(ima) - geom::min_row(ima) + 1;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_NROWS_HH
Index: mln/geom/min_row.hh
--- mln/geom/min_row.hh (revision 0)
+++ mln/geom/min_row.hh (revision 0)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_MIN_ROW_HH
+# define MLN_GEOM_MIN_ROW_HH
+
+/*! \file mln/geom/min_row.hh
+ *
+ * \brief Give the minimum row of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the minimum row of an image.
+ template <typename I>
+ mln_coord(I) min_row(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_coord(I) min_row(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return exact(ima).bbox().pmin().row();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_MIN_ROW_HH
Index: mln/geom/max_row.hh
--- mln/geom/max_row.hh (revision 0)
+++ mln/geom/max_row.hh (revision 0)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_MAX_ROW_HH
+# define MLN_GEOM_MAX_ROW_HH
+
+/*! \file mln/geom/max_row.hh
+ *
+ * \brief Give the maximum row of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the maximum row of an image.
+ template <typename I>
+ mln_coord(I) max_row(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_coord(I) max_row(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return exact(ima).bbox().pmax().row();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_MAX_ROW_HH
Index: mln/geom/ncols.hh
--- mln/geom/ncols.hh (revision 0)
+++ mln/geom/ncols.hh (revision 0)
@@ -0,0 +1,67 @@
+// 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_NCOLS_HH
+# define MLN_GEOM_NCOLS_HH
+
+/*! \file mln/geom/ncols.hh
+ *
+ * \brief Give the number of columns of an image.
+ */
+
+# include <mln/geom/min_col.hh>
+# include <mln/geom/max_col.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the number of columns of an image.
+ template <typename I>
+ unsigned ncols(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ unsigned ncols(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return geom::max_col(ima) - geom::min_col(ima) + 1;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_NCOLS_HH
Index: mln/geom/size2d.hh
--- mln/geom/size2d.hh (revision 0)
+++ mln/geom/size2d.hh (revision 0)
@@ -0,0 +1,40 @@
+// 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_SIZE2D_HH
+# define MLN_GEOM_SIZE2D_HH
+
+/*! \file mln/geom/size2d.hh
+ *
+ * \brief Facade to include 2D size access routines.
+ */
+
+# include <mln/geom/nrows.hh>
+# include <mln/geom/ncols.hh>
+
+
+#endif // ! MLN_GEOM_SIZE2D_HH
Index: mln/geom/min_col.hh
--- mln/geom/min_col.hh (revision 0)
+++ mln/geom/min_col.hh (revision 0)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_MIN_COL_HH
+# define MLN_GEOM_MIN_COL_HH
+
+/*! \file mln/geom/min_col.hh
+ *
+ * \brief Give the minimum column of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the minimum column of an image.
+ template <typename I>
+ mln_coord(I) min_col(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_coord(I) min_col(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return exact(ima).bbox().pmin().col();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_MIN_COL_HH
Index: mln/core/pixter2d_b.hh
--- mln/core/pixter2d_b.hh (revision 1057)
+++ mln/core/pixter2d_b.hh (working copy)
@@ -35,6 +35,7 @@
# include <mln/core/internal/pixel_iterator_base.hh>
# include <mln/core/point2d.hh>
+# include <mln/geom/size2d.hh>
@@ -84,8 +85,8 @@
{
mln_precondition(image.has_data());
border_x2_ = 2 * image.border();
- row_offset_ = image.max_col() - image.min_col() + 1 + border_x2_;
- eor_ = & image.at(image.min_row(), image.max_col()) + 1;
+ row_offset_ = geom::max_col(image) - geom::min_col(image) + 1 + border_x2_;
+ eor_ = & image.at(geom::min_row(image), geom::max_col(image)) + 1;
}
template <typename I>
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1057)
+++ mln/core/image2d_b.hh (working copy)
@@ -34,7 +34,6 @@
*/
# include <mln/core/internal/image_base.hh>
-# include <mln/core/internal/box_impl.hh>
# include <mln/core/box2d.hh>
# include <mln/border/thickness.hh>
@@ -75,8 +74,7 @@
* thickness around data.
*/
template <typename T>
- struct image2d_b : public internal::image_base_< box2d, image2d_b<T> >,
- public internal::box_impl_< 2, int, image2d_b<T> >
+ struct image2d_b : public internal::image_base_< box2d, image2d_b<T> >
{
// Warning: just to make effective types appear in Doxygen:
typedef box2d pset;
Index: mln/io/save_pgm.hh
--- mln/io/save_pgm.hh (revision 1057)
+++ mln/io/save_pgm.hh (working copy)
@@ -33,6 +33,7 @@
# include <fstream>
# include <mln/core/image2d_b.hh>
+# include <mln/geom/size2d.hh>
# include <mln/value/int_u8.hh>
@@ -53,16 +54,16 @@
}
file << "P5" << std::endl;
file << "# olena" << std::endl;
- file << ima.ncols() << ' ' << ima.nrows() << std::endl;
+ file << geom::ncols(ima) << ' ' << geom::nrows(ima) << std::endl;
file << "255" << std::endl;
const int
- min_row = ima.domain().pmin().row(),
- max_row = ima.domain().pmax().row();
+ min_row = geom::min_row(ima),
+ max_row = geom::max_row(ima);
point2d p;
if (sizeof(value::int_u8) = 1)
{
- p.col() = ima.domain().pmin().col();
- size_t len = ima.ncols();
+ p.col() = geom::min_col(ima);
+ size_t len = geom::ncols(ima);
for (p.row() = min_row; p.row() <= max_row; ++p.row())
file.write((char*)(& ima(p)), len);
}
@@ -70,10 +71,8 @@
{
// FIXME: code for g++-2.95 when sizeof(int_u8) = 2!!!
const int
- min_col = ima.domain().pmin().col(),
- max_col = ima.domain().pmax().col();
- std::cout << min_row << ' ' << max_row << std::endl;
- std::cout << min_col << ' ' << max_col << std::endl;
+ min_col = geom::min_col(ima),
+ max_col = geom::max_col(ima);
for (p.row() = min_row; p.row() <= max_row; ++p.row())
for (p.col() = min_col; p.col() <= max_col; ++p.col())
{
Index: mln/io/load_pgm.hh
--- mln/io/load_pgm.hh (revision 1057)
+++ mln/io/load_pgm.hh (working copy)
@@ -137,11 +137,11 @@
point2d p = make::point2d(0, ima.domain().pmin().col());
typedef mln_value(I) V;
const mln_coord(I)
- min_row = ima.domain().pmin().row(),
- max_row = ima.domain().pmax().row();
+ min_row = geom::min_row(ima),
+ max_row = geom::max_row(ima);
if (sizeof(V) = 1)
{
- size_t len = ima.ncols() * sizeof(mln_enc(V));
+ size_t len = geom::ncols(ima) * sizeof(mln_enc(V));
for (p.row() = min_row; p.row() <= max_row; ++p.row())
file.read((char*)(& ima(p)), len);
}
@@ -149,8 +149,8 @@
{
// FIXME: code for g++-2.95 when sizeof(int_u8) = 2!!!
const mln_coord(I)
- min_col = ima.domain().pmin().col(),
- max_col = ima.domain().pmax().col();
+ min_col = geom::min_col(ima),
+ max_col = geom::max_col(ima);
for (p.row() = min_row; p.row() <= max_row; ++p.row())
for (p.col() = min_col; p.col() <= max_col; ++p.col())
{
Index: mln/level/was.median.hh
--- mln/level/was.median.hh (revision 1057)
+++ mln/level/was.median.hh (working copy)
@@ -55,8 +55,8 @@
mln_precondition(output.has_data());
int
- min_row = input.min_row(), max_row = input.max_row(),
- min_col = input.min_col(), max_col = input.max_col();
+ min_row = geom::min_row(input), max_row = geom::max_row(input),
+ min_col = geom::min_col(input), max_col = geom::max_col(input);
window2d
win_fwd_plus = win - (win + left),
@@ -76,7 +76,7 @@
// initialization
- p = input.domain().pmin() + up;
+ p = input.bbox().pmin() + up;
med.init();
{
mln_qiter(W) q(win, p);
@@ -137,9 +137,8 @@
{
const int
- max_row = input.max_row(),
- min_col = input.min_col(),
- max_col = input.max_col();
+ min_row = geom::min_row(input), max_row = geom::max_row(input),
+ min_col = geom::min_col(input), max_col = geom::max_col(input);
const unsigned half = win.length() / 2;
point2d p;
@@ -148,7 +147,7 @@
accu::median<mln_vset(I)> med(input.values());
- for (row = input.min_row(); row <= max_row; ++row)
+ for (row = min_row; row <= max_row; ++row)
{
int ct, cu;
Index: mln/level/median.hh
--- mln/level/median.hh (revision 1057)
+++ mln/level/median.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/size2d.hh>
# include <mln/core/window2d.hh>
# include <mln/core/win/hline2d.hh>
@@ -162,9 +163,10 @@
{
typedef mln_coord(I) coord;
const coord
- max_row = input.bbox().max_row(),
- min_col = input.bbox().min_col(),
- max_col = input.bbox().max_col();
+ min_row = geom::min_row(input),
+ max_row = geom::max_row(input),
+ min_col = geom::min_col(input),
+ max_col = geom::max_col(input);
const coord half = win.length() / 2;
point2d p;
@@ -179,7 +181,7 @@
accu::median<mln_vset(I)> med(input.values());
- for (row = input.bbox().min_row(); row <= max_row; ++row)
+ for (row = min_row; row <= max_row; ++row)
{
pt.row() = pu.row() = row;
Index: mln/level/fast_median.hh
--- mln/level/fast_median.hh (revision 1057)
+++ mln/level/fast_median.hh (working copy)
@@ -73,8 +73,8 @@
mln_precondition(output.has_data());
int
- min_row = input.min_row(), max_row = input.max_row(),
- min_col = input.min_col(), max_col = input.max_col();
+ min_row = geom::min_row(input), max_row = geom::max_row(input),
+ min_col = geom::min_col(input), max_col = geom::max_col(input);
window2d
win_fwd_plus = win - (win + left),
Index: mln/canvas/sbrowsing.hh
--- mln/canvas/sbrowsing.hh (revision 1057)
+++ mln/canvas/sbrowsing.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/core/dpoint2d.hh> // for "up"
+# include <mln/geom/size2d.hh>
namespace mln
@@ -69,11 +70,11 @@
{
mln_precondition(f.input.has_data());
int
- min_row = f.input.min_row(), max_row = f.input.max_row(),
- min_col = f.input.min_col(), max_col = f.input.max_col();
+ min_row = geom::min_row(f.input), max_row = geom::max_row(f.input),
+ min_col = geom::min_col(f.input), max_col = geom::max_col(f.input);
// p
- f.p = f.input.domain().pmin() + up;
+ f.p = f.input.bbox().pmin() + up;
int& row = f.p.row();
int& col = f.p.col();
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment morpho and add saturation for int-like types.
* mln/arith/minus.hh (minus_inplace): New.
* mln/arith/plus.hh (plus_inplace): New.
* mln/fun/v2v/saturate.hh: New.
* mln/level/abs.hh: New.
* mln/level/saturate.hh: New.
* mln/linear/sobel.hh: Update.
* mln/math/round.hh (round_): Rename as...
(round): ...this.
* tests/convolve.cc,
* tests/line_convolve.cc,
* tests/sobel.cc: Update.
* mln/linear/line_convolve.hh,
* mln/linear/line_x2_convolve.hh,
* mln/make/w_window_line.hh: Unconst array literals to help
g++-2.95.
* mln/core/concept/function.hh (Function_v2b): New.
* mln/core/macros.hh (mln_value_): New.
* mln/fun/ops.hh (l_, r_, f_): Add const.
(mln_decl_binary_expr_): Use 'Out' part of fun type name.
(mln_decl_unary_expr_): Likewise.
New overload for "v2v -> v2b" operators.
* mln/fun/v2v/id.hh: New.
* mln/level/assign.hh,
* mln/level/fill.hh: Add todo.
* mln/morpho/erosion.hh: Update.
* mln/morpho/includes.hh,
* mln/morpho/closing.hh,
* mln/morpho/dilation.hh
* mln/morpho/gradient.hh
* mln/morpho/opening.hh: New.
* mln/test: New directory.
* mln/test/positive.hh,
* mln/test/predicate.hh,
* tests/morpho_gradient.cc: New.
mln/arith/minus.hh | 72 +++++++++++++++++++--
mln/arith/plus.hh | 42 ++++++++++++
mln/core/concept/function.hh | 70 ++++++++++++++++++++
mln/core/macros.hh | 1
mln/fun/internal/selector.hh | 22 +++---
mln/fun/ops.hh | 42 +++++++++---
mln/fun/v2v/id.hh | 77 ++++++++++++++++++++++
mln/fun/v2v/saturate.hh | 105 ++++++++++++++++++++++++++++++
mln/level/abs.hh | 89 ++++++++++++++++++++++++++
mln/level/assign.hh | 2
mln/level/fill.hh | 2
mln/level/saturate.hh | 121 +++++++++++++++++++++++++++++++++++
mln/linear/line_convolve.hh | 4 -
mln/linear/line_x2_convolve.hh | 4 -
mln/linear/sobel.hh | 16 ++--
mln/make/w_window_line.hh | 4 -
mln/math/round.hh | 4 -
mln/morpho/closing.hh | 79 +++++++++++++++++++++++
mln/morpho/dilation.hh | 102 ++++++++++++++++++++++++++++++
mln/morpho/erosion.hh | 32 ++++-----
mln/morpho/gradient.hh | 139 +++++++++++++++++++++++++++++++++++++++++
mln/morpho/includes.hh | 56 ++++++++++++++++
mln/morpho/opening.hh | 79 +++++++++++++++++++++++
mln/test/positive.hh | 73 +++++++++++++++++++++
mln/test/predicate.hh | 128 +++++++++++++++++++++++++++++++++++++
tests/convolve.cc | 2
tests/line_convolve.cc | 3
tests/morpho_gradient.cc | 58 +++++++++++++++++
tests/sobel.cc | 6 -
tests/test_positive.cc | 64 ++++++++++++++++++
30 files changed, 1431 insertions(+), 67 deletions(-)
Index: tests/convolve.cc
--- tests/convolve.cc (revision 1055)
+++ tests/convolve.cc (working copy)
@@ -63,7 +63,7 @@
image2d_b<float> tmp(lena.domain());
linear::convolve(lena, w, tmp);
- level::transform(tmp, math::round_<int_u8>(), out);
+ level::transform(tmp, math::round<int_u8>(), out);
io::save_pgm(out, "out.pgm");
}
Index: tests/sobel.cc
--- tests/sobel.cc (revision 1055)
+++ tests/sobel.cc (working copy)
@@ -32,13 +32,11 @@
#include <mln/core/image2d_b.hh>
#include <mln/value/int_u8.hh>
+#include <mln/level/saturate.hh>
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
-#include <mln/math/round_sat.hh>
-#include <mln/level/transform.hh>
-
#include <mln/border/thickness.hh>
#include <mln/linear/sobel.hh>
@@ -57,6 +55,6 @@
image2d_b<int> tmp(lena.domain());
linear::sobel(lena, tmp);
- level::transform(tmp, math::round_sat_<int_u8>(), out);
+ level::saturate(tmp, out);
io::save_pgm(out, "out.pgm");
}
Index: tests/test_positive.cc
--- tests/test_positive.cc (revision 0)
+++ tests/test_positive.cc (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/test_positive.cc
+ *
+ * \brief Tests on mln::test::positive.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/level/fill.hh>
+#include <mln/test/positive.hh>
+
+
+// both test routines can be called with a p2b function
+
+template <typename F>
+void test_p2v(const mln::Function_p2v<F>&)
+{
+}
+
+template <typename F>
+void test_v2b(const mln::Function_v2b<F>&)
+{
+}
+
+
+
+int main()
+{
+ using namespace mln;
+ typedef image2d_b<int> I;
+
+ I ima(1,1);
+ level::fill(ima, 0);
+
+ test_v2b(fun::v2v::id<mln_value_(I)>() >= pw::cst(0));
+
+ // test2(fun::v2v::id<mln_value_(I)>() >= pw::cst(0));
+ // test::positive(ima);
+}
Index: tests/line_convolve.cc
--- tests/line_convolve.cc (revision 1055)
+++ tests/line_convolve.cc (working copy)
@@ -36,7 +36,6 @@
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
#include <mln/math/round.hh>
-#include <mln/math/round_sat.hh>
#include <mln/level/transform.hh>
#include <mln/core/w_window2d_float.hh>
@@ -59,6 +58,6 @@
float ws[] = { .11, .11, .11, .11, .11, .11, .11, .11, .11 };
linear::line_convolve(lena, ws, tmp);
- level::transform(tmp, math::round_<int_u8>(), out);
+ level::transform(tmp, math::round<int_u8>(), out);
io::save_pgm(out, "out.pgm");
}
Index: tests/morpho_gradient.cc
--- tests/morpho_gradient.cc (revision 0)
+++ tests/morpho_gradient.cc (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/erosion.cc
+ *
+ * \brief Test on mln::morpho::erosion.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/win/rectangle2d.hh>
+
+#include <mln/io/load_pgm.hh>
+#include <mln/io/save_pgm.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/morpho/gradient.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ win::rectangle2d rect(5, 5);
+ border::thickness = 2;
+
+ image2d_b<int_u8>
+ lena = io::load_pgm("../img/tiny.pgm"),
+ out(lena.domain());
+
+ morpho::gradient(lena, rect, out);
+ io::save_pgm(out, "out.pgm");
+}
Index: mln/test/positive.hh
--- mln/test/positive.hh (revision 0)
+++ mln/test/positive.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_TEST_POSITIVE_HH
+# define MLN_TEST_POSITIVE_HH
+
+/*! \file mln/test/positive.hh
+ *
+ * \brief Test if an image only contains positive values.
+ */
+
+# include <mln/test/predicate.hh>
+# include <mln/pw/all.hh>
+# include <mln/fun/v2v/id.hh>
+
+
+namespace mln
+{
+
+ namespace test
+ {
+
+ /// Test if an image only contains positive values.
+ template <typename I>
+ bool positive(const Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ bool positive(const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+ return test::predicate(input.domain(),
+ pw::value(input) >= pw::cst(0));
+ // FIXME: test the version below.
+// return test::predicate(input,
+// fun::v2v::id<mln_value(I)>() >= pw::cst(0));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::test
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TEST_POSITIVE_HH
Index: mln/test/predicate.hh
--- mln/test/predicate.hh (revision 0)
+++ mln/test/predicate.hh (revision 0)
@@ -0,0 +1,128 @@
+// 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_TEST_PREDICATE_HH
+# define MLN_TEST_PREDICATE_HH
+
+/*! \file mln/test/predicate.hh
+ *
+ * \brief Test a predicate on the pixel values of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/point_set.hh>
+
+
+namespace mln
+{
+
+ namespace test
+ {
+
+ /*! Test if all pixel values of \p ima verify the predicate \p
+ * f.
+ *
+ * \param[in] ima The image.
+ * \param[in] f The predicate.
+ */
+ template <typename I, typename F>
+ bool predicate(const Image<I>& ima, const Function_v2b<F>& f);
+
+
+ /*! Test if all points of \p pset verify the predicate \p f.
+ *
+ * \param[in] pset The point set.
+ * \param[in] f The predicate.
+ */
+ template <typename S, typename F>
+ bool predicate(const Point_Set<S>& pset, const Function_p2b<F>& f);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I, typename F>
+ bool predicate_(const Image<I>& ima_, const F& f)
+ {
+ const I& ima = exact(ima_);
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ if (! f(ima(p)))
+ return false;
+ return true;
+ }
+
+ template <typename I, typename F>
+ bool predicate_(const Fast_Image<I>& ima_, const F& f)
+ {
+ const I& ima = exact(ima_);
+ mln_pixter(const I) pxl(ima);
+ for_all(pxl)
+ if (! f(pxl.val()))
+ return false;
+ return true;
+ }
+
+ template <typename S, typename F>
+ bool predicate_(const Point_Set<S>& pset, const F& f)
+ {
+ mln_piter(S) p(exact(pset));
+ for_all(p)
+ if (! f(p))
+ return false;
+ return true;
+ }
+
+ } // end of namespace mln::test::impl
+
+
+ // Facades.
+
+ template <typename I, typename F>
+ bool predicate(const Image<I>& ima, const Function_v2b<F>& f)
+ {
+ mln_precondition(exact(ima).has_data());
+ return impl::predicate_(exact(ima), exact(f));
+ }
+
+ template <typename S, typename F>
+ bool predicate(const Point_Set<S>& pset, const Function_p2b<F>& f)
+ {
+ return impl::predicate_(exact(pset), exact(f));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::test
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TEST_PREDICATE_HH
Index: mln/pw/value.hh
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 1055)
+++ mln/core/macros.hh (working copy)
@@ -148,6 +148,7 @@
/// Shortcut to access the value type associated to T.
# define mln_value(T) typename T::value
+# define mln_value_(T) T::value
/// Shortcut to the kind of values for an image with type \c I.
# define mln_value_kind(I) typename mln::value::props< mln_value(I) >::kind
Index: mln/core/concept/function.hh
--- mln/core/concept/function.hh (revision 1055)
+++ mln/core/concept/function.hh (working copy)
@@ -53,6 +53,7 @@
*/
protected:
Function();
+ Function(const Function&);
};
@@ -65,6 +66,7 @@
{
protected:
Function_v2v();
+ Function_v2v(const Function_v2v&);
};
@@ -77,6 +79,7 @@
{
protected:
Function_i2v();
+ Function_i2v(const Function_i2v&);
};
@@ -85,10 +88,25 @@
/// Base class for implementation of function-objects from point to
/// value.
template <typename E>
- struct Function_p2v : public Function_v2v<E>
+ struct Function_p2v : public virtual Function_v2v<E>
{
protected:
Function_p2v();
+ Function_p2v(const Function_p2v&);
+ };
+
+
+ // Value -> bool.
+
+ /// Base class for implementation of function-objects from value to
+ /// bool.
+ template <typename E>
+ struct Function_v2b : public virtual Function_v2v<E>
+ {
+ typedef bool result;
+ protected:
+ Function_v2b();
+ Function_v2b(const Function_v2b&);
};
@@ -97,11 +115,13 @@
/// Base class for implementation of function-objects from point to
/// bool.
template <typename E>
- struct Function_p2b : public Function_p2v<E>
+ struct Function_p2b : public Function_p2v<E>,
+ public Function_v2b<E>
{
typedef bool result;
protected:
Function_p2b();
+ Function_p2b(const Function_p2b&);
};
@@ -114,6 +134,7 @@
{
protected:
Function_p2p();
+ Function_p2p(const Function_p2p&);
};
@@ -127,25 +148,70 @@
}
template <typename E>
+ Function<E>::Function(const Function<E>&)
+ {
+ }
+
+ template <typename E>
Function_v2v<E>::Function_v2v()
{
}
template <typename E>
+ Function_v2v<E>::Function_v2v(const Function_v2v<E>&)
+ {
+ }
+
+ template <typename E>
Function_i2v<E>::Function_i2v()
{
}
template <typename E>
+ Function_i2v<E>::Function_i2v(const Function_i2v<E>&)
+ {
+ }
+
+ template <typename E>
Function_p2v<E>::Function_p2v()
{
}
template <typename E>
+ Function_p2v<E>::Function_p2v(const Function_p2v<E>&)
+ {
+ }
+
+ template <typename E>
+ Function_v2b<E>::Function_v2b()
+ {
+ }
+
+ template <typename E>
+ Function_v2b<E>::Function_v2b(const Function_v2b<E>&)
+ {
+ }
+
+ template <typename E>
Function_p2b<E>::Function_p2b()
{
}
+ template <typename E>
+ Function_p2b<E>::Function_p2b(const Function_p2b<E>&)
+ {
+ }
+
+ template <typename E>
+ Function_p2p<E>::Function_p2p()
+ {
+ }
+
+ template <typename E>
+ Function_p2p<E>::Function_p2p(const Function_p2p<E>&)
+ {
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/fun/ops.hh
--- mln/fun/ops.hh (revision 1055)
+++ mln/fun/ops.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
@@ -43,11 +44,12 @@
{ \
\
template <typename L, typename R> \
- struct Name##_expr_ : public Function_##Out < Name##_expr_<L,R> > \
+ struct Name##_##Out##_expr_ \
+ : public Function_##Out < Name##_##Out##_expr_<L,R> > \
{ \
typedef mln_result(L) result; \
\
- Name##_expr_(const L& l, const R& r) \
+ Name##_##Out##_expr_(const L& l, const R& r) \
: l_(l), r_(r) \
{ \
} \
@@ -59,17 +61,17 @@
} \
\
protected: \
- L l_; \
- R r_; \
+ const L l_; \
+ const R r_; \
}; \
\
} \
\
template <typename L, typename R> \
- fun::Name##_expr_<L,R> \
+ fun::Name##_##Out##_expr_<L,R> \
operator Symbol (const Function_##In<L>& lhs, const Function_##In<R>& rhs) \
{ \
- fun::Name##_expr_<L,R> tmp(exact(lhs), exact(rhs)); \
+ fun::Name##_##Out##_expr_<L,R> tmp(exact(lhs), exact(rhs)); \
return tmp; \
} \
\
@@ -82,11 +84,12 @@
{ \
\
template <typename F> \
- struct Name##_expr_ : public Function_##Out< Name##_expr_<F> > \
+ struct Name##_##Out##_expr_ \
+ : public Function_##Out< Name##_##Out##_expr_<F> > \
{ \
typedef mln_result(F) result; \
\
- Name##_expr_(const F& f) \
+ Name##_##Out##_expr_(const F& f) \
: f_(f) \
{ \
} \
@@ -98,16 +101,16 @@
} \
\
protected: \
- F f_; \
+ const F f_; \
}; \
\
} \
\
template <typename F> \
- fun::Name##_expr_<F> \
+ fun::Name##_##Out##_expr_<F> \
operator Symbol (const Function_##In<F>& f) \
{ \
- fun::Name##_expr_<F> tmp(exact(f)); \
+ fun::Name##_##Out##_expr_<F> tmp(exact(f)); \
return tmp; \
} \
\
@@ -117,6 +120,7 @@
namespace mln
{
+ // -> p2v
mln_decl_binary_expr_(p2v, p2b, equal, =);
mln_decl_binary_expr_(p2v, p2b, not_equal, !=);
@@ -141,6 +145,22 @@
mln_decl_unary_expr_(p2v, p2v, uplus, +);
mln_decl_unary_expr_(p2v, p2v, uminus, -);
+ // -> v2b
+
+ mln_decl_binary_expr_(v2v, v2b, equal, =);
+ mln_decl_binary_expr_(v2v, v2b, not_equal, !=);
+
+ mln_decl_binary_expr_(v2v, v2b, less, <);
+ mln_decl_binary_expr_(v2v, v2b, less_or_equal, <=);
+ mln_decl_binary_expr_(v2v, v2b, greater_or_equal, >=);
+ mln_decl_binary_expr_(v2v, v2b, greater, >);
+
+ mln_decl_binary_expr_(v2b, v2b, and, &&);
+ mln_decl_binary_expr_(v2b, v2b, or, ||);
+ mln_decl_binary_expr_(v2b, v2b, xor, ^);
+
+ mln_decl_unary_expr_(v2b, v2b, not, !);
+
} // end of namespace mln
Index: mln/fun/internal/selector.hh
--- mln/fun/internal/selector.hh (revision 1055)
+++ mln/fun/internal/selector.hh (working copy)
@@ -51,11 +51,13 @@
// Function_v2v
// |
- // + -- Function_i2v
- // |
- // + -- Function_p2v
- // |
- // + -- Function_p2b
+ // + ---------------------- Function_v2b
+ // | |
+ // + -- Function_i2v |
+ // | |
+ // + -- Function_p2v |
+ // | |
+ // + -- Function_p2b -- +
// |
// + -- Function_p2p
@@ -69,9 +71,9 @@
template <int arg, int res, typename E> struct helper_selector_;
- // no b2* type => v2v type
+ // b2* => v2v type, except for v2b
template <typename E>
- struct helper_selector_< b_, b_, E > { typedef Function_v2v<E> ret; };
+ struct helper_selector_< b_, b_, E > { typedef Function_v2b<E> ret; };
template <typename E>
struct helper_selector_< b_, i_, E > { typedef Function_v2v<E> ret; };
template <typename E>
@@ -79,7 +81,7 @@
template <typename E>
struct helper_selector_< b_, v_, E > { typedef Function_v2v<E> ret; };
- // i2* => only i2v type
+ // i2* => i2v type
template <typename E>
struct helper_selector_< i_, b_, E > { typedef Function_i2v<E> ret; };
template <typename E>
@@ -99,9 +101,9 @@
template <typename E>
struct helper_selector_< p_, v_, E > { typedef Function_p2v<E> ret; };
- // v2* => only v2v type
+ // v2* => v2v type, except for v2b
template <typename E>
- struct helper_selector_< v_, b_, E > { typedef Function_v2v<E> ret; };
+ struct helper_selector_< v_, b_, E > { typedef Function_v2b<E> ret; };
template <typename E>
struct helper_selector_< v_, i_, E > { typedef Function_v2v<E> ret; };
template <typename E>
Index: mln/fun/v2v/saturate.hh
--- mln/fun/v2v/saturate.hh (revision 0)
+++ mln/fun/v2v/saturate.hh (revision 0)
@@ -0,0 +1,105 @@
+// 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_FUN_V2V_SATURATE_HH
+# define MLN_FUN_V2V_SATURATE_HH
+
+/*! \file mln/fun/v2v/saturate.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/value/props.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct saturate : public Function_v2v< saturate<V> >
+ {
+ saturate();
+ saturate(const V& min, const V& max);
+
+ typedef V result;
+
+ template <typename W>
+ V operator()(const W& v) const;
+
+ protected:
+ V min_, max_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ saturate<V>::saturate()
+ : min_(mln_min(V)),
+ max_(mln_max(V))
+ {
+ }
+
+ template <typename V>
+ saturate<V>::saturate(const V& min, const V& max)
+ : min_(min),
+ max_(max)
+ {
+ mln_precondition(max > min);
+ }
+
+ template <typename V>
+ template <typename W>
+ V
+ saturate<V>::operator()(const W& v) const
+ {
+ if (v < min_)
+ return min_;
+ if (v > max_)
+ return max_;
+ return v;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_SATURATE_HH
Index: mln/fun/v2v/id.hh
--- mln/fun/v2v/id.hh (revision 0)
+++ mln/fun/v2v/id.hh (revision 0)
@@ -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.
+
+#ifndef MLN_FUN_V2V_ID_HH
+# define MLN_FUN_V2V_ID_HH
+
+/*! \file mln/fun/id.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename T>
+ struct id
+ : fun::internal::selector_<T, T, id<T> >::ret
+ {
+ typedef T result;
+ T operator()(const T& t) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ T
+ id<T>::operator()(const T& t) const
+ {
+ return t;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_ID_HH
Index: mln/math/round.hh
--- mln/math/round.hh (revision 1055)
+++ mln/math/round.hh (working copy)
@@ -47,7 +47,7 @@
template <typename R>
- struct round_ : public Function_v2v< round_<R> >
+ struct round : public Function_v2v< round<R> >
{
typedef R result;
@@ -61,7 +61,7 @@
template <typename R>
template <typename T>
- R round_<R>::operator()(const T& v) const
+ R round<R>::operator()(const T& v) const
{
return (long int)(v + 0.49999); // FIXME: !!!
}
Index: mln/morpho/dilation.hh
--- mln/morpho/dilation.hh (revision 0)
+++ mln/morpho/dilation.hh (revision 0)
@@ -0,0 +1,102 @@
+// 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_MORPHO_DILATION_HH
+# define MLN_MORPHO_DILATION_HH
+
+/*! \file mln/morpho/dilation.hh
+ *
+ * \brief Morphological dilation.
+ *
+ * \todo Mimic erosion.hh when completed.
+ */
+
+# include <mln/morpho/includes.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /*! Morphological dilation.
+ */
+ template <typename I, typename W, typename O>
+ void dilation(const Image<I>& input, const Window<W>& win, Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I, typename W, typename O>
+ void dilation_on_function(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ accu::max<mln_value(I)> max;
+
+ mln_piter(I) p(input.domain());
+ mln_qiter(W) q(win, p);
+ for_all(p)
+ {
+ max.init();
+ for_all(q) if (input.has(q))
+ max.take(input(q));
+ output(p) = max.to_value();
+ }
+ }
+
+ } // end of namespace mln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I, typename W, typename O>
+ void dilation(const Image<I>& input, const Window<W>& win, Image<O>& output)
+ {
+ mln_precondition(exact(output).domain() = exact(input).domain());
+ mln_precondition(! exact(win).is_empty());
+
+ impl::dilation_on_function(input, win, output);
+
+ if (exact(win).is_centered())
+ mln_postcondition(output >= input);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_DILATION_HH
Index: mln/morpho/includes.hh
--- mln/morpho/includes.hh (revision 0)
+++ mln/morpho/includes.hh (revision 0)
@@ -0,0 +1,56 @@
+// 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_MORPHO_INCLUDES_HH
+# define MLN_MORPHO_INCLUDES_HH
+
+/*! \file mln/morpho/includes.hh
+ *
+ * \brief Basic list of includes for all files in mln/morpho/.
+ */
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/window.hh>
+
+# include <mln/accu/min.hh>
+# include <mln/accu/max.hh>
+
+# include <mln/arith/minus.hh>
+
+# include <mln/level/compare.hh>
+# include <mln/level/fill.hh>
+
+# include <mln/border/resize.hh>
+# include <mln/border/fill.hh>
+
+# include <mln/morpho/dilation.hh>
+# include <mln/morpho/erosion.hh>
+
+
+
+#endif // ! MLN_MORPHO_INCLUDES_HH
Index: mln/morpho/gradient.hh
--- mln/morpho/gradient.hh (revision 0)
+++ mln/morpho/gradient.hh (revision 0)
@@ -0,0 +1,139 @@
+// 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_MORPHO_GRADIENT_HH
+# define MLN_MORPHO_GRADIENT_HH
+
+/*! \file mln/morpho/gradient.hh
+ *
+ * \brief Morphological gradient.
+ */
+
+# include <mln/morpho/includes.hh>
+# include <mln/test/positive.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /*! Morphological gradient.
+ *
+ * This operator is d_B - e_B.
+ */
+ template <typename I, typename W, typename O>
+ void gradient(const Image<I>& input, const Window<W>& win,
+ Image<O>& output);
+
+
+ /*! Morphological internal gradient.
+ *
+ * This operator is Id - e_B.
+ */
+ template <typename I, typename W, typename O>
+ void gradient_internal(const Image<I>& input, const Window<W>& win,
+ Image<O>& output);
+
+
+ /*! Morphological external gradient.
+ *
+ * This operator is d_B - Id.
+ */
+ template <typename I, typename W, typename O>
+ void gradient_external(const Image<I>& input, const Window<W>& win,
+ Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename W, typename O>
+ void gradient(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ O temp(input.domain());
+ erosion(input, win, temp);
+
+ dilation(input, win, output);
+ arith::minus_inplace(output, temp);
+
+ mln_postcondition(test::positive(output));
+ }
+
+ template <typename I, typename W, typename O>
+ void gradient_internal(const Image<I>& input_, const Window<W>& win_,
+ Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ O temp(input.domain());
+ erosion(input, win, temp);
+
+ arith::minus(input, temp, output);
+
+ mln_postcondition(test::positive(output));
+ }
+
+ template <typename I, typename W, typename O>
+ void gradient_external(const Image<I>& input_, const Window<W>& win_,
+ Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ O temp(input.domain());
+ dilation(input, win, temp);
+
+ arith::minus(temp, input, output);
+
+ mln_postcondition(test::positive(output));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_GRADIENT_HH
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 1055)
+++ mln/morpho/erosion.hh (working copy)
@@ -28,13 +28,7 @@
#ifndef MLN_MORPHO_EROSION_HH
# define MLN_MORPHO_EROSION_HH
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/window.hh>
-# include <mln/accu/min.hh>
-# include <mln/value/props.hh>
-# include <mln/level/compare.hh>
-# include <mln/level/fill.hh>
-// FIXME: # include <mln/border/assign.hh>
+# include <mln/morpho/includes.hh>
namespace mln
@@ -43,6 +37,11 @@
namespace morpho
{
+ /*! Morphological erosion.
+ *
+ * \todo Overload erosion_wrt_win for hline and vline and for fast
+ * images.
+ */
template <typename I, typename W, typename O>
void erosion(const Image<I>& input, const Window<W>& win, Image<O>& output);
@@ -52,7 +51,7 @@
namespace impl
{
- // on function
+ // On function.
template <typename I, typename W, typename O>
void erosion_on_function(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
@@ -75,7 +74,7 @@
}
- // on set
+ // On set.
template <typename I, typename W, typename O>
void erosion_on_set(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
@@ -104,10 +103,10 @@
- // FIXME: stage 3: dispatch w.r.t. fast property
+ // FIXME: Stage 3: dispatch w.r.t. fast property
- // stage 2: dispatch w.r.t. the value kind
+ // Stage 2: dispatch w.r.t. the value kind.
template <typename I, typename W, typename O>
void erosion_wrt_value(value::binary_kind, // binary => morphology on sets
@@ -125,7 +124,7 @@
- // stage 1: dispatch w.r.t. the window type
+ // Stage 1: dispatch w.r.t. the window type.
// |
// V
@@ -142,9 +141,9 @@
template <typename I, typename O>
void erosion_wrt_win(const Image<I>& input, const win::rectangle2d& win, Image<O>& output)
{
- O tmp(exact(output).domain());
- morpho::erosion(input, win::hline2d(win.width()), tmp);
- morpho::erosion(tmp, win::vline2d(win.height()), output);
+ O temp(exact(output).domain());
+ morpho::erosion(input, win::hline2d(win.width()), temp);
+ morpho::erosion(temp, win::vline2d(win.height()), output);
}
# endif // MLN_CORE_WIN_RECTANGLE2D_HH
@@ -157,7 +156,7 @@
} // end of namespace mln::morpho::impl
- // facade
+ // Facade.
template <typename I, typename W, typename O>
void erosion(const Image<I>& input, const Window<W>& win, Image<O>& output)
@@ -166,6 +165,7 @@
mln_precondition(! exact(win).is_empty());
impl::erosion_wrt_win(input, exact(win), output);
+
if (exact(win).is_centered())
mln_postcondition(output <= input);
}
Index: mln/morpho/closing.hh
--- mln/morpho/closing.hh (revision 0)
+++ mln/morpho/closing.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_MORPHO_CLOSING_HH
+# define MLN_MORPHO_CLOSING_HH
+
+/*! \file mln/morpho/closing.hh
+ *
+ * \brief Morphological closing.
+ */
+
+# include <mln/morpho/includes.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /*! Morphological closing.
+ *
+ * This operator is e_{-B} o d_B.
+ */
+ template <typename I, typename W, typename O>
+ void closing(const Image<I>& input, const Window<W>& win, Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename W, typename O>
+ void closing(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ O temp(input.domain());
+ dilation(input, win, temp);
+ erosion(temp, -win, output);
+
+ mln_postcondition(output >= input);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_HH
Index: mln/morpho/opening.hh
--- mln/morpho/opening.hh (revision 0)
+++ mln/morpho/opening.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_MORPHO_OPENING_HH
+# define MLN_MORPHO_OPENING_HH
+
+/*! \file mln/morpho/opening.hh
+ *
+ * \brief Morphological opening.
+ */
+
+# include <mln/morpho/includes.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /*! Morphological opening.
+ *
+ * This operator is d_{-B} o e_B.
+ */
+ template <typename I, typename W, typename O>
+ void opening(const Image<I>& input, const Window<W>& win, Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename W, typename O>
+ void opening(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ mln_precondition(output.domain() = input.domain());
+ mln_precondition(! win.is_empty());
+
+ O temp(input.domain());
+ erosion(input, win, temp);
+ dilation(temp, -win, output);
+
+ mln_postcondition(output <= input);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_OPENING_HH
Index: mln/level/assign.hh
--- mln/level/assign.hh (revision 1055)
+++ mln/level/assign.hh (working copy)
@@ -31,6 +31,8 @@
/*! \file mln/level/assign.hh
*
* \brief Assignment between a couple of images.
+ *
+ * \todo Assign should be a precondition then a call to level::fill.
*/
# include <mln/core/concept/image.hh>
Index: mln/level/fill.hh
--- mln/level/fill.hh (revision 1055)
+++ mln/level/fill.hh (working copy)
@@ -31,6 +31,8 @@
/*! \file mln/level/fill.hh
*
* \brief Fill an image, that is, set pixel values.
+ *
+ * \todo Overload for fast images.
*/
# include <cstring>
Index: mln/level/saturate.hh
--- mln/level/saturate.hh (revision 0)
+++ mln/level/saturate.hh (revision 0)
@@ -0,0 +1,121 @@
+// 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_LEVEL_SATURATE_HH
+# define MLN_LEVEL_SATURATE_HH
+
+/*! \file mln/level/saturate.hh
+ *
+ * \brief Apply a saturation function to image pixel values.
+ */
+
+# include <mln/fun/v2v/saturate.hh>
+# include <mln/level/apply.hh>
+# include <mln/level/transform.hh>
+
+
+namespace mln
+{
+
+ namespace level
+ {
+
+
+ /*! Apply the saturate function to image pixel values.
+ *
+ * \param[in] input The input image.
+ * \param[out] output The output image.
+ *
+ * The saturation is based on the min and max values of the output
+ * value type. This assumes that the range of values in the input
+ * image is larger than the one of the output image.
+ */
+ template <typename I, typename O>
+ void saturate(const Image<I>& input, Image<O>& output);
+
+
+ /*! Apply the saturate function to image pixel values.
+ *
+ * \param[in] input The input image.
+ * \param[in] min The minimum output value.
+ * \param[in] max The maximum output value.
+ * \param[out] output The output image.
+ */
+ template <typename I, typename O>
+ void saturate(const Image<I>& input,
+ const mln_value(O)& min, const mln_value(O)& max,
+ Image<O>& output);
+
+
+ /*! Apply the saturate function to image pixel values.
+ *
+ * \param[in,out] input The input image.
+ * \param[in] min The minimum output value.
+ * \param[in] max The maximum output value.
+ */
+ template <typename I>
+ void saturate_inplace(Image<I>& input,
+ const mln_value(I)& min, const mln_value(I)& max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename O>
+ void saturate(const Image<I>& input, Image<O>& output)
+ {
+ mln_precondition(exact(input).domain() = exact(output).domain());
+ fun::v2v::saturate<mln_value(O)> f;
+ level::transform(input, f, output);
+ }
+
+ template <typename I, typename O>
+ void saturate(const Image<I>& input,
+ const mln_value(O)& min, const mln_value(O)& max,
+ Image<O>& output)
+ {
+ mln_precondition(exact(input).domain() = exact(output).domain());
+ fun::v2v::saturate<mln_value(O)> f(min, max);
+ level::transform(input, f, output);
+ }
+
+ template <typename I>
+ void saturate_inplace(Image<I>& input,
+ const mln_value(I)& min, const mln_value(I)& max)
+ {
+ mln_precondition(exact(input).has_data());
+ fun::v2v::saturate<mln_value(I)> f(min, max);
+ level::apply(input, f);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LEVEL_SATURATE_HH
Index: mln/level/abs.hh
--- mln/level/abs.hh (revision 0)
+++ mln/level/abs.hh (revision 0)
@@ -0,0 +1,89 @@
+// 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_LEVEL_ABS_HH
+# define MLN_LEVEL_ABS_HH
+
+/*! \file mln/level/abs.hh
+ *
+ * \brief Apply the absolute value (abs) function to image pixel
+ * values.
+ */
+
+# include <mln/fun/v2v/abs.hh>
+# include <mln/level/apply.hh>
+# include <mln/level/transform.hh>
+
+
+namespace mln
+{
+
+ namespace level
+ {
+
+
+ /*! Apply the absolute value (abs) function to image pixel values.
+ *
+ * \param[in] input The input image.
+ * \param[out] output The output image.
+ */
+ template <typename I, typename O>
+ void abs(const Image<I>& input, Image<O>& output);
+
+
+ /*! Apply the absolute value (abs) function to image pixel values.
+ *
+ * \param[in,out] input The input image.
+ */
+ template <typename I>
+ void abs_inplace(Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename O>
+ void abs(const Image<I>& input, Image<O>& output)
+ {
+ mln_precondition(exact(input).domain() = exact(output).domain());
+ level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
+ }
+
+ template <typename I>
+ void abs_inplace(Image<I>& input)
+ {
+ mln_precondition(exact(input).has_data());
+ level::apply(input, fun::v2v::abs<mln_value(I)>());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LEVEL_ABS_HH
Index: mln/arith/plus.hh
--- mln/arith/plus.hh (revision 1055)
+++ mln/arith/plus.hh (working copy)
@@ -54,6 +54,20 @@
void plus(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output);
+ /*! Point-wise addition of image \p rhs in image \p lhs.
+ *
+ * \param[in] lhs First operand image (subject to addition).
+ * \param[in,out] rhs Second operand image (to be added to \p lhs).
+ *
+ * This addition performs: \n
+ * for all p of rhs.domain \n
+ * lhs(p) += rhs(p)
+ *
+ * \pre \p rhs.domain <= \p lhs.domain
+ */
+ template <typename L, typename R>
+ void plus_inplace(Image<L>& lhs, const Image<R>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
@@ -81,10 +95,29 @@
op.val() = lp.val() + rp.val();
}
+ template <typename L, typename R>
+ void plus_inplace_(Image<L>& lhs_, const Image<R>& rhs_)
+ {
+ L& lhs = exact(lhs_);
+ const R& rhs = exact(rhs_);
+ mln_piter(R) p(rhs.domain());
+ for_all(p)
+ lhs(p) += rhs(p);
+ }
+
+ template <typename L, typename R>
+ void plus_inplace_(Fast_Image<L>& lhs, const Fast_Image<R>& rhs)
+ {
+ mln_pixter(L) lp(exact(lhs));
+ mln_pixter(const R) rp(exact(rhs));
+ for_all_2(rp, lp)
+ lp.val() += rp.val();
+ }
+
} // end of namespace mln::arith::impl
- // Facade.
+ // Facades.
template <typename L, typename R, typename O>
void plus(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
@@ -94,6 +127,13 @@
impl::plus_(exact(lhs), exact(rhs), exact(output));
}
+ template <typename L, typename R>
+ void plus_inplace(Image<L>& lhs, const Image<R>& rhs)
+ {
+ mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
+ impl::plus_inplace_(exact(lhs), exact(rhs));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::arith
Index: mln/arith/minus.hh
--- mln/arith/minus.hh (revision 1055)
+++ mln/arith/minus.hh (working copy)
@@ -54,22 +54,84 @@
void minus(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output);
+ /*! Point-wise substraction of image \p lhs in image \p rhs.
+ *
+ * \param[in,out] lhs First operand image (subject to substraction).
+ * \param[in] rhs Second operand image (to be substracted to \p lhs).
+ *
+ * This substraction performs: \n
+ * for all p of rhs.domain \n
+ * lhs(p) -= rhs(p)
+ *
+ * \pre \p rhs.domain <= \p lhs.domain
+ */
+ template <typename L, typename R>
+ void minus_inplace(Image<L>& lhs, const Image<R>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename L, typename R, typename O>
- void minus(const Image<L>& lhs_, const Image<R>& rhs_, Image<O>& output_)
+ void minus_(const Image<L>& lhs_, const Image<R>& rhs_, Image<O>& output_)
{
const L& lhs = exact(lhs_);
const R& rhs = exact(rhs_);
O& output = exact(output_);
+ mln_piter(L) p(lhs.domain());
+ for_all(p)
+ output(p) = lhs(p) - rhs(p);
+ }
- mln_precondition(rhs.domain() = lhs.domain());
- mln_precondition(output.domain() = lhs.domain());
+ template <typename L, typename R, typename O>
+ void minus_(const Fast_Image<L>& lhs, const Fast_Image<R>& rhs, Fast_Image<O>& output)
+ {
+ mln_pixter(const L) lp(exact(lhs));
+ mln_pixter(const R) rp(exact(rhs));
+ mln_pixter(O) op(exact(output));
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() - rp.val();
+ }
- mln_piter(I) p(output.domain());
+ template <typename L, typename R>
+ void minus_inplace_(Image<L>& lhs_, const Image<R>& rhs_)
+ {
+ L& lhs = exact(lhs_);
+ const R& rhs = exact(rhs_);
+ mln_piter(R) p(rhs.domain());
for_all(p)
- output(p) = lhs(p) - rhs(p);
+ lhs(p) -= rhs(p);
+ }
+
+ template <typename L, typename R>
+ void minus_inplace_(Fast_Image<L>& lhs, const Fast_Image<R>& rhs)
+ {
+ mln_pixter(L) lp(exact(lhs));
+ mln_pixter(const R) rp(exact(rhs));
+ for_all_2(rp, lp)
+ lp.val() -= rp.val();
+ }
+
+ } // end of namespace mln::arith::impl
+
+
+ // Facades.
+
+ template <typename L, typename R, typename O>
+ void minus(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
+ {
+ mln_precondition(exact(rhs).domain() = exact(lhs).domain());
+ mln_precondition(exact(output).domain() = exact(lhs).domain());
+ impl::minus_(exact(lhs), exact(rhs), exact(output));
+ }
+
+ template <typename L, typename R>
+ void minus_inplace(Image<L>& lhs, const Image<R>& rhs)
+ {
+ mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
+ impl::minus_inplace_(exact(lhs), exact(rhs));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/linear/line_convolve.hh
--- mln/linear/line_convolve.hh (revision 1055)
+++ mln/linear/line_convolve.hh (working copy)
@@ -56,14 +56,14 @@
* \pre output.domain = input.domain
*/
template <typename I, typename W, unsigned N, typename O>
- void line_convolve(const Image<I>& input, const W (&weights)[N],
+ void line_convolve(const Image<I>& input, W (&weights)[N],
Image<O>& output);
# ifndef MLN_INCLUDE_ONLY
template <typename I, typename W, unsigned N, typename O>
- void line_convolve(const Image<I>& input, const W (&weights)[N],
+ void line_convolve(const Image<I>& input, W (&weights)[N],
Image<O>& output)
{
mln_precondition(exact(output).domain() = exact(input).domain());
Index: mln/linear/sobel.hh
--- mln/linear/sobel.hh (revision 1055)
+++ mln/linear/sobel.hh (working copy)
@@ -34,8 +34,7 @@
*/
# include <mln/arith/plus.hh>
-# include <mln/fun/v2v/abs.hh>
-# include <mln/level/apply.hh>
+# include <mln/level/abs.hh>
# include <mln/linear/line_x2_convolve.hh>
@@ -97,11 +96,14 @@
template <typename I, typename O>
void sobel_(const Image<I>& input, Image<O>& output)
{
- O temp_h(exact(input).domain()), temp_v(exact(input).domain());
- sobel_h(input, temp_h);
- sobel_v(input, temp_v);
- arith::plus(temp_h, temp_v, output);
- level::apply(exact(output), fun::v2v::abs<mln_value(O)>());
+ // h
+ sobel_h(input, output);
+ // v
+ O temp(exact(input).domain());
+ sobel_v(input, temp);
+ // output
+ arith::plus_inplace(output, temp);
+ level::abs_inplace(output);
}
} // end of namespace mln::linear::impl
Index: mln/linear/line_x2_convolve.hh
--- mln/linear/line_x2_convolve.hh (revision 1055)
+++ mln/linear/line_x2_convolve.hh (working copy)
@@ -59,7 +59,7 @@
typename W, unsigned Nr, unsigned Nc,
typename O>
void line_x2_convolve(const Image<I>& input,
- const W (&row_weights)[Nr], const W (&col_weights)[Nc],
+ W (&row_weights)[Nr], W (&col_weights)[Nc],
Image<O>& output);
@@ -69,7 +69,7 @@
typename W, unsigned Nr, unsigned Nc,
typename O>
void line_x2_convolve(const Image<I>& input,
- const W (&row_weights)[Nr], const W (&col_weights)[Nc],
+ W (&row_weights)[Nr], W (&col_weights)[Nc],
Image<O>& output)
{
// FIXME: Check 2D.
Index: mln/make/w_window_line.hh
--- mln/make/w_window_line.hh (revision 1055)
+++ mln/make/w_window_line.hh (working copy)
@@ -52,13 +52,13 @@
* \return A window.
*/
template <typename D, typename W, unsigned L>
- mln::w_window<D,W> w_window_line(const W (&w)[L]);
+ mln::w_window<D,W> w_window_line(W (&w)[L]);
# ifndef MLN_INCLUDE_ONLY
template <typename D, typename W, unsigned L>
- mln::w_window<D,W> w_window_line(const W (&w)[L])
+ mln::w_window<D,W> w_window_line(W (&w)[L])
{
mln_precondition(L % 2 = 1);
mln::w_window<D,W> w_win;
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment tools for linear filtering; add sobel.
* mln/core/decorated_image.hh
(helper_decorated_image_write_): Replace by...
(decorated_image_impl_): ...this.
(impl_): New.
(lvalue): Update.
(write_): Remove; now in impl_.
* mln/value/all.hh: Update.
* mln/value/props.hh,
* mln/value/int_u.hh,
* mln/value/int_s.hh (min, max): Change to proc.
* mln/value/props.hh (mln_min, mln_max): Update.
(epsilon): Change to proc.
* mln/value/aliases.hh: New.
* mln/level/stretch.hh: Update.
* mln/arith/abs.hh: New.
* mln/arith/plus.hh: Overload.
* mln/fun/v2v/abs.hh: New.
* mln/level/apply.hh: Fix meaning; add todo.
* mln/math/abs.hh: Overload.
* mln/core/concept/iterator.hh (for_all_3): New.
* mln/math/round_sat.hh: New.
* mln/make/w_window_line.hh: New.
* mln/metal/abort.hh: New.
* mln/linear/line_convolve.hh: New.
* mln/linear/line_x2_convolve.hh: New.
* mln/linear/sobel.hh: New.
* tests/line_convolve.cc: New.
* tests/sobel.cc: New.
mln/arith/plus.hh | 34 ++++++++-
mln/core/concept/iterator.hh | 9 ++
mln/core/decorated_image.hh | 55 +++++++++-------
mln/fun/v2v/abs.hh | 77 ++++++++++++++++++++++
mln/level/apply.hh | 42 +++++-------
mln/level/stretch.hh | 2
mln/linear/convolve.hh | 8 +-
mln/linear/hconvolve.hh | 109 +++++++++++++++++++++++++++++++
mln/linear/line_convolve.hh | 82 ++++++++++++++++++++++++
mln/linear/line_x2_convolve.hh | 92 ++++++++++++++++++++++++++
mln/linear/sobel.hh | 140 +++++++++++++++++++++++++++++++++++++++++
mln/make/w_window_line.hh | 81 +++++++++++++++++++++++
mln/math/abs.hh | 13 +++
mln/math/round_sat.hh | 83 ++++++++++++++++++++++++
mln/metal/abort.hh | 50 ++++++++++++++
mln/value/aliases.hh | 43 ++++++++++++
mln/value/all.hh | 9 ++
mln/value/int_s.hh | 23 ++----
mln/value/int_u.hh | 13 ---
mln/value/props.hh | 52 +++++++--------
tests/line_convolve.cc | 64 ++++++++++++++++++
tests/sobel.cc | 62 ++++++++++++++++++
22 files changed, 1034 insertions(+), 109 deletions(-)
Index: tests/sobel.cc
--- tests/sobel.cc (revision 0)
+++ tests/sobel.cc (revision 0)
@@ -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/sobel.cc
+ *
+ * \brief Tests on mln::linear::sobel.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/load_pgm.hh>
+#include <mln/io/save_pgm.hh>
+
+#include <mln/math/round_sat.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/border/thickness.hh>
+#include <mln/linear/sobel.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ border::thickness = 1;
+
+ image2d_b<int_u8>
+ lena = io::load_pgm("../img/lena.pgm"),
+ out(lena.domain());
+
+ image2d_b<int> tmp(lena.domain());
+ linear::sobel(lena, tmp);
+
+ level::transform(tmp, math::round_sat_<int_u8>(), out);
+ io::save_pgm(out, "out.pgm");
+}
Index: tests/line_convolve.cc
--- tests/line_convolve.cc (revision 0)
+++ tests/line_convolve.cc (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/line_convolve.cc
+ *
+ * \brief Tests on mln::linear::line_convolve.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/load_pgm.hh>
+#include <mln/io/save_pgm.hh>
+#include <mln/math/round.hh>
+#include <mln/math/round_sat.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/core/w_window2d_float.hh>
+#include <mln/border/thickness.hh>
+#include <mln/linear/line_convolve.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ border::thickness = 4;
+
+ image2d_b<int_u8>
+ lena = io::load_pgm("../img/lena.pgm"),
+ out(lena.domain());
+
+ image2d_b<float> tmp(lena.domain());
+ float ws[] = { .11, .11, .11, .11, .11, .11, .11, .11, .11 };
+ linear::line_convolve(lena, ws, tmp);
+
+ level::transform(tmp, math::round_<int_u8>(), out);
+ io::save_pgm(out, "out.pgm");
+}
Index: mln/core/decorated_image.hh
--- mln/core/decorated_image.hh (revision 1054)
+++ mln/core/decorated_image.hh (working copy)
@@ -35,13 +35,39 @@
namespace mln
{
+ // Fwd decl.
+ template <typename I, typename D> class decorated_image;
+
+
+ namespace internal
+ {
+
+ template <typename I, typename E>
+ struct decorated_image_impl_
+ {
+ typedef mln::value::proxy<E> lvalue;
+ void write_(const mln_psite(I)& p, const mln_value(I)& v);
+ };
+
+ template <typename I, typename E>
+ struct decorated_image_impl_< const I, E >
+ {
+ typedef mln::value::proxy<const E> lvalue;
+ };
+
+ } // end of namespace::internal
+
+
+
// FIXME: Doc!
template <typename I, typename D>
- class decorated_image : public internal::image_adaptor_< I, decorated_image<I,D> >
+ class decorated_image : public internal::image_adaptor_< I, decorated_image<I,D> >,
+ public internal::decorated_image_impl_< I, decorated_image<I,D> >
{
typedef decorated_image<I, D> self_;
typedef internal::image_adaptor_< I, self_ > super_;
+ typedef internal::decorated_image_impl_< I, self_ > impl_;
public:
decorated_image(I& ima, const D& deco);
@@ -49,13 +75,12 @@
typedef mln_value(I) value;
typedef mln::value::proxy<const self_> rvalue;
- typedef mln::value::proxy<self_> lvalue;
+ typedef typename impl_::lvalue lvalue;
rvalue operator()(const mln_psite(I)& p) const;
lvalue operator()(const mln_psite(I)& p);
mln_value(I) read_(const mln_psite(I)& p) const;
- void write_(const mln_psite(I)& p, const mln_value(I)& v);
template <typename V>
struct change_value
@@ -110,7 +135,7 @@
}
template <typename I, typename D>
- mln::value::proxy< const decorated_image<I,D> >
+ typename decorated_image<I,D>::rvalue
decorated_image<I,D>::operator()(const mln_psite(I)& p) const
{
rvalue tmp(*this, p);
@@ -118,7 +143,7 @@
}
template <typename I, typename D>
- mln::value::proxy< decorated_image<I,D> >
+ typename decorated_image<I,D>::lvalue
decorated_image<I,D>::operator()(const mln_psite(I)& p)
{
lvalue tmp(*this, p);
@@ -128,32 +153,18 @@
namespace internal
{
- template <typename I, typename D>
+ template <typename I, typename E>
void
- helper_decorated_image_write_(decorated_image<I,D>& ima,
- const mln_psite(I)& p, const mln_value(I)& v)
+ decorated_image_impl_<I,E>::write_(const mln_psite(I)& p, const mln_value(I)& v)
{
+ E& ima = internal::force_exact<E>(*this);
ima.decoration().writing(ima.adaptee(), p, v);
ima.adaptee()(p) = v;
}
- template <typename I, typename D>
- void
- helper_decorated_image_write_(decorated_image<const I,D>&,
- const mln_psite(I)&, const mln_value(I)&)
- // FIXME: Static assertion instead.
- ;
-
} // end of namespace mln::internal
template <typename I, typename D>
- void
- decorated_image<I,D>::write_(const mln_psite(I)& p, const mln_value(I)& v)
- {
- internal::helper_decorated_image_write_(*this, p, v);
- }
-
- template <typename I, typename D>
mln_value(I)
decorated_image<I,D>::read_(const mln_psite(I)& p) const
{
Index: mln/core/concept/iterator.hh
--- mln/core/concept/iterator.hh (revision 1054)
+++ mln/core/concept/iterator.hh (working copy)
@@ -46,6 +46,15 @@
# define for_all_2(x1, x2) for(x1.start(),x2.start(); x1.is_valid(); x1.next(),x2.next())
+/*! \brief Loop to browse all the elements targetted by the triplet of
+ * iterators \p x1, \p x2, and \p x3.
+ */
+# define for_all_3(x1, x2, x3) \
+ for(x1.start(), x2.start(), x3.start(); \
+ x1.is_valid(); \
+ x1.next(), x2.next(), x3.next())
+
+
/*! \brief Loop to browse all the remaining elements targetted by the
* iterator \p x.
*/
Index: mln/fun/v2v/abs.hh
--- mln/fun/v2v/abs.hh (revision 0)
+++ mln/fun/v2v/abs.hh (revision 0)
@@ -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.
+
+#ifndef MLN_FUN_V2V_ABS_HH
+# define MLN_FUN_V2V_ABS_HH
+
+/*! \file mln/fun/v2v/abs.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/math/abs.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct abs : public Function_v2v< abs<V> >
+ {
+ typedef V result;
+ V operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ V
+ abs<V>::operator()(const V& v) const
+ {
+ return mln::math::abs(v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_ABS_HH
Index: mln/math/abs.hh
--- mln/math/abs.hh (revision 1054)
+++ mln/math/abs.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <cmath>
+# include <mln/value/all.hh>
@@ -55,6 +56,18 @@
return std::abs(v);
}
+ template <unsigned n>
+ value::int_u<n> abs(const value::int_u<n>& v)
+ {
+ return v;
+ }
+
+ template <unsigned n>
+ value::int_s<n> abs(const value::int_s<n>& v)
+ {
+ return std::abs(v.to_enc());
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::math
Index: mln/math/round_sat.hh
--- mln/math/round_sat.hh (revision 0)
+++ mln/math/round_sat.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_MATH_ROUND_SAT_HH
+# define MLN_MATH_ROUND_SAT_HH
+
+/*! \file mln/math/round_sat.hh
+ *
+ * \brief Define round_sat routine.
+ */
+
+# include <cmath>
+
+# include <mln/core/concept/function.hh>
+# include <mln/value/props.hh>
+
+
+
+namespace mln
+{
+
+ namespace math
+ {
+
+
+ template <typename R>
+ struct round_sat_ : public Function_v2v< round_sat_<R> >
+ {
+ typedef R result;
+
+ template <typename T>
+ result operator()(const T& v) const;
+
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename R>
+ template <typename T>
+ R round_sat_<R>::operator()(const T& v) const
+ {
+ long int l = (long int)(v + 0.49999); // FIXME: !!!
+ return
+ l < mln_min(R)
+ ? mln_min(R)
+ : (l > mln_max(R)
+ ? mln_max(R)
+ : R(l));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_ROUND_SAT_HH
Index: mln/metal/abort.hh
--- mln/metal/abort.hh (revision 0)
+++ mln/metal/abort.hh (revision 0)
@@ -0,0 +1,50 @@
+// 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_METAL_ABORT_HH
+# define MLN_METAL_ABORT_HH
+
+# include <mln/metal/bool.hh>
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct abort : false_
+ {};
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_ABORT_HH
Index: mln/level/apply.hh
--- mln/level/apply.hh (revision 1054)
+++ mln/level/apply.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/accumulator.hh>
+# include <mln/core/concept/function.hh>
namespace mln
@@ -45,19 +45,19 @@
/*! Apply a function-object to the image \p input.
*
- * \param[in] input The input image.
+ * \param[in,out] input The input image.
* \param[in] f The function-object.
- * \result A copy of the function-object.
*
* This routine runs: \n
- * for all p of \p input, \p f( \p input(p) ) \n
- * return \p f
+ * for all p of \p input, \p input(p) = \p f( \p input(p) ) \n
*
- * \todo Find a meaning for this routine! (Clue: f is mutable
- * and/or same for input?)
+ * This routine is equivalent to level::tranform(input, f, input)
+ * but it is faster since a single iterator is required.
+ *
+ * \todo Add versions for lowq images.
*/
template <typename I, typename F>
- F apply(const Image<I>& input, const Function<F>& f);
+ void apply(Image<I>& input, const Function_v2v<F>& f);
@@ -67,39 +67,33 @@
{
template <typename I, typename F>
- F apply(const Image<I>& input_, const Function<F>& f_)
+ void apply_(Image<I>& input_, const F& f)
{
- const I& input = exact(input_);
- F f = exact(f_);
-
+ I& input = exact(input_);
mln_piter(I) p(input.domain());
for_all(p)
- f(input(p));
- return f;
+ input(p) = f(input(p));
}
template <typename I, typename F>
- F apply(const Fast_Image<I>& input_, const Function<F>& f_)
+ void apply_(Fast_Image<I>& input_, const F& f)
{
- const I& input = exact(input_);
- F f = exact(f_);
-
- mln_pixter(const I) pxl(input);
+ I& input = exact(input_);
+ mln_pixter(I) pxl(input);
for_all(pxl)
- f(pxl.val());
- return f;
+ pxl.val() = f(pxl.val());
}
} // end of namespace mln::level::impl
- // Facades.
+ // Facade.
template <typename I, typename F>
- F apply(const Image<I>& input, const Function<F>& f)
+ void apply(Image<I>& input, const Function_v2v<F>& f)
{
mln_precondition(exact(input).has_data());
- return impl::apply(exact(input), f);
+ impl::apply_(exact(input), exact(f));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/level/stretch.hh
--- mln/level/stretch.hh (revision 1054)
+++ mln/level/stretch.hh (working copy)
@@ -71,7 +71,7 @@
if (max_ = min_)
return; // FIXME
float min = float(min_), max = float(max_);
- const float epsilon = value::props<float>::epsilon;
+ const float epsilon = value::props<float>::epsilon();
float m = 0.0f - 0.5f + epsilon;
float M = mln_max(value::int_u<n>) + 0.5f - epsilon;
float a = (M - m) / (max - min);
Index: mln/arith/plus.hh
--- mln/arith/plus.hh (revision 1054)
+++ mln/arith/plus.hh (working copy)
@@ -57,21 +57,43 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename L, typename R, typename O>
- void plus(const Image<L>& lhs_, const Image<R>& rhs_, Image<O>& output_)
+ void plus_(const Image<L>& lhs_, const Image<R>& rhs_, Image<O>& output_)
{
const L& lhs = exact(lhs_);
const R& rhs = exact(rhs_);
O& output = exact(output_);
-
- mln_precondition(rhs.domain() = lhs.domain());
- mln_precondition(output.domain() = lhs.domain());
-
- mln_piter(I) p(output.domain());
+ mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) + rhs(p);
}
+ template <typename L, typename R, typename O>
+ void plus_(const Fast_Image<L>& lhs, const Fast_Image<R>& rhs, Fast_Image<O>& output)
+ {
+ mln_pixter(const L) lp(exact(lhs));
+ mln_pixter(const R) rp(exact(rhs));
+ mln_pixter(O) op(exact(output));
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() + rp.val();
+ }
+
+ } // end of namespace mln::arith::impl
+
+
+ // Facade.
+
+ template <typename L, typename R, typename O>
+ void plus(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
+ {
+ mln_precondition(exact(rhs).domain() = exact(lhs).domain());
+ mln_precondition(exact(output).domain() = exact(lhs).domain());
+ impl::plus_(exact(lhs), exact(rhs), exact(output));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::arith
Index: mln/linear/line_convolve.hh
--- mln/linear/line_convolve.hh (revision 0)
+++ mln/linear/line_convolve.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_LINEAR_LINE_CONVOLVE_HH
+# define MLN_LINEAR_LINE_CONVOLVE_HH
+
+/*! \file mln/linear/line_convolve.hh
+ *
+ * \brief Convolution by a line-shaped kernel.
+ */
+
+# include <mln/linear/convolve.hh>
+# include <mln/make/w_window_line.hh>
+
+
+
+namespace mln
+{
+
+ namespace linear
+ {
+
+ /*! Convolution of an image \p input by a line-shaped weighted
+ * window defined by the array of \p weights.
+ *
+ * \warning Computation of \p output(p) is performed with the
+ * value type of \p output.
+ *
+ * \warning The weighted window is used as-is, considering that
+ * its symmetrization is handled by the client.
+ *
+ * \pre output.domain = input.domain
+ */
+ template <typename I, typename W, unsigned N, typename O>
+ void line_convolve(const Image<I>& input, const W (&weights)[N],
+ Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename W, unsigned N, typename O>
+ void line_convolve(const Image<I>& input, const W (&weights)[N],
+ Image<O>& output)
+ {
+ mln_precondition(exact(output).domain() = exact(input).domain());
+ linear::convolve(input,
+ make::w_window_line<mln_dpoint(I)>(weights),
+ output);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::linear
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LINEAR_LINE_CONVOLVE_HH
Index: mln/linear/hconvolve.hh
--- mln/linear/hconvolve.hh (revision 0)
+++ mln/linear/hconvolve.hh (revision 0)
@@ -0,0 +1,109 @@
+// 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_LINEAR_LINE_CONVOLVE_HH
+# define MLN_LINEAR_LINE_CONVOLVE_HH
+
+/*! \file mln/linear/line_convolve.hh
+ *
+ * \brief Convolution by an horizontal kernel.
+ */
+
+# include <vector>
+
+# include <mln/linear/convolve.hh>
+# include <mln/make/w_window_line.hh>
+# include <mln/core/t_image.hh>
+
+
+
+namespace mln
+{
+
+ namespace linear
+ {
+
+ /*! Convolution of an image \p input by an horizontal weighted
+ * window defined by the array of \p weights.
+ *
+ * \warning Computation of \p output(p) is performed with the
+ * value type of \p output.
+ *
+ * \warning The weighted window is used as-is, considering that
+ * its symmetrization is handled by the client.
+ *
+ * \pre output.domain = input.domain
+ */
+ template <typename I, typename W, unsigned N, typename O>
+ void line_convolve(const Image<I>& input, const W (&weights)[N],
+ Image<O>& output);
+
+ // FIXME: Doc!
+ template <typename I, typename W, unsigned Nr, unsigned Nc, typename O>
+ void line_convolve(const Image<I>& input,
+ const W (&row_weights)[Nr], const W (&col_weights)[Nc],
+ Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename W, unsigned N, typename O>
+ void line_convolve(const Image<I>& input, const W (&weights)[N],
+ Image<O>& output)
+ {
+ mln_precondition(exact(output).domain() = exact(input).domain());
+ linear::convolve(input,
+ make::w_window_line<mln_dpoint(I)>(weights),
+ output);
+ }
+
+
+ template <typename I, typename W, unsigned Nr, unsigned Nc, typename O>
+ void line_convolve(const Image<I>& input,
+ const W (&row_weights)[Nr], const W (&col_weights)[Nc],
+ Image<O>& output)
+ {
+ // FIXME: Check 2D.
+ mln_precondition(exact(output).domain() = exact(input).domain());
+ O tmp(exact(output).domain());
+ linear::convolve(input,
+ make::w_window_line<mln_dpoint(I)>(row_weights),
+ tmp);
+ t_image<O> swap_output = swap_coords(output, 0, 1);
+ linear::convolve(swap_coords(tmp, 0, 1),
+ make::w_window_line<mln_dpoint(I)>(col_weights),
+ swap_output);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::linear
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LINEAR_LINE_CONVOLVE_HH
Index: mln/linear/sobel.hh
--- mln/linear/sobel.hh (revision 0)
+++ mln/linear/sobel.hh (revision 0)
@@ -0,0 +1,140 @@
+// 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_LINEAR_SOBEL_HH
+# define MLN_LINEAR_SOBEL_HH
+
+/*! \file mln/linear/sobel.hh
+ *
+ * \brief Sobel filter.
+ */
+
+# include <mln/arith/plus.hh>
+# include <mln/fun/v2v/abs.hh>
+# include <mln/level/apply.hh>
+# include <mln/linear/line_x2_convolve.hh>
+
+
+
+namespace mln
+{
+
+ namespace linear
+ {
+
+ /*! Convolution of an image \p input by the weighted window \p w_win.
+ *
+ * \warning Computation of \p output(p) is performed with the
+ * value type of \p output.
+ *
+ * \warning The weighted window is used as-is, considering that
+ * its symmetrization is handled by the client.
+ *
+ * \pre output.domain = input.domain
+ *
+ * \todo Only for 2D so check + generalize.
+ *
+ * \todo Suboptimal since it is not point-wise and it costs temp
+ * images.
+ */
+ template <typename I, typename O>
+ void sobel_v(const Image<I>& input, Image<O>& output);
+
+ template <typename I, typename O>
+ void sobel_h(const Image<I>& input, Image<O>& output);
+
+ template <typename I, typename O>
+ void sobel(const Image<I>& input, Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I, typename O>
+ void sobel_h_(const Image<I>& input, Image<O>& output)
+ {
+ int wrow[] = { -1, 0, 1 }, wcol[] = { 1,
+ 2,
+ 1 };
+ linear::line_x2_convolve(input, wrow, wcol, output);
+ }
+
+ template <typename I, typename O>
+ void sobel_v_(const Image<I>& input, Image<O>& output)
+ {
+ int wrow[] = { 1, 2, 1 }, wcol[] = { -1,
+ 0,
+ +1 };
+ linear::line_x2_convolve(input, wrow, wcol, output);
+ }
+
+ template <typename I, typename O>
+ void sobel_(const Image<I>& input, Image<O>& output)
+ {
+ O temp_h(exact(input).domain()), temp_v(exact(input).domain());
+ sobel_h(input, temp_h);
+ sobel_v(input, temp_v);
+ arith::plus(temp_h, temp_v, output);
+ level::apply(exact(output), fun::v2v::abs<mln_value(O)>());
+ }
+
+ } // end of namespace mln::linear::impl
+
+
+ // Facades.
+
+ template <typename I, typename O>
+ void sobel_h(const Image<I>& input, Image<O>& output)
+ {
+ mln_precondition(exact(output).domain() = exact(input).domain());
+ impl::sobel_h_(exact(input), exact(output));
+ }
+
+ template <typename I, typename O>
+ void sobel_v(const Image<I>& input, Image<O>& output)
+ {
+ mln_precondition(exact(output).domain() = exact(input).domain());
+ impl::sobel_v_(exact(input), exact(output));
+ }
+
+ template <typename I, typename O>
+ void sobel(const Image<I>& input, Image<O>& output)
+ {
+ mln_precondition(exact(output).domain() = exact(input).domain());
+ impl::sobel_(exact(input), exact(output));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::linear
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LINEAR_SOBEL_HH
Index: mln/linear/convolve.hh
--- mln/linear/convolve.hh (revision 1054)
+++ mln/linear/convolve.hh (working copy)
@@ -46,7 +46,7 @@
namespace linear
{
- /*! Convolution of image \p input by the weighted window \p w_win.
+ /*! Convolution of an image \p input by the weighted window \p w_win.
*
* \warning Computation of \p output(p) is performed with the
* value type of \p output.
@@ -67,7 +67,7 @@
{
template <typename I, typename W, typename O>
- void convolve(const Image<I>& input_, const Weighted_Window<W>& w_win_,
+ void convolve_(const Image<I>& input_, const Weighted_Window<W>& w_win_,
Image<O>& output_)
{
const I& input = exact(input_);
@@ -87,7 +87,7 @@
}
template <typename I, typename W, typename O>
- void convolve(const Fast_Image<I>& input_, const Weighted_Window<W>& w_win_,
+ void convolve_(const Fast_Image<I>& input_, const Weighted_Window<W>& w_win_,
Fast_Image<O>& output_)
{
const I& input = exact(input_);
@@ -122,7 +122,7 @@
Image<O>& output)
{
mln_precondition(exact(output).domain() = exact(input).domain());
- impl::convolve(exact(input), exact(w_win), exact(output));
+ impl::convolve_(exact(input), exact(w_win), exact(output));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/linear/line_x2_convolve.hh
--- mln/linear/line_x2_convolve.hh (revision 0)
+++ mln/linear/line_x2_convolve.hh (revision 0)
@@ -0,0 +1,92 @@
+// 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_LINEAR_LINE_X2_CONVOLVE_HH
+# define MLN_LINEAR_LINE_X2_CONVOLVE_HH
+
+/*! \file mln/linear/line_x2_convolve.hh
+ *
+ * \brief 2D convolution by a couple of line kernels.
+ */
+
+# include <mln/linear/line_convolve.hh>
+# include <mln/core/t_image.hh>
+
+
+
+namespace mln
+{
+
+ namespace linear
+ {
+
+ /*! Convolution of an image \p input by two weighted line-shapes
+ * windows.
+ *
+ * \warning Computation of \p output(p) is performed with the
+ * value type of \p output.
+ *
+ * \warning The weighted window is used as-is, considering that
+ * its symmetrization is handled by the client.
+ *
+ * \pre output.domain = input.domain
+ */
+ template <typename I,
+ typename W, unsigned Nr, unsigned Nc,
+ typename O>
+ void line_x2_convolve(const Image<I>& input,
+ const W (&row_weights)[Nr], const W (&col_weights)[Nc],
+ Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I,
+ typename W, unsigned Nr, unsigned Nc,
+ typename O>
+ void line_x2_convolve(const Image<I>& input,
+ const W (&row_weights)[Nr], const W (&col_weights)[Nc],
+ Image<O>& output)
+ {
+ // FIXME: Check 2D.
+ mln_precondition(exact(output).domain() = exact(input).domain());
+
+ O tmp(exact(output).domain());
+ linear::line_convolve(input, row_weights, tmp);
+
+ t_image<O> swap_output = swap_coords(output, 0, 1);
+ linear::line_convolve(swap_coords(tmp, 0, 1), col_weights, swap_output);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::linear
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LINEAR_LINE_X2_CONVOLVE_HH
Index: mln/value/aliases.hh
--- mln/value/aliases.hh (revision 0)
+++ mln/value/aliases.hh (revision 0)
@@ -0,0 +1,43 @@
+// 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_VALUE_ALIASES_HH
+# define MLN_VALUE_ALIASES_HH
+
+/*! \file mln/value/aliases.hh
+ *
+ * \brief File that includes all aliases of value types.
+ */
+
+
+# include <mln/value/int_u8.hh>
+# include <mln/value/int_u16.hh>
+
+# include <mln/value/int_s8.hh>
+
+
+#endif // ! MLN_VALUE_ALIASES_HH
Index: mln/value/props.hh
--- mln/value/props.hh (revision 1054)
+++ mln/value/props.hh (working copy)
@@ -42,11 +42,11 @@
/// Get the minimum value of type \c T.
-# define mln_min(T) mln::value::props< T >::min
+# define mln_min(T) mln::value::props< T >::min()
/// Get the maximum value of type \c T.
-# define mln_max(T) mln::value::props< T >::max
+# define mln_max(T) mln::value::props< T >::max()
/// Get the number of values for value type \c T.
@@ -108,8 +108,8 @@
template <>
struct props<bool>
{
- static const bool min = false;
- static const bool max = true;
+ static const bool min() { return false; }
+ static const bool max() { return true; }
static const std::size_t card_ = 2;
typedef binary_kind kind;
};
@@ -120,8 +120,8 @@
template <>
struct props<unsigned char>
{
- static const unsigned char min = 0;
- static const unsigned char max = 255;
+ static const unsigned char min() { return 0; }
+ static const unsigned char max() { return 255; }
static const std::size_t card_ = 256;
typedef data_kind kind;
typedef float sum;
@@ -130,8 +130,8 @@
template <>
struct props<signed char>
{
- static const signed char min = -128;
- static const signed char max = 127;
+ static const signed char min() { return -128; }
+ static const signed char max() { return 127; }
static const std::size_t card_ = 256;
typedef data_kind kind;
typedef float sum;
@@ -140,8 +140,8 @@
template <>
struct props<unsigned short>
{
- static const unsigned short min = 0;
- static const unsigned short max = 65535;
+ static const unsigned short min() { return 0; }
+ static const unsigned short max() { return 65535; }
static const std::size_t card_ = 65536;
typedef data_kind kind;
typedef float sum;
@@ -150,8 +150,8 @@
template <>
struct props<signed short>
{
- static const signed short min = -32768;
- static const signed short max = 32767;
+ static const signed short min() { return -32768; }
+ static const signed short max() { return 32767; }
static const std::size_t card_ = 655356;
typedef data_kind kind;
typedef float sum;
@@ -160,8 +160,8 @@
template <>
struct props<unsigned int>
{
- static const unsigned int min = 0;
- static const unsigned int max = UINT_MAX;
+ static const unsigned int min() { return 0; }
+ static const unsigned int max() { return UINT_MAX; }
typedef data_kind kind;
static const std::size_t card_ = 0;
typedef float sum;
@@ -170,8 +170,8 @@
template <>
struct props<signed int>
{
- static const signed int min = INT_MIN;
- static const signed int max = INT_MAX;
+ static const signed int min() { return INT_MIN; }
+ static const signed int max() { return INT_MAX; }
typedef data_kind kind;
static const std::size_t card_ = 0;
typedef float sum;
@@ -180,8 +180,8 @@
template <>
struct props<unsigned long int>
{
- static const unsigned long int min = 0;
- static const unsigned long int max = ULONG_MAX;
+ static const unsigned long int min() { return 0; }
+ static const unsigned long int max() { return ULONG_MAX; }
typedef data_kind kind;
static const std::size_t card_ = 0;
typedef float sum;
@@ -190,8 +190,8 @@
template <>
struct props<signed long int>
{
- static const signed long int min = LONG_MIN;
- static const signed long int max = LONG_MAX;
+ static const signed long int min() { return LONG_MIN; }
+ static const signed long int max() { return LONG_MAX; }
typedef data_kind kind;
static const std::size_t card_ = 0;
typedef float sum;
@@ -203,9 +203,9 @@
template <>
struct props<float>
{
- static const float min = FLT_MIN;
- static const float max = FLT_MAX;
- static const float epsilon = 0.00001f;
+ static const float min() { return FLT_MIN; }
+ static const float max() { return FLT_MAX; }
+ static const float epsilon() { return 0.00001f; }
typedef data_kind kind;
static const std::size_t card_ = 0;
typedef float sum;
@@ -214,9 +214,9 @@
template <>
struct props<double>
{
- static const double min = DBL_MIN;
- static const double max = DBL_MAX;
- static const double epsilon = 0.0000001;
+ static const double min() { return DBL_MIN; }
+ static const double max() { return DBL_MAX; }
+ static const double epsilon() { return 0.0000001; }
typedef data_kind kind;
static const std::size_t card_ = 0;
typedef double sum;
Index: mln/value/all.hh
--- mln/value/all.hh (revision 1054)
+++ mln/value/all.hh (working copy)
@@ -44,7 +44,16 @@
}
+# include <mln/value/aliases.hh>
+# include <mln/value/label.hh>
# include <mln/value/props.hh>
+# include <mln/value/proxy.hh>
+
+
+// FIXME: that includes concept/image.hh!
+
+// # include <mln/value/cast.hh>
+// # include <mln/value/stack.hh>
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1054)
+++ mln/value/int_s.hh (working copy)
@@ -89,23 +89,24 @@
+ // Safety.
+ template <> struct int_s<0>;
+ template <> struct int_s<1>;
+
+
+
template <unsigned n>
struct props< int_s<n> >
{
- static const int_s<n> max; // = 2^(n-1) - 1
- static const int_s<n> min; // = - max
static const std::size_t card_ = metal::pow<2, n>::value;
+ static const int_s<n> max() { return metal::pow<2, n-1>::value - 1; }
+ static const int_s<n> min() { return - max(); }
static const unsigned nbits = n;
typedef data_kind kind;
typedef float sum;
};
- // Safety.
- template <> struct int_s<0>;
- template <> struct int_s<1>;
-
-
/*! \brief Print an signed integer \p i into the output stream \p ostr.
*
@@ -167,14 +168,6 @@
const int_s<n> int_s<n>::one = 1;
template <unsigned n>
- const int_s<n>
- props< int_s<n> >::min = 1 - metal::pow<2, n - 1>::value;
-
- template <unsigned n>
- const int_s<n>
- props< int_s<n> >::max = metal::pow<2, n - 1>::value - 1;
-
- template <unsigned n>
std::ostream& operator<<(std::ostream& ostr, const int_s<n>& i)
{
return ostr << debug::format(i.to_equiv());
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1054)
+++ mln/value/int_u.hh (working copy)
@@ -95,8 +95,8 @@
struct props< int_u<n> >
{
static const std::size_t card_ = metal::pow<2, n>::value;
- static const int_u<n> min; // = 0
- static const int_u<n> max; // = card_ - 1
+ static const int_u<n> min() { return 0; }
+ static const int_u<n> max() { return card_ - 1; }
static const unsigned nbits = n;
typedef data_kind kind;
typedef float sum;
@@ -156,15 +156,6 @@
template <unsigned n>
const int_u<n> int_u<n>::one = 1;
-
- template <unsigned n>
- const int_u<n>
- props< int_u<n> >::min = 0;
-
- template <unsigned n>
- const int_u<n>
- props< int_u<n> >::max = metal::pow<2, n>::value - 1;
-
template <unsigned n>
std::ostream& operator<<(std::ostream& ostr, const int_u<n>& i)
{
Index: mln/make/w_window_line.hh
--- mln/make/w_window_line.hh (revision 0)
+++ mln/make/w_window_line.hh (revision 0)
@@ -0,0 +1,81 @@
+// 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_MAKE_W_WINDOW_LINE_HH
+# define MLN_MAKE_W_WINDOW_LINE_HH
+
+/*! \file mln/make/w_window_line.hh
+ *
+ * \brief Routine to create an horizontal mln::w_window.
+ */
+
+# include <mln/core/w_window.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an horizontal centered and symmetrical
+ * mln::w_window.
+ *
+ * The free parameter \c D is a type of delta-point.
+ *
+ * \pre The window length \c L has to be odd.
+ *
+ * \return A window.
+ */
+ template <typename D, typename W, unsigned L>
+ mln::w_window<D,W> w_window_line(const W (&w)[L]);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename D, typename W, unsigned L>
+ mln::w_window<D,W> w_window_line(const W (&w)[L])
+ {
+ mln_precondition(L % 2 = 1);
+ mln::w_window<D,W> w_win;
+ D dp = D::zero;
+ for (unsigned i = 0; i < L; ++i)
+ {
+ dp[D::dim - 1] = i - L / 2;
+ w_win.insert(w[i], dp);
+ }
+ return w_win;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_W_WINDOW_LINE_HH
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add proper inheritance to functions.
* mln/core/concept/doc/neighborhood.hh,
* mln/core/concept/neighborhood.hh,
* mln/core/neighb.hh (point): New.
* mln/convert/to_image.hh
(helper_dim_, helper_image_from_): New in mln::internal.
(image_from_): New in mln.
(mln_image_from): New macro.
(to_image): Fix; now generalized.
* mln/metal/all.hh: New.
* mln/metal/equal.hh: Update.
(mlc_equal): New.
* mln/metal/if.hh: New.
* mln/metal/is_a.hh: New.
* mln/metal/unptr.hh: New.
* mln/metal/unqualif.hh: New.
* mln/metal/unref.hh: New.
* mln/core/concept/function.hh (result): New in Function_p2b.
* mln/fun/internal: New directory.
* mln/pw/cst.hh: Precise inheritance.
* mln/pw/value.hh: Likewise.
(select_function_): Move to...
* mln/fun/internal/selector.hh: ...this new file.
(select_function_): Rename as...
(selector_): ...this.
* mln/fun/c.hh: New.
* mln/convert/to_fun.hh: New.
* mln/convert/to_window.hh (to_window): New overload.
* mln/estim/mean.hh (mean): New overload.
* mln/estim/sum.hh: New.
* mln/level/run.hh: Rename as...
* mln/level/compute.hh: ...this.
(run): Rename as...
(compute): ...this.
* tests/w_window2d_int.cc: Augment.
mln/convert/to_fun.hh | 77 ++++++++++++++++
mln/convert/to_image.hh | 59 ++++++++++--
mln/convert/to_window.hh | 29 ++++--
mln/core/concept/doc/neighborhood.hh | 3
mln/core/concept/function.hh | 1
mln/core/concept/neighborhood.hh | 2
mln/core/neighb.hh | 3
mln/estim/mean.hh | 28 +++++
mln/estim/sum.hh | 88 ++++++++++++++++++
mln/fun/c.hh | 85 +++++++++++++++++
mln/fun/internal/selector.hh | 168 +++++++++++++++++++++++++++++++++++
mln/level/compute.hh | 18 +--
mln/metal/all.hh | 58 ++++++++++++
mln/metal/equal.hh | 16 +--
mln/metal/if.hh | 85 +++++++++++++++++
mln/metal/is_a.hh | 88 ++++++++++++++++++
mln/metal/unptr.hh | 58 ++++++++++++
mln/metal/unqualif.hh | 58 ++++++++++++
mln/metal/unref.hh | 58 ++++++++++++
mln/pw/cst.hh | 13 +-
mln/pw/value.hh | 21 ----
tests/pw_value.cc | 1
tests/w_window2d_int.cc | 24 +++--
23 files changed, 968 insertions(+), 73 deletions(-)
Index: tests/w_window2d_int.cc
--- tests/w_window2d_int.cc (revision 1052)
+++ tests/w_window2d_int.cc (working copy)
@@ -35,23 +35,22 @@
#include <mln/convert/to_image.hh>
#include <mln/convert/to_w_window.hh>
-#include <mln/debug/println.hh>
+#include <mln/convert/to_fun.hh>
+#include <mln/estim/sum.hh>
-struct my_f : mln::Function_p2v< my_f >
-{
- typedef int result;
- int operator()(const mln::point2d& p) const
+
+int f(mln::point2d p)
{
return p.row() + p.col();
}
-};
int main()
{
using namespace mln;
+ {
int ws[] = { -1, 0, 1,
-2, 0, 2,
-1, 0, 1 };
@@ -60,7 +59,16 @@
image2d_b<int> ima = convert::to_image(w_win);
w_window2d_int w_win_2 = convert::to_w_window(ima);
mln_assertion(w_win_2 = w_win);
+ }
+
+ {
+ w_window2d_int w_win = make::w_window(win::rectangle2d(3, 5),
+ convert::to_fun(f));
+ // -3 -2 -1 0 +1
+ // -2 -1 0 +1 +2
+ // -1 0 +1 +2 +3
+ image2d_b<int> ima = convert::to_image(w_win);
+ mln_assertion(estim::sum(ima) = 0);
+ }
- w_window2d_int tmp = make::w_window(win::rectangle2d(3, 5), my_f());
- debug::println(convert::to_image(tmp));
}
Index: tests/pw_value.cc
--- tests/pw_value.cc (revision 1052)
+++ tests/pw_value.cc (working copy)
@@ -43,6 +43,5 @@
image2d_b<int> ima(3, 3);
point2d p = make::point2d(1, 1);
ima(p) = 51;
-
mln_assertion( (pw::value(ima) = pw::cst(51))(p) = true );
}
Index: mln/convert/to_image.hh
--- mln/convert/to_image.hh (revision 1052)
+++ mln/convert/to_image.hh (working copy)
@@ -45,36 +45,73 @@
# include <mln/level/fill.hh>
+# define mln_image_from(Src, Value) typename mln::image_from_< Src, Value >::ret
+
+
+
namespace mln
{
+ // FIXME: Move elsewhere.
+ namespace internal
+ {
+
+ template <typename T>
+ struct helper_dim_
+ {
+ typedef mln_point(T) P;
+ enum { value = P::dim };
+ };
+
+ template <unsigned dim, typename V> struct helper_image_from_;
+
+ template <typename V>
+ struct helper_image_from_< 2, V >
+ {
+ typedef image2d_b<V> ret;
+ };
+
+ } // end of namespace mln::internal
+
+
+ // FIXME: Doc + move elsewhere!
+ template <typename T, typename V>
+ struct image_from_
+ {
+ enum { dim = internal::helper_dim_<T>::value };
+ typedef typename internal::helper_image_from_< dim, V >::ret ret;
+ };
+
+
+
namespace convert
{
+
/// Convert a point set \p pset into a binary image.
template <typename S>
- image2d_b<bool> to_image(const Point_Set<S>& pset);
+ mln_image_from(S, bool) to_image(const Point_Set<S>& pset);
/// Convert a window \p win into a binary image.
template <typename W>
- image2d_b<bool> to_image(const Window<W>& win);
+ mln_image_from(W, bool) to_image(const Window<W>& win);
/// Convert a neighborhood \p nbh into a binary image.
template <typename N>
- image2d_b<bool> to_image(const Neighborhood<N>& nbh);
+ mln_image_from(N, bool) to_image(const Neighborhood<N>& nbh);
/// Convert a weighted window \p w_win into an image.
template <typename W>
- image2d_b<mln_weight(W)> to_image(const Weighted_Window<W>& w_win);
+ mln_image_from(W, mln_weight(W)) to_image(const Weighted_Window<W>& w_win);
# ifndef MLN_INCLUDE_ONLY
template <typename S>
- image2d_b<bool> to_image(const Point_Set<S>& pset_)
+ mln_image_from(S, bool) to_image(const Point_Set<S>& pset_)
{
const S& pset = exact(pset_);
- image2d_b<bool> ima(pset.bbox());
+ mln_image_from(S, bool) ima(pset.bbox());
level::fill(ima, false);
mln_piter(S) p(pset);
for_all(p)
@@ -83,14 +120,14 @@
}
template <typename W>
- image2d_b<bool> to_image(const Window<W>& win_)
+ mln_image_from(W, bool) to_image(const Window<W>& win_)
{
const W& win = exact(win_);
mln_precondition(! win.is_empty());
typedef mln_point(W) P;
box2d b = geom::bbox(win);
- image2d_b<bool> ima(b);
+ mln_image_from(W, bool) ima(b);
level::fill(ima, false);
mln_qiter(W) q(win, P::zero);
for_all(q)
@@ -99,20 +136,20 @@
}
template <typename N>
- image2d_b<bool> to_image(const Neighborhood<N>& nbh)
+ mln_image_from(N, bool) to_image(const Neighborhood<N>& nbh)
{
return to_image(convert::to_window(nbh));
}
template <typename W>
- image2d_b<mln_weight(W)> to_image(const Weighted_Window<W>& w_win_)
+ mln_image_from(W, mln_weight(W)) to_image(const Weighted_Window<W>& w_win_)
{
const W& w_win = exact(w_win_);
mln_precondition(! w_win.is_empty());
typedef mln_point(W) P;
box2d b = geom::bbox(w_win);
- image2d_b<mln_weight(W)> ima(b);
+ mln_image_from(W, mln_weight(W)) ima(b);
mln_qiter(W) q(w_win, P::zero);
for_all(q)
ima(q) = q.w();
Index: mln/convert/to_window.hh
--- mln/convert/to_window.hh (revision 1052)
+++ mln/convert/to_window.hh (working copy)
@@ -33,9 +33,10 @@
* \brief Conversions to mln::window.
*/
-# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/window.hh>
+# include <mln/pw/image.hh>
+# include <mln/pw/cst.hh>
namespace mln
@@ -48,9 +49,13 @@
template <typename N>
window<mln_dpoint(N)> to_window(const Neighborhood<N>& nbh);
- /// Convert a binary image \p input into a window.
+ /// Convert a binary image \p ima into a window.
template <typename I>
- window<mln_dpoint(I)> to_window(const Image<I>& input);
+ window<mln_dpoint(I)> to_window(const Image<I>& ima);
+
+ /// Convert a point set \p pset into a window.
+ template <typename S, typename F>
+ window<mln_dpoint(S)> to_window(const Point_Set<S>& pset);
# ifndef MLN_INCLUDE_ONLY
@@ -69,21 +74,27 @@
}
template <typename I>
- window<mln_dpoint(I)> to_window(const Image<I>& input_)
+ window<mln_dpoint(I)> to_window(const Image<I>& ima_)
{
- const I& input = exact(input_);
- mln_precondition(input.has_data());
- // FIXME: Check that input is binary!
+ const I& ima = exact(ima_);
+ mln_precondition(ima.has_data());
+ // FIXME: Check that ima is binary!
typedef mln_dpoint(I) D;
typedef mln_point(D) P;
window<D> win;
- mln_piter(I) p(input.domain());
+ mln_piter(I) p(ima.domain());
for_all(p)
- if (input(p))
+ if (ima(p))
win.insert(p - P::zero);
return win;
}
+ template <typename S, typename F>
+ window<mln_dpoint(S)> to_window(const Point_Set<S>& pset)
+ {
+ return to_window(pw::cst(true) | pset);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::convert
Index: mln/convert/to_fun.hh
--- mln/convert/to_fun.hh (revision 0)
+++ mln/convert/to_fun.hh (revision 0)
@@ -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.
+
+#ifndef MLN_CONVERT_TO_FUN_HH
+# define MLN_CONVERT_TO_FUN_HH
+
+/*! \file mln/convert/to_fun.hh
+ *
+ * \brief Conversions towards some mln::Function.
+ */
+
+# include <mln/pw/value.hh>
+# include <mln/fun/c.hh>
+
+
+namespace mln
+{
+
+ namespace convert
+ {
+
+ /// Convert a C unary function into an mln::fun::C.
+ template <typename R, typename A>
+ fun::C<R(*)(A)> to_fun(R (*f)(A));
+
+ /// Convert an image into a function.
+ template <typename I>
+ pw::value_<I> to_fun(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename R, typename A>
+ fun::C<R(*)(A)> to_fun(R (*f_)(A))
+ {
+ fun::C<R(*)(A)> f(f_);
+ return f;
+ }
+
+ template <typename I>
+ pw::value_<I> to_fun(const Image<I>& ima)
+ {
+ return pw::value(ima);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CONVERT_TO_FUN_HH
Index: mln/estim/sum.hh
--- mln/estim/sum.hh (revision 0)
+++ mln/estim/sum.hh (revision 0)
@@ -0,0 +1,88 @@
+// 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_ESTIM_SUM_HH
+# define MLN_ESTIM_SUM_HH
+
+/*! \file mln/estim/sum.hh
+ *
+ * \brief Compute the sum pixel value.
+ */
+
+# include <mln/accu/sum.hh>
+# include <mln/level/compute.hh>
+
+
+namespace mln
+{
+
+ namespace estim
+ {
+
+ /*! \brief Compute the sum value of the pixels of image \p input.
+ *
+ * \param[in] input The image.
+ * \return The sum value.
+ */
+ template <typename I>
+ mln_sum(mln_value(I)) sum(const Image<I>& input);
+
+
+ /*! \brief Compute the sum value of the pixels of image \p input.
+ *
+ * \param[in] input The image.
+ * \param[out] result The sum value.
+ */
+ template <typename I, typename S>
+ void sum(const Image<I>& input, S& result);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_sum(mln_value(I)) sum(const Image<I>& input)
+ {
+ mln_precondition(exact(input).has_data());
+ return level::compute(input, accu::sum<mln_value(I)>()).to_value();
+ }
+
+ template <typename I, typename S>
+ void sum(const Image<I>& input, S& result)
+ {
+ mln_precondition(exact(input).has_data());
+ result = level::compute(input,
+ accu::sum<mln_value(I), S>()).to_value();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::estim
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ESTIM_SUM_HH
Index: mln/estim/mean.hh
--- mln/estim/mean.hh (revision 1052)
+++ mln/estim/mean.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/accu/mean.hh>
-# include <mln/level/run.hh>
+# include <mln/level/compute.hh>
namespace mln
@@ -46,20 +46,40 @@
/*! \brief Compute the mean value of the pixels of image \p input.
*
* \param[in] input The image.
+ * \return The mean value.
*/
template <typename I>
mln_sum(mln_value(I)) mean(const Image<I>& input);
+ /*! \brief Compute the mean value of the pixels of image \p input.
+ *
+ * \param[in] input The image.
+ * \param[out] result The mean value.
+ *
+ * The free parameter \c S is the type used to compute the
+ * summation.
+ */
+ template <typename S, typename I, typename M>
+ void mean(const Image<I>& input, M& result);
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_sum(mln_value(I)) mean(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- typedef mln_value(I) V;
- typedef mln_sum(V) S;
- return level::run(input, accu::mean<V, S>()).to_value();
+ return level::compute(input,
+ accu::mean<mln_value(I)>()).to_value();
+ }
+
+ template <typename S, typename I, typename M>
+ void mean(const Image<I>& input, M& result)
+ {
+ mln_precondition(exact(input).has_data());
+ result = level::compute(input,
+ accu::mean<mln_value(I), S, M>()).to_value();
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/pw/cst.hh
--- mln/pw/cst.hh (revision 1052)
+++ mln/pw/cst.hh (working copy)
@@ -33,7 +33,7 @@
* \brief FIXME.
*/
-# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
namespace mln
@@ -45,11 +45,12 @@
// FIXME: Doc!
template <typename T>
- struct cst_ : public Function_p2v< cst_<T> >
+ struct cst_
+ : fun::internal::selector_p2_<T, cst_<T> >::ret
{
typedef T result;
- cst_(T t);
+ cst_(const T& t);
template <typename P>
T operator()(const P&) const;
@@ -62,7 +63,7 @@
// FIXME: Doc!
template <typename T>
- cst_<T> cst(T t);
+ cst_<T> cst(const T& t);
# ifndef MLN_INCLUDE_ONLY
@@ -70,7 +71,7 @@
// pw::cst_<T>
template <typename T>
- cst_<T>::cst_(T t)
+ cst_<T>::cst_(const T& t)
: t_(t)
{
}
@@ -86,7 +87,7 @@
// pw::cst(t)
template <typename T>
- cst_<T> cst(T t)
+ cst_<T> cst(const T& t)
{
cst_<T> tmp(t);
return tmp;
Index: mln/pw/value.hh
--- mln/pw/value.hh (revision 1052)
+++ mln/pw/value.hh (working copy)
@@ -33,9 +33,8 @@
* \brief FIXME.
*/
-# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
# include <mln/core/concept/image.hh>
-# include <mln/value/props.hh>
@@ -45,26 +44,12 @@
namespace pw
{
- // FIXME: Move!
-
- namespace internal
- {
-
- template <typename K, typename E>
- struct select_function_ : Function_p2v<E>
- {};
-
- template <typename E>
- struct select_function_< value::binary_kind, E > : Function_p2b<E>
- {};
-
- } // end of namespace mln::pw::internal
-
// FIXME: Doc!
template <typename I>
- struct value_ : public internal::select_function_< mln_value_kind(I), value_<I> >
+ struct value_
+ : fun::internal::selector_p2_< mln_value(I), value_<I> >::ret
{
typedef mln_value(I) result;
value_(const I& ima);
Index: mln/core/neighb.hh
--- mln/core/neighb.hh (revision 1052)
+++ mln/core/neighb.hh (working copy)
@@ -58,6 +58,9 @@
/// Dpoint associated type.
typedef D dpoint;
+ /// Point associated type.
+ typedef mln_point(D) point;
+
/*! \brief Point_Iterator type to browse the points of a generic
* neighborhood w.r.t. the ordering of delta-points.
*/
Index: mln/core/concept/function.hh
--- mln/core/concept/function.hh (revision 1052)
+++ mln/core/concept/function.hh (working copy)
@@ -99,6 +99,7 @@
template <typename E>
struct Function_p2b : public Function_p2v<E>
{
+ typedef bool result;
protected:
Function_p2b();
};
Index: mln/core/concept/neighborhood.hh
--- mln/core/concept/neighborhood.hh (revision 1052)
+++ mln/core/concept/neighborhood.hh (working copy)
@@ -52,6 +52,7 @@
typedef bkd_niter;
typedef dpoint;
+ typedef point;
*/
protected:
@@ -68,6 +69,7 @@
typedef mln_fwd_niter(E) fwd_niter;
typedef mln_bkd_niter(E) bkd_niter;
typedef mln_dpoint(E) dpoint;
+ typedef mln_point(E) point;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/doc/neighborhood.hh
--- mln/core/concept/doc/neighborhood.hh (revision 1052)
+++ mln/core/concept/doc/neighborhood.hh (working copy)
@@ -59,6 +59,9 @@
/// Dpoint associated type.
typedef void dpoint;
+
+ /// Point associated type.
+ typedef void point;
};
} // end of namespace mln::doc
Index: mln/fun/c.hh
--- mln/fun/c.hh (revision 0)
+++ mln/fun/c.hh (revision 0)
@@ -0,0 +1,85 @@
+// 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_FUN_C_HH
+# define MLN_FUN_C_HH
+
+/*! \file mln/fun/c.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/fun/internal/selector.hh>
+# include <mln/metal/unqualif.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ template <typename F> struct C;
+
+
+ // FIXME: Doc!
+ template <typename R, typename A>
+ struct C< R (*)(A) >
+ :
+ fun::internal::selector_< R, A, C<R(*)(A)> >::ret
+ {
+ C(R (*f)(A));
+ typedef R result;
+ R operator()(const mlc_unqualif(A)& a) const;
+ protected:
+ R (*f_)(A);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename R, typename A>
+ C<R(*)(A)>::C(R (*f)(A))
+ : f_(f)
+ {
+ }
+
+ template <typename R, typename A>
+ R
+ C<R(*)(A)>::operator()(const mlc_unqualif(A)& a) const
+ {
+ return f_(a);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_C_HH
Index: mln/fun/internal/selector.hh
--- mln/fun/internal/selector.hh (revision 0)
+++ mln/fun/internal/selector.hh (revision 0)
@@ -0,0 +1,168 @@
+// 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_FUN_INTERNAL_SELECTOR_HH
+# define MLN_FUN_INTERNAL_SELECTOR_HH
+
+/*! \file mln/fun/internal/selector.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/point.hh>
+# include <mln/metal/unqualif.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/is_a.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ // Function_v2v
+ // |
+ // + -- Function_i2v
+ // |
+ // + -- Function_p2v
+ // |
+ // + -- Function_p2b
+ // |
+ // + -- Function_p2p
+
+ enum
+ {
+ b_,
+ i_,
+ p_,
+ v_
+ };
+
+ template <int arg, int res, typename E> struct helper_selector_;
+
+ // no b2* type => v2v type
+ template <typename E>
+ struct helper_selector_< b_, b_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, i_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, p_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, v_, E > { typedef Function_v2v<E> ret; };
+
+ // i2* => only i2v type
+ template <typename E>
+ struct helper_selector_< i_, b_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, i_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, p_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, v_, E > { typedef Function_i2v<E> ret; };
+
+ // p2*
+ template <typename E>
+ struct helper_selector_< p_, b_, E > { typedef Function_p2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< p_, i_, E > { typedef Function_p2v<E> ret; }; // no p2i type => p2v
+ template <typename E>
+ struct helper_selector_< p_, p_, E > { typedef Function_p2p<E> ret; };
+ template <typename E>
+ struct helper_selector_< p_, v_, E > { typedef Function_p2v<E> ret; };
+
+ // v2* => only v2v type
+ template <typename E>
+ struct helper_selector_< v_, b_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, i_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, p_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, v_, E > { typedef Function_v2v<E> ret; };
+
+
+ // tag_
+
+ template <typename T> struct tag_;
+
+ template <>
+ struct tag_< bool >
+ {
+ enum { value = b_ };
+ };
+
+ template <>
+ struct tag_< unsigned >
+ {
+ enum { value = i_ };
+ };
+
+ template <typename T>
+ struct tag_
+ {
+ enum { value = mlc_is_a(T, Point)::to_bool
+ ? p_
+ : v_ };
+ };
+
+
+ template <typename R_, typename A_, typename E>
+ struct selector_
+ {
+ typedef mlc_unqualif(R_) R;
+ typedef mlc_unqualif(A_) A;
+ enum { arg = tag_<A>::value,
+ res = tag_<R>::value };
+ typedef typename helper_selector_<arg, res, E>::ret ret;
+ private:
+ selector_();
+ };
+
+
+ template <typename R_, typename E>
+ struct selector_p2_
+ {
+ typedef mlc_unqualif(R_) R;
+ enum { res = tag_<R>::value };
+ typedef typename helper_selector_<p_, res, E>::ret ret;
+ private:
+ selector_p2_();
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_INTERNAL_SELECTOR_HH
Index: mln/metal/unqualif.hh
--- mln/metal/unqualif.hh (revision 0)
+++ mln/metal/unqualif.hh (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_METAL_UNQUALIF_HH
+# define MLN_METAL_UNQUALIF_HH
+
+# include <mln/metal/unconst.hh>
+# include <mln/metal/unptr.hh>
+# include <mln/metal/unref.hh>
+
+
+# define mlc_unqualif(T) typename mln::metal::unqualif< T >::ret
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct unqualif
+ {
+ typedef mlc_unref(T) tmp1;
+ typedef mlc_unconst(tmp1) tmp2;
+ typedef mlc_unptr(tmp2) ret;
+ };
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_UNQUALIF_HH
Index: mln/metal/if.hh
--- mln/metal/if.hh (revision 0)
+++ mln/metal/if.hh (revision 0)
@@ -0,0 +1,85 @@
+// 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_CORE_METAL_IF_HH
+# define MLN_CORE_METAL_IF_HH
+
+/*! \file mln/metal/if.hh
+ *
+ * \brief Definition of an "if-then-else" expression type.
+ */
+
+# include <mln/metal/bool.hh>
+
+# define mlc_if(Cond, Then, Else) typename mln::metal::if_< Cond, Then, Else >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ namespace internal
+ {
+
+ template <bool cond, typename Then, typename Else>
+ struct helper_if_;
+
+ template <typename Then, typename Else>
+ struct helper_if_< true, Then, Else >
+ {
+ typedef Then ret;
+ };
+
+ template <typename Then, typename Else>
+ struct helper_if_< false, Then, Else >
+ {
+ typedef Else ret;
+ };
+
+ } // end of namespace mln::metal::internal
+
+
+ /*! \brief "if-then-else" expression.
+ *
+ * FIXME: Doc!
+ */
+ template <typename Cond, typename Then, typename Else>
+ struct if_ : internal::helper_if_< Cond::value, Then, Else >
+ {
+ // ret is inherited.
+ };
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_METAL_IF_HH
Index: mln/metal/equal.hh
--- mln/metal/equal.hh (revision 1052)
+++ mln/metal/equal.hh (working copy)
@@ -28,6 +28,11 @@
#ifndef MLN_METAL_EQUAL_HH
# define MLN_METAL_EQUAL_HH
+# include <mln/metal/bool.hh>
+
+
+# define mlc_equal(T1, T2) mln::metal::equal< T1, T2 >
+
namespace mln
{
@@ -36,15 +41,12 @@
{
template <typename T1, typename T2>
- struct equal
- {
- };
+ struct equal : false_
+ {};
template <typename T>
- struct equal< T, T >
- {
- static void check() {}
- };
+ struct equal< T, T > : true_
+ {};
} // end of namespace mln::metal
Index: mln/metal/unptr.hh
--- mln/metal/unptr.hh (revision 0)
+++ mln/metal/unptr.hh (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_METAL_UNPTR_HH
+# define MLN_METAL_UNPTR_HH
+
+
+# define mlc_unptr(T) typename mln::metal::unptr< T >::ret
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct unptr
+ {
+ typedef T ret;
+ };
+
+ template <typename T>
+ struct unptr< T* >
+ {
+ typedef mlc_unptr(T) ret;
+ };
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_UNPTR_HH
Index: mln/metal/all.hh
--- mln/metal/all.hh (revision 0)
+++ mln/metal/all.hh (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_METAL_ALL_HH
+# define MLN_METAL_ALL_HH
+
+/*! \file mln/metal/all.hh
+ *
+ * \brief File that includes all meta-programming tools.
+ */
+
+namespace mln
+{
+
+ /// Namespace of meta-programming tools.
+ namespace metal {}
+
+} // end of namespace mln
+
+
+# include <mln/metal/bexpr.hh> // <- bool.hh
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/is_a.hh>
+# include <mln/metal/math.hh>
+# include <mln/metal/none.hh>
+# include <mln/metal/unqualif.hh> // <- unconst.hh, unptr.hh, unref.hh
+# include <mln/metal/vec.hh>
+
+# include <mln/metal/same_coord.hh>
+# include <mln/metal/same_point.hh>
+
+
+#endif // ! MLN_METAL_ALL_HH
Index: mln/metal/is_a.hh
--- mln/metal/is_a.hh (revision 0)
+++ mln/metal/is_a.hh (revision 0)
@@ -0,0 +1,88 @@
+// 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_CORE_METAL_IS_A_HH
+# define MLN_CORE_METAL_IS_A_HH
+
+/*! \file mln/metal/is_a.hh
+ *
+ * \brief Definition of a type that means "is_a".
+ */
+
+
+# define mlc_is_a(T, U) mln::metal::is_a< T, U >
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ namespace internal
+ {
+
+ typedef char yes_;
+ struct no_ { char dummy[2]; };
+
+ template <typename T>
+ struct make_
+ {
+ static T* ptr();
+ };
+
+ template <typename T, template <class> class U>
+ struct helper_is_a_
+ {
+
+ template<class V>
+ static yes_ selector(U<V>*);
+ static no_ selector(...);
+ };
+
+ } // end of namespace mln::metal::internal
+
+
+
+ /*! \brief "is_a" check.
+ *
+ * FIXME: Doc!
+ */
+ template <typename T, template <class> class U>
+ struct is_a : bool_<( sizeof( internal::helper_is_a_<T,U>::selector(internal::make_<T>::ptr()) )
+ =
+ sizeof( internal::yes_ ) )>::type
+ {};
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_METAL_IS_A_HH
Index: mln/metal/unref.hh
--- mln/metal/unref.hh (revision 0)
+++ mln/metal/unref.hh (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_METAL_UNREF_HH
+# define MLN_METAL_UNREF_HH
+
+
+# define mlc_unref(T) typename mln::metal::unref< T >::ret
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct unref
+ {
+ typedef T ret;
+ };
+
+ template <typename T>
+ struct unref< T& >
+ {
+ typedef T ret;
+ };
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_UNREF_HH
Index: mln/level/compute.hh
--- mln/level/compute.hh (revision 1052)
+++ mln/level/compute.hh (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_LEVEL_RUN_HH
-# define MLN_LEVEL_RUN_HH
+#ifndef MLN_LEVEL_COMPUTE_HH
+# define MLN_LEVEL_COMPUTE_HH
-/*! \file mln/level/run.hh
+/*! \file mln/level/compute.hh
*
- * \brief Run an accumulator onto image pixel values.
+ * \brief Compute an accumulator onto image pixel values.
*/
# include <mln/level/take.hh>
@@ -42,26 +42,26 @@
namespace level
{
- /*! Run an accumulator onto the pixel values of the image \p input.
+ /*! Compute an accumulator onto the pixel values of the image \p input.
*
* \param[in] input The input image.
* \param[in] a The accumulator.
* \return A resulting accumulator.
*
- * This routine runs: \n
+ * This routine computes: \n
* res = \p a \n
* res.init() \n
* level::take(res, \p input) \n
* return res \n
*/
template <typename I, typename A>
- A run(const Image<I>& input, const Accumulator<A>& a);
+ A compute(const Image<I>& input, const Accumulator<A>& a);
# ifndef MLN_INCLUDE_ONLY
template <typename I, typename A>
- A run(const Image<I>& input, const Accumulator<A>& a)
+ A compute(const Image<I>& input, const Accumulator<A>& a)
{
A res = exact(a);
res.init();
@@ -76,4 +76,4 @@
} // end of namespace mln
-#endif // ! MLN_LEVEL_RUN_HH
+#endif // ! MLN_LEVEL_COMPUTE_HH