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)
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)
* 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
* 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