https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Fix conversion problems in linear::gaussian.
* tests/linear/gaussian.cc: Update tests.
* mln/linear/gaussian.hh: Fix conversion issues.
* doc/tutorial/design/include/imagetours.tex: Update documentation.
doc/tutorial/design/include/imagetours.tex | 17 +++-----
mln/linear/gaussian.hh | 61 +++++++++++++++++++++++++----
tests/linear/gaussian.cc | 7 +++
3 files changed, 68 insertions(+), 17 deletions(-)
Index: tests/linear/gaussian.cc
--- tests/linear/gaussian.cc (revision 2840)
+++ tests/linear/gaussian.cc (working copy)
@@ -38,6 +38,7 @@
#include <mln/io/pgm/save.hh>
#include <mln/level/transform.hh>
+#include <mln/level/paste.hh>
#include <mln/math/round.hh>
#include <mln/linear/gaussian.hh>
@@ -57,4 +58,10 @@
image2d<value::int_u8> out = linear::gaussian(lena, 5.1f);
io::pgm::save(out, "out.pgm");
+
+
+ image2d<float> lenaf(lena.domain());
+ level::paste(lena, lenaf);
+
+ image2d<float> outf = linear::gaussian(lenaf, 5.1f);
}
Index: doc/tutorial/design/include/imagetours.tex
--- doc/tutorial/design/include/imagetours.tex (revision 2840)
+++ doc/tutorial/design/include/imagetours.tex (working copy)
@@ -34,16 +34,15 @@
In the Milena library, an image can be seen as an application
$site$ to $value$.
A $site$ is a localized object in space.
-Points in $1D$, $2D$ or $3D$, are the sites objects commonly used in the
+Points $1D$, $2D$ or $3D$ are the sites objects commonly used in the
library.
-However, the $site$ concept allows Milena to deal with complicated image type
-(for instance see the \verb+graph_image+ type).
+%%However, the $site$ concept allows Milena to deal with complicated image type
+%%(for instance see the \verb+graph_image+ type).
-So, an image is composed by a set of localized objects, $sites$, that
-compose the definition domain of the image.
+An image is composed by a set of localized objects ($sites$): the definition domain of the image.
A value is associated to each site of the image. This is the destination domain
of the image.
-To access to a value of an image named $ima$ localized at the point p, we
+To access to a value localized at the site p in an image named $ima$, we
just use the mathematics notation: \verb+ima(p)+.
Obviously, every image types of Milena provide an access $site$ to $value$,
@@ -65,11 +64,11 @@
In this document, we will used the following naming convention for the
image types parameters:
\begin{itemize}
-\item{\verb+T+:} represents an image value type.
-\item{\verb+S+:} represents a type of a $sites$ set.
+\item{\verb+T+:} represents an image $value$ type.
+\item{\verb+S+:} represents a type of a $sites$ $set$ type.
\item{\verb+F+:} is a type of a function $site$ to $value$.
\item{\verb+P+:} represents a $site$ type.
-\item{\verb+I+:} represents an image type.
+\item{\verb+I+:} represents an $image$ type.
\end{itemize}
\subsection{Primary images}
Index: mln/linear/gaussian.hh
--- mln/linear/gaussian.hh (revision 2840)
+++ mln/linear/gaussian.hh (working copy)
@@ -470,7 +470,7 @@
template <class I, class F, class O>
inline
void
- generic_filter_common_(trait::value::nature::scalar,
+ generic_filter_common_(trait::value::nature::floating,
const Image<I>& in,
const F& coef,
float sigma,
@@ -487,15 +487,14 @@
generic_filter_(mln_trait_image_dimension(I)(),
work_img, coef, i);
- // FIXME deal with overflow problem
- // for instance, when we paste a float image into a int_u8 images.
+ // We don't need to convert work_img
level::paste(work_img, out);
}
template <class I, class F, class O>
inline
void
- generic_filter_common_(trait::value::nature::scalar,
+ generic_filter_common_(trait::value::nature::floating,
const Image<I>& in,
const F& coef,
float sigma,
@@ -512,12 +511,60 @@
generic_filter_(mln_trait_image_dimension(I)(),
work_img, coef, dir);
- // FIXME deal with overflow problem
- // for instance, when we paste a float image into a int_u8 images.
+ // We don't need to convert work_img
level::paste(work_img, out);
}
+ template <class I, class F, class O>
+ inline
+ void
+ generic_filter_common_(trait::value::nature::scalar,
+ const Image<I>& in,
+ const F& coef,
+ float sigma,
+ Image<O>& out)
+ {
+ mln_ch_value(O, float) work_img(exact(in).domain());
+ level::paste(in, work_img);
+ extension::adjust_fill(work_img, 4, 0);
+
+ // On tiny sigma, Derich algorithm doesn't work.
+ // It is the same thing that to convolve with a Dirac.
+ if (sigma > 0.006)
+ for (int i = 0; i < I::site::dim; ++i)
+ generic_filter_(mln_trait_image_dimension(I)(),
+ work_img, coef, i);
+
+ // Convert work_img into result type
+ level::paste(level::stretch(mln_value(I)(), work_img), out);
+ }
+
+ template <class I, class F, class O>
+ inline
+ void
+ generic_filter_common_(trait::value::nature::scalar,
+ const Image<I>& in,
+ const F& coef,
+ float sigma,
+ Image<O>& out,
+ int dir)
+ {
+ mln_ch_value(O, float) work_img(exact(in).domain());
+ level::paste(in, work_img);
+ extension::adjust_fill(work_img, 4, 0);
+
+ // On tiny sigma, Derich algorithm doesn't work.
+ // It is the same thing that to convolve with a Dirac.
+ if (sigma > 0.006)
+ generic_filter_(mln_trait_image_dimension(I)(),
+ work_img, coef, dir);
+
+ // Convert work_img into result type
+ level::paste(level::stretch(mln_value(I)(), work_img), out);
+ }
+
+
template <class I, class F, class O>
inline
@@ -565,10 +612,8 @@
} // end of namespace mln::linear::impl
-
// Facade.
-
/*! Apply an approximated gaussian filter of \p sigma on \p input.
* on a specific direction \p dir
* if \p dir = 0, the filter is applied on the first image dimension.
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add accu snake_2d and transform; revamp accu compute.
* tests/accu/snake_2d.cc: New.
* mln/accu/snake_2d.hh: New.
* mln/accu/transform.hh: New.
* mln/core/image/image2d.hh (include): Re-activate make/image2d.
* tests/accu/transform.cc: New.
* tests/accu/compute.cc (FIXME): Fix.
* tests/accu/Makefile.am: Update.
* mln/accu/min.hh: Fix (c) and upgrade doc layout.
* mln/accu/count.hh: Likewise.
(untake): New.
* mln/accu/compute.hh: Revamp w.r.t. convention.
* mln/transform/influence_zone_geodesic.hh: Fix guard.
* mln/transform/distance.hh: Upgrade doc layout.
* mln/transform/distance_geodesic.hh: Fix guard.
* tests/transform/Makefile.am: Update.
* mln/morpho/erosion.hh: Fix layout.
mln/accu/compute.hh | 83 ++++++++++++--
mln/accu/count.hh | 28 ++++
mln/accu/min.hh | 8 -
mln/accu/snake_2d.hh | 130 +++++++++++++++++++----
mln/accu/transform.hh | 175 +++++++++++++++++++++++++++++++
mln/core/image/image2d.hh | 2
mln/morpho/erosion.hh | 10 +
mln/transform/distance.hh | 9 -
mln/transform/distance_geodesic.hh | 2
mln/transform/influence_zone_geodesic.hh | 3
tests/accu/Makefile.am | 4
tests/accu/compute.cc | 26 +---
tests/accu/snake_2d.cc | 52 +++++++++
tests/accu/transform.cc | 62 ++++++++++
tests/transform/Makefile.am | 6 -
15 files changed, 533 insertions(+), 67 deletions(-)
Index: tests/accu/transform.cc
--- tests/accu/transform.cc (revision 0)
+++ tests/accu/transform.cc (revision 0)
@@ -0,0 +1,62 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/transform.cc
+///
+/// Tests on mln::accu::transform.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/accu/transform.hh>
+
+#include <mln/accu/count.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/pw/all.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(4, 5);
+ win::rectangle2d rec(3, 3);
+
+ {
+ image2d<unsigned>
+ out = accu::transform(ima, accu::count<int>(), rec),
+ ref(ima.domain());
+ mln_assertion(out == (pw::cst(rec.size()) | ima.domain()));
+ }
+
+ {
+ image2d<unsigned>
+ out = accu::transform(ima, accu::meta::count(), rec),
+ ref(ima.domain());
+ mln_assertion(out == (pw::cst(rec.size()) | ima.domain()));
+ }
+}
Index: tests/accu/compute.cc
--- tests/accu/compute.cc (revision 2833)
+++ tests/accu/compute.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,31 +26,24 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/accu/compute.cc
- *
- * \brief Tests on mln::accu::compute.
- */
+/// \file tests/accu/compute.cc
+///
+/// Tests on mln::accu::compute.
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
+#include <mln/accu/count.hh>
#include <mln/accu/compute.hh>
-#include <mln/level/compute.hh>
-#include <mln/accu/min.hh>
int main()
{
using namespace mln;
using typename value::int_u8;
- // FIXME : make this test compile
-// int_u8 vs[3][3] = { {9,8,7},
-// {6,5,4},
-// {3,2,1} };
-
-// image2d<int_u8> ima = make::image(vs);
-// int a = accu::compute<accu::min>(ima);
-
-// std::cout << a << std::endl;
+ unsigned n = 3;
+ image2d<int_u8> ima(n, n);
+ unsigned c = accu::compute(accu::meta::count(), ima);
+ mln_assertion(c = n * n);
}
Index: tests/accu/Makefile.am
--- tests/accu/Makefile.am (revision 2833)
+++ tests/accu/Makefile.am (working copy)
@@ -19,6 +19,8 @@
nil \
pair \
rank \
+ snake_2d \
+ transform \
tuple
all_accus_SOURCES = all_accus.cc
@@ -37,6 +39,8 @@
nil_SOURCES = nil.cc
pair_SOURCES = pair.cc
rank_SOURCES = rank.cc
+snake_2d_SOURCES = snake_2d.cc
+transform_SOURCES = transform.cc
tuple_SOURCES = tuple.cc
TESTS = $(check_PROGRAMS)
Index: tests/accu/snake_2d.cc
--- tests/accu/snake_2d.cc (revision 0)
+++ tests/accu/snake_2d.cc (revision 0)
@@ -0,0 +1,52 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/snake_2d.cc
+///
+/// Tests on mln::accu::snake_2d.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/accu/snake_2d.hh>
+#include <mln/accu/count.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/pw/all.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(4, 5);
+ win::rectangle2d rec(3, 3);
+
+ image2d<unsigned>
+ out = accu::snake_2d(accu::meta::count(), ima, rec),
+ ref(ima.domain());
+
+ mln_assertion(out == (pw::cst(rec.size()) | ima.domain()));
+}
Index: tests/transform/Makefile.am
--- tests/transform/Makefile.am (revision 2833)
+++ tests/transform/Makefile.am (working copy)
@@ -3,8 +3,12 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
- distance
+ distance \
+ distance_geodesic \
+ influence_zone_geodesic
distance_SOURCES = distance.cc
+distance_geodesic_SOURCES = distance_geodesic.cc
+influence_zone_geodesic_SOURCES = influence_zone_geodesic.cc
TESTS = $(check_PROGRAMS)
Index: mln/core/image/image2d.hh
--- mln/core/image/image2d.hh (revision 2833)
+++ mln/core/image/image2d.hh (working copy)
@@ -691,7 +691,7 @@
# include <mln/make/image.hh>
-// # include <mln/make/image2d.hh>
+# include <mln/make/image2d.hh>
#endif // ! MLN_CORE_IMAGE_IMAGE2D_HH
Index: mln/accu/snake_2d.hh
--- mln/accu/snake_2d.hh (revision 2832)
+++ mln/accu/snake_2d.hh (working copy)
@@ -1,16 +1,90 @@
-#include <mln/core/alias/neighb2d.hh>
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_SNAKE_2D_HH
+# define MLN_ACCU_SNAKE_2D_HH
+
+/// \file mln/accu/snake_2d.hh
+///
+/// Run an accumulator in a snake-like browsing.
+
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/meta_accumulator.hh>
+#include <mln/core/alias/window2d.hh>
#include <mln/win/diff.hh>
#include <mln/win/shift.hh>
-#include <mln/extension/adjust_fill.hh>
+#include <mln/extension/adjust.hh>
#include <mln/canvas/browsing/snake_generic.hh>
+
+
namespace mln
{
+ namespace accu
+ {
+
+
+ template <typename A, typename I, typename W>
+ mln_ch_value(I, mln_result(A))
+ snake_2d(const Accumulator<A>&, const Image<I>& input, const Window<W>& win);
+
+
+ template <typename A, typename I, typename W>
+ mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
+ snake_2d(const Meta_Accumulator<A>&, const Image<I>& input, const Window<W>& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+
+ template <typename I, typename W>
+ void snake_2d_tests(const Image<I>& input_, const Window<W>& win_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+
+ mln_precondition(input.has_data());
+ mln_precondition(! win.is_empty());
+ // mln_precondition(! win.is_valid());
+
+ (void) input;
+ (void) win;
+ }
+
+
template <typename I, typename W, typename A>
- struct snake2d_functor
+ struct snake_2d_functor
{
- typedef snake2d_functor<I,W, A> self;
+ typedef snake_2d_functor<I,W, A> self;
typedef void (self::*move_fun)();
typedef mln_deduce(I, psite, delta) dpsite;
@@ -44,9 +118,9 @@
std::vector<move_fun> moves;
std::vector<dpsite> dps;
- snake2d_functor(const I& input, const W& win)
- : input(input),
- win(win),
+ snake_2d_functor(const Image<I>& input, const Window<W>& win)
+ : input(exact(input)),
+ win(exact(win)),
accu(),
win_left_fwd(win::shift(win, mln::left) - win),
@@ -155,36 +229,54 @@
};
+
+ } // end of namespace mln::accu::internal
+
+
+
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- snake2d(const Accumulator<A>&, const Image<I>& input, const Window<W>& win)
+ snake_2d(const Accumulator<A>&, const Image<I>& input, const Window<W>& win)
{
- trace::entering("accu::snake2d");
+ trace::entering("accu::snake_2d");
- typedef snake2d_functor<I, W, A> F;
- F f(exact(input), exact(win));
- canvas::browsing::snake_generic(f);
+ internal::snake_2d_tests(input, win);
- trace::exiting("accu::snake2d");
+ extension::adjust(input, win);
+ internal::snake_2d_functor<I, W, A> f(input, win);
+ canvas::browsing::snake_generic(f);
+ trace::exiting("accu::snake_2d");
return f.output;
}
+
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- snake2d(const Meta_Accumulator<A>&, const Image<I>& input, const Window<W>& win)
+ snake_2d(const Meta_Accumulator<A>&, const Image<I>& input, const Window<W>& win)
{
- trace::entering("accu::snake2d");
+ trace::entering("accu::snake_2d");
+
+ internal::snake_2d_tests(input, win);
typedef mln_accu_with(A, mln_value(I)) A_;
- typedef snake2d_functor<I, W, A_> F;
- F f(exact(input), exact(win));
+
+ extension::adjust(input, win);
+ internal::snake_2d_functor<I, W, A_> f(input, win);
canvas::browsing::snake_generic(f);
- trace::exiting("accu::snake2d");
+ trace::exiting("accu::snake_2d");
return f.output;
}
-} // mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_SNAKE_2D_HH
Property changes on: mln/accu/snake_2d.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/accu/transform.hh
--- mln/accu/transform.hh (revision 0)
+++ mln/accu/transform.hh (revision 0)
@@ -0,0 +1,175 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_TRANSFORM_HH
+# define MLN_ACCU_TRANSFORM_HH
+
+/// \file mln/accu/transform.hh
+///
+/// Transform an image by applying locally an accumulator on its
+/// values.
+///
+/// \todo Specialize for fastest images.
+
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/extension/adjust.hh>
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+ template <typename I, typename A, typename W>
+ mln_ch_value(I, mln_result(A))
+ transform(const Image<I>& input,
+ const Accumulator<A>& a,
+ const Window<W>& win);
+
+ template <typename I, typename A, typename W>
+ mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
+ transform(const Image<I>& input,
+ const Meta_Accumulator<A>& a,
+ const Window<W>& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename I, typename A, typename W>
+ mln_ch_value(I, mln_result(A))
+ transform(const Image<I>& input_,
+ const Accumulator<A>& a_,
+ const Window<W>& win_)
+ {
+ trace::entering("accu::impl::generic::transform");
+
+ const I& input = exact(input_);
+ A a = exact(a_);
+ const W& win = exact(win_);
+
+ mln_precondition(input.has_data());
+ // mln_precondition(win.is_valid());
+
+ extension::adjust(input, win);
+
+ mln_ch_value(I, mln_result(A)) output;
+ initialize(output, input);
+
+ mln_piter(I) p(input.domain());
+ mln_qiter(W) q(win, p);
+ for_all(p)
+ {
+ a.init();
+ for_all(q)
+ a.take(input(q));
+ output(p) = a.to_result();
+ }
+
+ trace::exiting("accu::impl::generic::transform");
+ return output;
+ }
+
+ } // end of namespace mln::accu::impl::generic
+
+ } // end of namespace mln::accu::impl
+
+
+ namespace internal
+ {
+
+ template <typename I, typename A, typename W>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_dispatch(const Image<I>& input,
+ const Accumulator<A>& a,
+ const Window<W>& win)
+ {
+ return impl::generic::transform(input, a, win);
+ }
+
+ } // end of namespace mln::accu::internal
+
+
+
+ template <typename I, typename A, typename W>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform(const Image<I>& input,
+ const Accumulator<A>& a,
+ const Window<W>& win)
+ {
+ trace::entering("accu::transform");
+
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(win).is_valid());
+
+ mln_ch_value(I, mln_result(A)) output;
+ output = internal::transform_dispatch(input, a, win);
+
+ trace::exiting("accu::transform");
+ return output;
+ }
+
+ template <typename I, typename A, typename W>
+ mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
+ transform(const Image<I>& input,
+ const Meta_Accumulator<A>&,
+ const Window<W>& win)
+ {
+ trace::entering("accu::transform");
+
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(win).is_valid());
+
+ typedef mln_accu_with(A, mln_value(I)) A_;
+ A_ a;
+ mln_ch_value(I, mln_result(A_)) output;
+ output = internal::transform_dispatch(input, a, win);
+
+ trace::exiting("accu::transform");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_TRANSFORM_HH
Index: mln/accu/min.hh
--- mln/accu/min.hh (revision 2833)
+++ mln/accu/min.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_ACCU_MIN_HH
# define MLN_ACCU_MIN_HH
-/*! \file mln/accu/min.hh
- *
- * \brief Define an accumulator that computes a min.
- */
+/// \file mln/accu/min.hh
+///
+/// Define an accumulator that computes a min.
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
Index: mln/accu/count.hh
--- mln/accu/count.hh (revision 2833)
+++ mln/accu/count.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,11 +30,13 @@
# define MLN_ACCU_COUNT_HH
/// \file mln/accu/count.hh
+///
/// \brief Define an accumulator that counts.
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
+
namespace mln
{
@@ -55,6 +58,9 @@
void take(const argument&);
void take(const count<T>& other);
+ void untake(const argument&);
+ void untake(const count<T>& other);
+
/// Force the value of the counter to \a c.
void set_value(unsigned c);
/// \}
@@ -71,6 +77,7 @@
unsigned count_;
};
+
namespace meta
{
@@ -87,6 +94,7 @@
} // end of namespace mln::accu::meta
+
# ifndef MLN_INCLUDE_ONLY
template <typename T>
@@ -115,6 +123,15 @@
template <typename T>
inline
void
+ count<T>::untake(const argument&)
+ {
+ mln_precondition(count_ > 0);
+ --count_;
+ }
+
+ template <typename T>
+ inline
+ void
count<T>::take(const count<T>& other)
{
count_ += other.count_;
@@ -122,6 +139,15 @@
template <typename T>
inline
+ void
+ count<T>::untake(const count<T>& other)
+ {
+ mln_precondition(other.count_ <= count_);
+ count_ -= other.count_;
+ }
+
+ template <typename T>
+ inline
unsigned
count<T>::to_result() const
{
Index: mln/accu/compute.hh
--- mln/accu/compute.hh (revision 2833)
+++ mln/accu/compute.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,15 +29,15 @@
#ifndef MLN_ACCU_COMPUTE_HH
# define MLN_ACCU_COMPUTE_HH
-/*! \file mln/accu/compute.hh
- *
- * \brief Define an accumulator that computes image pixels.
- */
+/// \file mln/accu/compute.hh
+///
+/// Compute an accumulator on image pixels, i.e., couples (site,
+/// value).
+///
+/// \todo Specialize for fastest images.
# include <mln/core/concept/meta_accumulator.hh>
-# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
-# include <mln/metal/is_a.hh>
# include <mln/util/pix.hh>
@@ -58,7 +59,7 @@
*/
template <typename A, typename I>
mln_result(A)
- compute(const Image<I>& input);
+ compute(const Accumulator<A>& a, const Image<I>& input);
/*! \brief Make an accumulator compute the pixels of the image \p input.
@@ -73,34 +74,86 @@
*/
template <typename A, typename I>
mln_accu_with(A, util::pix<I>)::result
- compute(const Image<I>& input);
+ compute(const Meta_Accumulator<A>& a, const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
template <typename A, typename I>
- inline
mln_result(A)
- compute(const Image<I>& input_)
+ compute(const Accumulator<A>&, const Image<I>& input_)
{
- mlc_is_a(A, Accumulator)::check();
+ trace::entering("accu::impl::generic::compute");
+
const I& input = exact(input_);
+ mln_precondition(input.has_data());
+
A a;
mln_piter(I) p(input.domain());
for_all(p)
a.take(make::pix(input, p));
+
+ trace::exiting("accu::impl::generic::compute");
return a.to_result();
}
+ } // end of namespace mln::accu::impl::generic
+
+ } // end of namespace mln::accu::impl
+
+
+ namespace internal
+ {
+
+ template <typename A, typename I>
+ inline
+ mln_result(A)
+ compute_dispatch(const Accumulator<A>& a, const Image<I>& input)
+ {
+ return impl::generic::compute(a, input);
+ }
+
+ } // end of namespace mln::accu::internal
+
+
+
+ template <typename A, typename I>
+ inline
+ mln_result(A)
+ compute(const Accumulator<A>& a, const Image<I>& input)
+ {
+ trace::entering("accu::compute");
+
+ mln_precondition(exact(input).has_data());
+ mln_result(A) output = internal::compute_dispatch(a, input);
+
+ trace::exiting("accu::compute");
+ return output;
+ }
+
template <typename A, typename I>
inline
mln_accu_with(A, util::pix<I>)::result
- compute(const Image<I>& input)
+ compute(const Meta_Accumulator<A>&, const Image<I>& input)
{
- mlc_is_a(A, Meta_Accumulator)::check();
+ trace::entering("accu::compute");
+
+ mln_precondition(exact(input).has_data());
+
typedef mln_accu_with(A, util::pix<I>) A_;
- return compute<A_>(input);
+ A_ a;
+ mln_result(A_) output = internal::compute_dispatch(a, input);
+
+ trace::exiting("accu::compute");
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/transform/influence_zone_geodesic.hh
--- mln/transform/influence_zone_geodesic.hh (revision 2833)
+++ mln/transform/influence_zone_geodesic.hh (working copy)
@@ -50,7 +50,6 @@
# ifndef MLN_INCLUDE_ONLY
-
namespace internal
{
@@ -107,4 +106,4 @@
} // end of namespace mln
-#endif // ! MLN_TRANSFORM_DISTANCE_HH
+#endif // ! MLN_TRANSFORM_INFLUENCE_ZONE_GEODESIC_HH
Index: mln/transform/distance.hh
--- mln/transform/distance.hh (revision 2833)
+++ mln/transform/distance.hh (working copy)
@@ -28,10 +28,11 @@
#ifndef MLN_TRANSFORM_DISTANCE_HH
# define MLN_TRANSFORM_DISTANCE_HH
-/*! \file mln/transform/distance.hh
- *
- * \brief Discrete distance transform.
- */
+/// \file mln/transform/distance.hh
+///
+/// Discrete distance transform.
+///
+/// \todo Make a canvas out of it.
# include <vector>
# include <mln/core/concept/image.hh>
Index: mln/transform/distance_geodesic.hh
--- mln/transform/distance_geodesic.hh (revision 2833)
+++ mln/transform/distance_geodesic.hh (working copy)
@@ -104,4 +104,4 @@
} // end of namespace mln
-#endif // ! MLN_TRANSFORM_DISTANCE_HH
+#endif // ! MLN_TRANSFORM_DISTANCE_GEODESIC_HH
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 2833)
+++ mln/morpho/erosion.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,6 +30,7 @@
# define MLN_MORPHO_EROSION_HH
/// \file mln/morpho/erosion.hh
+///
/// \brief Morphological erosion.
# include <mln/morpho/includes.hh>
@@ -63,11 +65,13 @@
{
const I& input = exact(input_);
const W& win = exact(win_);
+
+ mln_precondition(input.has_data());
+ mln_precondition(! win.is_empty());
+ // mln_precondition(win.is_valid());
+
(void) input;
(void) win;
-
- mln_precondition(exact(input).has_data());
- mln_precondition(! exact(win).is_empty());
}
} // end of mln::morpho::internal