Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2009
- 11 participants
- 312 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Several fixes and new stuff.
Starting revamping world inter-pixel.
* mln/world/inter_pixel/image2full.hh: Rename as...
* mln/world/inter_pixel/immerse.hh: ...this new file.
(image2full): Rename as...
(immerse): ...this.
Revamp.
* mln/world/inter_pixel/separator_to_pixels.hh: New.
* mln/world/inter_pixel/is_separator.hh: New.
* mln/world/inter_pixel/is_pixel.hh: New.
* mln/world/inter_pixel/compute.hh: New.
* mln/world/inter_pixel/make: New directory.
* mln/world/inter_pixel/neighb2d.hh: Fix ending guard.
* mln/world/inter_pixel/display_edge.hh: Likewise.
* mln/core/macros.hh (mln_unmorph, mln_unmorph_): New.
* mln/core/point.hh (point): Fix warning.
Add static check.
* mln/core/internal/image_morpher.hh (unmorph): New typedef.
* mln/core/internal/pixel_impl.hh
(pixel_impl_): Fix compile errors with g++-3.4.
* mln/core/concept/gpoint.hh (operator*): New overload with scalar.
(trait): New corresponding trait.
* tests/world/inter_pixel/compute.cc: New.
* tests/world/inter_pixel/immerse.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
Fix missing code for operator less with builtins.
* mln/value/builtin/ops.hh:
(mln_internal_decl_op_less_): New.
(mln_internal_def_op_less_): New.
(mln_internal_builtins_op_less_): New.
Misc.
* mln/accu/stat/all.hh: New.
* mln/accu/all.hh: Update.
* mln/convert/to_fun.hh: Upgrade doc style.
* mln/data/paste_without_localization.hh: New.
* mln/data/paste.hh: New static check.
* mln/fun/c.hh: Likewise.
Fix ending guard.
Augmenting accumulators.
* mln/accu/stat/var.hh (mean_t): New typedef.
(to_result, mean): Fix null_ construction.
* tests/accu/stat: New directory.
* tests/accu/stat/Makefile.am: New.
* tests/accu/stat/var.cc: New.
* tests/accu/Makefile.am: Update.
Augmenting fun :-)
* mln/fun/access: New directory.
* mln/fun/access/all.hh: New.
* mln/fun/access/mean.hh: New.
* mln/fun/all.hh: Update.
* mln/fun/stat: New.
* mln/fun/stat/all.hh: New.
* mln/fun/stat/mahalanobis.hh: New.
* tests/fun/stat: New.
* tests/fun/stat/mahalanobis.cc: New.
* tests/fun/stat/Makefile.am: New.
* tests/fun/Makefile.am: Update.
mln/accu/all.hh | 1
mln/accu/stat/all.hh | 53 +++++++++++
mln/accu/stat/var.hh | 14 ++-
mln/convert/to_fun.hh | 10 +-
mln/core/concept/gpoint.hh | 32 ++++++-
mln/core/internal/image_morpher.hh | 4
mln/core/internal/pixel_impl.hh | 14 +--
mln/core/macros.hh | 10 ++
mln/core/point.hh | 11 +-
mln/data/paste.hh | 6 -
mln/data/paste_without_localization.hh | 93 ++++++++++++++++++++
mln/fun/access/all.hh | 52 +++++++++++
mln/fun/access/mean.hh | 91 +++++++++++++++++++
mln/fun/all.hh | 18 +--
mln/fun/c.hh | 14 +--
mln/fun/stat/all.hh | 54 +++++++++++
mln/fun/stat/mahalanobis.hh | 95 ++++++++++++++++++++
mln/value/builtin/ops.hh | 76 +++++++++++++++-
mln/world/inter_pixel/compute.hh | 99 +++++++++++++++++++++
mln/world/inter_pixel/display_edge.hh | 2
mln/world/inter_pixel/immerse.hh | 63 +++++++------
mln/world/inter_pixel/is_pixel.hh | 47 +++++++---
mln/world/inter_pixel/is_separator.hh | 91 +++++++++++++++++++
mln/world/inter_pixel/neighb2d.hh | 2
mln/world/inter_pixel/separator_to_pixels.hh | 123 +++++++++++++++++++++++++++
tests/accu/Makefile.am | 3
tests/accu/stat/Makefile.am | 10 ++
tests/accu/stat/var.cc | 73 ++++++++++++++++
tests/fun/Makefile.am | 10 +-
tests/fun/stat/Makefile.am | 10 ++
tests/fun/stat/mahalanobis.cc | 74 ++++++++++++++++
tests/world/inter_pixel/Makefile.am | 4
tests/world/inter_pixel/compute.cc | 87 +++++++++++++++++++
tests/world/inter_pixel/immerse.cc | 46 +++++-----
34 files changed, 1274 insertions(+), 118 deletions(-)
Index: mln/world/inter_pixel/immerse.hh
--- mln/world/inter_pixel/immerse.hh (revision 3759)
+++ mln/world/inter_pixel/immerse.hh (working copy)
@@ -25,20 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IMMERSE_HH
+# define MLN_WORLD_INTER_PIXEL_IMMERSE_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/immerse.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// Convert a classical image to an inter-pixel image.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/data/paste_without_localization.hh>
+# include <mln/geom/nsites.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
namespace mln
@@ -50,44 +47,48 @@
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
+ /// Convert an image to an inter-pixel image.
///
+ /// \param[in] input An image.
/// \return An inter-pixel image.
//
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
+ template <typename I>
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input);
-# ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
+ template <typename I>
+ inline
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input_)
{
- trace::entering("world::inter_pixel::image2full");
+ trace::entering("world::inter_pixel::immerse");
+
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ const I& input = exact(input_);
mln_precondition(input.is_valid());
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ mln_domain(I) b(2 * input.domain().pmin(),
+ 2 * input.domain().pmax());
+ mln_concrete(I) output(b);
+ mln_assertion(geom::nsites(output | is_pixel()) == input.domain().nsites());
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+ data::paste_without_localization(input, (output | is_pixel()).rw());
+ trace::exiting("world::inter_pixel::immerse");
+ return output | is_pixel();
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IMMERSE_HH
Property changes on: mln/world/inter_pixel/immerse.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/world/inter_pixel/neighb2d.hh
--- mln/world/inter_pixel/neighb2d.hh (revision 3767)
+++ mln/world/inter_pixel/neighb2d.hh (working copy)
@@ -101,4 +101,4 @@
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D
+#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D_HH
Index: mln/world/inter_pixel/separator_to_pixels.hh
--- mln/world/inter_pixel/separator_to_pixels.hh (revision 0)
+++ mln/world/inter_pixel/separator_to_pixels.hh (revision 0)
@@ -0,0 +1,123 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+# define MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+
+/// \file mln/world/inter_pixel/separator_to_pixels.hh
+///
+/// FIXME: doc.
+///
+/// \todo Generalize to n-D.
+
+# include <mln/core/concept/gpoint.hh>
+# include <mln/core/concept/site_proxy.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+
+ template <typename P>
+ void
+ separator_to_pixels(const Gpoint<P>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+ template <typename Ps, typename P>
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename P>
+ inline
+ void
+ separator_to_pixels(const Gpoint<P>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const P& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ // FIXME: 2D only.
+ if (s.row() % 2)
+ {
+ // Horizontal edge.
+ p1 = point2d(s.row() - 1, s.col());
+ p2 = point2d(s.row() + 1, s.col());
+ }
+ else
+ {
+ // Vertical edge.
+ p1 = point2d(s.row(), s.col() - 1);
+ p2 = point2d(s.row(), s.col() + 1);
+ }
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+ template <typename Ps, typename P>
+ inline
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const Ps& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ separator_to_pixels(s.to_site(), p1, p2);
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
Index: mln/world/inter_pixel/display_edge.hh
--- mln/world/inter_pixel/display_edge.hh (revision 3767)
+++ mln/world/inter_pixel/display_edge.hh (working copy)
@@ -82,4 +82,4 @@
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE
+#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH
Index: mln/world/inter_pixel/is_separator.hh
--- mln/world/inter_pixel/is_separator.hh (revision 0)
+++ mln/world/inter_pixel/is_separator.hh (revision 0)
@@ -0,0 +1,91 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
+# define MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
+
+/// \file mln/world/inter_pixel/is_separator.hh
+///
+/// FIXME: doc.
+///
+/// \todo Make it work in n-D.
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ struct is_separator : public Function_p2b< is_separator >
+ {
+ typedef bool result;
+
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
+
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Gpoint<P>& p_) const
+ {
+ const P& p = exact(p_);
+ return p.row() % 2 + p.col() % 2 == 1;
+ }
+
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
Index: mln/world/inter_pixel/is_pixel.hh
--- mln/world/inter_pixel/is_pixel.hh (revision 3759)
+++ mln/world/inter_pixel/is_pixel.hh (working copy)
@@ -25,14 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH
-# define MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
+# define MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
-/// \file mln/world/inter_pixel/dim2d/is_pixel.hh
+/// \file mln/world/inter_pixel/is_pixel.hh
///
-/// FIXME: insert comment.
+/// FIXME: doc.
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
-# include <mln/core/alias/point2d.hh>
namespace mln
{
@@ -43,29 +46,43 @@
namespace inter_pixel
{
- namespace dim2
- {
-
struct is_pixel : public Function_p2b< is_pixel >
{
typedef bool result;
- bool operator()(const point2d& p) const;
+
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
+
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
};
# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
inline
bool
- is_pixel::operator()(const point2d& p) const
+ is_pixel::operator()(const Gpoint<P>& p_) const
{
- return p.row() % 2 == 0 && p.col() % 2 == 0;
+ const P& p = exact(p_);
+ const unsigned n = P::dim;
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] % 2 == 1)
+ return false;
+ return true;
}
-# endif // ! MLN_INCLUDE_ONLY
-
+ template <typename P>
+ inline
+ bool
+ is_pixel::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
- } // end of namespace mln::world::inter_pixel::dim2
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::world::inter_pixel
@@ -73,4 +90,4 @@
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
Property changes on: mln/world/inter_pixel/is_pixel.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/world/inter_pixel/compute.hh
--- mln/world/inter_pixel/compute.hh (revision 0)
+++ mln/world/inter_pixel/compute.hh (revision 0)
@@ -0,0 +1,99 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_WORLD_INTER_PIXEL_COMPUTE_HH
+# define MLN_WORLD_INTER_PIXEL_COMPUTE_HH
+
+/// \file mln/world/inter_pixel/compute.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+
+ template <typename I, typename F>
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input, const Function_vv2v<F>& f);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename F>
+ inline
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input_, const Function_vv2v<F>& f_)
+ {
+ trace::entering("world::inter_pixel::compute");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
+
+ mln_precondition(input.is_valid());
+
+ typedef mln_unmorph(I) I_;
+ typedef mln_ch_value(I_, mln_result(F)) O_;
+ O_ output_;
+ initialize(output_, input.unmorph_());
+
+ typedef image_if<O_, is_separator> O;
+ O output(output_, is_separator());
+
+ mln_piter(O) e(output.domain());
+ for_all(e)
+ {
+ mln_site(I) p1, p2;
+ separator_to_pixels(e, p1, p2);
+ output(e) = f(input(p1), input(p2));
+ }
+
+ trace::exiting("world::inter_pixel::compute");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_COMPUTE_HH
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 3767)
+++ mln/core/macros.hh (working copy)
@@ -372,6 +372,16 @@
+// u
+
+/// Shortcuts to access the unmorph type associated to T.
+/// \{
+# define mln_unmorph(T) typename T::unmorph
+# define mln_unmorph_(T) T::unmorph
+/// \}
+
+
+
// v
/// Shortcuts to access the value type associated to T.
Index: mln/core/point.hh
--- mln/core/point.hh (revision 3767)
+++ mln/core/point.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -294,16 +294,17 @@
inline
point<G,C>::point(const algebra::vec<dim,C2>& v)
{
+ mlc_converts_to(C2, C)::check();
unsigned j = 0;
- //FIXME: to be improved.
+ //FIXME: to be improved while adding a conversion routine.
if (dim < 3)
coord_ = v;
else
{
for (unsigned i = dim - 2; i < dim; ++i)
- coord_[i] = v[j++];
+ coord_[i] = static_cast<C>(v[j++]);
for (unsigned i = 2; i < dim; ++i, ++j)
- coord_[i-j] = v[j];
+ coord_[i-j] = static_cast<C>(v[j]);
}
}
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 3767)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -64,6 +64,10 @@
I* delegatee_();
+
+ /// Unmorph image associated type.
+ typedef I unmorph;
+
/// Give the morphed image (mutable version).
I& unmorph_();
Index: mln/core/internal/pixel_impl.hh
--- mln/core/internal/pixel_impl.hh (revision 3767)
+++ mln/core/internal/pixel_impl.hh (working copy)
@@ -233,7 +233,7 @@
bool
pixel_impl_<I, E>::is_valid_() const
{
- return value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -249,7 +249,7 @@
pixel_impl_<I, E>::val()
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -258,7 +258,7 @@
pixel_impl_<I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -267,7 +267,7 @@
pixel_impl_<I, E>::ima() const
{
// a const pixel, yet a mutable image
- return const_cast<I&>(image_);
+ return const_cast<I&>(this->image_);
}
template <typename I, typename E>
@@ -286,7 +286,7 @@
bool
pixel_impl_<const I, E>::is_valid_() const
{
- return value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -302,7 +302,7 @@
pixel_impl_<const I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -310,7 +310,7 @@
const I&
pixel_impl_<const I, E>::ima() const
{
- return image_;
+ return this->image_;
}
template <typename I, typename E>
Index: mln/core/concept/gpoint.hh
--- mln/core/concept/gpoint.hh (revision 3767)
+++ mln/core/concept/gpoint.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/site.hh>
# include <mln/core/concept/gdpoint.hh>
-# include <mln/value/concept/scalar.hh>
+# include <mln/value/scalar.hh>
# include <mln/algebra/vec.hh>
# include <mln/util/ord.hh>
# include <mln/debug/format.hh>
@@ -74,6 +74,14 @@
typedef mln_delta(L) ret;
};
+ template < typename L, typename R >
+ struct set_binary_< op::times,
+ mln::Gpoint, L,
+ mln::Object, mln::value::scalar_<R> >
+ {
+ typedef L ret;
+ };
+
template <typename P>
struct set_unary_< op::ord, mln::Gpoint, P >
@@ -200,7 +208,7 @@
- /// Substract a delta-point \p rhs to a grid point \p lhs.
+ /// Substract a delta-point \p dp to a grid point \p p.
///
/*! \param[in] p A grid point.
* \param[in] dp A delta-point.
@@ -217,6 +225,13 @@
operator-(const Gpoint<P>& p, const Gdpoint<D>& dp);
+ /// Multiply a point \p p by a scalar \p s.
+ //
+ template <typename P, typename S>
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s);
+
+
/// Print a grid point \p p into the output stream \p ostr.
/*! \param[in,out] ostr An output stream.
* \param[in] p A grid point.
@@ -380,6 +395,19 @@
return tmp;
}
+ template <typename P, typename S>
+ inline
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s)
+ {
+ int s_ = s.to_equiv();
+ const unsigned n = P::dim;
+ P tmp = exact(p);
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] *= s_;
+ return tmp;
+ }
+
template <typename P>
inline
std::ostream& operator<<(std::ostream& ostr, const Gpoint<P>& p)
Index: mln/data/paste_without_localization.hh
--- mln/data/paste_without_localization.hh (revision 0)
+++ mln/data/paste_without_localization.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_DATA_PASTE_WITHOUT_LOCALIZATION_HH
+# define MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
+
+/// \file mln/data/paste_without_localization.hh
+///
+/// Paste the contents of an image into another one without taking
+/// into account the localization of sites.
+
+# include <mln/core/concept/image.hh>
+
+
+
+namespace mln
+{
+
+ namespace data
+ {
+
+ /// \brief Paste the contents of image \p input into the image \p
+ /// output without taking into account the localization of sites.
+ ///
+ /// \param[in] input The input image providing pixels values.
+ /// \param[in,out] output The image in which values are
+ /// assigned.
+ //
+ template <typename I, typename J>
+ void paste_without_localization(const Image<I>& input, Image<J>& output);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename J>
+ inline
+ void paste_without_localization(const Image<I>& input_, Image<J>& output_)
+ {
+ trace::entering("data::paste_without_localization");
+
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
+ const I& input = exact(input_);
+ J& output = exact(output_);
+
+ mln_fwd_piter(I) pi(input.domain());
+ pi.start();
+ mln_fwd_piter(J) po(output.domain());
+ po.start();
+ while (pi.is_valid() && po.is_valid())
+ {
+ output(po) = input(pi);
+ pi.next();
+ po.next();
+ }
+
+ trace::exiting("data::paste_without_localization");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::data
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
Index: mln/data/paste.hh
--- mln/data/paste.hh (revision 3767)
+++ mln/data/paste.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -129,6 +129,8 @@
{
trace::entering("data::paste");
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
internal::paste_tests(input, output);
internal::paste_dispatch(input, output);
Index: mln/accu/all.hh
--- mln/accu/all.hh (revision 3767)
+++ mln/accu/all.hh (working copy)
@@ -99,6 +99,7 @@
# include <mln/accu/image/all.hh>
# include <mln/accu/site_set/all.hh>
+# include <mln/accu/stat/all.hh>
#endif // ! MLN_ACCU_ALL_HH
Index: mln/accu/stat/var.hh
--- mln/accu/stat/var.hh (revision 3767)
+++ mln/accu/stat/var.hh (working copy)
@@ -40,6 +40,7 @@
# include <mln/fun/i2v/all_to.hh>
# include <mln/util/pix.hh>
+
namespace mln
{
@@ -84,8 +85,13 @@
/// Get the number of items.
unsigned n_items() const;
+
+ /// Type equipment.
+ typedef algebra::vec<dim,float> mean_t;
+ // ...
+
/// Get the mean vector.
- algebra::vec<dim,float> mean() const;
+ mean_t mean() const;
/// Check whether this accu returns a valid result.
bool is_valid() const;
@@ -163,7 +169,7 @@
mln_result(var<T>)
var<T>::to_result() const
{
- static result null_(fun::i2v::all_to(0));
+ static result null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
@@ -192,10 +198,10 @@
template <typename T>
inline
- algebra::vec<dim,float>
+ typename var<T>::mean_t
var<T>::mean() const
{
- static algebra::vec<dim,float> null_(fun::i2v::all_to(0));
+ static algebra::vec<dim,float> null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
Index: mln/accu/stat/all.hh
--- mln/accu/stat/all.hh (revision 0)
+++ mln/accu/stat/all.hh (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_ACCU_STAT_ALL_HH
+# define MLN_ACCU_STAT_ALL_HH
+
+/// \file mln/accu/stat/all.hh
+///
+/// File that includes all statistical accumulator types.
+
+
+namespace mln
+{
+ namespace accu
+ {
+
+ /// Namespace of statistical accumulators.
+ namespace stat {}
+
+ }
+}
+
+
+# include <mln/accu/stat/deviation.hh>
+# include <mln/accu/stat/var.hh>
+# include <mln/accu/stat/variance.hh>
+
+
+#endif // ! MLN_ACCU_STAT_ALL_HH
Index: mln/value/builtin/ops.hh
--- mln/value/builtin/ops.hh (revision 3767)
+++ mln/value/builtin/ops.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
#ifndef MLN_VALUE_BUILTIN_OPS_HH
# define MLN_VALUE_BUILTIN_OPS_HH
-/*! \file mln/value/builtin/ops.hh
- *
- * \brief Definitions of binary operators when lhs is a built-in and
- * rhs is an mln object.
- */
+/// \file mln/value/builtin/ops.hh
+///
+/// Definitions of binary operators when lhs is a built-in and
+/// rhs is an mln object.
# include <mln/value/scalar.hh>
# include <mln/trait/op/all.hh>
@@ -149,6 +149,7 @@
+
# define mln_internal_op_obj_builtins_(De, Symb, Name) \
\
mln_internal_##De##_op_obj_bi_(Symb, Name, signed char); \
@@ -317,6 +318,55 @@
+
+// Operator less (<) is a special case.
+
+# define mln_internal_decl_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs); \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_def_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs) \
+ { \
+ return exact(lhs) Symb value::scalar(rhs); \
+ } \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs) \
+ { \
+ return value::scalar(lhs) Symb exact(rhs); \
+ } \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_builtins_op_less_(De, Symb, Name) \
+ \
+ mln_internal_##De##_op_less_(Symb, Name, signed char); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned char); \
+ mln_internal_##De##_op_less_(Symb, Name, signed short); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned short); \
+ mln_internal_##De##_op_less_(Symb, Name, signed int); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned int); \
+ mln_internal_##De##_op_less_(Symb, Name, signed long); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned long); \
+ mln_internal_##De##_op_less_(Symb, Name, float); \
+ mln_internal_##De##_op_less_(Symb, Name, double); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
// FIXME: What about pointers, arrays, bool, etc.
// FIXME: Mod is not defined for float and double...
@@ -468,6 +518,12 @@
typedef mln_trait_op_less(O, mln::value::scalar_<B>) ret;
};
+ template <typename B, typename O>
+ struct set_binary_< op::less, mln::value::Built_In, B, mln::Object, O >
+ {
+ typedef mln_trait_op_less(mln::value::scalar_<B>, O) ret;
+ };
+
// 'Op+' is commutative so "o + b" => "o + scalar(b)".
@@ -548,6 +604,10 @@
mln_internal_builtins_opeq_obj_(decl, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(decl, <, less);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -583,6 +643,10 @@
mln_internal_builtins_opeq_obj_(def, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(def, <, less);
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/convert/to_fun.hh
--- mln/convert/to_fun.hh (revision 3767)
+++ mln/convert/to_fun.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_CONVERT_TO_FUN_HH
# define MLN_CONVERT_TO_FUN_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+/// \file mln/convert/to_fun.hh
+///
+/// Conversions towards some mln::Function.
# include <mln/pw/value.hh>
# include <mln/fun/c.hh>
Index: mln/fun/c.hh
--- mln/fun/c.hh (revision 3767)
+++ mln/fun/c.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
#ifndef MLN_FUN_C_HH
# define MLN_FUN_C_HH
-/*! \file mln/fun/c.hh
- *
- * \brief Encapsulate a plain (C language-like) pointer to function
- * into a functor.
- */
+/// \file mln/fun/c.hh
+///
+/// Encapsulate a plain (C language-like) pointer to function
+/// into a functor.
# include <mln/fun/internal/selector.hh>
# include <mln/metal/unqualif.hh>
@@ -137,4 +137,4 @@
} // end of namespace mln
-#endif // ! MLN_FUN_P2B_C_HH
+#endif // ! MLN_FUN_C_HH
Index: mln/fun/access/all.hh
--- mln/fun/access/all.hh (revision 0)
+++ mln/fun/access/all.hh (revision 0)
@@ -0,0 +1,52 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_ACCESS_ALL_HH
+# define MLN_FUN_ACCESS_ALL_HH
+
+/// \file mln/fun/access/all.hh
+///
+/// File that includes all access functions.
+
+
+namespace mln
+{
+ namespace fun
+ {
+
+ /// Namespace for access functions.
+ namespace access
+ {}
+
+ }
+}
+
+
+# include <mln/fun/access/mean.hh>
+
+
+#endif // ! MLN_FUN_ACCESS_ALL_HH
Index: mln/fun/access/mean.hh
--- mln/fun/access/mean.hh (revision 0)
+++ mln/fun/access/mean.hh (revision 0)
@@ -0,0 +1,91 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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 F 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_ACCESS_MEAN_HH
+# define MLN_FUN_ACCESS_MEAN_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace access
+ {
+
+ struct mean : unary<mean>
+ {
+ };
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct method_mean
+ {
+ typedef method_mean ret;
+
+ typedef typename T::mean_t result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return x.mean();
+ }
+ };
+
+ }
+
+ } // end of namespace mln::access
+
+ } // end of namespace mln
+
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename A>
+ struct set_unary_< fun::access::mean,
+ Accumulator, A > : fun::access::internal::method_mean<A>
+ {
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_ACCESS_MEAN_HH
Index: mln/fun/all.hh
--- mln/fun/all.hh (revision 3767)
+++ mln/fun/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_FUN_ALL_HH
# define MLN_FUN_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/all.hh
+///
+/// File that includes all fun-related routines.
namespace mln
@@ -43,25 +43,25 @@
/// Internal namespace of functions.
namespace internal
- {
- }
- }
+ {}
}
+}
# include <mln/fun/c.hh>
# include <mln/fun/ops.hh>
# include <mln/fun/i2v/all.hh>
+# include <mln/fun/meta/all.hh>
# include <mln/fun/p2b/all.hh>
# include <mln/fun/p2v/all.hh>
+# include <mln/fun/stat/all.hh>
# include <mln/fun/v2b/all.hh>
# include <mln/fun/v2v/all.hh>
# include <mln/fun/vv2v/all.hh>
# include <mln/fun/x2p/all.hh>
# include <mln/fun/x2v/all.hh>
# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
#endif // ! MLN_FUN_ALL_HH
Index: mln/fun/stat/all.hh
--- mln/fun/stat/all.hh (revision 0)
+++ mln/fun/stat/all.hh (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_STAT_ALL_HH
+# define MLN_FUN_STAT_ALL_HH
+
+/// \file mln/fun/stat/all.hh
+///
+/// File that includes all statistical functions.
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// \brief Namespace of statistical functions.
+ ///
+ /// \ingroup modfun
+ namespace stat {}
+
+ }
+}
+
+
+# include <mln/fun/stat/mahalanobis.hh>
+
+
+#endif // ! MLN_FUN_STAT_ALL_HH
Index: mln/fun/stat/mahalanobis.hh
--- mln/fun/stat/mahalanobis.hh (revision 0)
+++ mln/fun/stat/mahalanobis.hh (revision 0)
@@ -0,0 +1,95 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_STAT_MAHALANOBIS_HH
+# define MLN_FUN_STAT_MAHALANOBIS_HH
+
+/// \file mln/fun/stat/mahalanobis.hh
+///
+/// Define the FIXME
+
+# include <mln/core/concept/function.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace stat
+ {
+
+ template <typename V>
+ struct mahalanobis
+ : public Function_v2v< mahalanobis<V> >,
+ private metal::equal< V, algebra::vec<V::dim,float> >::check_t
+ {
+ enum { n = V::dim };
+ typedef float result;
+
+ mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean);
+
+ float operator()(const V& v) const;
+
+ algebra::mat<n,n,float> var_1;
+ algebra::vec<n,float> mean;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ mahalanobis<V>::mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean)
+ {
+ var_1 = var._1();
+ mean = mean;
+ }
+
+ template <typename V>
+ inline
+ float
+ mahalanobis<V>::operator()(const V& v) const
+ {
+ return (v - mean).t() * var_1 * (v - mean);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::stat
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2V_NORM_MAHALANOBIS_HH
Index: tests/world/inter_pixel/compute.cc
--- tests/world/inter_pixel/compute.cc (revision 0)
+++ tests/world/inter_pixel/compute.cc (revision 0)
@@ -0,0 +1,87 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/world/inter_pixel/compute.cc
+///
+/// Tests on mln::world::inter_pixel::compute.
+
+#include <cmath>
+
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/immerse.hh>
+#include <mln/world/inter_pixel/compute.hh>
+
+#include <mln/world/inter_pixel/neighb2d.hh>
+#include <mln/morpho/watershed/flooding.hh>
+#include <mln/debug/println.hh>
+
+
+
+struct d_t : mln::Function_vv2v<d_t>
+{
+ typedef int result;
+
+ int operator()(int i1, int i2) const
+ {
+ return std::abs(i2 - i1);
+ }
+}
+ d;
+
+
+
+int main()
+{
+ using namespace mln;
+
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
+
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
+
+ using namespace world::inter_pixel;
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
+
+
+ int refs[] = { 0, 1, 0, 1, 0,
+ 2, 0, 1, 0, 1,
+ 0, 2, 0, 3, 0,
+ 7, 0, 4, 0, 3,
+ 0, 1, 0, 4, 0 };
+
+ mln_assertion(compute(imax, d) == (make::image2d(refs) | is_separator()));
+
+ mln_VAR(g, compute(imax, d));
+
+ unsigned n_basins;
+ debug::println(morpho::watershed::flooding(g, e2e(), n_basins));
+}
Index: tests/world/inter_pixel/immerse.cc
--- tests/world/inter_pixel/immerse.cc (revision 3759)
+++ tests/world/inter_pixel/immerse.cc (working copy)
@@ -25,36 +25,42 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/world/inter_pixel/image2full.cc
+/// \file tests/world/inter_pixel/immerse.cc
///
-/// Tests on mln::world::inter_pixel::image2full
+/// Tests on mln::world::inter_pixel::immerse.
+#include <mln/core/var.hh>
#include <mln/core/image/image2d.hh>
-#include <mln/make/image.hh>
-#include <mln/value/int_u8.hh>
#include <mln/level/compare.hh>
-#include <mln/world/inter_pixel/image2full.hh>
+#include <mln/world/inter_pixel/immerse.hh>
+
int main()
{
using namespace mln;
- value::int_u8 vals[][3] = { { 3, 4, 5 },
- { 1, 3, 6 },
- { 8, 7, 3 } } ;
-
- value::int_u8 refs[][5] = { { 3, 0, 4, 0, 5 },
- { 0, 0, 0, 0, 0 },
- { 1, 0, 3, 0, 6 },
- { 0, 0, 0, 0, 0 },
- { 8, 0, 7, 0, 3 } };
-
- typedef image2d<value::int_u8> ima_t;
- ima_t ima = make::image(vals);
- ima_t ref = make::image(refs);
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
+
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
+
+ using namespace world::inter_pixel;
+
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
+
- ima_t ima_l = world::inter_pixel::image2full(ima);
+ int refs[] = { 3, 0, 4, 0, 5,
+ 0, 0, 0, 0, 0,
+ 1, 0, 3, 0, 6,
+ 0, 0, 0, 0, 0,
+ 8, 0, 7, 0, 3 };
- mln_assertion(ima_l == ref);
+ mln_assertion(imax == (make::image2d(refs) | is_pixel()));
+ mln_piter_(Ix) p(imax.domain());
+ for_all(p)
+ mln_assertion(is_pixel()(p));
}
Property changes on: tests/world/inter_pixel/immerse.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/world/inter_pixel/Makefile.am
--- tests/world/inter_pixel/Makefile.am (revision 3767)
+++ tests/world/inter_pixel/Makefile.am (working copy)
@@ -6,8 +6,10 @@
dim2
check_PROGRAMS = \
- image2full
+ image2full \
+ immerse
image2full_SOURCES = image2full.cc
+immerse_SOURCES = immerse.cc
TESTS = $(check_PROGRAMS)
Index: tests/accu/Makefile.am
--- tests/accu/Makefile.am (revision 3767)
+++ tests/accu/Makefile.am (working copy)
@@ -4,7 +4,8 @@
SUBDIRS = \
image \
- site_set
+ site_set \
+ stat
check_PROGRAMS = \
all_accus \
Index: tests/accu/stat/Makefile.am
--- tests/accu/stat/Makefile.am (revision 0)
+++ tests/accu/stat/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ var
+
+var_SOURCES = var.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/accu/stat/var.cc
--- tests/accu/stat/var.cc (revision 0)
+++ tests/accu/stat/var.cc (revision 0)
@@ -0,0 +1,73 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/accu/stat/var.cc
+///
+/// Tests on mln::accu::stat::var.
+
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
+
+
+float my_rand(int c)
+{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef algebra::vec<3,float> vec3f;
+
+ enum { n = 1000 };
+ vec3f v[n];
+
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+
+ mln_assertion(a.n_items() == n);
+
+ vec3f m = a.mean();
+ mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+ mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+ mln_assertion(m[2] > 1.4 && m[2] < 1.6);
+
+ algebra::mat<3,3,float> s_1 = a.variance()._1();
+ mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+ mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+ mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
Index: tests/fun/Makefile.am
--- tests/fun/Makefile.am (revision 3767)
+++ tests/fun/Makefile.am (working copy)
@@ -2,4 +2,12 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x
+SUBDIRS = \
+ i2v \
+ p2b \
+ p2p \
+ p2v \
+ stat \
+ v2v \
+ vv2v \
+ x2x
Index: tests/fun/stat/mahalanobis.cc
--- tests/fun/stat/mahalanobis.cc (revision 0)
+++ tests/fun/stat/mahalanobis.cc (revision 0)
@@ -0,0 +1,74 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/fun/stat/mahalanobis.cc
+///
+/// Tests on mln::fun::stat::mahalanobis.
+
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
+#include <mln/fun/stat/mahalanobis.hh>
+
+
+float my_rand(int c)
+{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef algebra::vec<3,float> vec3f;
+
+ enum { n = 1000 };
+ vec3f v[n];
+
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+
+// vec3f m = a.mean();
+// mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+// mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+// mln_assertion(m[2] > 1.4 && m[2] < 1.6);
+
+ fun::stat::mahalanobis<vec3f> f(a.variance(), a.mean());
+
+// algebra::mat<3,3,float> s_1 = a.variance()._1();
+// mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+// mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+// mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
Property changes on: tests/fun/stat/mahalanobis.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/fun/stat/Makefile.am
--- tests/fun/stat/Makefile.am (revision 0)
+++ tests/fun/stat/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ mahalanobis
+
+mahalanobis_SOURCES = mahalanobis.cc
+
+TESTS = $(check_PROGRAMS)
1
0
Starting revamping world inter-pixel.
* mln/world/inter_pixel/image2full.hh: Rename as...
* mln/world/inter_pixel/immerse.hh: ...this new file.
(image2full): Rename as...
(immerse): ...this.
Revamp.
* mln/world/inter_pixel/separator_to_pixels.hh: New.
* mln/world/inter_pixel/is_separator.hh: New.
* mln/world/inter_pixel/is_pixel.hh: New.
* mln/world/inter_pixel/compute.hh: New.
* mln/world/inter_pixel/make: New directory.
* mln/world/inter_pixel/neighb2d.hh: Fix ending guard.
* mln/world/inter_pixel/display_edge.hh: Likewise.
* mln/core/macros.hh (mln_unmorph, mln_unmorph_): New.
* mln/core/point.hh (point): Fix warning.
Add static check.
* mln/core/internal/image_morpher.hh (unmorph): New typedef.
* mln/core/internal/pixel_impl.hh
(pixel_impl_): Fix compile errors with g++-3.4.
* mln/core/concept/gpoint.hh (operator*): New overload with scalar.
(trait): New corresponding trait.
* tests/world/inter_pixel/compute.cc: New.
* tests/world/inter_pixel/immerse.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
Fix missing code for operator less with builtins.
* mln/value/builtin/ops.hh:
(mln_internal_decl_op_less_): New.
(mln_internal_def_op_less_): New.
(mln_internal_builtins_op_less_): New.
Misc.
* mln/accu/stat/all.hh: New.
* mln/accu/all.hh: Update.
* mln/convert/to_fun.hh: Upgrade doc style.
* mln/data/paste_without_localization.hh: New.
* mln/data/paste.hh: New static check.
* mln/fun/c.hh: Likewise.
Fix ending guard.
Augmenting accumulators.
* mln/accu/stat/var.hh (mean_t): New typedef.
(to_result, mean): Fix null_ construction.
* tests/accu/stat: New directory.
* tests/accu/stat/Makefile.am: New.
* tests/accu/stat/var.cc: New.
* tests/accu/Makefile.am: Update.
Augmenting fun :-)
* mln/fun/access: New directory.
* mln/fun/access/all.hh: New.
* mln/fun/access/mean.hh: New.
* mln/fun/all.hh: Update.
* mln/fun/stat: New.
* mln/fun/stat/all.hh: New.
* mln/fun/stat/mahalanobis.hh: New.
* tests/fun/stat: New.
* tests/fun/stat/mahalanobis.cc: New.
* tests/fun/stat/Makefile.am: New.
* tests/fun/Makefile.am: Update.
---
milena/ChangeLog | 70 +++++++++++
milena/mln/accu/all.hh | 1 +
milena/mln/{fun => accu/stat}/all.hh | 42 +++-----
milena/mln/accu/stat/var.hh | 16 ++-
milena/mln/convert/to_fun.hh | 10 +-
milena/mln/core/concept/gpoint.hh | 32 +++++-
milena/mln/core/internal/image_morpher.hh | 4 +
milena/mln/core/internal/pixel_impl.hh | 14 +-
milena/mln/core/macros.hh | 10 ++
milena/mln/core/point.hh | 11 +-
milena/mln/data/paste.hh | 6 +-
.../paste_without_localization.hh} | 88 +++++++-------
milena/mln/fun/{ => access}/all.hh | 39 ++-----
.../mln/{convert/to_fun.hh => fun/access/mean.hh} | 80 ++++++++------
milena/mln/fun/all.hh | 18 ++--
milena/mln/fun/c.hh | 14 +-
milena/mln/fun/{ => stat}/all.hh | 39 ++----
.../{convert/to_fun.hh => fun/stat/mahalanobis.hh} | 80 ++++++++-----
milena/mln/value/builtin/ops.hh | 76 +++++++++++-
.../inter_pixel/{image2full.hh => compute.hh} | 74 +++++++------
milena/mln/world/inter_pixel/display_edge.hh | 2 +-
.../inter_pixel/{image2full.hh => immerse.hh} | 63 +++++-----
.../inter_pixel/{image2full.hh => is_pixel.hh} | 76 ++++++------
.../inter_pixel/{image2full.hh => is_separator.hh} | 72 ++++++------
milena/mln/world/inter_pixel/neighb2d.hh | 2 +-
.../mln/world/inter_pixel/separator_to_pixels.hh | 123 ++++++++++++++++++++
milena/tests/accu/Makefile.am | 3 +-
milena/tests/{fun => accu/stat}/Makefile.am | 7 +-
milena/{mln/fun/all.hh => tests/accu/stat/var.cc} | 66 ++++++-----
milena/tests/fun/Makefile.am | 10 ++-
.../{world/inter_pixel => fun/stat}/Makefile.am | 9 +-
.../fun/all.hh => tests/fun/stat/mahalanobis.cc} | 67 ++++++-----
milena/tests/world/inter_pixel/Makefile.am | 6 +-
.../world/inter_pixel/compute.cc} | 78 +++++++------
.../all.hh => tests/world/inter_pixel/immerse.cc} | 59 +++++-----
35 files changed, 850 insertions(+), 517 deletions(-)
copy milena/mln/{fun => accu/stat}/all.hh (63%)
copy milena/mln/{world/inter_pixel/image2full.hh => data/paste_without_localization.hh} (50%)
copy milena/mln/fun/{ => access}/all.hh (64%)
copy milena/mln/{convert/to_fun.hh => fun/access/mean.hh} (56%)
copy milena/mln/fun/{ => stat}/all.hh (64%)
copy milena/mln/{convert/to_fun.hh => fun/stat/mahalanobis.hh} (52%)
copy milena/mln/world/inter_pixel/{image2full.hh => compute.hh} (56%)
copy milena/mln/world/inter_pixel/{image2full.hh => immerse.hh} (59%)
copy milena/mln/world/inter_pixel/{image2full.hh => is_pixel.hh} (56%)
rename milena/mln/world/inter_pixel/{image2full.hh => is_separator.hh} (56%)
create mode 100644 milena/mln/world/inter_pixel/separator_to_pixels.hh
copy milena/tests/{fun => accu/stat}/Makefile.am (61%)
copy milena/{mln/fun/all.hh => tests/accu/stat/var.cc} (57%)
copy milena/tests/{world/inter_pixel => fun/stat}/Makefile.am (61%)
copy milena/{mln/fun/all.hh => tests/fun/stat/mahalanobis.cc} (55%)
copy milena/{mln/convert/to_fun.hh => tests/world/inter_pixel/compute.cc} (52%)
copy milena/{mln/fun/all.hh => tests/world/inter_pixel/immerse.cc} (61%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2583428..c69383e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,73 @@
+2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+
+ Several fixes and new stuff.
+
+ Starting revamping world inter-pixel.
+
+ * mln/world/inter_pixel/image2full.hh: Rename as...
+ * mln/world/inter_pixel/immerse.hh: ...this new file.
+ (image2full): Rename as...
+ (immerse): ...this.
+ Revamp.
+ * mln/world/inter_pixel/separator_to_pixels.hh: New.
+ * mln/world/inter_pixel/is_separator.hh: New.
+ * mln/world/inter_pixel/is_pixel.hh: New.
+ * mln/world/inter_pixel/compute.hh: New.
+ * mln/world/inter_pixel/make: New directory.
+ * mln/world/inter_pixel/neighb2d.hh: Fix ending guard.
+ * mln/world/inter_pixel/display_edge.hh: Likewise.
+ * mln/core/macros.hh (mln_unmorph, mln_unmorph_): New.
+ * mln/core/point.hh (point): Fix warning.
+ Add static check.
+ * mln/core/internal/image_morpher.hh (unmorph): New typedef.
+ * mln/core/internal/pixel_impl.hh
+ (pixel_impl_): Fix compile errors with g++-3.4.
+ * mln/core/concept/gpoint.hh (operator*): New overload with scalar.
+ (trait): New corresponding trait.
+ * tests/world/inter_pixel/compute.cc: New.
+ * tests/world/inter_pixel/immerse.cc: New.
+ * tests/world/inter_pixel/Makefile.am: Update.
+
+ Fix missing code for operator less with builtins.
+
+ * mln/value/builtin/ops.hh:
+ (mln_internal_decl_op_less_): New.
+ (mln_internal_def_op_less_): New.
+ (mln_internal_builtins_op_less_): New.
+
+ Misc.
+
+ * mln/accu/stat/all.hh: New.
+ * mln/accu/all.hh: Update.
+ * mln/convert/to_fun.hh: Upgrade doc style.
+ * mln/data/paste_without_localization.hh: New.
+ * mln/data/paste.hh: New static check.
+ * mln/fun/c.hh: Likewise.
+ Fix ending guard.
+
+ Augmenting accumulators.
+
+ * mln/accu/stat/var.hh (mean_t): New typedef.
+ (to_result, mean): Fix null_ construction.
+ * tests/accu/stat: New directory.
+ * tests/accu/stat/Makefile.am: New.
+ * tests/accu/stat/var.cc: New.
+ * tests/accu/Makefile.am: Update.
+
+ Augmenting fun :-)
+
+ * mln/fun/access: New directory.
+ * mln/fun/access/all.hh: New.
+ * mln/fun/access/mean.hh: New.
+ * mln/fun/all.hh: Update.
+ * mln/fun/stat: New.
+ * mln/fun/stat/all.hh: New.
+ * mln/fun/stat/mahalanobis.hh: New.
+ * tests/fun/stat: New.
+ * tests/fun/stat/mahalanobis.cc: New.
+ * tests/fun/stat/Makefile.am: New.
+ * tests/fun/Makefile.am: Update.
+
2009-05-07 Guillaume Sadegh <sadegh(a)lrde.epita.fr>
Add couple to couple conversion.
diff --git a/milena/mln/accu/all.hh b/milena/mln/accu/all.hh
index 5dfe51e..1bf7cf8 100644
--- a/milena/mln/accu/all.hh
+++ b/milena/mln/accu/all.hh
@@ -99,6 +99,7 @@ namespace mln
# include <mln/accu/image/all.hh>
# include <mln/accu/site_set/all.hh>
+# include <mln/accu/stat/all.hh>
#endif // ! MLN_ACCU_ALL_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/accu/stat/all.hh
similarity index 63%
copy from milena/mln/fun/all.hh
copy to milena/mln/accu/stat/all.hh
index 8e9ddad..1c9f8ef 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/accu/stat/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,29 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_ACCU_STAT_ALL_HH
+# define MLN_ACCU_STAT_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/accu/stat/all.hh
+///
+/// File that includes all statistical accumulator types.
namespace mln
{
-
- /// Namespace of image processing routines related to functions.
- namespace fun
+ namespace accu
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// Namespace of statistical accumulators.
+ namespace stat {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/accu/stat/deviation.hh>
+# include <mln/accu/stat/var.hh>
+# include <mln/accu/stat/variance.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_ACCU_STAT_ALL_HH
diff --git a/milena/mln/accu/stat/var.hh b/milena/mln/accu/stat/var.hh
index c871e7d..3dece0b 100644
--- a/milena/mln/accu/stat/var.hh
+++ b/milena/mln/accu/stat/var.hh
@@ -40,6 +40,7 @@
# include <mln/fun/i2v/all_to.hh>
# include <mln/util/pix.hh>
+
namespace mln
{
@@ -84,8 +85,13 @@ namespace mln
/// Get the number of items.
unsigned n_items() const;
+
+ /// Type equipment.
+ typedef algebra::vec<dim,float> mean_t;
+ // ...
+
/// Get the mean vector.
- algebra::vec<dim,float> mean() const;
+ mean_t mean() const;
/// Check whether this accu returns a valid result.
bool is_valid() const;
@@ -115,7 +121,7 @@ namespace mln
{
n_ = 0;
sum_.set_all(0);
- cov_ .set_all(0);
+ cov_.set_all(0);
}
template <typename T>
@@ -163,7 +169,7 @@ namespace mln
mln_result(var<T>)
var<T>::to_result() const
{
- static result null_(fun::i2v::all_to(0));
+ static result null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
@@ -192,10 +198,10 @@ namespace mln
template <typename T>
inline
- algebra::vec<dim,float>
+ typename var<T>::mean_t
var<T>::mean() const
{
- static algebra::vec<dim,float> null_(fun::i2v::all_to(0));
+ static algebra::vec<dim,float> null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/convert/to_fun.hh
index 86a1ddc..6484c42 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/convert/to_fun.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_CONVERT_TO_FUN_HH
# define MLN_CONVERT_TO_FUN_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+/// \file mln/convert/to_fun.hh
+///
+/// Conversions towards some mln::Function.
# include <mln/pw/value.hh>
# include <mln/fun/c.hh>
diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh
index 9311535..504e2ac 100644
--- a/milena/mln/core/concept/gpoint.hh
+++ b/milena/mln/core/concept/gpoint.hh
@@ -36,7 +36,7 @@
# include <mln/core/concept/site.hh>
# include <mln/core/concept/gdpoint.hh>
-# include <mln/value/concept/scalar.hh>
+# include <mln/value/scalar.hh>
# include <mln/algebra/vec.hh>
# include <mln/util/ord.hh>
# include <mln/debug/format.hh>
@@ -74,6 +74,14 @@ namespace mln
typedef mln_delta(L) ret;
};
+ template < typename L, typename R >
+ struct set_binary_< op::times,
+ mln::Gpoint, L,
+ mln::Object, mln::value::scalar_<R> >
+ {
+ typedef L ret;
+ };
+
template <typename P>
struct set_unary_< op::ord, mln::Gpoint, P >
@@ -200,7 +208,7 @@ namespace mln
- /// Substract a delta-point \p rhs to a grid point \p lhs.
+ /// Substract a delta-point \p dp to a grid point \p p.
///
/*! \param[in] p A grid point.
* \param[in] dp A delta-point.
@@ -217,6 +225,13 @@ namespace mln
operator-(const Gpoint<P>& p, const Gdpoint<D>& dp);
+ /// Multiply a point \p p by a scalar \p s.
+ //
+ template <typename P, typename S>
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s);
+
+
/// Print a grid point \p p into the output stream \p ostr.
/*! \param[in,out] ostr An output stream.
* \param[in] p A grid point.
@@ -380,6 +395,19 @@ namespace mln
return tmp;
}
+ template <typename P, typename S>
+ inline
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s)
+ {
+ int s_ = s.to_equiv();
+ const unsigned n = P::dim;
+ P tmp = exact(p);
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] *= s_;
+ return tmp;
+ }
+
template <typename P>
inline
std::ostream& operator<<(std::ostream& ostr, const Gpoint<P>& p)
diff --git a/milena/mln/core/internal/image_morpher.hh b/milena/mln/core/internal/image_morpher.hh
index fd170ea..0969acc 100644
--- a/milena/mln/core/internal/image_morpher.hh
+++ b/milena/mln/core/internal/image_morpher.hh
@@ -64,6 +64,10 @@ namespace mln
I* delegatee_();
+
+ /// Unmorph image associated type.
+ typedef I unmorph;
+
/// Give the morphed image (mutable version).
I& unmorph_();
diff --git a/milena/mln/core/internal/pixel_impl.hh b/milena/mln/core/internal/pixel_impl.hh
index f3162e5..eb956cf 100644
--- a/milena/mln/core/internal/pixel_impl.hh
+++ b/milena/mln/core/internal/pixel_impl.hh
@@ -233,7 +233,7 @@ namespace mln
bool
pixel_impl_<I, E>::is_valid_() const
{
- return value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -249,7 +249,7 @@ namespace mln
pixel_impl_<I, E>::val()
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -258,7 +258,7 @@ namespace mln
pixel_impl_<I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -267,7 +267,7 @@ namespace mln
pixel_impl_<I, E>::ima() const
{
// a const pixel, yet a mutable image
- return const_cast<I&>(image_);
+ return const_cast<I&>(this->image_);
}
template <typename I, typename E>
@@ -286,7 +286,7 @@ namespace mln
bool
pixel_impl_<const I, E>::is_valid_() const
{
- return value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -302,7 +302,7 @@ namespace mln
pixel_impl_<const I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -310,7 +310,7 @@ namespace mln
const I&
pixel_impl_<const I, E>::ima() const
{
- return image_;
+ return this->image_;
}
template <typename I, typename E>
diff --git a/milena/mln/core/macros.hh b/milena/mln/core/macros.hh
index 8aa59ad..75ab5f0 100644
--- a/milena/mln/core/macros.hh
+++ b/milena/mln/core/macros.hh
@@ -372,6 +372,16 @@
+// u
+
+/// Shortcuts to access the unmorph type associated to T.
+/// \{
+# define mln_unmorph(T) typename T::unmorph
+# define mln_unmorph_(T) T::unmorph
+/// \}
+
+
+
// v
/// Shortcuts to access the value type associated to T.
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index 54289fa..ca15b4c 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -294,16 +294,17 @@ namespace mln
inline
point<G,C>::point(const algebra::vec<dim,C2>& v)
{
+ mlc_converts_to(C2, C)::check();
unsigned j = 0;
- //FIXME: to be improved.
+ //FIXME: to be improved while adding a conversion routine.
if (dim < 3)
coord_ = v;
else
{
for (unsigned i = dim - 2; i < dim; ++i)
- coord_[i] = v[j++];
+ coord_[i] = static_cast<C>(v[j++]);
for (unsigned i = 2; i < dim; ++i, ++j)
- coord_[i-j] = v[j];
+ coord_[i-j] = static_cast<C>(v[j]);
}
}
diff --git a/milena/mln/data/paste.hh b/milena/mln/data/paste.hh
index 6457411..ef3911d 100644
--- a/milena/mln/data/paste.hh
+++ b/milena/mln/data/paste.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -129,6 +129,8 @@ namespace mln
{
trace::entering("data::paste");
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
internal::paste_tests(input, output);
internal::paste_dispatch(input, output);
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/data/paste_without_localization.hh
similarity index 50%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/data/paste_without_localization.hh
index 03102f7..8b10bee 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/data/paste_without_localization.hh
@@ -25,69 +25,69 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
+# define MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/data/paste_without_localization.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// Paste the contents of an image into another one without taking
+/// into account the localization of sites.
+
+# include <mln/core/concept/image.hh>
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
namespace mln
{
- namespace world
+ namespace data
{
- namespace inter_pixel
- {
+ /// \brief Paste the contents of image \p input into the image \p
+ /// output without taking into account the localization of sites.
+ ///
+ /// \param[in] input The input image providing pixels values.
+ /// \param[in,out] output The image in which values are
+ /// assigned.
+ //
+ template <typename I, typename J>
+ void paste_without_localization(const Image<I>& input, Image<J>& output);
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
# ifndef MLN_INCLUDE_ONLY
-
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
-
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
-
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
-
+ template <typename I, typename J>
+ inline
+ void paste_without_localization(const Image<I>& input_, Image<J>& output_)
+ {
+ trace::entering("data::paste_without_localization");
+
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
+ const I& input = exact(input_);
+ J& output = exact(output_);
+
+ mln_fwd_piter(I) pi(input.domain());
+ pi.start();
+ mln_fwd_piter(J) po(output.domain());
+ po.start();
+ while (pi.is_valid() && po.is_valid())
+ {
+ output(po) = input(pi);
+ pi.next();
+ po.next();
+ }
+
+ trace::exiting("data::paste_without_localization");
+ }
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::data
- } // end of namespace mln::world::inter_pixel
+} // end of namespace mln
- } // end of namespace mln::world
-} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/access/all.hh
similarity index 64%
copy from milena/mln/fun/all.hh
copy to milena/mln/fun/access/all.hh
index 8e9ddad..ecae22d 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/access/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,28 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_FUN_ACCESS_ALL_HH
+# define MLN_FUN_ACCESS_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/access/all.hh
+///
+/// File that includes all access functions.
namespace mln
{
-
- /// Namespace of image processing routines related to functions.
namespace fun
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// Namespace for access functions.
+ namespace access
+ {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/fun/access/mean.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_FUN_ACCESS_ALL_HH
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/fun/access/mean.hh
similarity index 56%
copy from milena/mln/convert/to_fun.hh
copy to milena/mln/fun/access/mean.hh
index 86a1ddc..e287882 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/fun/access/mean.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -7,7 +7,7 @@
//
// 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
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
@@ -25,55 +25,67 @@
// 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
+#ifndef MLN_FUN_ACCESS_MEAN_HH
+# define MLN_FUN_ACCESS_MEAN_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
-
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
namespace mln
{
- namespace convert
+ namespace fun
{
- /// Convert a C unary function into an mln::fun::C.
- template <typename R, typename A>
- fun::C<R(*)(A)> to_fun(R (*f)(A));
+ namespace access
+ {
- /// Convert an image into a function.
- template <typename I>
- pw::value_<I> to_fun(const Image<I>& ima);
+ struct mean : unary<mean>
+ {
+ };
+ namespace internal
+ {
-# ifndef MLN_INCLUDE_ONLY
+ template <typename T>
+ struct method_mean
+ {
+ typedef method_mean ret;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ typedef typename T::mean_t result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return x.mean();
+ }
+ };
+
+ }
+
+ } // end of namespace mln::access
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
+ } // end of namespace mln
+
+
+ namespace trait
+ {
+
+ namespace next
{
- return pw::value(ima);
- }
-# endif // ! MLN_INCLUDE_ONLY
+ template <typename A>
+ struct set_unary_< fun::access::mean,
+ Accumulator, A > : fun::access::internal::method_mean<A>
+ {
+ };
+
+ } // end of namespace mln::trait::next
- } // end of namespace mln::convert
+ } // end of namespace mln::trait
} // end of namespace mln
-#endif // ! MLN_CONVERT_TO_FUN_HH
+#endif // ! MLN_FUN_ACCESS_MEAN_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/all.hh
index 8e9ddad..96a347a 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_FUN_ALL_HH
# define MLN_FUN_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/all.hh
+///
+/// File that includes all fun-related routines.
namespace mln
@@ -43,25 +43,25 @@ namespace mln
/// Internal namespace of functions.
namespace internal
- {
- }
- }
+ {}
+ }
}
# include <mln/fun/c.hh>
# include <mln/fun/ops.hh>
# include <mln/fun/i2v/all.hh>
+# include <mln/fun/meta/all.hh>
# include <mln/fun/p2b/all.hh>
# include <mln/fun/p2v/all.hh>
+# include <mln/fun/stat/all.hh>
# include <mln/fun/v2b/all.hh>
# include <mln/fun/v2v/all.hh>
# include <mln/fun/vv2v/all.hh>
# include <mln/fun/x2p/all.hh>
# include <mln/fun/x2v/all.hh>
# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
#endif // ! MLN_FUN_ALL_HH
diff --git a/milena/mln/fun/c.hh b/milena/mln/fun/c.hh
index 8ee9c24..400c781 100644
--- a/milena/mln/fun/c.hh
+++ b/milena/mln/fun/c.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
#ifndef MLN_FUN_C_HH
# define MLN_FUN_C_HH
-/*! \file mln/fun/c.hh
- *
- * \brief Encapsulate a plain (C language-like) pointer to function
- * into a functor.
- */
+/// \file mln/fun/c.hh
+///
+/// Encapsulate a plain (C language-like) pointer to function
+/// into a functor.
# include <mln/fun/internal/selector.hh>
# include <mln/metal/unqualif.hh>
@@ -137,4 +137,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_P2B_C_HH
+#endif // ! MLN_FUN_C_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/stat/all.hh
similarity index 64%
copy from milena/mln/fun/all.hh
copy to milena/mln/fun/stat/all.hh
index 8e9ddad..8ad5257 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/stat/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,30 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_FUN_STAT_ALL_HH
+# define MLN_FUN_STAT_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/stat/all.hh
+///
+/// File that includes all statistical functions.
namespace mln
{
- /// Namespace of image processing routines related to functions.
namespace fun
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// \brief Namespace of statistical functions.
+ ///
+ /// \ingroup modfun
+ namespace stat {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/fun/stat/mahalanobis.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_FUN_STAT_ALL_HH
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/fun/stat/mahalanobis.hh
similarity index 52%
copy from milena/mln/convert/to_fun.hh
copy to milena/mln/fun/stat/mahalanobis.hh
index 86a1ddc..79eea0e 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/fun/stat/mahalanobis.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,55 +25,71 @@
// 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
+#ifndef MLN_FUN_STAT_MAHALANOBIS_HH
+# define MLN_FUN_STAT_MAHALANOBIS_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+/// \file mln/fun/stat/mahalanobis.hh
+///
+/// Define the FIXME
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
namespace mln
{
- namespace convert
+ namespace fun
{
- /// Convert a C unary function into an mln::fun::C.
- template <typename R, typename A>
- fun::C<R(*)(A)> to_fun(R (*f)(A));
+ namespace stat
+ {
- /// Convert an image into a function.
- template <typename I>
- pw::value_<I> to_fun(const Image<I>& ima);
+ template <typename V>
+ struct mahalanobis
+ : public Function_v2v< mahalanobis<V> >,
+ private metal::equal< V, algebra::vec<V::dim,float> >::check_t
+ {
+ enum { n = V::dim };
+ typedef float result;
+ mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean);
-# ifndef MLN_INCLUDE_ONLY
+ float operator()(const V& v) const;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ algebra::mat<n,n,float> var_1;
+ algebra::vec<n,float> mean;
+ };
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
- {
- return pw::value(ima);
- }
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ mahalanobis<V>::mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean)
+ {
+ var_1 = var._1();
+ mean = mean;
+ }
+
+ template <typename V>
+ inline
+ float
+ mahalanobis<V>::operator()(const V& v) const
+ {
+ return (v - mean).t() * var_1 * (v - mean);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
+ } // end of namespace mln::fun::stat
+
+ } // end of namespace mln::fun
} // end of namespace mln
-#endif // ! MLN_CONVERT_TO_FUN_HH
+#endif // ! MLN_FUN_X2V_NORM_MAHALANOBIS_HH
diff --git a/milena/mln/value/builtin/ops.hh b/milena/mln/value/builtin/ops.hh
index 24dbfd7..c4bcab6 100644
--- a/milena/mln/value/builtin/ops.hh
+++ b/milena/mln/value/builtin/ops.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
#ifndef MLN_VALUE_BUILTIN_OPS_HH
# define MLN_VALUE_BUILTIN_OPS_HH
-/*! \file mln/value/builtin/ops.hh
- *
- * \brief Definitions of binary operators when lhs is a built-in and
- * rhs is an mln object.
- */
+/// \file mln/value/builtin/ops.hh
+///
+/// Definitions of binary operators when lhs is a built-in and
+/// rhs is an mln object.
# include <mln/value/scalar.hh>
# include <mln/trait/op/all.hh>
@@ -149,6 +149,7 @@
+
# define mln_internal_op_obj_builtins_(De, Symb, Name) \
\
mln_internal_##De##_op_obj_bi_(Symb, Name, signed char); \
@@ -317,6 +318,55 @@
+
+// Operator less (<) is a special case.
+
+# define mln_internal_decl_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs); \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_def_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs) \
+ { \
+ return exact(lhs) Symb value::scalar(rhs); \
+ } \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs) \
+ { \
+ return value::scalar(lhs) Symb exact(rhs); \
+ } \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_builtins_op_less_(De, Symb, Name) \
+ \
+ mln_internal_##De##_op_less_(Symb, Name, signed char); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned char); \
+ mln_internal_##De##_op_less_(Symb, Name, signed short); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned short); \
+ mln_internal_##De##_op_less_(Symb, Name, signed int); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned int); \
+ mln_internal_##De##_op_less_(Symb, Name, signed long); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned long); \
+ mln_internal_##De##_op_less_(Symb, Name, float); \
+ mln_internal_##De##_op_less_(Symb, Name, double); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
// FIXME: What about pointers, arrays, bool, etc.
// FIXME: Mod is not defined for float and double...
@@ -468,6 +518,12 @@ namespace mln
typedef mln_trait_op_less(O, mln::value::scalar_<B>) ret;
};
+ template <typename B, typename O>
+ struct set_binary_< op::less, mln::value::Built_In, B, mln::Object, O >
+ {
+ typedef mln_trait_op_less(mln::value::scalar_<B>, O) ret;
+ };
+
// 'Op+' is commutative so "o + b" => "o + scalar(b)".
@@ -548,6 +604,10 @@ namespace mln
mln_internal_builtins_opeq_obj_(decl, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(decl, <, less);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -583,6 +643,10 @@ namespace mln
mln_internal_builtins_opeq_obj_(def, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(def, <, less);
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/compute.hh
similarity index 56%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/compute.hh
index 03102f7..9cb01fe 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/compute.hh
@@ -25,20 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_COMPUTE_HH
+# define MLN_WORLD_INTER_PIXEL_COMPUTE_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/compute.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// FIXME: insert comment.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
namespace mln
@@ -50,44 +47,53 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
+ template <typename I, typename F>
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input, const Function_vv2v<F>& f);
-# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename F>
+ inline
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input_, const Function_vv2v<F>& f_)
{
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
+ trace::entering("world::inter_pixel::compute");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ mln_precondition(input.is_valid());
- trace::exiting("world::inter_pixel::image2full");
+ typedef mln_unmorph(I) I_;
+ typedef mln_ch_value(I_, mln_result(F)) O_;
+ O_ output_;
+ initialize(output_, input.unmorph_());
+
+ typedef image_if<O_, is_separator> O;
+ O output(output_, is_separator());
+
+ mln_piter(O) e(output.domain());
+ for_all(e)
+ {
+ mln_site(I) p1, p2;
+ separator_to_pixels(e, p1, p2);
+ output(e) = f(input(p1), input(p2));
+ }
+
+ trace::exiting("world::inter_pixel::compute");
return output;
}
-
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_COMPUTE_HH
diff --git a/milena/mln/world/inter_pixel/display_edge.hh b/milena/mln/world/inter_pixel/display_edge.hh
index 6eb43c4..9cfa046 100644
--- a/milena/mln/world/inter_pixel/display_edge.hh
+++ b/milena/mln/world/inter_pixel/display_edge.hh
@@ -82,4 +82,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE
+#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/immerse.hh
similarity index 59%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/immerse.hh
index 03102f7..59df2a6 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/immerse.hh
@@ -25,20 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IMMERSE_HH
+# define MLN_WORLD_INTER_PIXEL_IMMERSE_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/immerse.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// Convert a classical image to an inter-pixel image.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/data/paste_without_localization.hh>
+# include <mln/geom/nsites.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
namespace mln
@@ -50,44 +47,48 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
+ /// Convert an image to an inter-pixel image.
///
+ /// \param[in] input An image.
/// \return An inter-pixel image.
//
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
+ template <typename I>
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input);
-# ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
+ template <typename I>
+ inline
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input_)
{
- trace::entering("world::inter_pixel::image2full");
+ trace::entering("world::inter_pixel::immerse");
+
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ const I& input = exact(input_);
mln_precondition(input.is_valid());
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ mln_domain(I) b(2 * input.domain().pmin(),
+ 2 * input.domain().pmax());
+ mln_concrete(I) output(b);
+ mln_assertion(geom::nsites(output | is_pixel()) == input.domain().nsites());
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+ data::paste_without_localization(input, (output | is_pixel()).rw());
+ trace::exiting("world::inter_pixel::immerse");
+ return output | is_pixel();
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IMMERSE_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/is_pixel.hh
similarity index 56%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/is_pixel.hh
index 03102f7..a393de6 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/is_pixel.hh
@@ -25,20 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
+# define MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/is_pixel.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// FIXME: doc.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
namespace mln
@@ -50,44 +46,48 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
-
-
-# ifndef MLN_INCLUDE_ONLY
+ struct is_pixel : public Function_p2b< is_pixel >
+ {
+ typedef bool result;
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
+ };
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ inline
+ bool
+ is_pixel::operator()(const Gpoint<P>& p_) const
+ {
+ const P& p = exact(p_);
+ const unsigned n = P::dim;
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] % 2 == 1)
+ return false;
+ return true;
+ }
+
+ template <typename P>
+ inline
+ bool
+ is_pixel::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/is_separator.hh
similarity index 56%
rename from milena/mln/world/inter_pixel/image2full.hh
rename to milena/mln/world/inter_pixel/is_separator.hh
index 03102f7..0c8f281 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/is_separator.hh
@@ -25,20 +25,18 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
+# define MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/is_separator.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
+/// FIXME: doc.
///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// \todo Make it work in n-D.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
namespace mln
@@ -50,44 +48,44 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
-
+ struct is_separator : public Function_p2b< is_separator >
+ {
+ typedef bool result;
-# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
+ };
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
-
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Gpoint<P>& p_) const
+ {
+ const P& p = exact(p_);
+ return p.row() % 2 + p.col() % 2 == 1;
+ }
+
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
diff --git a/milena/mln/world/inter_pixel/neighb2d.hh b/milena/mln/world/inter_pixel/neighb2d.hh
index a61edeb..00e6418 100644
--- a/milena/mln/world/inter_pixel/neighb2d.hh
+++ b/milena/mln/world/inter_pixel/neighb2d.hh
@@ -101,4 +101,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D
+#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D_HH
diff --git a/milena/mln/world/inter_pixel/separator_to_pixels.hh b/milena/mln/world/inter_pixel/separator_to_pixels.hh
new file mode 100644
index 0000000..9e77afc
--- /dev/null
+++ b/milena/mln/world/inter_pixel/separator_to_pixels.hh
@@ -0,0 +1,123 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+# define MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+
+/// \file mln/world/inter_pixel/separator_to_pixels.hh
+///
+/// FIXME: doc.
+///
+/// \todo Generalize to n-D.
+
+# include <mln/core/concept/gpoint.hh>
+# include <mln/core/concept/site_proxy.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+
+ template <typename P>
+ void
+ separator_to_pixels(const Gpoint<P>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+ template <typename Ps, typename P>
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename P>
+ inline
+ void
+ separator_to_pixels(const Gpoint<P>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const P& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ // FIXME: 2D only.
+ if (s.row() % 2)
+ {
+ // Horizontal edge.
+ p1 = point2d(s.row() - 1, s.col());
+ p2 = point2d(s.row() + 1, s.col());
+ }
+ else
+ {
+ // Vertical edge.
+ p1 = point2d(s.row(), s.col() - 1);
+ p2 = point2d(s.row(), s.col() + 1);
+ }
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+ template <typename Ps, typename P>
+ inline
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const Ps& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ separator_to_pixels(s.to_site(), p1, p2);
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
diff --git a/milena/tests/accu/Makefile.am b/milena/tests/accu/Makefile.am
index 7aca2bd..f7b9927 100644
--- a/milena/tests/accu/Makefile.am
+++ b/milena/tests/accu/Makefile.am
@@ -4,7 +4,8 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
image \
- site_set
+ site_set \
+ stat
check_PROGRAMS = \
all_accus \
diff --git a/milena/tests/fun/Makefile.am b/milena/tests/accu/stat/Makefile.am
similarity index 61%
copy from milena/tests/fun/Makefile.am
copy to milena/tests/accu/stat/Makefile.am
index 4ea605e..2e2b71c 100644
--- a/milena/tests/fun/Makefile.am
+++ b/milena/tests/accu/stat/Makefile.am
@@ -2,4 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x
+check_PROGRAMS = \
+ var
+
+var_SOURCES = var.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/fun/all.hh b/milena/tests/accu/stat/var.cc
similarity index 57%
copy from milena/mln/fun/all.hh
copy to milena/tests/accu/stat/var.cc
index 8e9ddad..40d2126 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/accu/stat/var.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,49 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/accu/stat/var.cc
+///
+/// Tests on mln::accu::stat::var.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
-namespace mln
+float my_rand(int c)
{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+int main()
+{
+ using namespace mln;
-}
+ typedef algebra::vec<3,float> vec3f;
+ enum { n = 1000 };
+ vec3f v[n];
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+ mln_assertion(a.n_items() == n);
-#endif // ! MLN_FUN_ALL_HH
+ vec3f m = a.mean();
+ mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+ mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+ mln_assertion(m[2] > 1.4 && m[2] < 1.6);
+
+ algebra::mat<3,3,float> s_1 = a.variance()._1();
+ mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+ mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+ mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
diff --git a/milena/tests/fun/Makefile.am b/milena/tests/fun/Makefile.am
index 4ea605e..7cea3a5 100644
--- a/milena/tests/fun/Makefile.am
+++ b/milena/tests/fun/Makefile.am
@@ -2,4 +2,12 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x
+SUBDIRS = \
+ i2v \
+ p2b \
+ p2p \
+ p2v \
+ stat \
+ v2v \
+ vv2v \
+ x2x
diff --git a/milena/tests/world/inter_pixel/Makefile.am b/milena/tests/fun/stat/Makefile.am
similarity index 61%
copy from milena/tests/world/inter_pixel/Makefile.am
copy to milena/tests/fun/stat/Makefile.am
index cffbcdd..c9bc2e6 100644
--- a/milena/tests/world/inter_pixel/Makefile.am
+++ b/milena/tests/fun/stat/Makefile.am
@@ -2,12 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = \
- dim2
+check_PROGRAMS = \
+ mahalanobis
-check_PROGRAMS = \
- image2full
-
-image2full_SOURCES = image2full.cc
+mahalanobis_SOURCES = mahalanobis.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/fun/all.hh b/milena/tests/fun/stat/mahalanobis.cc
similarity index 55%
copy from milena/mln/fun/all.hh
copy to milena/tests/fun/stat/mahalanobis.cc
index 8e9ddad..7df7af2 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/fun/stat/mahalanobis.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,50 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/fun/stat/mahalanobis.cc
+///
+/// Tests on mln::fun::stat::mahalanobis.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
+#include <mln/fun/stat/mahalanobis.hh>
-namespace mln
+float my_rand(int c)
{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+int main()
+{
+ using namespace mln;
-}
+ typedef algebra::vec<3,float> vec3f;
+ enum { n = 1000 };
+ vec3f v[n];
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+// vec3f m = a.mean();
+// mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+// mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+// mln_assertion(m[2] > 1.4 && m[2] < 1.6);
-#endif // ! MLN_FUN_ALL_HH
+ fun::stat::mahalanobis<vec3f> f(a.variance(), a.mean());
+
+// algebra::mat<3,3,float> s_1 = a.variance()._1();
+// mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+// mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+// mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
diff --git a/milena/tests/world/inter_pixel/Makefile.am b/milena/tests/world/inter_pixel/Makefile.am
index cffbcdd..fdbcea2 100644
--- a/milena/tests/world/inter_pixel/Makefile.am
+++ b/milena/tests/world/inter_pixel/Makefile.am
@@ -5,9 +5,11 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
dim2
-check_PROGRAMS = \
- image2full
+check_PROGRAMS = \
+ image2full \
+ immerse
image2full_SOURCES = image2full.cc
+immerse_SOURCES = immerse.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/convert/to_fun.hh b/milena/tests/world/inter_pixel/compute.cc
similarity index 52%
copy from milena/mln/convert/to_fun.hh
copy to milena/tests/world/inter_pixel/compute.cc
index 86a1ddc..9226a67 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/tests/world/inter_pixel/compute.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,55 +25,63 @@
// 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 tests/world/inter_pixel/compute.cc
+///
+/// Tests on mln::world::inter_pixel::compute.
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+#include <cmath>
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/immerse.hh>
+#include <mln/world/inter_pixel/compute.hh>
+#include <mln/world/inter_pixel/neighb2d.hh>
+#include <mln/morpho/watershed/flooding.hh>
+#include <mln/debug/println.hh>
-namespace mln
+
+
+struct d_t : mln::Function_vv2v<d_t>
{
+ typedef int result;
- namespace convert
+ int operator()(int i1, int i2) const
{
+ return std::abs(i2 - i1);
+ }
+}
+ d;
- /// 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);
+int main()
+{
+ using namespace mln;
-# ifndef MLN_INCLUDE_ONLY
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
- {
- return pw::value(ima);
- }
+ using namespace world::inter_pixel;
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
-# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
+ int refs[] = { 0, 1, 0, 1, 0,
+ 2, 0, 1, 0, 1,
+ 0, 2, 0, 3, 0,
+ 7, 0, 4, 0, 3,
+ 0, 1, 0, 4, 0 };
-} // end of namespace mln
+ mln_assertion(compute(imax, d) == (make::image2d(refs) | is_separator()));
+ mln_VAR(g, compute(imax, d));
-#endif // ! MLN_CONVERT_TO_FUN_HH
+ unsigned n_basins;
+ debug::println(morpho::watershed::flooding(g, e2e(), n_basins));
+}
diff --git a/milena/mln/fun/all.hh b/milena/tests/world/inter_pixel/immerse.cc
similarity index 61%
copy from milena/mln/fun/all.hh
copy to milena/tests/world/inter_pixel/immerse.cc
index 8e9ddad..42094b9 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/world/inter_pixel/immerse.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,42 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/world/inter_pixel/immerse.cc
+///
+/// Tests on mln::world::inter_pixel::immerse.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/immerse.hh>
-namespace mln
+int main()
{
+ using namespace mln;
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
-}
+ using namespace world::inter_pixel;
+
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ int refs[] = { 3, 0, 4, 0, 5,
+ 0, 0, 0, 0, 0,
+ 1, 0, 3, 0, 6,
+ 0, 0, 0, 0, 0,
+ 8, 0, 7, 0, 3 };
+ mln_assertion(imax == (make::image2d(refs) | is_pixel()));
-#endif // ! MLN_FUN_ALL_HH
+ mln_piter_(Ix) p(imax.domain());
+ for_all(p)
+ mln_assertion(is_pixel()(p));
+}
--
1.6.1.2
1
0
* mln/fun/i2v/array.hh (from_to_): Remove static check.
* milena/mln/convert/from_to.hxx: New overload for couple->couple.
---
milena/ChangeLog | 56 ++++++++++++++++++++++------------------
milena/mln/convert/from_to.hxx | 10 +++++++
milena/mln/fun/i2v/array.hh | 4 ---
3 files changed, 41 insertions(+), 29 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a8a37ed..2583428 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-07 Guillaume Sadegh <sadegh(a)lrde.epita.fr>
+
+ Add couple to couple conversion.
+ * mln/fun/i2v/array.hh (from_to_): Remove static check.
+ * milena/mln/convert/from_to.hxx: New overload for couple->couple.
+
2009-05-06 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add I/O tests.
@@ -66,7 +72,7 @@
* sandbox/fred/tests/thru.cc: Added test for thrubin.
2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
-
+
Add make_edge_image in world::inter_pixel and few missing tests.
* mln/world/inter_pixel/dim2/make_edge_image.hh: new routine.
@@ -368,7 +374,7 @@
* mln/algebra/vec.hh (trait): Fix missing definitions.
(set_precise_binary_): Duplicate explicitly for op::times
and op::div.
- (operator-): New unary operator.
+ (operator-): New unary operator.
* tests/algebra/mat.cc: Copy to...
* tests/algebra/h_mat.cc: ...this new file.
* tests/algebra/mat.cc: Revamp so that there is no h_mat.
@@ -540,7 +546,7 @@
* mln/algebra/all.hh: fix comments.
* mln/algebra/vec.hh: add operator>>.
-
+
* mln/core/internal/graph_psite_base.hh: convert to the correct id
type.
@@ -701,7 +707,7 @@
Fix ambiguities while loading PGM images into label values.
- * mln/io/pnm/load.hh: Use the value equivalent type to read
+ * mln/io/pnm/load.hh: Use the value equivalent type to read
data correctly.
2009-04-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -760,7 +766,7 @@
2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Revamp graph images.
-
+
* headers.mk: update distributed file list.
* mln/make/dummy_p_edges.hh,
@@ -799,7 +805,7 @@
* mln/util/internal/id2element.hh: function mapping ids to graph
elements.
-
+
* mln/make/p_edges_with_mass_centers.hh: fix guards.
* tests/make/dummy_p_vertices.cc,
@@ -822,7 +828,7 @@
* doc/outputs/outputs.mk,
* doc/generate_dist_files.sh: do not add distributed files in
EXTRA_DIST.
-
+
* doc/examples/samples.mk: remove since useless now.
2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -847,7 +853,7 @@
* mln/registration/get_rot.hh: Update.
* mln/registration/icp.hh: Update.
* mln/algebra/vec.hh (mat<n, 1, U>): New conversion op, ctor,
- and assignment; declarations only, definitions are...
+ and assignment; declarations only, definitions are...
* mln/algebra/mat.hh (mat<n, 1, U>): ...new.
* tests/algebra/op_times.cc: New.
@@ -905,9 +911,9 @@
* mln/make/influence_zone_adjacency_graph.hh: rename the routine in
order to have the same name as the file name.
-
+
* mln/make/rag_and_labeled_wsl.hh: Add more doc.
-
+
* mln/value/lut_vec.hh: add a constructor overload for util::array
which is now considered as a function.
@@ -1057,7 +1063,7 @@
* mln/labeling/pack.hh: ... in this new routine.
* tests/labeling/Makefile.am,
- * tests/labeling/pack.cc: add a new test.
+ * tests/labeling/pack.cc: add a new test.
2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -1099,7 +1105,7 @@
* mln/core/site_set/p_graph_piter.hh,
* mln/core/internal/image_base.hh,
* mln/core/image/essential.hh: update doc.
-
+
* mln/core/image/all.hh: include new headers.
* mln/core/image/vertex_image.hh,
@@ -1183,7 +1189,7 @@
fun::l2l::relabel as lut.
2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
-
+
Remove debug in io::tiff::load.
* mln/io/tiff/load.hh: Remove debug.
@@ -1308,7 +1314,7 @@
Add new accumulators related to labels.
* mln/accu/all.hh: include new accumulators.
-
+
* mln/accu/count_labels.hh: count how many different labels are in an
image.
@@ -1382,8 +1388,8 @@
Add some simple triangle meshes.
- * mesh/one-triangle.off:
- * mesh/two-triangles.off:
+ * mesh/one-triangle.off:
+ * mesh/two-triangles.off:
* mesh/three-triangles.off:
New.
@@ -1595,7 +1601,7 @@
Small fixes.
* headers.mk: update distributed header list.
-
+
* doc/Doxyfile.in: Do not use mln:: prefix in class name lists.
* doc/ref_guide/ref_guide.tex: update reference to clone().
@@ -2714,7 +2720,7 @@
* mln/transform/distance_and_closest_point_geodesic.hh: ... this.
Now returns both dmap and closest point images.
Add a version returning a closest point image containing indexes.
-
+
* mln/transform/all.hh: update includes.
* mln/transform/internal/closest_point_functor.hh: add a new functor
@@ -3397,7 +3403,7 @@
* tests/registration/multiscale.cc,
* mln/registration/multiscale.hh: remove.
-
+
* tests/registration/Makefile.am: remove multiscale.cc from test list.
* mln/value/rgb.hh: fix a recursive inclusion.
@@ -3488,7 +3494,7 @@
* mln/fun/x2x/rotation.hh:
(get_rot_h_mat 3d): fix matrix construction.
(rotation(algebra::quat)): update attributes in order to produce a
- valid inverted rotation.
+ valid inverted rotation.
* tests/fun/x2x/rotation.cc: improve test.
@@ -3544,7 +3550,7 @@
Revamp icp2.hh.
- * registration/icp2.hh: move registration*...
+ * registration/icp2.hh: move registration*...
* registration/registration.hh: ... here.
2009-02-16 Guillaume Lazzara <z(a)lrde.epita.fr>
@@ -3660,9 +3666,9 @@
Update apps/statues/ to catch up with recent changes of interface.
* apps/statues/mesh-complex-max-curv-segm.cc,
- * apps/statues/mesh-complex-max-curv.cc,
- * apps/statues/mesh-complex-segm.cc,
- * apps/statues/trimesh/misc.hh:
+ * apps/statues/mesh-complex-max-curv.cc,
+ * apps/statues/mesh-complex-segm.cc,
+ * apps/statues/trimesh/misc.hh:
Adjust to the new interface of mln::morpho::closing_area and the
renaming of mln::level as mln::data.
* apps/statues/Makefile.am: Adjust comments.
@@ -3671,7 +3677,7 @@
Add a shortcut for planar 1-complex-based images.
- * mln/core/alias/complex_image.hh (mln::int_u8_1complex_image2d):
+ * mln/core/alias/complex_image.hh (mln::int_u8_1complex_image2d):
New typedef.
2009-02-11 Roland Levillain <roland(a)lrde.epita.fr>
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index ded3998..ca6eb81 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -36,6 +36,7 @@
# include <mln/core/def/all.hh>
# include <mln/core/grids.hh>
+# include <mln/util/couple.hh>
//FIXME: have a forward declaration.
# include <vector>
@@ -409,6 +410,15 @@ namespace mln
void
from_to_(const util::array<V>& from, image1d<T>& to);
+ // util::couple<T, U> -> util::couple<V, W>
+ template <typename T, typename U, typename V, typename W>
+ void
+ from_to_(const util::couple<T, U>& from, util::couple<V, W>& to)
+ {
+ from_to(from.first(), to.first());
+ from_to(from.second(), to.second());
+ }
+
} // end of namespace mln::convert::over_load
} // end of namespace mln::convert
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index f8030a9..e7fb61a 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -211,8 +211,6 @@ namespace mln
void
from_to_(const util::array<T>& from, fun::i2v::array<U>& to)
{
- mlc_converts_to(T,U)::check();
-
to.reserve(from.nelements());
for (unsigned i = 0; i < from.nelements(); ++i)
to.append(convert::to<U>(from[i]));
@@ -231,8 +229,6 @@ namespace mln
void
from_to_(const std::vector<T>& from, fun::i2v::array<U>& to)
{
- mlc_converts_to(T,U)::check();
-
to.reserve(from.nelements());
for (unsigned i = 0; i < from.size(); ++i)
to.append(convert::to<U>(from[i]));
--
1.6.1.2
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
New ESIEE stuff.
* theo/esiee/slides_2009_may: New.
* theo/esiee/slides_2009_may/dilation.hh: New.
* theo/esiee/slides_2009_may/main.cc: New.
* theo/esiee/laurent/ismm09/extinct_attributes.hh: New.
* theo/esiee/laurent/ismm09/main.ext.cc: New.
laurent/ismm09/extinct_attributes.hh | 136 +++++++++++++++++++++++++++++++++++
laurent/ismm09/main.ext.cc | 76 +++++++++++++++++++
slides_2009_may/dilation.hh | 70 ++++++++++++++++++
slides_2009_may/main.cc | 31 +++++++
4 files changed, 313 insertions(+)
Index: theo/esiee/slides_2009_may/dilation.hh
--- theo/esiee/slides_2009_may/dilation.hh (revision 0)
+++ theo/esiee/slides_2009_may/dilation.hh (revision 0)
@@ -0,0 +1,70 @@
+
+#include <mln/pw/image.hh>
+#include <mln/convert/to_fun.hh>
+#include <mln/accu/max.hh>
+
+
+namespace mln
+{
+
+ // To be added in mln/pw/image.hh
+
+ template <typename V, typename P, typename S>
+ pw::image< fun::C<V(*)(P)>, S >
+ operator | (V (*f)(P), const S& s)
+ {
+ return convert::to_fun(f) | s;
+ }
+
+
+// namespace accu
+// {
+// template <typename T> struct sup : max<T> {};
+// }
+
+
+ namespace accu
+ {
+ template <typename T>
+ struct sup : public accu::internal::base< T, sup<T> >
+ {
+ typedef T argument;
+ T t_;
+
+ void init() { t_ = mln_min(T); }
+ void take(const T& t) { if (t > t_) t_ = t; }
+ void take(const sup& o) { if (o.t_ > t_) t_ = o.t_; }
+ T to_result() const { return t_; }
+ bool is_valid() const { return true; }
+ };
+
+ } // mln::accu
+
+
+ namespace morpho
+ {
+
+ template <typename I, typename W>
+ mln_concrete(I) dilation(const I& ima, const W& win)
+ {
+ mln_concrete(I) out;
+ initialize(out, ima);
+
+ mln_piter(I) p(ima.domain());
+ mln_qiter(W) q(win, p);
+ accu::sup<mln_value(I)> sup;
+
+ for_all(p)
+ {
+ sup.init();
+ for_all(q) if (ima.has(q))
+ sup.take(ima(q));
+ out(p) = sup;
+ }
+
+ return out;
+ }
+
+ } // mln::morpho
+
+} // mln
Index: theo/esiee/slides_2009_may/main.cc
--- theo/esiee/slides_2009_may/main.cc (revision 0)
+++ theo/esiee/slides_2009_may/main.cc (revision 0)
@@ -0,0 +1,31 @@
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+#include "dilation.hh"
+
+
+
+int slope(mln::point2d p)
+{
+ return p.row() + p.col();
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(2,2);
+ debug::iota(ima);
+ debug::println(ima);
+
+ debug::println(morpho::dilation(ima,
+ win_c4p()) );
+
+ mln_VAR(ima2, slope | box2d(3,3));
+ debug::println(ima2);
+ debug::println(morpho::dilation(ima2, c4().win()) );
+}
Index: theo/esiee/laurent/ismm09/extinct_attributes.hh
--- theo/esiee/laurent/ismm09/extinct_attributes.hh (revision 0)
+++ theo/esiee/laurent/ismm09/extinct_attributes.hh (revision 0)
@@ -0,0 +1,136 @@
+
+namespace mln
+{
+
+ // Display.
+ // --------
+
+
+ template <typename T, typename I>
+ void display_tree_attributes(const T& t, // Tree.
+ const I& a) // Attribute image.
+ {
+ typedef mln_site(I) P;
+
+ mln_ch_value(I, bool) deja_vu;
+ initialize(deja_vu, a);
+ data::fill(deja_vu, false);
+
+ mln_up_node_piter(T) p(t);
+ for_all(p)
+ {
+ if (deja_vu(p))
+ continue;
+
+ P e = p;
+ do
+ {
+ std::cout << a(e) << ':' << e << " -> ";
+ deja_vu(e) = true;
+ e = t.parent(e);
+ }
+ while (! deja_vu(e));
+ std::cout << a(e) << ':' << e << std::endl;
+ }
+ std::cout << std::endl;
+ }
+
+
+ // Attribute Extinction.
+ // ---------------------
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct node_pred : Function_p2b< node_pred<T> >
+ {
+ typedef bool result;
+
+ template <typename P>
+ bool operator()(const P& p) const
+ {
+ return t->is_a_node(p);
+ }
+
+ const T* t;
+ };
+
+
+ // Vachier's version.
+
+ template <typename T, typename I, typename M>
+ inline
+ mln_value(I)
+ extinct_rec(const T& t, // tree
+ I& a, // attribute image
+ M& mark,
+ const mln_psite(I)& p)
+ {
+ mln_invariant(mark(p) == false);
+ mark(p) = true;
+ if (t.parent(p) == p || mark(t.parent(p)) == true) // Stop.
+ return a(p);
+ return a(p) = extinct_rec(t, a, mark, t.parent(p));
+ }
+
+
+ } // end of internal
+
+
+ // Vachier's version.
+
+ template <typename T, typename I>
+ void
+ extinct_attributes(const T& t, // Tree.
+ I& a, // Attribute image.
+ bool echo = false)
+ {
+ if (echo)
+ {
+ std::cout << "before:" << std::endl;
+ display_tree_attributes(t, a);
+ }
+
+ typedef mln_site(I) P;
+ typedef mln_value(I) A; // Type of attributes.
+
+ mln_ch_value(I, bool) mark;
+ initialize(mark, a);
+ data::fill(mark, false);
+
+ internal::node_pred<T> node_only;
+ node_only.t = &t;
+
+ typedef p_array<P> S;
+ S s = level::sort_psites_increasing(a | node_only);
+
+// {
+// mln_fwd_piter(S) p(s);
+// for_all(p)
+// std::cout << p << ' ' << a(p) << " - ";
+// std::cout << std::endl
+// << std::endl;
+// }
+
+ mln_invariant(geom::nsites(a | t.nodes()) == s.nsites());
+
+ mln_fwd_piter(S) p(s);
+ for_all(p)
+ {
+ if (mark(p) == true)
+ continue;
+ internal::extinct_rec(t, a, mark, p);
+ }
+
+ // debug::println(mark | t.nodes());
+
+ if (echo)
+ {
+ std::cout << "after:" << std::endl;
+ display_tree_attributes(t, a);
+ }
+ }
+
+
+} // mln
Index: theo/esiee/laurent/ismm09/main.ext.cc
--- theo/esiee/laurent/ismm09/main.ext.cc (revision 0)
+++ theo/esiee/laurent/ismm09/main.ext.cc (revision 0)
@@ -0,0 +1,76 @@
+
+#include <mln/core/var.hh>
+
+#include <mln/value/label_16.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/morpho/tree/data.hh>
+#include <mln/morpho/tree/compute_attribute_image.hh>
+#include <mln/morpho/attribute/height.hh>
+#include <mln/labeling/regional_minima.hh>
+
+#include "cplx2d.hh"
+#include "extinct_attributes.hh"
+
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.pgm" << std::endl;
+ std::cerr << "Laurent ISMM 2009 scheme." << std::endl;
+ abort();
+}
+
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::label_16;
+
+ if (argc != 2)
+ usage(argv);
+
+ // f: regular image.
+
+ image2d<int_u8> f;
+ io::pgm::load(f, argv[1]);
+
+
+ // g: weights on edges.
+
+ mln_VAR(g, cplx2d::f_to_g(f) );
+ debug::println("g:", g);
+
+
+ // a: array "label -> attribute".
+
+ typedef unsigned A; // <--- Type of attributes.
+
+ {
+ typedef p_array<point2d> s_t;
+ s_t s = level::sort_psites_decreasing(g); // min-tree
+
+ typedef morpho::tree::data<g_t,s_t> tree_t;
+ tree_t t(g, s, cplx2d::e2e());
+
+ morpho::attribute::height<g_t> a;
+ mln_VAR(h, morpho::tree::compute_attribute_image(a, t));
+ debug::println("h:", h);
+
+ unsigned l_max;
+
+ mln_VAR(h_r, labeling::regional_minima(h, cplx2d::e2e(), l_max));
+ debug::println("h_r:", h_r);
+
+ extinct_attributes(t, h, /* echo = */ true);
+ debug::println("he | nodes:", h | t.nodes());
+ }
+
+}
1
0
* theo/esiee/slides_2009_may: New.
* theo/esiee/slides_2009_may/dilation.hh: New.
* theo/esiee/slides_2009_may/main.cc: New.
* theo/esiee/laurent/ismm09/extinct_attributes.hh: New.
* theo/esiee/laurent/ismm09/main.ext.cc: New.
---
milena/sandbox/ChangeLog | 10 ++
.../esiee/laurent/ismm09/extinct_attributes.hh | 136 ++++++++++++++++++++
.../sandbox/theo/esiee/laurent/ismm09/main.ext.cc | 76 +++++++++++
.../sandbox/theo/esiee/slides_2009_may/dilation.hh | 70 ++++++++++
milena/sandbox/theo/esiee/slides_2009_may/main.cc | 31 +++++
5 files changed, 323 insertions(+), 0 deletions(-)
create mode 100644 milena/sandbox/theo/esiee/laurent/ismm09/extinct_attributes.hh
create mode 100644 milena/sandbox/theo/esiee/laurent/ismm09/main.ext.cc
create mode 100644 milena/sandbox/theo/esiee/slides_2009_may/dilation.hh
create mode 100644 milena/sandbox/theo/esiee/slides_2009_may/main.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 123d1e0..0e9423a 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-06 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+
+ New ESIEE stuff.
+
+ * theo/esiee/slides_2009_may: New.
+ * theo/esiee/slides_2009_may/dilation.hh: New.
+ * theo/esiee/slides_2009_may/main.cc: New.
+ * theo/esiee/laurent/ismm09/extinct_attributes.hh: New.
+ * theo/esiee/laurent/ismm09/main.ext.cc: New.
+
2009-05-05 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a file to test exprs like ''pw::value(ima) < 3''.
diff --git a/milena/sandbox/theo/esiee/laurent/ismm09/extinct_attributes.hh b/milena/sandbox/theo/esiee/laurent/ismm09/extinct_attributes.hh
new file mode 100644
index 0000000..2190ec2
--- /dev/null
+++ b/milena/sandbox/theo/esiee/laurent/ismm09/extinct_attributes.hh
@@ -0,0 +1,136 @@
+
+namespace mln
+{
+
+ // Display.
+ // --------
+
+
+ template <typename T, typename I>
+ void display_tree_attributes(const T& t, // Tree.
+ const I& a) // Attribute image.
+ {
+ typedef mln_site(I) P;
+
+ mln_ch_value(I, bool) deja_vu;
+ initialize(deja_vu, a);
+ data::fill(deja_vu, false);
+
+ mln_up_node_piter(T) p(t);
+ for_all(p)
+ {
+ if (deja_vu(p))
+ continue;
+
+ P e = p;
+ do
+ {
+ std::cout << a(e) << ':' << e << " -> ";
+ deja_vu(e) = true;
+ e = t.parent(e);
+ }
+ while (! deja_vu(e));
+ std::cout << a(e) << ':' << e << std::endl;
+ }
+ std::cout << std::endl;
+ }
+
+
+ // Attribute Extinction.
+ // ---------------------
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct node_pred : Function_p2b< node_pred<T> >
+ {
+ typedef bool result;
+
+ template <typename P>
+ bool operator()(const P& p) const
+ {
+ return t->is_a_node(p);
+ }
+
+ const T* t;
+ };
+
+
+ // Vachier's version.
+
+ template <typename T, typename I, typename M>
+ inline
+ mln_value(I)
+ extinct_rec(const T& t, // tree
+ I& a, // attribute image
+ M& mark,
+ const mln_psite(I)& p)
+ {
+ mln_invariant(mark(p) == false);
+ mark(p) = true;
+ if (t.parent(p) == p || mark(t.parent(p)) == true) // Stop.
+ return a(p);
+ return a(p) = extinct_rec(t, a, mark, t.parent(p));
+ }
+
+
+ } // end of internal
+
+
+ // Vachier's version.
+
+ template <typename T, typename I>
+ void
+ extinct_attributes(const T& t, // Tree.
+ I& a, // Attribute image.
+ bool echo = false)
+ {
+ if (echo)
+ {
+ std::cout << "before:" << std::endl;
+ display_tree_attributes(t, a);
+ }
+
+ typedef mln_site(I) P;
+ typedef mln_value(I) A; // Type of attributes.
+
+ mln_ch_value(I, bool) mark;
+ initialize(mark, a);
+ data::fill(mark, false);
+
+ internal::node_pred<T> node_only;
+ node_only.t = &t;
+
+ typedef p_array<P> S;
+ S s = level::sort_psites_increasing(a | node_only);
+
+// {
+// mln_fwd_piter(S) p(s);
+// for_all(p)
+// std::cout << p << ' ' << a(p) << " - ";
+// std::cout << std::endl
+// << std::endl;
+// }
+
+ mln_invariant(geom::nsites(a | t.nodes()) == s.nsites());
+
+ mln_fwd_piter(S) p(s);
+ for_all(p)
+ {
+ if (mark(p) == true)
+ continue;
+ internal::extinct_rec(t, a, mark, p);
+ }
+
+ // debug::println(mark | t.nodes());
+
+ if (echo)
+ {
+ std::cout << "after:" << std::endl;
+ display_tree_attributes(t, a);
+ }
+ }
+
+
+} // mln
diff --git a/milena/sandbox/theo/esiee/laurent/ismm09/main.ext.cc b/milena/sandbox/theo/esiee/laurent/ismm09/main.ext.cc
new file mode 100644
index 0000000..3f223d8
--- /dev/null
+++ b/milena/sandbox/theo/esiee/laurent/ismm09/main.ext.cc
@@ -0,0 +1,76 @@
+
+#include <mln/core/var.hh>
+
+#include <mln/value/label_16.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/morpho/tree/data.hh>
+#include <mln/morpho/tree/compute_attribute_image.hh>
+#include <mln/morpho/attribute/height.hh>
+#include <mln/labeling/regional_minima.hh>
+
+#include "cplx2d.hh"
+#include "extinct_attributes.hh"
+
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.pgm" << std::endl;
+ std::cerr << "Laurent ISMM 2009 scheme." << std::endl;
+ abort();
+}
+
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::label_16;
+
+ if (argc != 2)
+ usage(argv);
+
+ // f: regular image.
+
+ image2d<int_u8> f;
+ io::pgm::load(f, argv[1]);
+
+
+ // g: weights on edges.
+
+ mln_VAR(g, cplx2d::f_to_g(f) );
+ debug::println("g:", g);
+
+
+ // a: array "label -> attribute".
+
+ typedef unsigned A; // <--- Type of attributes.
+
+ {
+ typedef p_array<point2d> s_t;
+ s_t s = level::sort_psites_decreasing(g); // min-tree
+
+ typedef morpho::tree::data<g_t,s_t> tree_t;
+ tree_t t(g, s, cplx2d::e2e());
+
+ morpho::attribute::height<g_t> a;
+ mln_VAR(h, morpho::tree::compute_attribute_image(a, t));
+ debug::println("h:", h);
+
+ unsigned l_max;
+
+ mln_VAR(h_r, labeling::regional_minima(h, cplx2d::e2e(), l_max));
+ debug::println("h_r:", h_r);
+
+ extinct_attributes(t, h, /* echo = */ true);
+ debug::println("he | nodes:", h | t.nodes());
+ }
+
+}
diff --git a/milena/sandbox/theo/esiee/slides_2009_may/dilation.hh b/milena/sandbox/theo/esiee/slides_2009_may/dilation.hh
new file mode 100644
index 0000000..2d0be82
--- /dev/null
+++ b/milena/sandbox/theo/esiee/slides_2009_may/dilation.hh
@@ -0,0 +1,70 @@
+
+#include <mln/pw/image.hh>
+#include <mln/convert/to_fun.hh>
+#include <mln/accu/max.hh>
+
+
+namespace mln
+{
+
+ // To be added in mln/pw/image.hh
+
+ template <typename V, typename P, typename S>
+ pw::image< fun::C<V(*)(P)>, S >
+ operator | (V (*f)(P), const S& s)
+ {
+ return convert::to_fun(f) | s;
+ }
+
+
+// namespace accu
+// {
+// template <typename T> struct sup : max<T> {};
+// }
+
+
+ namespace accu
+ {
+ template <typename T>
+ struct sup : public accu::internal::base< T, sup<T> >
+ {
+ typedef T argument;
+ T t_;
+
+ void init() { t_ = mln_min(T); }
+ void take(const T& t) { if (t > t_) t_ = t; }
+ void take(const sup& o) { if (o.t_ > t_) t_ = o.t_; }
+ T to_result() const { return t_; }
+ bool is_valid() const { return true; }
+ };
+
+ } // mln::accu
+
+
+ namespace morpho
+ {
+
+ template <typename I, typename W>
+ mln_concrete(I) dilation(const I& ima, const W& win)
+ {
+ mln_concrete(I) out;
+ initialize(out, ima);
+
+ mln_piter(I) p(ima.domain());
+ mln_qiter(W) q(win, p);
+ accu::sup<mln_value(I)> sup;
+
+ for_all(p)
+ {
+ sup.init();
+ for_all(q) if (ima.has(q))
+ sup.take(ima(q));
+ out(p) = sup;
+ }
+
+ return out;
+ }
+
+ } // mln::morpho
+
+} // mln
diff --git a/milena/sandbox/theo/esiee/slides_2009_may/main.cc b/milena/sandbox/theo/esiee/slides_2009_may/main.cc
new file mode 100644
index 0000000..ebb9074
--- /dev/null
+++ b/milena/sandbox/theo/esiee/slides_2009_may/main.cc
@@ -0,0 +1,31 @@
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+#include "dilation.hh"
+
+
+
+int slope(mln::point2d p)
+{
+ return p.row() + p.col();
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(2,2);
+ debug::iota(ima);
+ debug::println(ima);
+
+ debug::println(morpho::dilation(ima,
+ win_c4p()) );
+
+ mln_VAR(ima2, slope | box2d(3,3));
+ debug::println(ima2);
+ debug::println(morpho::dilation(ima2, c4().win()) );
+}
--
1.6.1.2
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-06 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add I/O tests.
* tests/io/Makefile.am: Update for dicom and IM.
* tests/io/dicom/Makefile.am: New Makefile for dicom.
* tests/io/dicom/dicom.cc: New test.
* tests/io/magick/Makefile.am: New Makefile for IM.
* tests/io/magick/magick.cc: New test.
---
Makefile.am | 2 +
dicom/Makefile.am | 10 ++++++++
dicom/dicom.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++
magick/Makefile.am | 10 ++++++++
magick/magick.cc | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 132 insertions(+)
Index: trunk/milena/tests/io/Makefile.am
===================================================================
--- trunk/milena/tests/io/Makefile.am (revision 3764)
+++ trunk/milena/tests/io/Makefile.am (revision 3765)
@@ -3,8 +3,10 @@
include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
+ dicom \
dump \
fits \
+ magick \
off \
pbm \
pfm \
Index: trunk/milena/tests/io/dicom/dicom.cc
===================================================================
--- trunk/milena/tests/io/dicom/dicom.cc (revision 0)
+++ trunk/milena/tests/io/dicom/dicom.cc (revision 3765)
@@ -0,0 +1,50 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/io/dicom/dicom.cc
+///
+/// Test on mln::io::dicom::*.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/io/dicom/load.hh>
+#include <mln/io/dump/save.hh>
+
+#include <mln/level/compare.hh>
+
+#include <mln/value/int_u12.hh>
+
+#include "tests/data.hh"
+
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ return 0;
+}
+
Index: trunk/milena/tests/io/dicom/Makefile.am
===================================================================
--- trunk/milena/tests/io/dicom/Makefile.am (revision 0)
+++ trunk/milena/tests/io/dicom/Makefile.am (revision 3765)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ dicom
+
+dicom_SOURCES = dicom.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/io/magick/magick.cc
===================================================================
--- trunk/milena/tests/io/magick/magick.cc (revision 0)
+++ trunk/milena/tests/io/magick/magick.cc (revision 3765)
@@ -0,0 +1,60 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/io/magick/magick.cc
+///
+/// Test on mln::io::magick::*.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/io/magick/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/level/compare.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
+#include "tests/data.hh"
+
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ image2d<value::rgb8> lena_im;
+ io::magick::load(lena_im, "lena.png");
+
+ image2d<value::rgb8> lena_mln;
+ io::ppm::load(lena_mln, "lena.ppm");
+
+ mln_assertion(lena_im.domain() == lena_mln.domain());
+ mln_assertion(lena_im == lena_mln);
+ }
+}
+
Index: trunk/milena/tests/io/magick/Makefile.am
===================================================================
--- trunk/milena/tests/io/magick/Makefile.am (revision 0)
+++ trunk/milena/tests/io/magick/Makefile.am (revision 3765)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ magick
+
+magick_SOURCES = magick.cc
+
+TESTS = $(check_PROGRAMS)
1
0
* tests/io/Makefile.am: Update for dicom and IM.
* tests/io/dicom/Makefile.am: New Makefile for dicom.
* tests/io/dicom/dicom.cc: New test.
* tests/io/magick/Makefile.am: New Makefile for IM.
* tests/io/magick/magick.cc: New test.
---
milena/ChangeLog | 9 +++++
milena/tests/io/Makefile.am | 2 +
milena/tests/io/dicom/Makefile.am | 10 ++++++
milena/tests/io/dicom/dicom.cc | 50 ++++++++++++++++++++++++++++++
milena/tests/io/magick/Makefile.am | 10 ++++++
milena/tests/io/magick/magick.cc | 60 ++++++++++++++++++++++++++++++++++++
6 files changed, 141 insertions(+), 0 deletions(-)
create mode 100644 milena/tests/io/dicom/Makefile.am
create mode 100644 milena/tests/io/dicom/dicom.cc
create mode 100644 milena/tests/io/magick/Makefile.am
create mode 100644 milena/tests/io/magick/magick.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ff6c707..a8a37ed 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,12 @@
+2009-05-06 Fabien Freling <fabien.freling(a)lrde.epita.fr>
+
+ Add I/O tests.
+ * tests/io/Makefile.am: Update for dicom and IM.
+ * tests/io/dicom/Makefile.am: New Makefile for dicom.
+ * tests/io/dicom/dicom.cc: New test.
+ * tests/io/magick/Makefile.am: New Makefile for IM.
+ * tests/io/magick/magick.cc: New test.
+
2009-05-06 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Add adjacency matrix.
diff --git a/milena/tests/io/Makefile.am b/milena/tests/io/Makefile.am
index cc4a0f8..760d591 100644
--- a/milena/tests/io/Makefile.am
+++ b/milena/tests/io/Makefile.am
@@ -3,8 +3,10 @@
include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
+ dicom \
dump \
fits \
+ magick \
off \
pbm \
pfm \
diff --git a/milena/tests/io/dicom/Makefile.am b/milena/tests/io/dicom/Makefile.am
new file mode 100644
index 0000000..07646c8
--- /dev/null
+++ b/milena/tests/io/dicom/Makefile.am
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ dicom
+
+dicom_SOURCES = dicom.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/io/dicom/dicom.cc b/milena/tests/io/dicom/dicom.cc
new file mode 100644
index 0000000..ada15f8
--- /dev/null
+++ b/milena/tests/io/dicom/dicom.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/io/dicom/dicom.cc
+///
+/// Test on mln::io::dicom::*.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/io/dicom/load.hh>
+#include <mln/io/dump/save.hh>
+
+#include <mln/level/compare.hh>
+
+#include <mln/value/int_u12.hh>
+
+#include "tests/data.hh"
+
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ return 0;
+}
+
diff --git a/milena/tests/io/magick/Makefile.am b/milena/tests/io/magick/Makefile.am
new file mode 100644
index 0000000..1c7308d
--- /dev/null
+++ b/milena/tests/io/magick/Makefile.am
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ magick
+
+magick_SOURCES = magick.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/io/magick/magick.cc b/milena/tests/io/magick/magick.cc
new file mode 100644
index 0000000..d6145fc
--- /dev/null
+++ b/milena/tests/io/magick/magick.cc
@@ -0,0 +1,60 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/io/magick/magick.cc
+///
+/// Test on mln::io::magick::*.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/io/magick/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/level/compare.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
+#include "tests/data.hh"
+
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ image2d<value::rgb8> lena_im;
+ io::magick::load(lena_im, "lena.png");
+
+ image2d<value::rgb8> lena_mln;
+ io::ppm::load(lena_mln, "lena.ppm");
+
+ mln_assertion(lena_im.domain() == lena_mln.domain());
+ mln_assertion(lena_im == lena_mln);
+ }
+}
+
--
1.6.1.2
1
0
---
AUTHORS | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ChangeLog | 4 +
2 files changed, 245 insertions(+), 0 deletions(-)
create mode 100644 AUTHORS
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..c165b77
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,241 @@
+The Olena Group consists of
+
+===============
+Permanent staff
+===============
+
+* Thierry Geraud thierry.geraud(a)lrde.epita.fr
+ - Management of the project in the first place
+ - Type system
+ - Revamp of Metalic (Olena 1.0)
+ - SCOOP, SCOOP 2, Static (Olena proto-1.0, Olena 1.0)
+ - Extended (Olena 1.0)
+ - Numerous hours spent thinking about Olena
+
+* Roland Levillain roland.levillain(a)lrde.epita.fr
+ - Project manager,
+ - Theoritical mentor
+ - Renovation of Swilena (Olena 0.10a),
+ - G++ 4.0 and 4.1 compatibility (Olena 0.10a),
+ - Integration of GNU Libtool (Olena 0.10a),
+ - SCOOP 2 and Static (Olena 1.0).
+
+
+
+===============
+Temporary staff
+===============
+
+* Yann Régis-Gianas
+ - type system.
+
+* Yoann Fabre
+ - type system.
+
+* Vincent Berruchon
+
+* Simon Odou
+ - contributions to document the code,
+ - deconvolution,
+ - generic morphers,
+ - SCOOP 2 (Olena proto-1.0).
+
+* Sylvain Berlemont
+ - combinatorial maps,
+ - cleanup the sources.
+
+* Alexandre Duret-Lutz
+ - maintenance of the source tree for several years,
+ - type system,
+ - test system,
+ - first documentation system,
+ - numerous hours spent on Olena to make it better.
+
+* Réda Dehak
+ - management of the project,
+ - color conversions,
+ - cleanup the sources.
+
+* Akim Demaille
+ - configuration system.
+ - maintenance of code's clearness.
+
+* Anthony Pinagot
+ - Olena I/O,
+ - statistical operators,
+ - FFT algorithm.
+
+* Astrid Wang
+ - new documentation system,
+ - static arrays implementation.
+
+* David Lesage
+ - type system,
+ - new paradigm,
+ - cleanup the sources.
+
+* Dimitri Papadopoulos-Orfanos
+ - type system
+
+* Emmanuel Turquin
+ - implementation of transforms,
+ - integre.
+
+* Giovanni Palma
+ - color conversion,
+ - attribute opening and closing algorithms,
+ - new documentation system,
+ - document the code,
+ - cleanup the sources.
+
+* Heru Xue
+ - color system.
+
+* Ignacy Gawedzki
+ - color system.
+
+* Jean Chalard
+ - colors,
+ - vectors and matrices implementation,
+ - Olena iterators implementation,
+ - wavelets.
+
+* Jean-Sébastien Mouret
+ - image I/O,
+ - source tree and configuration system,
+ - fast morphological operators.
+
+* Jérôme Darbon
+ - image morphology and Olena morpho.
+
+* Ludovic Perrine
+ - fuzzy types.
+
+* Michaël Strauss
+ - image morphology,
+ - watershed algorithms,
+ - Olena I/O.
+
+* Niels Van Vliet
+ - color conversion,
+ - attribute opening and closing algorithms,
+ - contributions to document the code,
+ - histograms.
+
+* Pierre-Yves Strub
+ - Olena morpho,
+ - source tree and configuration system,
+ - type system.
+
+* Quôc Peyrot
+ - watershed algorithm.
+
+* Rémi Coupet
+ - Olena morpho,
+ - data types (pre-0.6),
+ - Olena core,
+ - bibliographical research.
+
+* Renaud François
+ - bibliographical research.
+
+* Fabien Freling fabien.freling(a)lrde.epita.fr
+ - Work on Melimage with IGR.
+ - Library improvements.
+
+* Guillaume Lazzara
+ - Work on Scribo
+ - Library improvements.
+
+
+==================
+Year 2003 students
+==================
+
+* Raphaël Poss
+ - source tree and configuration system,
+ - documentation.
+
+
+==================
+Year 2004 students
+==================
+
+* Nicolas Burrus
+ - integre,
+ - Olena I/O,
+ - source tree.
+
+
+==================
+Year 2006 students
+==================
+
+* Nicolas Pouillard
+ - Dynamic? (Dyn) (Olena proto-1.0).
+
+* Damien Thivolle
+ - contributions to document the code,
+ - generic morphers,
+ - configuration system,
+ - shapelets transform,
+ - G++ 4.0 compatibility (Olena 0.10a),
+ - canvas for algorithms (Olena proto-1.0),
+ - SCOOP 2 (Olena proto-1.0),
+ - Dynamic? (Dyn) (Olena proto-1.0).
+
+
+==================
+Year 2007 students
+==================
+
+* Christophe Berger
+ - connected filters (Olena proto-1.0, Olena 1.0),
+ - SCOOP 2 (Olena proto-1.0).
+
+* Nicolas Widynski
+ - connected filters (Olena proto-1.0),
+ - inpainting (Olena proto-1.0),
+ - segmentation (watershed transform, watersnake, snakes) (Olena proto-1.0)
+
+
+==================
+Year 2008 students
+==================
+
+* Tristan Croiset
+ - Dynamic (Dyn) (Olena proto-1.0)
+
+* Quentin Hocquet
+ - SCOOL? (Olena 1.0).
+
+* Thomas Moulard
+ - Scool (Olena 1.0)
+
+==================
+Year 2009 students
+==================
+
+* Alexandre Abraham alexandre.abraham(a)lrde.epita.fr
+
+* Nicolas Ballas nicolas.ballas(a)lrde.epita.fr
+
+* Matthieu Garrigues matthieu.garrigues(a)lrde.epita.fr
+
+* Ugo Jardonnet ugo.jardonnet(a)lrde.epita.fr
+
+
+==================
+Year 2010 students
+==================
+
+* Etienne Folio etienne.folio(a)lrde.epita.fr
+
+
+==================
+Year 2011 students
+==================
+
+* Frederic Bour frederic.bour(a)lrde.epita.fr
+* Edwin Carlinet edwin.carlinet(a)lrde.epita.fr
+
diff --git a/ChangeLog b/ChangeLog
index d32d1c1..faa0325 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-05-06 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ * AUTHORS: First draft.
+
2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
* configure.ac: Configure tests/world/*
--
1.5.6.5
1
0
---
AUTHORS | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ChangeLog | 4 +
2 files changed, 245 insertions(+), 0 deletions(-)
create mode 100644 AUTHORS
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..c165b77
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,241 @@
+The Olena Group consists of
+
+===============
+Permanent staff
+===============
+
+* Thierry Geraud thierry.geraud(a)lrde.epita.fr
+ - Management of the project in the first place
+ - Type system
+ - Revamp of Metalic (Olena 1.0)
+ - SCOOP, SCOOP 2, Static (Olena proto-1.0, Olena 1.0)
+ - Extended (Olena 1.0)
+ - Numerous hours spent thinking about Olena
+
+* Roland Levillain roland.levillain(a)lrde.epita.fr
+ - Project manager,
+ - Theoritical mentor
+ - Renovation of Swilena (Olena 0.10a),
+ - G++ 4.0 and 4.1 compatibility (Olena 0.10a),
+ - Integration of GNU Libtool (Olena 0.10a),
+ - SCOOP 2 and Static (Olena 1.0).
+
+
+
+===============
+Temporary staff
+===============
+
+* Yann Régis-Gianas
+ - type system.
+
+* Yoann Fabre
+ - type system.
+
+* Vincent Berruchon
+
+* Simon Odou
+ - contributions to document the code,
+ - deconvolution,
+ - generic morphers,
+ - SCOOP 2 (Olena proto-1.0).
+
+* Sylvain Berlemont
+ - combinatorial maps,
+ - cleanup the sources.
+
+* Alexandre Duret-Lutz
+ - maintenance of the source tree for several years,
+ - type system,
+ - test system,
+ - first documentation system,
+ - numerous hours spent on Olena to make it better.
+
+* Réda Dehak
+ - management of the project,
+ - color conversions,
+ - cleanup the sources.
+
+* Akim Demaille
+ - configuration system.
+ - maintenance of code's clearness.
+
+* Anthony Pinagot
+ - Olena I/O,
+ - statistical operators,
+ - FFT algorithm.
+
+* Astrid Wang
+ - new documentation system,
+ - static arrays implementation.
+
+* David Lesage
+ - type system,
+ - new paradigm,
+ - cleanup the sources.
+
+* Dimitri Papadopoulos-Orfanos
+ - type system
+
+* Emmanuel Turquin
+ - implementation of transforms,
+ - integre.
+
+* Giovanni Palma
+ - color conversion,
+ - attribute opening and closing algorithms,
+ - new documentation system,
+ - document the code,
+ - cleanup the sources.
+
+* Heru Xue
+ - color system.
+
+* Ignacy Gawedzki
+ - color system.
+
+* Jean Chalard
+ - colors,
+ - vectors and matrices implementation,
+ - Olena iterators implementation,
+ - wavelets.
+
+* Jean-Sébastien Mouret
+ - image I/O,
+ - source tree and configuration system,
+ - fast morphological operators.
+
+* Jérôme Darbon
+ - image morphology and Olena morpho.
+
+* Ludovic Perrine
+ - fuzzy types.
+
+* Michaël Strauss
+ - image morphology,
+ - watershed algorithms,
+ - Olena I/O.
+
+* Niels Van Vliet
+ - color conversion,
+ - attribute opening and closing algorithms,
+ - contributions to document the code,
+ - histograms.
+
+* Pierre-Yves Strub
+ - Olena morpho,
+ - source tree and configuration system,
+ - type system.
+
+* Quôc Peyrot
+ - watershed algorithm.
+
+* Rémi Coupet
+ - Olena morpho,
+ - data types (pre-0.6),
+ - Olena core,
+ - bibliographical research.
+
+* Renaud François
+ - bibliographical research.
+
+* Fabien Freling fabien.freling(a)lrde.epita.fr
+ - Work on Melimage with IGR.
+ - Library improvements.
+
+* Guillaume Lazzara
+ - Work on Scribo
+ - Library improvements.
+
+
+==================
+Year 2003 students
+==================
+
+* Raphaël Poss
+ - source tree and configuration system,
+ - documentation.
+
+
+==================
+Year 2004 students
+==================
+
+* Nicolas Burrus
+ - integre,
+ - Olena I/O,
+ - source tree.
+
+
+==================
+Year 2006 students
+==================
+
+* Nicolas Pouillard
+ - Dynamic? (Dyn) (Olena proto-1.0).
+
+* Damien Thivolle
+ - contributions to document the code,
+ - generic morphers,
+ - configuration system,
+ - shapelets transform,
+ - G++ 4.0 compatibility (Olena 0.10a),
+ - canvas for algorithms (Olena proto-1.0),
+ - SCOOP 2 (Olena proto-1.0),
+ - Dynamic? (Dyn) (Olena proto-1.0).
+
+
+==================
+Year 2007 students
+==================
+
+* Christophe Berger
+ - connected filters (Olena proto-1.0, Olena 1.0),
+ - SCOOP 2 (Olena proto-1.0).
+
+* Nicolas Widynski
+ - connected filters (Olena proto-1.0),
+ - inpainting (Olena proto-1.0),
+ - segmentation (watershed transform, watersnake, snakes) (Olena proto-1.0)
+
+
+==================
+Year 2008 students
+==================
+
+* Tristan Croiset
+ - Dynamic (Dyn) (Olena proto-1.0)
+
+* Quentin Hocquet
+ - SCOOL? (Olena 1.0).
+
+* Thomas Moulard
+ - Scool (Olena 1.0)
+
+==================
+Year 2009 students
+==================
+
+* Alexandre Abraham alexandre.abraham(a)lrde.epita.fr
+
+* Nicolas Ballas nicolas.ballas(a)lrde.epita.fr
+
+* Matthieu Garrigues matthieu.garrigues(a)lrde.epita.fr
+
+* Ugo Jardonnet ugo.jardonnet(a)lrde.epita.fr
+
+
+==================
+Year 2010 students
+==================
+
+* Etienne Folio etienne.folio(a)lrde.epita.fr
+
+
+==================
+Year 2011 students
+==================
+
+* Frederic Bour frederic.bour(a)lrde.epita.fr
+* Edwin Carlinet edwin.carlinet(a)lrde.epita.fr
+
diff --git a/ChangeLog b/ChangeLog
index d32d1c1..faa0325 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-05-06 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ * AUTHORS: First draft.
+
2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
* configure.ac: Configure tests/world/*
--
1.6.1.2
1
0
* mln/make/influence_zone_adjacency_graph.hh,
* mln/make/region_adjacency_graph.hh: make use of this new structure.
* mln/util/adjacency_matrix.hh: new structure.
* tests/util/Makefile.am,
* tests/util/adjacency_matrix.cc: associated test.
---
milena/ChangeLog | 12 +
milena/mln/make/influence_zone_adjacency_graph.hh | 17 +-
milena/mln/make/region_adjacency_graph.hh | 15 +-
milena/mln/util/adjacency_matrix.hh | 335 +++++++++++++++++++++
milena/tests/util/Makefile.am | 3 +
milena/tests/util/adjacency_matrix.cc | 76 +++++
6 files changed, 440 insertions(+), 18 deletions(-)
create mode 100644 milena/mln/util/adjacency_matrix.hh
create mode 100644 milena/tests/util/adjacency_matrix.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d68a7e9..ff6c707 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2009-05-06 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add adjacency matrix.
+
+ * mln/make/influence_zone_adjacency_graph.hh,
+ * mln/make/region_adjacency_graph.hh: make use of this new structure.
+
+ * mln/util/adjacency_matrix.hh: new structure.
+
+ * tests/util/Makefile.am,
+ * tests/util/adjacency_matrix.cc: associated test.
+
+2009-05-06 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Small fixes.
* doc/tutorial/tutorial.tex: fix compilation.
diff --git a/milena/mln/make/influence_zone_adjacency_graph.hh b/milena/mln/make/influence_zone_adjacency_graph.hh
index 7113962..6cbaa4c 100644
--- a/milena/mln/make/influence_zone_adjacency_graph.hh
+++ b/milena/mln/make/influence_zone_adjacency_graph.hh
@@ -44,6 +44,8 @@
# include <mln/core/alias/box2d.hh>
# include <mln/extension/adjust_fill.hh>
# include <mln/util/graph.hh>
+# include <mln/util/adjacency_matrix.hh>
+
namespace mln
{
@@ -104,8 +106,7 @@ namespace mln
const I& iz = exact(iz_);
const N& nbh = exact(nbh_);
- mln::image2d<bool> adj(mln::box2d(nlabels.next(), nlabels.next()));
- data::fill(adj, false);
+ util::adjacency_matrix<> adj(nlabels.next());
extension::adjust_fill(iz, nbh, 0u);
typedef mln_value(I) L;
@@ -120,13 +121,7 @@ namespace mln
{
L l2 = iz(n);
if (iz(n) != iz((p)))
- {
- // l2 is adjacent to l1
- if (l2 < l1)
- adj(point2d(l1,l2)) = true;
- else
- adj(point2d(l2,l1)) = true;
- }
+ adj.add(l1, l2);
}
}
}
@@ -134,9 +129,9 @@ namespace mln
// Construct graph.
util::graph g;
g.add_vertices(nlabels.next());
- for (unsigned i = 0; i < geom::nrows(adj); ++i)
+ for (unsigned i = 0; i < nlabels.next(); ++i)
for (unsigned j = 0; j < i; ++j)
- if (adj(point2d(i,j)))
+ if (adj.are_adjacent(i, j))
g.add_edge(i, j);
trace::exiting("make::impl::generic::influence_zone_adjacency_graph");
diff --git a/milena/mln/make/region_adjacency_graph.hh b/milena/mln/make/region_adjacency_graph.hh
index 695174d..b930367 100644
--- a/milena/mln/make/region_adjacency_graph.hh
+++ b/milena/mln/make/region_adjacency_graph.hh
@@ -33,6 +33,8 @@
/// Create a region_adjacency_graph from a watershed image.
///
/// \sa morpho::meyer_wst.
+///
+/// \todo add dispatch.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -40,6 +42,8 @@
# include <mln/core/alias/box2d.hh>
# include <mln/extension/adjust_fill.hh>
# include <mln/util/graph.hh>
+# include <mln/util/adjacency_matrix.hh>
+
namespace mln
{
@@ -100,8 +104,7 @@ namespace mln
const I& wshd = exact(wshd_);
const N& nbh = exact(nbh_);
- mln::image2d<bool> adj(mln::box2d(nbasins.next(), nbasins.next()));
- data::fill(adj, false);
+ util::adjacency_matrix<> adj(nbasins.next());
extension::adjust_fill(wshd, nbh, 0u);
typedef mln_value(I) L;
@@ -129,19 +132,17 @@ namespace mln
}
if (l2 == 0u || l1 == 0u)
continue;
- if (l2 < l1)
- std::swap(l1, l2);
// adjacency l1 l2
- adj(point2d(l2,l1)) = true;
+ adj.add(l2, l1);
}
// Construct graph.
util::graph g;
g.add_vertices(nbasins.next());
- for (unsigned i = 1; i < geom::nrows(adj); ++i)
+ for (unsigned i = 1; i < nbasins.next(); ++i)
for (unsigned j = 1; j < i; ++j)
- if (adj(point2d(i,j)))
+ if (adj.are_adjacent(i, j))
g.add_edge(i, j);
diff --git a/milena/mln/util/adjacency_matrix.hh b/milena/mln/util/adjacency_matrix.hh
new file mode 100644
index 0000000..dfda26f
--- /dev/null
+++ b/milena/mln/util/adjacency_matrix.hh
@@ -0,0 +1,335 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_ADJACENCY_MATRIX_HH
+# define MLN_UTIL_ADJACENCY_MATRIX_HH
+
+/// \file mln/util/adjacency_matrix.hh
+///
+/// A class of adjacency matrix.
+///
+/// FIXME: the underlying data structure is chosen according
+/// to the value type quantification however we may like to make it
+/// depend on the number of elements.
+
+# include <mln/core/image/image2d.hh>
+# include <mln/util/set.hh>
+# include <mln/util/ord_pair.hh>
+# include <mln/trait/value_.hh>
+# include <mln/metal/converts_to.hh>
+# include <mln/debug/println.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ namespace internal
+ {
+
+ // Implementation for low quantification.
+
+ template <typename V, typename Q>
+ struct adjacency_matrix_impl_selector
+ {
+ /// Data structure used to store adjacency information.
+ typedef image2d<bool> adj_t;
+
+ /// Constructor.
+ adjacency_matrix_impl_selector(const V& nelements);
+
+ /// Make \p e1 and \p e2 adjacent.
+ void add(const V& e1, const V& e2);
+
+ /// Remove adjacency between \p e1 and \p e2.
+ void remove(const V& e1, const V& e2);
+
+ /// Clear all adjacencies.
+ void clear();
+
+ /// Check whether \p e1 and \p e2 are adjacent.
+ bool are_adjacent(const V& e1, const V& e2) const;
+
+ /// Print data to std::out.
+ std::ostream& print_data_(std::ostream& ostr) const;
+
+ protected:
+ adj_t adj_;
+ };
+
+
+ // Implementation for high quantification.
+
+ template <typename V>
+ struct adjacency_matrix_impl_selector<V, metal::bool_<false> >
+ {
+ /// Data structure used to store adjacency information.
+ typedef util::set< util::ord_pair<V> > adj_t;
+
+ /// Constructor.
+ adjacency_matrix_impl_selector(const V& nelements);
+
+ /// Make \p e1 and \p e2 adjacent.
+ void add(const V& e1, const V& e2);
+
+ /// Remove adjacency between \p e1 and \p e2.
+ void remove(const V& e1, const V& e2);
+
+ /// Clear all adjacencies.
+ void clear();
+
+ /// Check whether \p e1 and \p e2 are adjacent.
+ bool are_adjacent(const V& e1, const V& e2) const;
+
+ /// Print data to std::out.
+ std::ostream& print_data_(std::ostream& ostr) const;
+
+ protected:
+ adj_t adj_;
+
+# ifndef NDEBUG
+ unsigned nelements_;
+# endif // ! NDEBUG
+ };
+
+
+ } // end of namespace mln::util::internal
+
+
+ /// A class of adjacency matrix.
+ ///
+ /// Support low and high quantification value types.
+ /// In case of low quantification value type, it uses
+ /// an image2d to store adjacency information.
+ /// In case of high quantification value type, it uses
+ /// a util::set to store the adjacency information.
+ ///
+ /// \ingroup modutil
+ //
+ template <typename V = def::coord>
+ class adjacency_matrix
+ : private mlc_converts_to(V,unsigned)::check_t,
+ public internal::adjacency_matrix_impl_selector<V, typename mlc_equal(mln_trait_value_quant(V),trait::value::quant::low)::eval>
+ {
+ typedef internal::adjacency_matrix_impl_selector<V, typename mlc_equal(mln_trait_value_quant(V),trait::value::quant::low)::eval>
+ impl_t;
+
+ typedef typename impl_t::adj_t adj_t;
+
+ public:
+ /// Constructors.
+ /// \@{
+ ///
+ /// Default
+ adjacency_matrix();
+ /// Construct an adjacency matrix with \p nelements elements
+ /// maximum.
+ adjacency_matrix(const V& nelements);
+ ///
+ /// \@}
+
+ /// Hook member used to retrieve the underlying data structure.
+ const adj_t& hook_data_() const;
+ };
+
+
+ // <<
+
+ template <typename V>
+ std::ostream&
+ operator<<(std::ostream& ostr, const adjacency_matrix<V>& adj);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace internal
+ {
+
+ // Low quantification.
+
+ template <typename V, typename Q>
+ adjacency_matrix_impl_selector<V, Q>::adjacency_matrix_impl_selector(const V& nelements)
+ : adj_(nelements, nelements)
+ {
+ clear();
+ }
+
+ template <typename V, typename Q>
+ void
+ adjacency_matrix_impl_selector<V, Q>::add(const V& e1, const V& e2)
+ {
+ mln_precondition(adj_.is_valid());
+ mln_precondition(e1 < adj_.nrows());
+ mln_precondition(e2 < adj_.nrows());
+
+ if (e1 > e2)
+ opt::at(adj_, e2, e1) = true;
+ else
+ opt::at(adj_, e1, e2) = true;
+ }
+
+ template <typename V, typename Q>
+ void
+ adjacency_matrix_impl_selector<V, Q>::remove(const V& e1, const V& e2)
+ {
+ mln_precondition(adj_.is_valid());
+ mln_precondition(e1 < adj_.nrows());
+ mln_precondition(e2 < adj_.nrows());
+
+ if (e1 > e2)
+ opt::at(adj_, e2, e1) = false;
+ else
+ opt::at(adj_, e1, e2) = false;
+ }
+
+ template <typename V, typename Q>
+ void
+ adjacency_matrix_impl_selector<V, Q>::clear()
+ {
+ mln_precondition(adj_.is_valid());
+ data::fill(adj_, false);
+ }
+
+ template <typename V, typename Q>
+ bool
+ adjacency_matrix_impl_selector<V, Q>::are_adjacent(const V& e1,
+ const V& e2) const
+ {
+ mln_precondition(adj_.is_valid());
+ mln_precondition(e1 < adj_.nrows());
+ mln_precondition(e2 < adj_.nrows());
+
+ if (e1 > e2)
+ return opt::at(adj_, e2, e1);
+ return opt::at(adj_, e1, e2);
+ }
+
+ template <typename V, typename Q>
+ std::ostream&
+ adjacency_matrix_impl_selector<V, Q>::print_data_(std::ostream& ostr) const
+ {
+ mln_precondition(adj_.is_valid());
+ debug::println(adj_);
+ return ostr;
+ }
+
+
+
+
+ // High quantification.
+
+ template <typename V>
+ adjacency_matrix_impl_selector<V, metal::bool_<false> >
+ ::adjacency_matrix_impl_selector(const V& nelements)
+ {
+ (void) nelements;
+# ifndef DNDEBUG
+ nelements_ = nelements;
+# endif // ! DNDEBUG
+ }
+
+ template <typename V>
+ void
+ adjacency_matrix_impl_selector<V, metal::bool_<false> >
+ ::add(const V& e1, const V& e2)
+ {
+ mln_precondition(e1 < nelements_);
+ mln_precondition(e2 < nelements_);
+ adj_.insert(make::ord_pair(e1, e2));
+ }
+
+ template <typename V>
+ void
+ adjacency_matrix_impl_selector<V, metal::bool_<false> >
+ ::remove(const V& e1, const V& e2)
+ {
+ mln_precondition(e1 < nelements_);
+ mln_precondition(e2 < nelements_);
+ mln_precondition(adj_.has(make::ord_pair(e1, e2)));
+ adj_.remove(make::ord_pair(e1, e2));
+ }
+
+ template <typename V>
+ void
+ adjacency_matrix_impl_selector<V, metal::bool_<false> >::clear()
+ {
+ adj_.clear();
+ }
+
+ template <typename V>
+ bool
+ adjacency_matrix_impl_selector<V, metal::bool_<false> >
+ ::are_adjacent(const V& e1, const V& e2) const
+ {
+ mln_precondition(e1 < nelements_);
+ mln_precondition(e2 < nelements_);
+ return adj_.has(make::ord_pair(e1, e2));
+ }
+
+ template <typename V>
+ std::ostream&
+ adjacency_matrix_impl_selector<V, metal::bool_<false> >::print_data_(std::ostream& ostr) const
+ {
+ return ostr << adj_;
+ }
+
+ } // end of namespace mln::internal
+
+
+ template <typename V>
+ adjacency_matrix<V>::adjacency_matrix()
+ : impl_t()
+ {
+ }
+
+
+ template <typename V>
+ adjacency_matrix<V>::adjacency_matrix(const V& nelements)
+ : impl_t(nelements)
+ {
+ }
+
+
+ template <typename V>
+ std::ostream&
+ operator<<(std::ostream& ostr, const adjacency_matrix<V>& adj)
+ {
+ return adj.print_data_(ostr);
+ }
+
+
+# endif // ! MLN_UTIL_ADJACENCY_MATRIX_HH
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UTIL_ADJACENCY_MATRIX_HH
diff --git a/milena/tests/util/Makefile.am b/milena/tests/util/Makefile.am
index c1d6c4d..07b6018 100644
--- a/milena/tests/util/Makefile.am
+++ b/milena/tests/util/Makefile.am
@@ -4,6 +4,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
+ adjacency_matrix \
branch_iter \
branch_iter_ind \
eat \
@@ -21,6 +22,8 @@ check_PROGRAMS = \
tree_to_fast \
tree_to_image
+
+adjacency_matrix_SOURCES = adjacency_matrix.cc
branch_iter_SOURCES = branch_iter.cc
branch_iter_ind_SOURCES = branch_iter_ind.cc
eat_SOURCES = eat.cc
diff --git a/milena/tests/util/adjacency_matrix.cc b/milena/tests/util/adjacency_matrix.cc
new file mode 100644
index 0000000..e67f659
--- /dev/null
+++ b/milena/tests/util/adjacency_matrix.cc
@@ -0,0 +1,76 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/util/adjacency_matrix.cc
+///
+/// test of mln::util::adjacency_matrix
+
+#include <mln/util/adjacency_matrix.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+
+int main()
+{
+ using namespace mln;
+
+ // The underlying data structure is a image2d.
+ {
+ util::adjacency_matrix<value::int_u8> adj(5);
+ adj.add(3, 4);
+ adj.add(2, 3);
+ adj.add(1, 2);
+
+ mln_assertion(adj.are_adjacent(2,3));
+ mln_assertion(adj.are_adjacent(4,3));
+ mln_assertion(adj.are_adjacent(2,1));
+ mln_assertion(adj.are_adjacent(1,2));
+ mln_assertion(!adj.are_adjacent(1,4));
+
+ adj.remove(2,3);
+ mln_assertion(!adj.are_adjacent(2,3));
+ mln_assertion(!adj.are_adjacent(2,2));
+ }
+
+ // The underlying data structure is a util::set
+ {
+ util::adjacency_matrix<value::int_u16> adj(5);
+ adj.add(3, 4);
+ adj.add(2, 3);
+ adj.add(1, 2);
+
+ mln_assertion(adj.are_adjacent(2,3));
+ mln_assertion(adj.are_adjacent(4,3));
+ mln_assertion(adj.are_adjacent(2,1));
+ mln_assertion(adj.are_adjacent(1,2));
+ mln_assertion(!adj.are_adjacent(1,4));
+
+ adj.remove(2,3);
+ mln_assertion(!adj.are_adjacent(2,3));
+ mln_assertion(!adj.are_adjacent(2,2));
+ }
+
+}
--
1.5.6.5
1
0