As the time of checking in, I realized this patch might be reverted very
soon, since labeling algorithms actually *do* need neighborhoods to
express a connexity, not windows (which lack the symmetry property).
So, instead of checking in this patch now, I just leave it here (in
olena-patches) so that we can possibly use it later, if needed (but I
doubt so).
ChangeLog:
Convert mln/labelling/ from neighborhoods to windows.
* mln/canvas/labeling.hh: Use windows instead of neighborhoods.
* mln/labeling/blobs.hh,
* mln/labeling/flat_zones.hh,
* mln/labeling/level.hh,
* mln/labeling/foreground.hh,
* mln/labeling/regional_minima.hh,
* mln/labeling/regional_maxima.hh,
* mln/labeling/level.spe.hh,
* mln/labeling/background.hh:
Convert routine calls using neighborhoods to windows.
canvas/labeling.hh | 24 +++++++++++++---------
labeling/background.hh | 18 +++++++----------
labeling/blobs.hh | 46 +++++++++++++++++++
+------------------------
labeling/flat_zones.hh | 40 +++++++++++++++++
+--------------------
labeling/foreground.hh | 18 +++++++----------
labeling/level.hh | 35 ++++++++++++++++++---------------
labeling/level.spe.hh | 42 +++++++++++++++++++
+--------------------
labeling/regional_maxima.hh | 40 +++++++++++++++++
+--------------------
labeling/regional_minima.hh | 40 +++++++++++++++++
+--------------------
9 files changed, 148 insertions(+), 155 deletions(-)
Index: mln/canvas/labeling.hh
--- mln/canvas/labeling.hh (revision 1697)
+++ mln/canvas/labeling.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/image.hh>
# include <mln/level/fill.hh>
-# include <mln/convert/to_window.hh> // FIXME: to_upper_window
+# include <mln/convert/to_upper_window.hh>
namespace mln
@@ -53,9 +53,13 @@
// Functor.
F& f;
+ // Image type.
typedef typename F::I I;
- typedef typename F::N N;
+ // Window type.
+ typedef typename F::W W;
+ // Label type.
typedef typename F::L L;
+ // Point set.
typedef typename F::S S;
// Local type.
@@ -100,7 +104,7 @@
F& f;
typedef typename F::I I;
- typedef typename F::N N;
+ typedef typename F::W W;
typedef typename F::L L;
// Auxiliary data.
@@ -163,16 +167,16 @@
labeling<F>::pass_1()
{
mln_fwd_piter(S) p(f.s);
- mln_niter(N) n(f.nbh, p);
+ mln_qiter(W) q(f.win, p);
for_all(p) if (f.handles(p))
{
make_set(p);
- for_all(n)
- if (f.input.has(n) && deja_vu(n))
- if (f.equiv(n, p))
- do_union(n, p);
+ for_all(q)
+ if (f.input.has(q) && deja_vu(q))
+ if (f.equiv(q, p))
+ do_union(q, p);
else
- f.do_no_union(n, p);
+ f.do_no_union(q, p);
deja_vu(p) = true;
}
}
@@ -272,7 +276,7 @@
mln_bkd_pixter(const I) p(f.input);
typedef window<mln_dpoint(I)> W;
- W win = mln::convert::to_upper_window(f.nbh);
+ W win = mln::convert::to_upper_window(f.win);
mln_qixter(const I, W) n(p, win);
for_all(p) if (f.handles(p))
Index: mln/labeling/blobs.hh
--- mln/labeling/blobs.hh (revision 1697)
+++ mln/labeling/blobs.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/level/fill.hh>
# include <mln/core/p_queue_fast.hh>
@@ -47,16 +47,14 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the binary objects of a binary
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood.
+ * \param[in] win The connexity of the objects.
* \param[out] nlabels The number of labels.
* \return The label image.
*
@@ -65,10 +63,9 @@
* A fast queue is used so that the algorithm is not recursive and
* can handle large binary objects (blobs).
*/
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- blobs(const Image<I>& input, const Neighborhood<N>& nbh,
- unsigned& nlabels);
+ blobs(const Image<I>& input, const Window<W>& win, unsigned&
nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -79,14 +76,14 @@
namespace generic
{
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- blobs_(const I& input, const N& nbh, unsigned& nlabels)
+ blobs_(const I& input, const W& win, unsigned& nlabels)
{
typedef mln_psite(I) P;
P cur;
- mln_niter(N) n(nbh, cur);
+ mln_qiter(W) q(win, cur);
p_queue_fast<P> qu;
// Initialization.
@@ -109,12 +106,12 @@
{
cur = qu.front();
qu.pop();
- for_all(n) if (input.has(n))
- if (input(n) && ! output(n))
+ for_all(q) if (input.has(q))
+ if (input(q) && ! output(q))
{
- mln_invariant(! qu.has(n));
- qu.push(n);
- output(n) = nlabels;
+ mln_invariant(! qu.has(q));
+ qu.push(q);
+ output(q) = nlabels;
}
}
while (! qu.is_empty());
@@ -126,12 +123,12 @@
} // end of namespace mln::labeling::impl::generic
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- blobs_(const I& input, const N& nbh, unsigned& nlabels)
+ blobs_(const I& input, const W& win, unsigned& nlabels)
{
// The only implementation is the generic one.
- return generic::blobs_(input, nbh, nlabels);
+ return generic::blobs_(input, win, nlabels);
}
} // end of namespace mln::labeling::impl
@@ -139,20 +136,19 @@
// Facade.
- template <typename I, typename N>
+ template <typename I, typename W>
inline
mln_ch_value(I, unsigned)
- blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
- unsigned& nlabels)
+ blobs(const Image<I>& input_, const Window<W>& win_,
unsigned&
nlabels)
{
trace::entering("labeling::blobs");
mlc_equal(mln_trait_image_kind(I),
mln::trait::image::kind::binary)::check();
const I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ const W& win = exact(win_);
mln_precondition(input.has_data());
- mln_ch_value(I, unsigned) output = impl::blobs_(input, nbh,
nlabels);
+ mln_ch_value(I, unsigned) output = impl::blobs_(input, win,
nlabels);
trace::exiting("labeling::blobs");
return output;
Index: mln/labeling/flat_zones.hh
--- mln/labeling/flat_zones.hh (revision 1697)
+++ mln/labeling/flat_zones.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/canvas/labeling.hh>
@@ -44,21 +44,19 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the flat zones of an image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] win The connexity of the flat zones.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- flat_zones(const Image<I>& input, const Neighborhood<N>& nbh,
L&
nlabels);
+ flat_zones(const Image<I>& input, const Window<W>& win, L&
nlabels);
@@ -69,7 +67,7 @@
// Flat zone functor for the labeling canvas.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct flat_zones_functor
{
typedef mln_psite(I_) P;
@@ -77,12 +75,12 @@
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef mln_pset(I) S;
const I& input;
- const N& nbh;
+ const W& win;
const S& s;
bool handles(const P&) const { return true; }
@@ -97,9 +95,9 @@
// end of requirements
- flat_zones_functor(const I_& input, const N_& nbh)
+ flat_zones_functor(const I_& input, const W_& win)
: input(input),
- nbh(nbh),
+ win(win),
s(input.domain())
{}
};
@@ -110,14 +108,14 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- flat_zones_(const I& input, const N& nbh, L& nlabels)
+ flat_zones_(const I& input, const W& win, L& nlabels)
{
trace::entering("labeling::impl::generic::flat_zones_");
- typedef flat_zones_functor<I,N,L> F;
- F f(input, nbh);
+ typedef flat_zones_functor<I,W,L> F;
+ F f(input, win);
canvas::labeling<F> run(f);
nlabels = run.nlabels;
@@ -134,19 +132,19 @@
// Facade.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- flat_zones(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ flat_zones(const Image<I>& input_, const Window<W>& win_,
L& nlabels)
{
trace::entering("labeling::flat_zones");
const I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ const W& win = exact(win_);
mln_precondition(input.has_data());
// Calls the only (generic) impl.
mln_ch_value(I, L) output =
- impl::generic::flat_zones_(input, nbh, nlabels);
+ impl::generic::flat_zones_(input, win, nlabels);
trace::exiting("labeling::flat_zones");
return output;
Index: mln/labeling/level.hh
--- mln/labeling/level.hh (revision 1697)
+++ mln/labeling/level.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/canvas/labeling.hh>
# include <mln/level/fill.hh>
@@ -50,6 +50,9 @@
namespace labeling
{
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
+
/* FIXME: The neighborhood shall not be passed as argument, but
bound to the input image. We can also optionnaly provide a
version of this function for regular-grid-based images where
@@ -60,14 +63,14 @@
*
* \param[in] input The input image.
* \param[in] val The level to consider for the labeling.
- * \param[in] nbh The neighborhood.
+ * \param[in] win The connexity of the components.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level(const Image<I>& input, const mln_value(I)& val,
- const Neighborhood<N>& nbh, L& nlabels);
+ const Window<W>& win, L& nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -77,7 +80,7 @@
// Generic functor.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct level_functor
{
typedef mln_psite(I_) P;
@@ -85,12 +88,12 @@
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef mln_pset(I) S;
const I& input;
- const N& nbh;
+ const W& win;
const S& s;
bool handles(const P& p) const { return input(p) == val; }
@@ -106,9 +109,9 @@
const mln_value(I_)& val;
- level_functor(const I_& input, const mln_value(I_)& val, const N_&
nbh)
+ level_functor(const I_& input, const mln_value(I_)& val, const W_&
win)
: input(input),
- nbh(nbh),
+ win(win),
s(input.domain()),
val(val)
{}
@@ -120,15 +123,15 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- level_(const I& input, const mln_value(I)& val, const N& nbh,
+ level_(const I& input, const mln_value(I)& val, const W& win,
L& nlabels)
{
trace::entering("labeling::impl::generic::level_");
- typedef level_functor<I,N,L> F;
- F f(input, val, nbh);
+ typedef level_functor<I,W,L> F;
+ F f(input, val, win);
canvas::labeling<F> run(f);
nlabels = run.nlabels;
@@ -147,17 +150,17 @@
// Facade.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level(const Image<I>& input, const mln_value(I)& val,
- const Neighborhood<N>& nbh, L& nlabels)
+ const Window<W>& win, L& nlabels)
{
trace::entering("labeling::level");
mln_precondition(exact(input).has_data());
mln_ch_value(I, L) output =
impl::level_(mln_trait_image_speed(I)(),
- exact(input), val, exact(nbh), nlabels);
+ exact(input), val, exact(win), nlabels);
trace::exiting("labeling::level");
return output;
Index: mln/labeling/foreground.hh
--- mln/labeling/foreground.hh (revision 1697)
+++ mln/labeling/foreground.hh (working copy)
@@ -43,16 +43,14 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the object part in a binary
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] win The connexity of the foreground.
* \param[out] nlabels The number of labels.
* \return The label image.
*
@@ -63,18 +61,18 @@
*
* \see mln::labeling::level
*/
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- foreground(const Image<I>& input, const Neighborhood<N>& nbh,
+ foreground(const Image<I>& input, const Window<W>& win,
unsigned& nlabels);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N>
+ template <typename I, typename W>
inline
mln_ch_value(I, unsigned)
- foreground(const Image<I>& input, const Neighborhood<N>& nbh,
+ foreground(const Image<I>& input, const Window<W>& win,
unsigned& nlabels)
{
trace::entering("labeling::foreground");
@@ -83,7 +81,7 @@
mln_precondition(exact(input).has_data());
mln_ch_value(I, unsigned) output =
- labeling::level(input, true, nbh, nlabels);
+ labeling::level(input, true, win, nlabels);
trace::exiting("labeling::foreground");
return output;
Index: mln/labeling/regional_minima.hh
--- mln/labeling/regional_minima.hh (revision 1697)
+++ mln/labeling/regional_minima.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/canvas/labeling.hh>
# include <mln/level/fill.hh>
# include <mln/level/sort_points.hh>
@@ -47,23 +47,21 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the regional minima of an
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] win The connexity of the minima.
* \param[out] nlabels The number of labeled regions.
* \return The label image.
*
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_minima(const Image<I>& input, const Neighborhood<N>&
nbh,
+ regional_minima(const Image<I>& input, const Window<W>& win,
L& nlabels);
@@ -74,7 +72,7 @@
// Generic functor.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct regional_minima_functor
{
typedef mln_psite(I_) P;
@@ -82,12 +80,12 @@
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef p_array<P> S;
const I& input;
- const N& nbh;
+ const W& win;
S s;
void init() { level::fill(attr,
true); }
@@ -106,9 +104,9 @@
mln_ch_value(I, bool) attr;
- regional_minima_functor(const I_& input, const N_& nbh)
+ regional_minima_functor(const I_& input, const W_& win)
: input(input),
- nbh(nbh),
+ win(win),
s(level::sort_points_increasing(input)), // FIXME:
//
sort_psites_increasing
attr(input.domain())
@@ -122,15 +120,15 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_minima_(const I& input, const N& nbh,
+ regional_minima_(const I& input, const W& win,
L& nlabels)
{
trace::entering("labeling::impl::generic::regional_minima_");
- typedef impl::regional_minima_functor<I,N,L> F;
- F f(input, nbh);
+ typedef impl::regional_minima_functor<I,W,L> F;
+ F f(input, win);
canvas::labeling<F> run(f);
nlabels = run.nlabels;
@@ -147,19 +145,19 @@
// Facade.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_minima(const Image<I>& input_, const Neighborhood<N>&
nbh_,
+ regional_minima(const Image<I>& input_, const Window<W>& win_,
L& nlabels)
{
trace::entering("labeling::regional_minima");
const I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ const W& win = exact(win_);
mln_precondition(input.has_data());
// Calls the only (generic) impl.
mln_ch_value(I, L) output =
- impl::generic::regional_minima_(input, nbh, nlabels);
+ impl::generic::regional_minima_(input, win, nlabels);
trace::exiting("labeling::regional_minima");
return output;
Index: mln/labeling/regional_maxima.hh
--- mln/labeling/regional_maxima.hh (revision 1697)
+++ mln/labeling/regional_maxima.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/canvas/labeling.hh>
# include <mln/level/fill.hh>
# include <mln/level/sort_points.hh>
@@ -47,23 +47,21 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the regional maxima of an
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] nbh The connexity of the maxima.
* \param[out] nlabels The number of labeled regions.
* \return The label image.
*
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_maxima(const Image<I>& input, const Neighborhood<N>&
nbh,
+ regional_maxima(const Image<I>& input, const Window<W>& win,
L& nlabels);
@@ -75,7 +73,7 @@
// Generic functor.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct regional_maxima_functor
{
typedef mln_psite(I_) P;
@@ -83,12 +81,12 @@
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef p_array<P> S;
const I& input;
- const N& nbh;
+ const W& win;
S s;
void init() { level::fill(attr,
true); }
@@ -107,9 +105,9 @@
mln_ch_value(I, bool) attr;
- regional_maxima_functor(const I_& input, const N_& nbh)
+ regional_maxima_functor(const I_& input, const W_& win)
: input(input),
- nbh(nbh),
+ win(win),
s(level::sort_points_decreasing(input)), // FIXME:
//
sort_psites_decreasing
attr(input.domain())
@@ -123,15 +121,15 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_maxima_(const I& input, const N& nbh,
+ regional_maxima_(const I& input, const W& win,
L& nlabels)
{
trace::entering("labeling::impl::generic::regional_maxima_");
- typedef impl::regional_maxima_functor<I,N,L> F;
- F f(input, nbh);
+ typedef impl::regional_maxima_functor<I,W,L> F;
+ F f(input, win);
canvas::labeling<F> run(f);
nlabels = run.nlabels;
@@ -148,19 +146,19 @@
// Facade.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_maxima(const Image<I>& input_, const Neighborhood<N>&
nbh_,
+ regional_maxima(const Image<I>& input_, const Window<W>& win_,
L& nlabels)
{
trace::entering("labeling::regional_maxima");
const I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ const W& win = exact(win_);
mln_precondition(input.has_data());
// Calls the only (generic) impl.
mln_ch_value(I, L) output =
- impl::generic::regional_maxima_(input, nbh, nlabels);
+ impl::generic::regional_maxima_(input, win, nlabels);
trace::exiting("labeling::regional_maxima");
return output;
Index: mln/labeling/level.spe.hh
--- mln/labeling/level.spe.hh (revision 1697)
+++ mln/labeling/level.spe.hh (working copy)
@@ -59,14 +59,14 @@
*
* \param[in] input The input image.
* \param[in] val The level to consider for the labeling.
- * \param[in] nbh The neighborhood.
+ * \param[in] win The connexity of the components.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level(const Image<I>& input, const mln_value(I)& val,
- const Neighborhood<N>& nbh, L& nlabels);
+ const Window<W>& win, L& nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -79,9 +79,9 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- level_(const I& input, const mln_value(I)& val, const N& nbh,
+ level_(const I& input, const mln_value(I)& val, const W& win,
L& nlabels);
} // end of namespace mln::labeling::impl::generic
@@ -90,18 +90,18 @@
// Fastest functor.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct level_fastest_functor
{
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef mln_pset(I) S;
const I& input;
- const N& nbh;
+ const W& win;
const S& s;
bool handles(unsigned p) const { return input[p] == val; }
@@ -118,9 +118,9 @@
const mln_value(I_)& val;
level_fastest_functor(const I_& input, const mln_value(I_)& val,
- const N_& nbh)
+ const W_& win)
: input(input),
- nbh(nbh),
+ win(win),
s(input.domain()),
val(val)
{}
@@ -129,18 +129,18 @@
// Fastest routine.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- level_fastest_(const I& input, const mln_value(I)& val, const N& nbh,
+ level_fastest_(const I& input, const mln_value(I)& val, const W& win,
L& nlabels)
{
trace::entering("labeling::impl::level_fastest_");
- border::adjust(input, nbh.delta());
+ border::adjust(input, win.delta());
border::fill(input, value::other(val));
- typedef level_fastest_functor<I,N,L> F;
- F f(input, val, nbh);
+ typedef level_fastest_functor<I,W,L> F;
+ F f(input, val, win);
canvas::labeling_fastest<F> run(f);
nlabels = run.nlabels;
@@ -153,22 +153,22 @@
// Disjunction between "fastest" and "not fastest".
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level_(trait::image::speed::any,
- const I& input, const mln_value(I)& val, const N& nbh,
+ const I& input, const mln_value(I)& val, const W& win,
L& nlabels)
{
- return generic::level_(input, val, nbh, nlabels);
+ return generic::level_(input, val, win, nlabels);
}
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level_(trait::image::speed::fastest,
- const I& input, const mln_value(I)& val, const N& nbh,
+ const I& input, const mln_value(I)& val, const W& win,
L& nlabels)
{
- return level_fastest_(input, val, nbh, nlabels);
+ return level_fastest_(input, val, win, nlabels);
}
Index: mln/labeling/background.hh
--- mln/labeling/background.hh (revision 1697)
+++ mln/labeling/background.hh (working copy)
@@ -43,16 +43,14 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the background part in a
* binary image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] win The connexity of the background.
* \param[out] nlabels The number of labels.
* \return The label image.
*
@@ -63,18 +61,18 @@
*
* \see mln::labeling::level
*/
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- background(const Image<I>& input, const Neighborhood<N>& nbh,
+ background(const Image<I>& input, const Window<W>& win,
unsigned& nlabels);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N>
+ template <typename I, typename W>
inline
mln_ch_value(I, unsigned)
- background(const Image<I>& input, const Neighborhood<N>& nbh,
+ background(const Image<I>& input, const Window<W>& win,
unsigned& nlabels)
{
trace::entering("labeling::background");
@@ -83,7 +81,7 @@
mln_precondition(exact(input).has_data());
mln_ch_value(I, unsigned) output =
- labeling::level(input, false, nbh, nlabels);
+ labeling::level(input, false, win, nlabels);
trace::exiting("labeling::background");
return output;