
https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Start to mark out and clean up bad usages of neighborhoods. * mln/trait/neighborhood.hh: New. Traits for neighborhoods. * mln/core/macros.hh (mln_neighb, mln_neighb_): New macros. * mln/convert/to_window.hh, * mln/geom/seeds2tiling_roundness.hh, * mln/labeling/background.hh, * mln/labeling/blobs.hh, * mln/labeling/flat_zones.hh, * mln/labeling/foreground.hh, * mln/labeling/level.hh, * mln/labeling/level.spe.hh, * mln/labeling/regional_maxima.hh, * mln/labeling/regional_minima.hh, * mln/make/voronoi.hh, * mln/morpho/Rd.hh, * mln/morpho/opening_area.hh, * mln/morpho/opening_attribute.hh: Add a few remarks and FIXMEs. Fix some typos. * mln/morpho/includes.hh: Include mln/convert/to_window.hh. * mln/morpho/dilation.hh: Add more documentation. Wrap long lines. (dilation(const Image<I>& input)) (dilation(const Image<I>&, Image<O>&)) (impl::dilation_wrt_nbh(const Image<I>&, const Neighborhood<N>&, Image<O>&)): New functions. (dilation(const Image<I>&, const Window<W>&, Image<O>&)): Add tracing guards. * tests/morpho/dilation.cc: Re-enable more test cases. Use a smaller octagon structuring element to speed up the test. mln/convert/to_window.hh | 11 + mln/core/macros.hh | 10 + mln/geom/seeds2tiling_roundness.hh | 26 ++-- mln/labeling/background.hh | 13 +- mln/labeling/blobs.hh | 17 ++ mln/labeling/flat_zones.hh | 16 +- mln/labeling/foreground.hh | 13 +- mln/labeling/level.hh | 19 ++- mln/labeling/level.spe.hh | 14 +- mln/labeling/regional_maxima.hh | 22 ++- mln/labeling/regional_minima.hh | 23 ++- mln/make/voronoi.hh | 7 + mln/morpho/Rd.hh | 8 + mln/morpho/dilation.hh | 213 +++++++++++++++++++++++++++++++------ mln/morpho/includes.hh | 1 mln/morpho/opening_area.hh | 18 +-- mln/morpho/opening_attribute.hh | 17 +- mln/trait/neighborhood.hh | 110 +++++++++++++++++++ tests/morpho/dilation.cc | 24 ++-- 19 files changed, 479 insertions(+), 103 deletions(-) Index: tests/morpho/dilation.cc --- tests/morpho/dilation.cc (revision 1679) +++ tests/morpho/dilation.cc (working copy) @@ -59,25 +59,35 @@ using namespace mln; using value::int_u8; - win::rectangle2d rec(21, 21); border::thickness = 66; + // FIXME: Maybe we should split all these tests cases into severals + // files. Sure it's a pain to create, but we want to be able to + // choose the granularity of the executed test suite (fast, + // comprehensive, etc.). + image2d<int_u8> lena; io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); -// { -// image2d<int_u8> out(lena.domain()); -// morpho::dilation(lena, rec, out); -// io::pgm::save(out, "out1.pgm"); -// } + { + // FIXME: This struct. elt. is far too big for a routinely run + // test; either use a smaller one or qualify this test as + // ``long''. + win::rectangle2d rec(21, 21); + image2d<int_u8> out(lena.domain()); + morpho::dilation(lena, rec, out); + io::pgm::save(out, "out1.pgm"); + } { - win::octagon2d oct(31); + win::octagon2d oct(6); image2d<int_u8> out(lena.domain()); morpho::dilation(lena, oct, out); io::pgm::save(out, "out2.pgm"); } + // FIXME: Add tests using neighborhoods, too. + // { // p_array<point2d> vec = convert::to_p_array(rec, point2d::zero); // window2d win = convert::to_window(vec); Index: mln/trait/neighborhood.hh --- mln/trait/neighborhood.hh (revision 0) +++ mln/trait/neighborhood.hh (revision 0) @@ -0,0 +1,110 @@ +// 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_TRAIT_NEIGHBORHOOD_HH +# define MLN_TRAIT_NEIGHBORHOOD_HH + +/// \file mln/trait/neighborhood.hh +/// \brief Some base trait types for neighborhood types. + +# include <string> + + +/// Shortcuts. +/// \{ +# define mln_trait_neighborhood_kind(N) \ + typename mln::trait::neighborhood< N >::nature +# define mln_trait_neighborhood_kind_(N) \ + mln::trait::neighborhood< N >::nature +/// \} + + +namespace mln +{ + + namespace trait + { + + struct undefined_neighborhood + { + typedef undef kind; + }; + + + struct default_neighborhood : undefined_neighborhood + { + typedef trait::neighborhood::kind::generic kind; + }; + + + template <typename V> + struct neighborhood : default_neighborhood + { + }; + + + /*----------------. + | Traits values. | + `----------------*/ + + // FIXME: Might be moved to another file, as it's the case for + // images and values. + + /// Traits related to neighborhoods. + namespace neighborhood + { + + /// Kind of neighborhood. + struct kind + { + /// The base class of the hierarchy of neighborhood traits. + struct any + { + std::string name() const { return "kind::any"; } + }; + + /// A generic neighborhood, with no particular feature. + struct generic : any + { + std::string name() const { return "kind::generic"; } + }; + + /// A neighborhood on a regular grid, i.e. + /// holding/convertible to a window. + struct regular : any + { + std::string name() const { return "kind::regular"; } + }; + }; + } + + + } // end of namespace mln::trait + +} // end of namespace mln + +#endif // ! MLN_TRAIT_NEIGHBORHOOD_HH Index: mln/core/macros.hh --- mln/core/macros.hh (revision 1679) +++ mln/core/macros.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -128,12 +128,18 @@ // m - /// Shortcut to access the mesh type associated to T. # define mln_mesh(T) typename T::mesh # define mln_mesh_(T) T::mesh +// n + +/// Shortcut to access the neighborhood type associated to T. +# define mln_neighb(T) typename T::neighb +# define mln_neighb_(T) T::neighb + + // p /// Shortcut to access the type of point iterator (piter) associated to T. Index: mln/make/voronoi.hh --- mln/make/voronoi.hh (revision 1679) +++ mln/make/voronoi.hh (working copy) @@ -47,8 +47,13 @@ namespace make { + /* 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. */ + /*! - * \brief Apply Voronoi algorithm on \p ima_ with the original + * \brief Apply the Voronoi algorithm on \p ima_ with the original * image \p orig_ for node computing with neighborhood \p nbh. * * \param[in] ima_ The labeling image. Index: mln/convert/to_window.hh --- mln/convert/to_window.hh (revision 1679) +++ mln/convert/to_window.hh (working copy) @@ -72,6 +72,15 @@ # ifndef MLN_INCLUDE_ONLY + /* FIXME: According to milena/core/concepts/README, windows are + not necessarily based on a set of dpoints. So the current + algorithm won't work on non dpoint-set-based windows. In the + general case (of windows not being a set of dpoints), the + window resulting from this conversion (as well as the iterators + based on such windows!) should depend on the initial + neighborhood (i.e., delegate the actual iteration to the + aggregated neighborhood). When this is fixed, document this in + depth in milena/core/concepts/README. */ template <typename N> inline window<mln_dpoint(N)> to_window(const Neighborhood<N>& nbh_) @@ -86,6 +95,7 @@ return win; } + // FIXME: Same remark as for to_window(const Neighborhood<N>&) template <typename N> inline window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh_) @@ -101,6 +111,7 @@ return win; } + // FIXME: Same remark as for to_window(const Neighborhood<N>&) template <typename I> inline window<mln_dpoint(I)> to_window(const Image<I>& ima_) Index: mln/geom/seeds2tiling_roundness.hh --- mln/geom/seeds2tiling_roundness.hh (revision 1679) +++ mln/geom/seeds2tiling_roundness.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -50,13 +50,19 @@ namespace geom { + /* 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. */ /*! Take a labeled image \p ima_ with seeds and extend them until - * creating tiles nore roundness that the primary version. + * creating tiles rounder than the primary version. * * \param[in,out] ima_ The labeled image with seed. - * \param[in] win_w The weight window using by geom::chamfer to compute distance. - * \param[in] max Unsigned using by geom::chamfer to compute distance. + * \param[in] win_w The weight window using by geom::chamfer to + * compute distance. + * \param[in] max Unsigned using by geom::chamfer to compute + * the distance. * \param[in] nbh The neighborhood to use on this algorithm. * * \pre \p ima_ has to be initialized. @@ -64,8 +70,8 @@ */ template <typename I, typename N> I - seeds2tiling_roundness (Image<I>& ima_, const w_window2d_int& w_win, unsigned max, - const Neighborhood<N>& nbh); + seeds2tiling_roundness (Image<I>& ima_, const w_window2d_int& w_win, + unsigned max, const Neighborhood<N>& nbh); @@ -77,8 +83,8 @@ template <typename I, typename N> inline I - seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, unsigned max, - const Neighborhood<N>& nbh) + seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, + unsigned max, const Neighborhood<N>& nbh) { trace::entering("geom::impl::seed2tiling_roundness"); @@ -123,8 +129,8 @@ template <typename I, typename N> inline I - seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, unsigned max, - const Neighborhood<N>& nbh) + seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, + unsigned max, const Neighborhood<N>& nbh) { trace::entering("geom::seed2tiling_roundness"); Index: mln/morpho/opening_attribute.hh --- mln/morpho/opening_attribute.hh (revision 1679) +++ mln/morpho/opening_attribute.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -45,12 +45,16 @@ namespace morpho { - /*! Morphological area opening. - */ + /* 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. */ + + /// Morphological attribute opening. template <typename A, typename I, typename N, typename O> - void opening_attribute(const Image<I>& input, const Neighborhood<N>& nbh, mln_result(A) lambda, - Image<O>& output); + void opening_attribute(const Image<I>& input, const Neighborhood<N>& nbh, + mln_result(A) lambda, Image<O>& output); # ifndef MLN_INCLUDE_ONLY @@ -101,7 +105,8 @@ // end of requirements inline - opening_attribute_t(const I_& input, const N_& nbh, mln_result(A) lambda, O_& output) + opening_attribute_t(const I_& input, const N_& nbh, + mln_result(A) lambda, O_& output) : input(input), nbh(nbh), lambda(lambda), output(output), s(level::sort_points_decreasing(input)) { Index: mln/morpho/opening_area.hh --- mln/morpho/opening_area.hh (revision 1679) +++ mln/morpho/opening_area.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -43,19 +43,23 @@ namespace morpho { - /*! Morphological area opening. - */ + /* 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. */ + + /// Morphological area opening. template <typename I, typename N, typename O> - void opening_area(const Image<I>& input, const Neighborhood<N>& nbh, std::size_t lambda, - Image<O>& output); + void opening_area(const Image<I>& input, const Neighborhood<N>& nbh, + std::size_t lambda, Image<O>& output); # ifndef MLN_INCLUDE_ONLY template <typename I, typename N, typename O> inline - void opening_area(const Image<I>& input, const Neighborhood<N>& nbh, std::size_t lambda, - Image<O>& output) + void opening_area(const Image<I>& input, const Neighborhood<N>& nbh, + std::size_t lambda, Image<O>& output) { mln_precondition(exact(output).domain() == exact(input).domain()); typedef util::pix<I> pix_t; Index: mln/morpho/dilation.hh --- mln/morpho/dilation.hh (revision 1679) +++ mln/morpho/dilation.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 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 @@ -43,16 +43,47 @@ namespace morpho { - /*! Morphological dilation. - * - * \todo Overload dilation_wrt_win for hline and vline and for fast - * images. - */ + /// Morphological dilation using the neighborhood bound to an image. + /// + /// \{ + + /// Perform a morphological dilation of \a input using its + /// neighborhood and store the result into \a output. + /// + /// \pre \a input must be an image with a neighborhood. + /* FIXME: Do we want to keep this version? */ + template <typename I, typename O> + void + dilation(const Image<I>& input, Image<O>& output); + + /// Perform a morphological dilation of \a input using its + /// neighborhood and return the result. + /// + /// \pre \a input must be an image with a neighborhood. + template <typename I> + mln_concrete(I) + dilation(const Image<I>& input); + /// \} + + /// Morphological dilation using windows. + /// + /// \todo Overload dilation_wrt_win for hline and vline and for fast + /// images. + /// + /// \{ + /// Perform a morphological dilation of \a input using \a win and + /// store the result into \a output. + /* FIXME: Do we want to keep this version? */ template <typename I, typename W, typename O> - void dilation(const Image<I>& input, const Window<W>& win, Image<O>& output); + void + dilation(const Image<I>& input, const Window<W>& win, Image<O>& output); + /// Perform a morphological dilation of \a input using \a win and + /// return the result. template <typename I, typename W> - mln_concrete(I) dilation(const Image<I>& input, const Window<W>& win); + mln_concrete(I) + dilation(const Image<I>& input, const Window<W>& win); + /// \} @@ -61,11 +92,42 @@ namespace impl { + /*---------------------. + | Neighborhood-based. | + `---------------------*/ + + /* FIXME: We might want to move this function into the body of + the facade (see at the bottom of the file. */ + // Sole case. Convert the neighborhood into a window, and + // delegate to the window-based implementation. + template <typename I, typename N, typename O> + inline + void dilation_wrt_nbh(const Image<I>& input, + const Neighborhood<N>& nbh, + Image<O>& output) + { + /* FIXME: The following comment applies to every algorithm + having a neighborhood and a window flavor: move it + elsewhere. + + We solely depend on the neighborhood-to-window conversion + here. This means the conversion should be smart enough to + produce a working window, even in the case of a non + dpoint-set-based neighborhood. */ + dilation_wrt_win(input, to_window(nbh), output); + } + + + /*---------------. + | Window-based. | + `---------------*/ + // On function. template <typename I, typename W, typename O> inline - void dilation_on_function(const Image<I>& input_, const Window<W>& win_, Image<O>& output_) + void dilation_on_function(const Image<I>& input_, const Window<W>& win_, + Image<O>& output_) { const I& input = exact(input_); const W& win = exact(win_); @@ -88,7 +150,8 @@ template <typename I, typename W, typename O> inline - void dilation_on_set(const Image<I>& input_, const Window<W>& win_, Image<O>& output_) + void dilation_on_set(const Image<I>& input_, const Window<W>& win_, + Image<O>& output_) { const I& input = exact(input_); const W& win = exact(win_); @@ -108,51 +171,83 @@ } } + // FIXME: Seems to be duplicate code! + +// /// Stage 1: dispatch w.r.t. the window type. +// /// \{ + +// /// Default case. +// template <typename I, typename W, typename O> +// inline +// void dilation_wrt_win(const Image<I>& input, const Window<W>& win, +// Image<O>& output) +// { +// // Perform stage 2: dispatch w.r.t. the value kind. +// dilation_wrt_value(mln_trait_image_kind(I)(), exact(input), +// exact(win), output); +// } // ... - // FIXME: Stage 3: dispatch w.r.t. fast property + // ------------- // + // Dispatchers. // + // ------------- // + + // FIXME: Stage 3: dispatch w.r.t. speed property. + // ... - // Stage 2: dispatch w.r.t. the value kind. + /// Stage 2: dispatch w.r.t. the value kind. + /// \{ + /// Binary => morphology on sets. template <typename I, typename W, typename O> inline - void dilation_wrt_value(trait::image::kind::logic, // binary => morphology on sets - const Image<I>& input, const Window<W>& win, Image<O>& output) + void dilation_wrt_value(trait::image::kind::logic, + const Image<I>& input, const Window<W>& win, + Image<O>& output) { return impl::dilation_on_set(exact(input), exact(win), output); } + /// Otherwise => morphology on functions. template <typename I, typename W, typename O> inline - void dilation_wrt_value(trait::image::kind::any, // otherwise => morphology on functions - const Image<I>& input, const Window<W>& win, Image<O>& output) + void dilation_wrt_value(trait::image::kind::any, + const Image<I>& input, const Window<W>& win, + Image<O>& output) { return impl::dilation_on_function(exact(input), exact(win), output); } + // End of stage 2. + /// \} - // Stage 1: dispatch w.r.t. the window type. - // | - // V + + /// Stage 1: dispatch w.r.t. the window type. + /// \{ + + /// Default case. template <typename I, typename W, typename O> inline - void dilation_wrt_win(const Image<I>& input, const Window<W>& win, Image<O>& output) + void dilation_wrt_win(const Image<I>& input, const Window<W>& win, + Image<O>& output) { - dilation_wrt_value(mln_trait_image_kind(I)(), exact(input), exact(win), output); - // | - // --> call stage 2: dispatch w.r.t. the value kind + // Perform stage 2: dispatch w.r.t. the value kind. + dilation_wrt_value(mln_trait_image_kind(I)(), exact(input), + exact(win), output); } # ifdef MLN_CORE_WIN_RECTANGLE2D_HH + /// Rectangle window. template <typename I, typename O> inline - void dilation_wrt_win(const Image<I>& input, const win::rectangle2d& win, Image<O>& output) + void dilation_wrt_win(const Image<I>& input, const win::rectangle2d& win, + Image<O>& output) { O temp(exact(output).domain()); morpho::dilation(input, win::hline2d(win.width()), temp); @@ -166,8 +261,10 @@ # ifdef MLN_CORE_WIN_DIAG2D_HH # ifdef MLN_CORE_WIN_BACKDIAG2D_HH + /// Octagon window. template <typename I, typename O> - void dilation_wrt_win(const Image<I>& input, const win::octagon2d& win, Image<O>& output) + void dilation_wrt_win(const Image<I>& input, const win::octagon2d& win, + Image<O>& output) { const unsigned len = win.length() / 3 + 1; @@ -183,18 +280,72 @@ # endif // MLN_CORE_WIN_DIAG2D_HH # endif // MLN_CORE_WIN_OCTAGON2D_HH - // ^ - // | - // end of stage1 (dispatch w.r.t. the window type) + // End of stage 1. + + /// \} } // end of namespace mln::morpho::impl - // Facade. + /*----------. + | Facades. | + `----------*/ + + // ------------------------------------------------ // + // Facades for neighborhood-based implementations. // + // ------------------------------------------------ // + + template <typename I, typename O> + void + dilation(const Image<I>& input, Image<O>& output) + { + trace::entering("morpho::dilation"); + + mln_precondition(exact(output).domain() == exact(input).domain()); + + // Ensure the image has a `neighb' typedef. + typedef mln_neighb(I) neighb; + + // FIXME: Encapsulate this in a class + a macro. + // FIXME: Do we have better concept checking tools? + { + // Ensure the image has a `neighb' method. + neighb (I::*m)() const = &I::neighb; + m = 0; + + // FIXME: Do we need to check for more? + } + + impl::dilation_wrt_nbh(input, output); + + trace::exiting("morpho::dilation"); + } + + template <typename I> + mln_concrete(I) + dilation(const Image<I>& input) + { + trace::entering("morpho::dilation"); + + mln_concrete(I) output; + initialize(output, input); + dilation(input, output); + + trace::exiting("morpho::dilation"); + return output; + } + + + // ------------------------------------------ // + // Facades for window-based implementations. // + // ------------------------------------------ // template <typename I, typename W, typename O> - void dilation(const Image<I>& input, const Window<W>& win, Image<O>& output) + void + dilation(const Image<I>& input, const Window<W>& win, Image<O>& output) { + trace::entering("morpho::dilation"); + mln_precondition(exact(output).domain() == exact(input).domain()); mln_precondition(! exact(win).is_empty()); @@ -202,6 +353,8 @@ if (exact(win).is_centered()) mln_postcondition(output >= input); + + trace::exiting("morpho::dilation"); } template <typename I, typename W> Index: mln/morpho/Rd.hh --- mln/morpho/Rd.hh (revision 1679) +++ mln/morpho/Rd.hh (working copy) @@ -28,6 +28,9 @@ #ifndef MLN_MORPHO_RD_HH # define MLN_MORPHO_RD_HH +// FIXME: This file, as well its functions and classes, shall not +// contain capital letters. + /*! * \file mln/morpho/Rd.hh * @@ -52,6 +55,11 @@ namespace morpho { + /* 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. */ + template <typename I, typename N> I Rd(const Image<I>& f, const Image<I>& g, const Neighborhood<N>& nbh); Index: mln/morpho/includes.hh --- mln/morpho/includes.hh (revision 1679) +++ mln/morpho/includes.hh (working copy) @@ -65,5 +65,6 @@ # include <mln/morpho/minus.hh> # include <mln/morpho/plus.hh> +# include <mln/convert/to_window.hh> #endif // ! MLN_MORPHO_INCLUDES_HH Index: mln/labeling/blobs.hh --- mln/labeling/blobs.hh (revision 1679) +++ mln/labeling/blobs.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -47,6 +47,11 @@ 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. */ + /*! Connected component labeling of the binary objects of a binary * image. * @@ -62,8 +67,8 @@ */ template <typename I, typename N> mln_ch_value(I, unsigned) - blobs(const Image<I>& input, const Neighborhood<N>& nbh, unsigned& nlabels); - + blobs(const Image<I>& input, const Neighborhood<N>& nbh, + unsigned& nlabels); # ifndef MLN_INCLUDE_ONLY @@ -137,10 +142,12 @@ template <typename I, typename N> inline mln_ch_value(I, unsigned) - blobs(const Image<I>& input_, const Neighborhood<N>& nbh_, unsigned& nlabels) + blobs(const Image<I>& input_, const Neighborhood<N>& nbh_, + unsigned& nlabels) { trace::entering("labeling::blobs"); - mlc_equal(mln_trait_image_kind(I), mln::trait::image::kind::binary)::check(); + mlc_equal(mln_trait_image_kind(I), + mln::trait::image::kind::binary)::check(); const I& input = exact(input_); const N& nbh = exact(nbh_); mln_precondition(input.has_data()); Index: mln/labeling/flat_zones.hh --- mln/labeling/flat_zones.hh (revision 1679) +++ mln/labeling/flat_zones.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -44,6 +44,11 @@ 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. */ + /*! Connected component labeling of the flat zones of an image. * * \param[in] input The input image. @@ -53,8 +58,7 @@ */ template <typename I, typename N, 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 Neighborhood<N>& nbh, L& nlabels); @@ -82,7 +86,8 @@ const S& s; bool handles(const P&) const { return true; } - bool equiv(const P& n, const P& p) const { return input(n) == input(p); } + bool equiv(const P& n, const P& p) const { return input(n) == + input(p); } void init() {} bool labels(const P&) const { return true; } @@ -140,7 +145,8 @@ mln_precondition(input.has_data()); // Calls the only (generic) impl. - mln_ch_value(I, L) output = impl::generic::flat_zones_(input, nbh, nlabels); + mln_ch_value(I, L) output = + impl::generic::flat_zones_(input, nbh, nlabels); trace::exiting("labeling::flat_zones"); return output; Index: mln/labeling/level.hh --- mln/labeling/level.hh (revision 1679) +++ mln/labeling/level.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -50,6 +50,11 @@ 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. */ + /*! Connected component labeling of the image objects at a given * level. * @@ -61,9 +66,8 @@ */ template <typename I, typename N, typename L> mln_ch_value(I, L) - level(const Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh, - L& nlabels); - + level(const Image<I>& input, const mln_value(I)& val, + const Neighborhood<N>& nbh, L& nlabels); # ifndef MLN_INCLUDE_ONLY @@ -145,13 +149,14 @@ template <typename I, typename N, typename L> mln_ch_value(I, L) - level(const Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh, - L& nlabels) + level(const Image<I>& input, const mln_value(I)& val, + const Neighborhood<N>& nbh, 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)(), + mln_ch_value(I, L) output = + impl::level_(mln_trait_image_speed(I)(), exact(input), val, exact(nbh), nlabels); trace::exiting("labeling::level"); Index: mln/labeling/foreground.hh --- mln/labeling/foreground.hh (revision 1679) +++ mln/labeling/foreground.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -43,6 +43,11 @@ 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. */ + /*! Connected component labeling of the object part in a binary * image. * @@ -73,10 +78,12 @@ unsigned& nlabels) { trace::entering("labeling::foreground"); - mlc_equal(mln_trait_image_kind(I), mln::trait::image::kind::binary)::check(); + mlc_equal(mln_trait_image_kind(I), + mln::trait::image::kind::binary)::check(); mln_precondition(exact(input).has_data()); - mln_ch_value(I, unsigned) output = labeling::level(input, true, nbh, nlabels); + mln_ch_value(I, unsigned) output = + labeling::level(input, true, nbh, nlabels); trace::exiting("labeling::foreground"); return output; Index: mln/labeling/regional_minima.hh --- mln/labeling/regional_minima.hh (revision 1679) +++ mln/labeling/regional_minima.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -47,6 +47,11 @@ 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. */ + /*! Connected component labeling of the regional minima of an * image. * @@ -62,7 +67,6 @@ L& nlabels); - # ifndef MLN_INCLUDE_ONLY namespace impl @@ -89,11 +93,14 @@ void init() { level::fill(attr, true); } bool handles(const P&) const { return true; } bool labels(const P& p) const { return attr(p); } - bool equiv(const P& n, const P& p) const { return input(n) == input(p); } - void do_no_union(const P& n, const P& p) { mln_invariant(input(n) < input(p)); + bool equiv(const P& n, const P& p) const { return input(n) == + input(p); } + void do_no_union(const P& n, const P& p) { mln_invariant(input(n) < + input(p)); attr(p) = false; } void init_attr(const P&) {} - void merge_attr(const P& r, const P& p) { attr(p) = attr(p) && attr(r); } + void merge_attr(const P& r, const P& p) { attr(p) = attr(p) && + attr(r); } // end of requirements @@ -102,7 +109,8 @@ regional_minima_functor(const I_& input, const N_& nbh) : input(input), nbh(nbh), - s(level::sort_points_increasing(input)), // FIXME: sort_psites_increasing + s(level::sort_points_increasing(input)), // FIXME: + // sort_psites_increasing attr(input.domain()) { } @@ -150,7 +158,8 @@ mln_precondition(input.has_data()); // Calls the only (generic) impl. - mln_ch_value(I, L) output = impl::generic::regional_minima_(input, nbh, nlabels); + mln_ch_value(I, L) output = + impl::generic::regional_minima_(input, nbh, nlabels); trace::exiting("labeling::regional_minima"); return output; Index: mln/labeling/regional_maxima.hh --- mln/labeling/regional_maxima.hh (revision 1679) +++ mln/labeling/regional_maxima.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -47,6 +47,11 @@ 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. */ + /*! Connected component labeling of the regional maxima of an * image. * @@ -89,11 +94,14 @@ void init() { level::fill(attr, true); } bool handles(const P&) const { return true; } bool labels(const P& p) const { return attr(p); } - bool equiv(const P& n, const P& p) const { return input(n) == input(p); } - void do_no_union(const P& n, const P& p) { mln_invariant(input(n) > input(p)); + bool equiv(const P& n, const P& p) const { return input(n) == + input(p); } + void do_no_union(const P& n, const P& p) { mln_invariant(input(n) > + input(p)); attr(p) = false; } void init_attr(const P&) {} - void merge_attr(const P& r, const P& p) { attr(p) = attr(p) && attr(r); } + void merge_attr(const P& r, const P& p) { attr(p) = attr(p) && + attr(r); } // end of requirements @@ -102,7 +110,8 @@ regional_maxima_functor(const I_& input, const N_& nbh) : input(input), nbh(nbh), - s(level::sort_points_decreasing(input)), // FIXME: sort_psites_decreasing + s(level::sort_points_decreasing(input)), // FIXME: + // sort_psites_decreasing attr(input.domain()) { } @@ -150,7 +159,8 @@ mln_precondition(input.has_data()); // Calls the only (generic) impl. - mln_ch_value(I, L) output = impl::generic::regional_maxima_(input, nbh, nlabels); + mln_ch_value(I, L) output = + impl::generic::regional_maxima_(input, nbh, nlabels); trace::exiting("labeling::regional_maxima"); return output; Index: mln/labeling/level.spe.hh --- mln/labeling/level.spe.hh (revision 1679) +++ mln/labeling/level.spe.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -49,6 +49,11 @@ 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. */ + /*! Connected component labeling of the image objects at a given * level. * @@ -60,8 +65,8 @@ */ template <typename I, typename N, typename L> mln_ch_value(I, L) - level(const Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh, - L& nlabels); + level(const Image<I>& input, const mln_value(I)& val, + const Neighborhood<N>& nbh, L& nlabels); # ifndef MLN_INCLUDE_ONLY @@ -112,7 +117,8 @@ const mln_value(I_)& val; - level_fastest_functor(const I_& input, const mln_value(I_)& val, const N_& nbh) + level_fastest_functor(const I_& input, const mln_value(I_)& val, + const N_& nbh) : input(input), nbh(nbh), s(input.domain()), Index: mln/labeling/background.hh --- mln/labeling/background.hh (revision 1679) +++ mln/labeling/background.hh (working copy) @@ -1,4 +1,4 @@ -// 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 @@ -43,6 +43,11 @@ 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. */ + /*! Connected component labeling of the background part in a * binary image. * @@ -73,10 +78,12 @@ unsigned& nlabels) { trace::entering("labeling::background"); - mlc_equal(mln_trait_image_kind(I), mln::trait::image::kind::binary)::check(); + mlc_equal(mln_trait_image_kind(I), + mln::trait::image::kind::binary)::check(); mln_precondition(exact(input).has_data()); - mln_ch_value(I, unsigned) output = labeling::level(input, false, nbh, nlabels); + mln_ch_value(I, unsigned) output = + labeling::level(input, false, nbh, nlabels); trace::exiting("labeling::background"); return output;