https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update canvas labelingand labeling level.
* mln/accu/compute.hh: Upgrade doc style.
Fix unmeta call with util pix.
* mln/canvas/labeling.hh: Update.
* mln/util/pix.hh: Upgrade doc style.
* mln/labeling/level.hh
(labeling_functor_base): New.
(level_functor, level): Update.
* mln/labeling/level.spe.hh: De-activate code.
accu/compute.hh | 40 +++++++++++-----------
canvas/labeling.hh | 89 +++++++++++++++++++++++++++++---------------------
labeling/level.hh | 69 ++++++++++++++++++++++++--------------
labeling/level.spe.hh | 5 +-
util/pix.hh | 55 ++++++++++++------------------
5 files changed, 142 insertions(+), 116 deletions(-)
Index: mln/accu/compute.hh
--- mln/accu/compute.hh (revision 2913)
+++ mln/accu/compute.hh (working copy)
@@ -48,30 +48,30 @@
{
/// Make an accumulator compute the pixels of the image \p input.
- /*!
- * \param[in] input The input image.
- *
- * This routine runs: \n
- * a.take(make::pix(input, p));
- * on all pixels on the images.
- *
- * \warning This routine does not perform a.init().
- */
+ ///
+ /// \param[in] input The input image.
+ ///
+ /// This routine runs: \n
+ /// a.take(make::pix(input, p));
+ /// on all pixels on the images.
+ ///
+ /// \warning This routine does not perform a.init().
+ ///
template <typename A, typename I>
mln_result(A)
compute(const Accumulator<A>& a, const Image<I>& input);
/// Make an accumulator compute the pixels of the image \p input.
- /*!
- * \param[in] input The input image.
- *
- * This routine runs: \n
- * a.take(make::pix(input, p));
- * on all pixels on the images.
- *
- * \warning This routine does not perform a.init().
- */
+ ///
+ /// \param[in] input The input image.
+ ///
+ /// This routine runs: \n
+ /// a.take(make::pix(input, p));
+ /// on all pixels on the images.
+ ///
+ /// \warning This routine does not perform a.init().
+ ///
template <typename A, typename I>
mln_accu_with(A, util::pix<I>)::result
compute(const Meta_Accumulator<A>& a, const Image<I>& input);
@@ -149,7 +149,9 @@
mln_precondition(exact(input).has_data());
typedef mln_accu_with(A, util::pix<I>) A_;
- A_ a_ = accu::unmeta(exact(a), util::pix<I>());
+ util::pix<I>* pix_; // So we can pass a pixel below (pixel has
+ // no ctor without arg).
+ A_ a_ = accu::unmeta(exact(a), *pix_);
mln_result(A_) output = internal::compute_dispatch(a_, input);
Index: mln/canvas/labeling.hh
--- mln/canvas/labeling.hh (revision 2913)
+++ mln/canvas/labeling.hh (working copy)
@@ -48,10 +48,10 @@
{
// General version.
- template <typename I, typename N, typename F>
- mln_ch_value(I, typename F::L)
+ template <typename I, typename N, typename F, typename L>
+ mln_ch_value(I, L)
labeling(const Image<I>& input, const Neighborhood<N>& nbh,
- F& functor, typename F::L& nlabels);
+ F& functor, L& nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -69,63 +69,75 @@
return parent(x) = find_root(parent, parent(x));
}
- template <typename I, typename N, typename F>
- mln_ch_value(I, typename F::L)
- labeling(const Image<I>& input, const Neighborhood<N>& nbh,
- F& functor, typename F::L& nlabels)
+ template <typename I, typename N, typename F, typename L>
+ mln_ch_value(I, L)
+ labeling(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ F& f, L& nlabels)
{
trace::entering("canvas::labeling");
- typedef typename F::L L;
+ // FIXME: Test?!
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
typedef typename F::S S;
// Local type.
- typedef mln_psite(I) psite;
+ typedef mln_psite(I) P;
// Auxiliary data.
mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, psite) parent;
+ mln_ch_value(I, P) parent;
// Output.
mln_ch_value(I, L) output;
bool status;
- // Initialization. init();
+ // Initialization.
+
{
- initialize(deja_vu, functor.input);
+ initialize(deja_vu, input);
mln::level::fill(deja_vu, false);
- initialize(parent, functor.input);
- initialize(output, functor.input);
+
+ initialize(parent, input);
+
+ initialize(output, input);
mln::level::fill(output, L(literal::zero));
nlabels = 0;
- functor.init(); // Client initialization.
+
+ f.init(); // Client initialization.
}
- // First Pass. pass_1();
+ // First Pass.
+
{
- mln_fwd_piter(S) p(functor.s);
- mln_niter(N) n(functor.nbh, p);
- for_all(p) if (functor.handles(p))
+ mln_fwd_piter(S) p(f.s);
+ mln_niter(N) n(nbh, p);
+ for_all(p) if (f.handles(p))
+ {
+
+ // Make-Set.
{
- // Make the set with p as root. make_set(p).
parent(p) = p;
- functor.init_attr(p);
+ f.init_attr(p);
+ }
for_all(n)
- if (functor.input.domain().has(n) && deja_vu(n))
+ if (input.domain().has(n) && deja_vu(n))
{
- if (functor.equiv(n, p))
+ if (f.equiv(n, p))
{
- // Put p as root. do_union(n, p);
- psite r = find_root(parent, n);
+ // Do-Union.
+ P r = find_root(parent, n);
if (r != p)
{
parent(r) = p;
- functor.merge_attr(r, p);
+ f.merge_attr(r, p);
}
}
else
- functor.do_no_union(n, p);
+ f.do_no_union(n, p);
}
deja_vu(p) = true;
}
@@ -133,12 +145,12 @@
// Second Pass. pass_2();
{
- mln_bkd_piter(S) p(functor.s);
- for_all(p) if (functor.handles(p))
+ mln_bkd_piter(S) p(f.s);
+ for_all(p) if (f.handles(p))
{
if (parent(p) == p) // if p is root
{
- if (functor.labels(p))
+ if (f.labels(p))
{
if (nlabels == mln_max(L))
{
@@ -159,7 +171,15 @@
return output;
}
-# endif // ! MLN_INCLUDE_ONLY
+
+
+
+
+ // -----------------------------------------------------------
+ // Old code below.
+
+
+ /*
// Fastest version.
@@ -200,12 +220,6 @@
};
-# ifndef MLN_INCLUDE_ONLY
-
- /*---------------------------.
- | canvas::labeling_fastest. |
- `---------------------------*/
-
template <typename F>
labeling_fastest<F>::labeling_fastest(F& f)
: f(f)
@@ -308,6 +322,7 @@
}
}
+*/
# endif // ! MLN_INCLUDE_ONLY
Index: mln/util/pix.hh
--- mln/util/pix.hh (revision 2913)
+++ mln/util/pix.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,10 +29,9 @@
#ifndef MLN_UTIL_PIX_HH
# define MLN_UTIL_PIX_HH
-/*! \file mln/util/pix.hh
- *
- * \brief Definition of an instant pix.
- */
+/// \file mln/util/pix.hh
+///
+/// Definition of an instant pix.
# include <mln/core/concept/image.hh>
@@ -39,13 +39,11 @@
namespace mln
{
- /// \brief Select namespace (FIXME doc).
+ /// Select namespace (FIXME doc).
namespace select
{
- /*! \brief Structure p_of.
- *
- */
+ /// Structure p_of.
template <typename P>
struct p_of : P
{
@@ -60,9 +58,9 @@
namespace util
{
- /*! \brief Structure pix.
- *
- */
+ /// Structure pix.
+ ///
+ ///
template <typename I>
struct pix
{
@@ -73,32 +71,25 @@
/// Value associated type.
typedef mln_value(I) value;
- /*! \brief Constructor.
- *
- * \param[in] ima The image.
- * \param[in] p The p_site.
- */
+ /// Constructor.
+ ///
+ /// \param[in] ima The image.
+ /// \param[in] p The p_site.
pix(const Image<I>& ima, const mln_psite(I)& p);
- /*! \brief The getter of the image associate to pix structure.
- *
- * \return The image ima_.
- *
- */
+ /// The getter of the image associate to pix structure.
+ ///
+ /// \return The image ima_.
const I& ima() const;
- /*! \brief The getter of psite associate to pix structure.
- *
- * \return The psite p_.
- *
- */
+ /// The getter of psite associate to pix structure.
+ ///
+ /// \return The psite p_.
const mln_psite(I)& p() const;
- /*! \brief The getter of value associate to pix structure.
- *
- * \return The value of pix.
- *
- */
+ /// The getter of value associate to pix structure.
+ ///
+ /// \return The value of pix.
mln_rvalue(I) v() const;
private:
Index: mln/labeling/level.hh
--- mln/labeling/level.hh (revision 2913)
+++ mln/labeling/level.hh (working copy)
@@ -96,46 +96,63 @@
namespace impl
{
- // Generic functor.
- template <typename I_, typename N_, typename L_>
- struct level_functor
+ struct labeling_functor_base
{
- typedef mln_psite(I_) P;
+ void init() {}
- // requirements from mln::canvas::labeling:
+ template <typename P>
+ bool handles(const P&) const { return true; }
+
+ template <typename L, typename R>
+ bool equiv(const L&, const R&) const { return false; }
+
+ template <typename P>
+ bool labels(const P&) const { return true; }
+
+ template <typename L, typename R>
+ void do_no_union(const L&, const R&) {}
+
+ template <typename P>
+ void init_attr(const P&) {}
+
+ template <typename L, typename R>
+ void merge_attr(const L&, const R&) {}
+ };
- typedef I_ I;
- typedef N_ N;
- typedef L_ L;
- typedef mln_pset(I) S;
+
+ // Generic functor.
+
+ template <typename I>
+ struct level_functor : labeling_functor_base
+ {
+ typedef mln_psite(I) P;
const I& input;
- const N& nbh;
+ const mln_value(I)& val;
+
+ // Requirements from mln::canvas::labeling.
+
+ typedef mln_pset(I) S;
const S& s;
+ void init() {}
bool handles(const P& p) const { return input(p) == val; }
bool equiv(const P& n, const P&) const { return input(n) == val; }
-
- void init() {}
bool labels(const P&) const { return true; }
- void do_no_union(const P&, const P&) {}
- void init_attr(const P&) {}
- void merge_attr(const P&, const P&) {}
-
- // end of requirements
- const mln_value(I_)& val;
+ // end of Requirements.
- level_functor(const I& input, const mln_value(I)& val, const N& nbh)
- : input(input),
- nbh(nbh),
- s(input.domain()),
- val(val)
- {}
+ level_functor(const Image<I>& input_, const mln_value(I)& val)
+ : input(exact(input_)),
+ val(val),
+ s(input.domain())
+ {
+ }
};
+
// Generic implementation.
namespace generic
@@ -151,9 +168,9 @@
internal::level_tests(input, val, nbh, nlabels);
- typedef level_functor<I,N,L> F;
- F f(exact(input), val, exact(nbh));
+ level_functor<I> f(input, val);
mln_ch_value(I, L) output = canvas::labeling(input, nbh, f, nlabels);
+
// FIXME: Handle canvas status.
trace::exiting("labeling::impl::generic::level");
Index: mln/labeling/level.spe.hh
--- mln/labeling/level.spe.hh (revision 2913)
+++ mln/labeling/level.spe.hh (working copy)
@@ -83,7 +83,7 @@
} // end of namespace mln::labeling::impl::generic
-
+ /*
// Fastest functor.
@@ -149,8 +149,9 @@
return run.output;
}
- } // end of namespace mln::labeling::impl
+ */
+ } // end of namespace mln::labeling::impl
# endif // ! MLN_INCLUDE_ONLY