
Index: doc/ChangeLog from Giovanni Palma <giovanni@lrde.epita.fr> * ref/out/exdoc.config.in: Correct autotools variable problems. * ref/img_conv.pl: Add file extension. * ref/Makefile.am: Fix compilation problems Index: olena/ChangeLog from Giovanni Palma <giovanni@lrde.epita.fr> * tests/morpho/tests/attr_op_cl: Initialize uninitialized variable. * tests/morpho/tests/attribute: Correct name of called functions. * oln/morpho/extrema.hh: Add comments. * oln/morpho/attribute_closing_opening_map.hh: Likewise. * oln/morpho/attributes.hh: Likewise. * oln/morpho/attribute_union_find.hh: Likewise. * oln/morpho/attribute_closing_opening.hh: Likewise. * oln/morpho/extrema_killer.hh: Likewise. * oln/morpho/extrema.hxx: Likewise. * oln/morpho/erosion.hh: Likewise. * oln/morpho/closing.inc: Likewise. Index: doc/ref/Makefile.am --- doc/ref/Makefile.am Mon, 08 Mar 2004 13:27:07 +0100 palma_g (oln/d/51_Makefile.a 1.27.1.11 640) +++ doc/ref/Makefile.am Wed, 10 Mar 2004 11:04:21 +0100 palma_g (oln/d/51_Makefile.a 1.27.1.11 640) @@ -12,7 +12,7 @@ doc: html.tar.gz oln-ref.pdf -html: +doxy: $(EXDOC) --config=$(OUT_DIR)/exdoc.config --output-dir=$(OUT_DIR) --input-dir=$(top_srcdir) mkdir -p img cd $(OUT_DIR) && make -f makefile @@ -20,10 +20,10 @@ $(IMG_CONV) img img $(DOXYGEN) doxygen.config -html.tar.gz: +html.tar.gz: doxy $(TAR) -czf $@ html -oln-ref.pdf: html +oln-ref.pdf: doxy cd latex && make && cp refman.pdf ../$@ dist_noinst_DATA = oln-ref.pdf html.tar.gz $(srcdir)/exdoc.pl $(srcdir)/img_conv.pl Index: olena/oln/morpho/closing.inc --- olena/oln/morpho/closing.inc Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/44_closing.in 1.14 640) +++ olena/oln/morpho/closing.inc Wed, 10 Mar 2004 11:43:18 +0100 palma_g (oln/44_closing.in 1.14 640) @@ -1,5 +1,5 @@ // -*- c++ -*- -// Copyright (C) 2001, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2003, 2004 EPITA Research and Development Laboratory // // 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,41 @@ * exi: object.pbm * exo: out.pbm =*/ +/*! +** \brief Processing closing. +** +** Compute the morphological closing of input using se as structural +** element. +** +** \param I: exact type of the input image. +** \param E: exact type of the structural element. +** +** \arg input: input image to close. +** \arg se: structural element to use. +** +** \warning This code is the same for morpho and morpho::fast +** namespaces. +** +** \code +** #include <oln/basics2d.hh> +** #include <oln/morpho/closing.hh> +** #include <oln/level/compare.hh> +** #include <ntg/all.hh> +** int main() +** { +** typedef oln::image2d<ntg::bin> im_type; +** +** im_type im1(oln::load(IMG_IN "object.pbm")); +** save(oln::morpho::closing(im1, oln::win_c8p()), IMG_OUT "oln_morpho_closing.pbm"); +** return 0; +** } +** \endcode +** \image html object.png +** \image latex object.png +** => +** \image html oln_morpho_closing.png +** \image latex oln_morpho_closing.png +*/ template<class I, class E> oln_concrete_type(I) closing(const abstract::non_vectorial_image<I>& input, Index: olena/oln/morpho/erosion.hh --- olena/oln/morpho/erosion.hh Thu, 07 Aug 2003 02:08:21 +0200 david (oln/b/4_erosion.hh 1.17 640) +++ olena/oln/morpho/erosion.hh Wed, 10 Mar 2004 11:58:38 +0100 palma_g (oln/b/4_erosion.hh 1.17 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2002, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -36,35 +36,51 @@ namespace oln { namespace morpho { - - /*=processing erosion - * ns: morpho, morpho::fast - * what: Morphological erosion. - * arg: const abstract::non_vectorial_image<I>&, input, IN, input image - * arg: const abstract::struct_elt<E>&, se, IN, structural element - * ret:oln_concrete_type(I) - * doc: - * Compute the morphological erosion of \var{input} using \var{se} - * as structural element. - * - * On grey-scale images, each point is replaced by the minimum value - * of its neighbors, as indicated by \var{se}. On binary images, - * a logical \code{and} is performed between neighbors. - * The \code{morpho::fast} version of this function use a different - * algorithm: an - * - * histogram of the value of the neighborhood indicated by - * \var{se} is updated while iterating over all point of the - * image. Doing so is more efficient when the - * structural element is large. - * see: morpho::n_erosion - * see: morpho::dilation - * ex: - * $ image2d<ntg::bin> im = load("object.pbm"); - * $ save(morpho::erosion(im, win_c8p()), "out.pbm"); - * exi: object.pbm - * exo: out.pbm - =*/ + /*! + ** \brief Perform a morphological erosion. + ** + ** Compute the morphological erosion of input using se + ** as structural element. + ** + ** On grey-scale images, each point is replaced by the minimum + ** value of its neighbors, as indicated by se. On binary + ** images, a logical and is performed between neighbors. The + ** morpho::fast version of this function use a different + ** algorithm: an histogram of the value of the neighborhood + ** indicated by se is updated while iterating over all point of + ** the image. Doing so is more efficient when the structural + ** element is large. + ** + ** \param I: exact type of the input image. + ** \param E: exact type of the structural element. + ** + ** + ** \arg input: input image. + ** \arg se: structural element to use. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/erosion.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::bin> im_type; + ** + ** im_type im1(oln::load(IMG_IN "object.pbm")); + ** save(oln::morpho::erosion(im1, oln::win_c8p()), IMG_OUT "oln_morpho_erosion.pbm"); + ** return 0; + ** } + ** \endcode + ** + ** \image html object.png + ** \image latex object.png + ** => + ** \image html oln_morpho_erosion.png + ** \image latex oln_morpho_erosion.png + ** + ** \see oln::morpho::fast::erosion() + */ template<class I, class E> oln_concrete_type(I) erosion(const abstract::non_vectorial_image<I>& input, @@ -80,19 +96,39 @@ return output; } - /*=processing n_erosion - * ns: morpho - * what: Morphological erosion itered n times. - * arg: const abstract::non_vectorial_image<I>&, input, IN, input image - * arg: const abstract::struct_elt<E>&, se, IN, structural element - * arg: unsigned, n, IN, number of iterations - * ret:oln_concrete_type(I) - * doc: - * Apply \code{morpho::erosion} \var{n} times. - * see: morpho::erosion - * see: morpho::n_dilation - =*/ - + /*! + ** \brief Perform morphological erosion itered n times. + ** + ** + ** \param I: exact type of the input image. + ** \param E: exact type of the structural element. + ** + ** \arg input: input image. + ** \arg se: structural element to use. + ** \arg n: number of iterations. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/erosion.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::bin> im_type; + ** + ** im_type im1(oln::load(IMG_IN "object.pbm")); + ** save(oln::morpho::n_erosion(im1, oln::win_c8p(), 5), IMG_OUT "oln_morpho_n_erosion.pbm"); + ** return 0; + ** } + ** \endcode + ** + ** \image html object.png + ** \image latex object.png + ** => + ** \image html oln_morpho_n_erosion.png + ** \image latex oln_morpho_n_erosion.png + ** + */ template<class I, class E> oln_concrete_type(I) n_erosion(const abstract::non_vectorial_image<I> & input, @@ -111,6 +147,41 @@ } namespace fast { + /*! + ** \brief Perform a morphological erosion. + ** + ** Compute the morphological erosion of input using se + ** as structural element. + ** + ** \param I: exact type of the input image. + ** \param E: exact type of the structural element. + ** + ** + ** \arg input: input image. + ** \arg se: structural element to use. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/erosion.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::bin> im_type; + ** + ** im_type im1(oln::load(IMG_IN "object.pbm")); + ** save(oln::morpho::erosion(im1, oln::win_c8p()), IMG_OUT "oln_morpho_fast_erosion.pbm"); + ** return 0; + ** } + ** \endcode + ** + ** \image html object.png + ** \image latex object.png + ** => + ** \image html oln_morpho_fast_erosion.png + ** \image latex oln_morpho_fast_erosion.png + ** \todo FIXME: Correct this function and make the example use it. + */ template<class I, class E> oln_concrete_type(I) erosion(const abstract::non_vectorial_image<I>& input, Index: olena/oln/morpho/extrema.hh --- olena/oln/morpho/extrema.hh Thu, 16 Jan 2003 18:13:46 +0100 akim (oln/38_extrema.hh 1.11 640) +++ olena/oln/morpho/extrema.hh Wed, 10 Mar 2004 12:08:41 +0100 palma_g (oln/38_extrema.hh 1.11 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2002 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2002, 2004 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -35,12 +35,29 @@ namespace oln { namespace morpho { + /*! + ** \brief oln::morpho::sure namespace. + ** + ** Here come algorithms that are sure. + */ namespace sure { # include <oln/morpho/extrema.hxx> } + + /*! + ** \brief oln::morpho::sequential namespace. + ** + ** Here come algorithms that are sequential. + */ namespace sequential { # include <oln/morpho/extrema.hxx> } + + /*! + ** \brief oln::morpho::hybrid namespace. + ** + ** Here come algorithms that are hybrid. + */ namespace hybrid { # include <oln/morpho/extrema.hxx> } Index: olena/oln/morpho/extrema.hxx --- olena/oln/morpho/extrema.hxx Sat, 27 Sep 2003 18:30:39 +0200 burrus_n (oln/j/4_extrema.hx 1.11 640) +++ olena/oln/morpho/extrema.hxx Wed, 10 Mar 2004 14:59:44 +0100 palma_g (oln/j/4_extrema.hx 1.11 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2002, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory // // 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,8 +25,19 @@ // reasons why the executable file might be covered by the GNU General // Public License. - +/*! +** \brief internal namespace +*/ namespace internal { + + /*! + ** \brief Create extremum image from another one. + ** + ** \param DestType: type of data in the wanted image. + ** \param I: Exact type of the input image. + ** + ** \arg input: input image. + */ template <class DestType, class I> typename mute<I, DestType>::ret create_minima_image_from_bin_(const abstract::non_vectorial_image<I>& input) @@ -43,7 +54,13 @@ return output; } - + /*! + ** \brief Create binary image from another one. + ** + ** \param I: exact type of the image. + ** + ** \arg input: input image. + */ template <class I> typename mute<I, ntg::bin>::ret ima_to_bin_(const abstract::non_vectorial_image<I>& input) @@ -61,28 +78,50 @@ // Minima Imposition - - -/*=processing sure_minima_imposition - * ns: morpho - * what: Minima Imposition. - * arg: const abstract::non_vectorial_image<I1>&, input, IN, input image - * arg: const abstract::non_vectorial_image<I2>&, minima_map, IN, bin image - * arg: const abstract::neighborhood<N>& Ng, IN, neighborhood - * ret:oln_concrete_type(I) - * doc: - * Impose minima defined by \var{minima_map} on \var{input} - * using \var{Ng} as neighborhood. \var{minima_map} must - * be a bin image (true for a minimum, false for a non minimum). - * Soille p.172. - * see: morpho::sure_geodesic_reconstruction_erosion - * ex: - * $ image2d<int_u8> light = load("lena.pgm"); - * $ image2d<ntg::bin> minima = load("map.pbm"); - * $ save(morpho::sure_minima_imposition(light, minima, neighb_c4()), "out.pgm"); - * exi: lena.pgm map.pbm - * exo: out.pgm - =*/ +/*! +** \brief Perform a minima imposition. +** +** Impose minima defined by minima_map on input using Ng as +** neighborhood. minima_map must be a bin image (true for a minimum, +** false for a non minimum). Soille p.172. +** +** \param I: exact type of the first image. +** \param I2: exact type of the second image. +** \param N: exact type of the neighborhood. +** +** \arg input: input image. +** \arg minima_map: minima map image. +** \arg Ng: neighborhood to use. +** +** \ref foototo +** \code +** #include <oln/basics2d.hh> +** #include <oln/morpho/extrema.hh> +** #include <ntg/all.hh> +** #include <iostream> +** int main() +** { +** typedef oln::image2d<ntg::int_u8> im_type; +** typedef oln::image2d<ntg::bin> bin_im_type; +** +** im_type light(oln::load(IMG_IN "lena.pgm")); +** bin_im_type minima(oln::load(IMG_IN "map.pbm")); +** +** oln::save(oln::morpho::sequential::minima_imposition(light, minima, oln::neighb_c4()), +** IMG_OUT "oln_morpho_sequential_minima_imposition.pgm"); +** return 0; +** } +** \endcode +** \image html lena.png +** \image latex lena.png +** and +** \image html map.png +** \image latex map.png +** => +** \image html oln_morpho_sequential_minima_imposition.png +** \image latex oln_morpho_sequential_minima_imposition.png +** +*/ template<class I, class I2, class N> oln_concrete_type(I) minima_imposition(const abstract::non_vectorial_image<I>& input, @@ -104,25 +143,38 @@ // Regional minima - -/*=processing sure_regional_minima - * ns: morpho - * what: Regional minima. - * arg: const abstract::non_vectorial_image<I1>&, input, IN, input image - * arg: const abstract::struct_elt<E>&, se, IN, structural element - * ret: typename mute<I, ntg::bin>::ret - * doc: - * Extract regional minima of \var{input} - * using \var{Ng} - * as neighborhhod. Soille p.169. The algorithm uses - * sure_geodesic_reconstruction_erosion. - * see: morpho::sure_geodesic_reconstruction_erosion - * ex: - * $ image2d<int_u8> light = load("lena.pgm"); - * $ save(morpho::sure_regional_minima(lena,neighb_c4()), "out.pgm"); - * exi: lena.pgm - * exo: out.pgm - =*/ +/*! +** \brief Extract regional minima. +** +** \param I: Exact type of input image. +** \param Exact type of neighborhood. +** +** \arg input: input image. +** \arg Ng: neighborhood to use. +** +** \code +** #include <oln/basics2d.hh> +** #include <oln/morpho/extrema.hh> +** #include <ntg/all.hh> +** #include <iostream> +** int main() +** { +** typedef oln::image2d<ntg::int_u8> im_type; +** +** im_type im(oln::load(IMG_IN "lena.pgm")); +** +** oln::save(oln::morpho::sequential::regional_minima(im, oln::neighb_c4()), +** IMG_OUT "oln_morpho_sequential_regional_minima.pgm"); +** return 0; +** } +** \endcode +** \image html lena.png +** \image latex lena.png +** => +** \image html oln_morpho_sequential_regional_minima.png +** \image latex oln_morpho_sequential_regional_minima.png +** +*/ template<class I, class N> typename mute<I, ntg::bin>::ret regional_minima(const abstract::non_vectorial_image<I>& input, Index: olena/oln/morpho/extrema_killer.hh --- olena/oln/morpho/extrema_killer.hh Thu, 07 Aug 2003 02:08:21 +0200 david (oln/e/19_extrema_ki 1.7.1.4.1.10 640) +++ olena/oln/morpho/extrema_killer.hh Wed, 10 Mar 2004 15:51:50 +0100 palma_g (oln/e/19_extrema_ki 1.7.1.4.1.10 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2002, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2002, 2003, 2004 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -48,6 +48,16 @@ namespace morpho { + /*! + ** \brief Kill connex components smaller than a given area. + ** + ** \param I: exact type of the input image. + ** \param N: exact type of the neighborhood. + ** + ** \arg input: the input image. + ** \arg area: the threshold to use. + ** \arg Ng: the neighborhood to use. + */ template<class I, class N> typename mute<I, ntg::bin>::ret internal_kill_cc_area(const abstract::non_vectorial_image<I>& input, @@ -81,25 +91,42 @@ // SURE VERSIONS - /*=processing sure_maxima_killer - * ns: morpho - * what: Maxima killer. - * arg: const abstract::non_vectorial_image<I1>&, marker, IN, marker image - * arg: const unsigned int area, area, IN, area - * arg: const abstract::struct_elt<E>&, se, IN, structural element - * ret:oln_concrete_type(I1) - * doc: It removes the small (in area) connected components of the upper - * level sets of \var{input} using \var{se} as structual element. The implementation - * uses the threshold superposition principle; so it is very slow ! it works only for - * int_u8 images. - * see: morpho::fast_maxima_killer - * ex: - * $ image2d<int_u8> light = load("light.pgm"); - * $ save(morpho::sure_maxima_killer(light, 20, win_c8p()), "out.pgm"); - * exi: light.pgm - * exo: out.pgm - * wontcompile: fixme - =*/ + /*! + ** \brief Maxima killer. + ** + ** It removes the small (in area) connected components of the upper + ** level sets of input using se as structual element. The implementation + ** uses the threshold superposition principle; so it is very slow ! it works only for + ** int_u8 images. + ** + ** \param I: image exact type. + ** \param N: neighborhood exact type. + ** + ** \arg input: the input image. + ** \arg area: threshold to use. + ** \arg Ng: the neighborhood to use. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/extrema_killer.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im(oln::load(IMG_IN "lena128.pgm")); + ** + ** oln::save(oln::morpho::sure_maxima_killer(im, 200, oln::neighb_c4()), + ** IMG_OUT "oln_morpho_sure_maxima_killer.pgm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_sure_maxima_killer.png + ** \image latex oln_morpho_sure_maxima_killer.png + */ template<class I, class N> oln_concrete_type(I) sure_maxima_killer(const abstract::non_vectorial_image<I>& input, @@ -137,25 +164,42 @@ } - /*=processing sure_minima_killer - * ns: morpho - * what: Minima killer. - * arg: const abstract::non_vectorial_image<I1>&, marker, IN, marker image - * arg: const unsigned int area, area, IN, area - * arg: const abstract::struct_elt<E>&, se, IN, structural element - * ret:oln_concrete_type(I1) - * doc: It removes the small (in area) connected components of the lower - * level sets of \var{input} using \var{se} as structual element. The implementation - * uses the threshold superposition principle; so it is very slow ! it works only for - * int_u8 images. - * see: morpho::fast_maxima_killer - * ex: - * $ image2d<int_u8> light = load("light.pgm"); - * $ save(morpho::sure_minima_killer(light, 20, win_c8p()), "out.pgm"); - * exi: light.pgm - * exo: out.pgm - * wontcompile: fixme - =*/ + /*! + ** \brief Minima killer. + ** + ** It removes the small (in area) connected components of the lower + ** level sets of input using se as structual element. The implementation + ** uses the threshold superposition principle; so it is very slow ! it works only for + ** int_u8 images. + ** + ** \param I: image exact type. + ** \param N: neighborhood exact type. + ** + ** \arg input: the input image. + ** \arg area: threshold to use. + ** \arg Ng: the neighborhood to use. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/extrema_killer.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im(oln::load(IMG_IN "lena128.pgm")); + ** + ** oln::save(oln::morpho::sure_minima_killer(im, 200, oln::neighb_c4()), + ** IMG_OUT "oln_morpho_sure_minima_killer.pgm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_sure_minima_killer.png + ** \image latex oln_morpho_sure_minima_killer.png + */ template<class I, class N> image2d<ntg::int_u8> sure_minima_killer(const abstract::non_vectorial_image<I>& input, @@ -198,6 +242,18 @@ // FAST VERSIONS + /*! + ** \brief Check if a point is a strict minimum. + ** + ** \param P: exact type of the point. + ** \param I: exact type of the image. + ** \param N: exact type of the neighborhood. + ** + ** \arg p: the point to consider. + ** \arg input: the image where to get the value of the point to + ** consider. + ** \arg Ng: type of neighborhood to use. + */ template<class P, class I, class N> // inline static bool @@ -221,7 +277,18 @@ return (is_p_lower && is_p_at_least_one_stricly_lower); } - + /*! + ** \brief Check if a point is a strict maximum. + ** + ** \param P: exact type of the point. + ** \param I: exact type of the image. + ** \param N: exact type of the neighborhood. + ** + ** \arg p: the point to consider. + ** \arg input: the image where to get the value of the point to + ** consider. + ** \arg Ng: type of neighborhood to use. + */ template<class P, class I, class N> // inline static bool @@ -246,27 +313,45 @@ } - - /*=processing fast_minima_killer - * ns: morpho - * what: Minima killer. - * arg: const abstract::non_vectorial_image<I1>&, marker, IN, marker image - * arg: const unsigned int area, area, IN, area - * arg: const abstract::neighborhood<N>&, Ng, IN, neighboorhood - * ret:oln_concrete_type(I1) - * doc: It removes the small (in area) connected components of the lower - * level sets of \var{input} using \var{Ng} as neighboorhood. The implementation - * is based on stak. Guichard and Morel, Image iterative smoothing and PDE's. - * Book in preparation. p 265. - * see: morpho::sure_minima_killer - * ex: - * $ image2d<int_u8> light = load("light.pgm"); - * $ save(morpho::fast_minima_killer(light, 20, win_c8p()), "out.pgm"); - * exi: light.pgm - * exo: out.pgm - * wontcompile: fixme - =*/ - // Guichard and Morel, Image iterative smoothing and PDE's. Book in preparation. p 265. + /*! + ** \brief Minima killer. + ** + ** It removes the small (in area) connected components of the + ** lower level sets of input using Ng as neighboorhood. The + ** implementation is based on stak. Guichard and Morel, Image + ** iterative smoothing and PDE's. Book in preparation. p 265. + ** + ** \param I: image exact type. + ** \param N: neighborhood exact type. + ** + ** \arg input: the input image. + ** \arg area: threshold to use. + ** \arg Ng: the neighborhood to use. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/extrema_killer.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im(oln::load(IMG_IN "lena128.pgm")); + ** + ** oln::save(oln::morpho::fast_minima_killer(im, 200, oln::neighb_c4()), + ** IMG_OUT "oln_morpho_fast_minima_killer.pgm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_minima_killer.png + ** \image latex oln_morpho_fast_minima_killer.png + ** + ** \warning Even if it is called fast minima killer, this algorithm + ** is slow. Please use card opening instead. + */ template<class I, class N> oln_concrete_type(I) fast_minima_killer(const abstract::non_vectorial_image<I>& input, @@ -353,25 +438,45 @@ return working_input; } - /*=processing fast_maxima_killer - * ns: morpho - * what: Maxima killer. - * arg: const abstract::non_vectorial_image<I1>&, marker, IN, marker image - * arg: const unsigned int area, area, IN, area - * arg: const abstract::neighborhood<N>&, Ng, IN, neighboorhood - * ret:oln_concrete_type(I1) - * doc: It removes the small (in area) connected components of the upper - * level sets of \var{input} using \var{Ng} as neighboorhood. The implementation - * is based on stak. Guichard and Morel, Image iterative smoothing and PDE's. Book in preparation. p 265. - * see: morpho::sure_maxima_killer - * ex: - * $ image2d<int_u8> light = load("light.pgm"); - * $ save(morpho::fast_maxima_killer(light, 20, win_c8p()), "out.pgm"); - * exi: light.pgm - * exo: out.pgm - * wontcompile: fixme - =*/ - // Guichard and Morel, Image iterative smoothing and PDE's. Book in preparation. p 265. + /*! + ** \brief Maxima killer. + ** + ** It removes the small (in area) connected components of the + ** upper level sets of input using Ng as neighboorhood. The + ** implementation is based on stak. Guichard and Morel, Image + ** iterative smoothing and PDE's. Book in preparation. p 265. + ** + ** \param I: image exact type. + ** \param N: neighborhood exact type. + ** + ** \arg input: the input image. + ** \arg area: threshold to use. + ** \arg Ng: the neighborhood to use. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/extrema_killer.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im(oln::load(IMG_IN "lena128.pgm")); + ** + ** oln::save(oln::morpho::fast_maxima_killer(im, 200, oln::neighb_c4()), + ** IMG_OUT "oln_morpho_fast_maxima_killer.pgm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_maxima_killer.png + ** \image latex oln_morpho_fast_maxima_killer.png + ** + ** \warning Even if it is called fast maxima killer, this algorithm + ** is slow. Please use card closing instead. + */ template<class I, class N> oln_concrete_type(I) fast_maxima_killer(const abstract::non_vectorial_image<I>& input, Index: olena/oln/morpho/attribute_closing_opening.hh --- olena/oln/morpho/attribute_closing_opening.hh Mon, 08 Mar 2004 08:12:15 +0100 palma_g (oln/q/49_attribute_ 1.16 640) +++ olena/oln/morpho/attribute_closing_opening.hh Wed, 10 Mar 2004 12:05:08 +0100 palma_g (oln/q/49_attribute_ 1.16 640) @@ -38,19 +38,35 @@ ** \brief oln::morpho namespace */ namespace morpho { - /*! \namespace oln::morpho::fast + /*! ** \brief oln::morpho::fast namespace + ** + ** In this namespace, you will find fast algorithms, but with intensive memory usage */ namespace fast { - /*! \namespace oln::morpho::fast::tarjan + /*! ** \brief oln::morpho::fast::tarjan namespace */ namespace tarjan { - /*! \namespace oln::morpho::fast::tarjan::internal + /*! ** \brief oln::morpho::fast::tarjan::internal namespace + ** + ** Internal usage only. */ namespace internal { + /*! + ** \brief Perform an attribute closing. + ** + ** \param I: image exact type. + ** \param N: neighborhood exact type. + ** \param A: Attribute exact type. + ** + ** \arg input: input image. + ** \arg Ng: neighborhood to use. + ** \arg lambda: threshold to use. + ** \arg env: environment. + */ template<class I, class N, class A> oln_concrete_type(I) attr_closing_(const abstract::non_vectorial_image<I>& input, @@ -63,7 +79,18 @@ return attr_closing.template get_comptute<true>(lambda, Ng); } - // attribute opening + /*! + ** \brief Perform an attribute opening. + ** + ** \param I: image exact type. + ** \param N: neighborhood exact type. + ** \param A: Attribute exact type. + ** + ** \arg input: input image. + ** \arg Ng: neighborhood to use. + ** \arg lambda: threshold to use. + ** \arg env: environment. + */ template<class I, class N, class A> oln_concrete_type(I) attr_opening_(const abstract::non_vectorial_image<I>& input, @@ -129,19 +156,18 @@ ** #include <oln/morpho/attribute_closing_opening.hh> ** #include <oln/level/compare.hh> ** #include <ntg/all.hh> - ** #include <iostream> ** int main() ** { ** typedef oln::image2d<ntg::int_u8> im_type; ** - ** im_type im1(oln::load(IMG_IN "lena256.pgm")); + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); ** im1 = oln::morpho::fast::card_closing(im1, oln::neighb_c4(), 200); ** oln::save(im1, IMG_OUT "oln_morpho_fast_card_closing.ppm"); ** return 0; ** } ** \endcode - ** \image html lena256.png - ** \image latex lena256.png + ** \image html lena128.png + ** \image latex lena128.png ** => ** \image html oln_morpho_fast_card_closing.png ** \image latex oln_morpho_fast_card_closing.png @@ -157,19 +183,18 @@ ** #include <oln/morpho/attribute_closing_opening.hh> ** #include <oln/level/compare.hh> ** #include <ntg/all.hh> - ** #include <iostream> ** int main() ** { ** typedef oln::image2d<ntg::int_u8> im_type; ** - ** im_type im1(oln::load(IMG_IN "lena256.pgm")); + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); ** im1 = oln::morpho::fast::card_opening(im1, oln::neighb_c4(), 200); ** oln::save(im1, IMG_OUT "oln_morpho_fast_card_opening.ppm"); ** return 0; ** } ** \endcode - ** \image html lena256.png - ** \image latex lena256.png + ** \image html lena128.png + ** \image latex lena128.png ** => ** \image html oln_morpho_fast_card_opening.png ** \image latex oln_morpho_fast_card_opening.png @@ -185,22 +210,21 @@ ** #include <oln/morpho/attribute_closing_opening.hh> ** #include <oln/level/compare.hh> ** #include <ntg/all.hh> - ** #include <iostream> ** int main() ** { ** typedef oln::image2d<ntg::int_u8> im_type; ** - ** im_type im1(oln::load(IMG_IN "lena256.pgm")); + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); ** im1 = oln::morpho::fast::integral_closing(im1, oln::neighb_c4(), 200); - ** oln::save(im1, IMG_OUT "olena_attribute_closing_opening_hh_integral_clo.ppm"); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_integral_closing.ppm"); ** return 0; ** } ** \endcode - ** \image html lena256.png - ** \image latex lena256.png + ** \image html lena128.png + ** \image latex lena128.png ** => - ** \image html olena_attribute_closing_opening_hh_integral_clo.png - ** \image latex olena_attribute_closing_opening_hh_integral_clo.png + ** \image html oln_morpho_fast_integral_closing.png + ** \image latex oln_morpho_fast_integral_closing.png ** */ xxx_closing_decl(integral); @@ -213,22 +237,21 @@ ** #include <oln/morpho/attribute_closing_opening.hh> ** #include <oln/level/compare.hh> ** #include <ntg/all.hh> - ** #include <iostream> ** int main() ** { ** typedef oln::image2d<ntg::int_u8> im_type; ** - ** im_type im1(oln::load(IMG_IN "lena256.pgm")); + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); ** im1 = oln::morpho::fast::integral_opening(im1, oln::neighb_c4(), 200); - ** oln::save(im1, IMG_OUT "olena_attribute_closing_opening_hh_integral_op.ppm"); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_integral_opening.ppm"); ** return 0; ** } ** \endcode - ** \image html lena256.png - ** \image latex lena256.png + ** \image html lena128.png + ** \image latex lena128.png ** => - ** \image html olena_attribute_closing_opening_hh_integral_op.png - ** \image latex olena_attribute_closing_opening_hh_integral_op.png + ** \image html oln_morpho_fast_integral_opening.png + ** \image latex oln_morpho_fast_integral_opening.png ** */ xxx_opening_decl(integral); @@ -241,22 +264,21 @@ ** #include <oln/morpho/attribute_closing_opening.hh> ** #include <oln/level/compare.hh> ** #include <ntg/all.hh> - ** #include <iostream> ** int main() ** { ** typedef oln::image2d<ntg::int_u8> im_type; ** - ** im_type im1(oln::load(IMG_IN "lena256.pgm")); + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); ** im1 = oln::morpho::fast::height_opening(im1, oln::neighb_c4(), 5); - ** oln::save(im1, IMG_OUT "olena_attribute_closing_opening_hh_height_op.ppm"); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_height_opening.ppm"); ** return 0; ** } ** \endcode - ** \image html lena256.png - ** \image latex lena256.png + ** \image html lena128.png + ** \image latex lena128.png ** => - ** \image html olena_attribute_closing_opening_hh_height_op.png - ** \image latex olena_attribute_closing_opening_hh_height_op.png + ** \image html oln_morpho_fast_height_opening.png + ** \image latex oln_morpho_fast_height_opening.png ** */ xxx_opening_decl(height); @@ -274,31 +296,358 @@ ** { ** typedef oln::image2d<ntg::int_u8> im_type; ** - ** im_type im1(oln::load(IMG_IN "lena256.pgm")); + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); ** im1 = oln::morpho::fast::height_closing(im1, oln::neighb_c4(), 5); - ** oln::save(im1, IMG_OUT "olena_attribute_closing_opening_hh_height_clo.ppm"); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_height_closing.ppm"); ** return 0; ** } ** \endcode - ** \image html lena256.png - ** \image latex lena256.png + ** \image html lena128.png + ** \image latex lena128.png ** => - ** \image html olena_attribute_closing_opening_hh_height_clo.png - ** \image latex olena_attribute_closing_opening_hh_height_clo.png + ** \image html oln_morpho_fast_height_closing.png + ** \image latex oln_morpho_fast_height_closing.png ** */ xxx_closing_decl(height); - xxx_opening_decl(maxvalue); + + + /*! + ** \brief Perform a maxvalue closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::maxvalue_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_maxvalue_closing.png.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_maxvalue_closing.png + ** \image latex oln_morpho_fast_maxvalue_closing.png + ** + */ xxx_closing_decl(maxvalue); + + /*! + ** \brief Perform a maxvalue opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::maxvalue_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_maxvalue_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_maxvalue_opening.png + ** \image latex oln_morpho_fast_maxvalue_opening.png + ** + */ + xxx_opening_decl(maxvalue); + + /*! + ** \brief Perform a minvalue opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::minvalue_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_minvalue_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_minvalue_opening.png + ** \image latex oln_morpho_fast_minvalue_opening.png + ** + */ xxx_opening_decl(minvalue); + + /*! + ** \brief Perform a minvalue closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::minvalue_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_minvalue_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_minvalue_closing.png + ** \image latex oln_morpho_fast_minvalue_closing.png + ** + */ xxx_closing_decl(minvalue); + + /*! + ** \brief Perform a ball opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::ball_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_ball_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_ball_opening.png + ** \image latex oln_morpho_fast_ball_opening.png + ** + */ xxx_opening_im_decl(ball); + + /*! + ** \brief Perform a ball closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::ball_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_ball_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_ball_closing.png + ** \image latex oln_morpho_fast_ball_closing.png + ** + */ xxx_closing_im_decl(ball); + + /*! + ** \brief Perform a dist opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::dist_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_dist_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_dist_opening.png + ** \image latex oln_morpho_fast_dist_opening.png + ** + */ xxx_opening_im_decl(dist); + + /*! + ** \brief Perform a dist closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::dist_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_dist_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_dist_closing.png + ** \image latex oln_morpho_fast_dist_closing.png + ** + */ xxx_closing_im_decl(dist); + + /*! + ** \brief Perform a cube closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::cube_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_cube_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_cube_closing.png + ** \image latex oln_morpho_fast_cube_closing.png + ** + */ xxx_closing_im_decl(cube); + + /*! + ** \brief Perform a cube opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::cube_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_cube_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_cube_opening.png + ** \image latex oln_morpho_fast_cube_opening.png + ** + */ xxx_opening_im_decl(cube); + + /*! + ** \brief Perform a box closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** ntg::vec<2, unsigned, mlc::final> lambda; + ** lambda[0] = lambda[1] = 50; + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::box_closing(im1, oln::neighb_c4(), lambda); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_box_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_box_closing.png + ** \image latex oln_morpho_fast_box_closing.png + ** + */ xxx_closing_im_decl(box); + + /*! + ** \brief Perform a box opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** ntg::vec<2, unsigned, mlc::final> lambda; + ** lambda[0] = lambda[1] = 50; + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::fast::box_opening(im1, oln::neighb_c4(), lambda); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_box_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_box_opening.png + ** \image latex oln_morpho_fast_box_opening.png + ** + */ xxx_opening_im_decl(box); } // !fast Index: olena/oln/morpho/attribute_union_find.hh --- olena/oln/morpho/attribute_union_find.hh Mon, 08 Mar 2004 08:12:15 +0100 palma_g (oln/q/50_attribute_ 1.13 640) +++ olena/oln/morpho/attribute_union_find.hh Wed, 10 Mar 2004 16:11:39 +0100 palma_g (oln/q/50_attribute_ 1.13 640) @@ -41,17 +41,89 @@ namespace fast { namespace tarjan { + /*! + ** \brief Struct that contains everything to compute an + ** attribute opening or closing + ** + ** \param T: exact type of images to process. + ** \param ATTRIBUTE: exact type of attribute to use. + ** \param Env: type of environment to use. + */ template<class T, class ATTRIBUTE, class Env = attr_env_type(ATTRIBUTE)> struct tarjan_set { - typedef oln_point_type(T) point_type; - typedef oln_value_type(T) data_type; - typedef oln_concrete_type(T) image_type; - typedef typename ATTRIBUTE::lambda_type lambda_type; - typedef Env env_type; + typedef oln_point_type(T) point_type; ///< Associated point type. + typedef oln_value_type(T) data_type; ///< Associated data_type. + typedef oln_concrete_type(T) image_type; ///< Image type to open/close + typedef typename ATTRIBUTE::lambda_type lambda_type; ///< Threshold type. + typedef Env env_type; ///< Environment type. + + /*! + ** \brief tarjan_set constructor. + ** \param ima: image to open/close. + ** \param env: environment to use to compute attributes. + */ + tarjan_set(const image_type& ima, const env_type &env) : input_(ima), + parent_(ima.size()), + aux_data_(ima.size()), + env_(env) + { + level::fill(parent_, INACTIVE()); + } + + /*! + ** \brief Main method to perform an attribute opening/closing. + ** \param closing: true -> a closing is performed, an opening otherwise. + ** + ** \param lambda: threshold to use for attribute growing. + ** \param Ng: neighborhood to use in the algorithm. + ** \return the resulting image. + */ + template<bool closing, class N> + image_type + get_comptute(const lambda_type & lambda, + const abstract::neighborhood<N>& Ng) + { + lambda_ = λ + + std::vector<point_type> I(input_.npoints()); + + oln::utils::select_distrib_sort<closing>()(input_, I); + + level::fill(aux_data_, ntg_sup_val(lambda_type)); + aux_data_.border_adapt_assign(Ng.delta(), ntg_sup_val(lambda_type)); + + // We are ready to perform stuff + for (unsigned int p = 0; p < I.size(); ++p) + { + point_type p_p = I[p]; + make_set(p_p); + oln_neighb_type(N) Q_prime(Ng, p_p); + for_all (Q_prime) + if (is_proc(Q_prime)) + uni(Q_prime.cur(), p_p); + } - // ACTIVE and INACTIVE are defined with a hook to be static - // and initialized ionly once. + // Resolving phase + image_type output(input_.size()); + for (int p = I.size() - 1; p >= 0; --p) + { + point_type p_p = I[p]; + if ((parent_[p_p] == ACTIVE()) || (parent_[p_p] == INACTIVE())) + output[p_p] = input_[p_p]; + else + output[p_p] = output[parent_[p_p]]; + // this code is equivalent to + // output[I[p].first] = input_[find_root(I[p].first)]; + + } + return output; + } + + protected: + /*! + ** \brief Return the value of an active point. + */ static const point_type& ACTIVE() { @@ -69,6 +141,9 @@ return tmp.elt; } + /*! + ** \brief Return the value of an inactive point. + */ static const point_type& INACTIVE() { @@ -85,14 +160,10 @@ return tmp.elt; } - tarjan_set(const image_type& ima, const env_type &env) : input_(ima), - parent_(ima.size()), - aux_data_(ima.size()), - env_(env) - { - level::fill(parent_, INACTIVE()); - } - + /*! + ** \brief Make a new component from a point. + ** \arg x: root of the component. + */ void make_set(const point_type& x) { @@ -101,6 +172,10 @@ aux_data_[x] = ATTRIBUTE(input_, x, env_); } + /*! + ** \brief find the root of a component. + ** \arg x: a point of the component. + */ point_type find_root(const point_type& x) { @@ -113,6 +188,11 @@ return x; } + /*! + ** \brief Check if two components should be merged. + ** \arg x: a point of the first component. + ** \arg y: a point of the second component. + */ bool criterion(const point_type& x, const point_type& y) { @@ -121,6 +201,11 @@ return ( (input_[x] == input_[y]) || (aux_data_[x] < *lambda_)); } + /*! + ** \brief Do union of two components. + ** \arg n: a point of the first component. + ** \arg p: a point of the second component. + */ void uni(const point_type& n, const point_type& p) { @@ -137,67 +222,25 @@ } } - // bool closing = true -> a closing is performed, - // an opening otherwise. - template<bool closing, class N> - image_type - get_comptute(const lambda_type & lambda, - const abstract::neighborhood<N>& Ng) - { - lambda_ = λ - - std::vector<point_type> I(input_.npoints()); - - oln::utils::select_distrib_sort<closing>()(input_, I); - - level::fill(aux_data_, ntg_sup_val(lambda_type)); - aux_data_.border_adapt_assign(Ng.delta(), ntg_sup_val(lambda_type)); - - // We are ready to perform stuff - for (unsigned int p = 0; p < I.size(); ++p) - { - point_type p_p = I[p]; - make_set(p_p); - oln_neighb_type(N) Q_prime(Ng, p_p); - for_all (Q_prime) - if (is_proc(Q_prime)) - uni(Q_prime.cur(), p_p); - } - - // Resolving phase - image_type output(input_.size()); - for (int p = I.size() - 1; p >= 0; --p) - { - point_type p_p = I[p]; - if ((parent_[p_p] == ACTIVE()) || (parent_[p_p] == INACTIVE())) - output[p_p] = input_[p_p]; - else - output[p_p] = output[parent_[p_p]]; - // this code is equivalent to - // output[I[p].first] = input_[find_root(I[p].first)]; - - } - return output; - } - - protected: - // tells if a point has been proceded + /*! + ** \brief Tells if a point has been proceded. + */ bool is_proc(const point_type &p) const { //FIXME: odd way to call !=, but it is to help the compiler //to find the good one when ATTRIBUTE is templeted by types - //in other namepaces. + //in other namespaces. // return aux_data_[p] != ntg_max_val(lambda_type); return aux_data_[p].operator!=(ntg_sup_val(lambda_type)); }; - const image_type & input_; - typename mute<T, point_type>::ret parent_; - typename mute<T, ATTRIBUTE>::ret aux_data_; - const lambda_type *lambda_; - const env_type env_; + const image_type &input_; ///< Input image. + typename mute<T, point_type>::ret parent_; ///< Give a parent of a point. + typename mute<T, ATTRIBUTE>::ret aux_data_; ///< Image to store attributes. + const lambda_type *lambda_; ///< Threshold. + const env_type env_; ///< Environment. }; } // !tarjan } // !fast Index: olena/oln/morpho/attributes.hh --- olena/oln/morpho/attributes.hh Mon, 08 Mar 2004 08:12:15 +0100 palma_g (oln/j/45_attributes 1.5 644) +++ olena/oln/morpho/attributes.hh Wed, 10 Mar 2004 11:09:44 +0100 palma_g (oln/j/45_attributes 1.5 644) @@ -48,8 +48,15 @@ namespace oln { namespace morpho { + /*! + ** \brief oln::morpho::tools namespace + */ namespace tools { - // should be moved elsewhere + + /*! + ** \brief Absolute value of difference between v1 and v2. + ** \warning Should be moved elsewhere. + */ template <class T> T diffabs(const T &v1, const T &v2) { @@ -57,8 +64,9 @@ } } // !tools - // environment herarchy - // not used yet + /*! + ** \brief Top of environment hierarchy. + */ template <class Exact> struct env: public mlc_hierarchy::any<Exact> { @@ -95,7 +103,33 @@ const im_type &im_; }; + /*! + ** \brief Environment containing point. + ** + ** Used for point substitution in other_point attribute. + */ + template <class I> + struct OtherPointEnv: public env<OtherPointEnv<I> > + { + typedef abstract::image<I> im_type; + +// OtherImageEnv(const abstract::image<I> &im): im_(im) +// {}; + + const oln_point_type(I) &getPoint(const oln_point_type(I) &p) const + { + return p; + } + +// protected: +// const im_type &im_; + }; + // the traits fwd declaration + /*! + ** Traits for attributes information. + ** \param T: exact type of the attribute. + */ template <class T> struct attr_traits; @@ -173,9 +207,9 @@ /*! ** \brief >= operator implementation. ** - ** This is an implementation of the >= operator. override this + ** This is an implementation of the >= operator. Override this ** method to provide a new implementation of this operator. - ** This method SHOULDN'T be called. + ** \warning This method SHOULDN'T be called. */ bool ge_impl(const lambda_type &lambda) const { @@ -191,49 +225,88 @@ | card | *-----------*/ + /*! + ** \brief Cardinal attribute. + ** + ** It is equivalent to an area in 2d, and a volume in 3D. + */ template <class T = unsigned, class Exact = mlc::final> class card_type: public attribute<mlc_2_exact_vt_type(card_type, T, Exact)> { public: - typedef card_type<T, Exact> self_type; + typedef card_type<T, Exact> self_type; /*!< Self type of the class. */ attr_type_decl(self_type); + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ card_type() { }; + /*! + ** \brief Ctor from a lambda_type value. + */ card_type(const lambda_type &lambda): value_(lambda) { }; + /*! + ** \brief Ctor from a point and an image. + ** + ** Every parameters are useless. + */ template <class I> card_type(const abstract::image<I>&, const oln_point_type(I)&, const env_type&): - value_(1) + value_(ntg_unit_val(value_type)) { }; + + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T be called. + */ void pe_impl(const self_type &rhs) { value_ += rhs.value_; }; + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the < operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T be called. + */ bool less_impl(const lambda_type &lambda) const { return value_ < lambda; }; + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the != operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T be called. + */ bool ne_impl(const lambda_type &lambda) const { return lambda != value_; }; protected: - value_type value_; - // const client_data_type &client_data; - // FIXME: client_data is usefull when attribute is computed from other data + value_type value_; /*!< Value used inside the class. */ }; @@ -241,95 +314,162 @@ | integral | *-----------*/ + /*! + ** \brief Integral attribute. + ** + ** It is equivalent to volume in 2D, and weight in 3D. + */ template <class T = unsigned, class Exact = mlc::final> class integral_type: public attribute<mlc_2_exact_vt_type(integral_type, T, Exact)> { public: - typedef integral_type<T, Exact> self_type; + typedef integral_type<T, Exact> self_type; /*!< Self type of the class. */ attr_type_decl(self_type); - // Ctors + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ integral_type() { }; - + /*! + ** \brief Ctor from a lambda_type value. + */ integral_type(const lambda_type &lambda): value_(lambda) { }; + /*! + ** \brief Ctor from a point and an image. + */ template <class I> integral_type(const abstract::image<I> &input, const oln_point_type(I) &p, const env_type &) : reflevel_(input[p]), - area_(1), - value_(1) + area_(ntg_unit_val(value_type)), + value_(ntg_unit_val(value_type)) { }; - /* - template <class I> - integral_type(const abstract::image<I> &input, - const oln_point_type(I) &p - ): - reflevel_(input[p]), - area_(1), - value_(1) - { - };*/ + // interface part + /*! + ** \brief Accessor to value_. + ** + ** Virtual method. + ** \see getValue_impl() + */ const value_type &getValue() const { mlc_dispatch(getValue)(); }; + /*! + ** \brief Accessor to the reference level. + ** + ** \see getReflevel_impl() + */ const value_type &getReflevel() const { mlc_dispatch(getReflevel)(); }; + /*! + ** \brief Accessor to the current area. + ** + ** \see getArea_impl() + */ const value_type &getArea() const { mlc_dispatch(getArea)(); }; // impl part + /*! + ** \brief Implementation of getValue(). + ** + ** Override this method in order to provide a new version of + ** getValue(). + ** + ** \warning Do not call this method, use getValue() instead. + */ const value_type &getValue_impl() const { return value_; }; + /*! + ** \brief Implementation of getReflevel(). + ** + ** Override this method in order to provide a new version of + ** getReflevel(). + ** + ** \warning Do not call this method, use getReflevel() instead. + */ const value_type &getReflevel_impl() const { return reflevel_; }; + /*! + ** \brief Implementation of getArea(). + ** + ** Override this method in order to provide a new version of + ** getArea(). + ** + ** \warning Do not call this method, use getArea() instead. + */ const value_type &getArea_impl() const { return area_; }; + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ void pe_impl(const self_type &rhs) { value_ += rhs.getValue() + area_ * tools::diffabs(reflevel_, rhs.getReflevel()); area_ += rhs.getArea(); }; + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool less_impl(const lambda_type &lambda) const { return value_ < lambda; }; + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool ne_impl(const lambda_type &lambda) const { return lambda != value_; }; protected: - value_type reflevel_; - value_type area_; - value_type value_; + value_type reflevel_; ///< Reference level. + value_type area_; ///< Current area. + value_type value_; ///< Current value (deduced from area and level). }; /*-------------------* @@ -340,7 +480,7 @@ ** ** \brief Metaclass used to change attribute behavior. ** - ** This class do the same job the its Dad parameter, but force it + ** This class do the same job that its Dad parameter, but force it ** to work on other data. */ template <class Dad, class I, class Exact = mlc::final> @@ -387,10 +527,67 @@ }; }; + /*--------------* + | other_point | + *------------*/ +// /*! +// ** \class other_point +// ** +// ** \brief Metaclass used to change attribute behavior. +// ** +// ** This class do the same job that its Dad parameter, but force it +// ** to work on other data. +// */ +// template <class Dad, class I, class Exact = mlc::final> +// class other_point: +// public change_exact<Dad, typename mlc::exact_vt<other_point<Dad, I, Exact>, Exact>::ret >::ret +// { +// public: +// typedef other_image<Dad, I, Exact> self_type; /*< Self type of the class.*/ +// typedef typename abstract::image<mlc_exact_type(I)> im_type; /*< Type of substituted image.*/ +// attr_type_decl(self_type); +// typedef typename change_exact<Dad, +// typename mlc::exact_vt<other_point<Dad, I, Exact>, +// Exact>::ret >::ret super_type; /*< Mother class type.*/ + +// /*! +// ** \brief Constructor. +// ** +// ** Dispatch to Dad constructor. +// */ +// other_point(): super_type() +// { +// }; + +// /*! +// ** \brief lambda_type Constructor. +// ** +// ** Dispatch to Dad constructor. +// */ +// other_point(const lambda_type &lambda): super_type(lambda) +// { +// }; + +// /*! +// ** \brief Image Constructor. +// ** +// ** Dispatch to Dad constructor but substitute image argument with +// ** the image contained in the environment. +// */ +// template <typename IM> +// other_point(const abstract::image<IM> &im, +// const oln_point_type(I) &p, +// const env_type &e): super_type(im, e.getPoint(p), e) +// { +// }; +// }; + /*-----------* | height | *-----------*/ - + /*! + ** \brief Attribute working on height between components. + */ template <class T = unsigned, class Exact = mlc::final> class height_type: public attribute<mlc_2_exact_vt_type(height_type, T, Exact)> @@ -399,10 +596,19 @@ typedef height_type<T, Exact> self_type; attr_type_decl(self_type); + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ height_type() { }; + /*! + ** \brief Ctor from a lambda_type value. + */ height_type(const lambda_type &lambda): value_(lambda), min_(ntg_zero_val(value_type)), @@ -410,6 +616,9 @@ { }; + /*! + ** \brief Ctor from a point and an image. + */ template <class I> height_type(const abstract::image<I> &input, const oln_point_type(I) &p, @@ -420,27 +629,62 @@ { }; - + /*! + ** \brief Accessor to min value. + ** + ** Virtual method. + ** \see getMin_impl() + */ const value_type &getMin() const { mlc_dispatch(getMin)(); }; + /*! + ** \brief Accessor to max value. + ** + ** Virtual method. + ** \see getMax_impl() + */ const value_type &getMax() const { mlc_dispatch(getMax)(); }; + // impl part + /*! + ** \brief Implementation of getMin(). + ** + ** Override this method in order to provide a new version of + ** getMin(). + ** + ** \warning Do not call this method, use getMin() instead. + */ const value_type &getMin_impl() const { return min_; }; + /*! + ** \brief Implementation of getMax(). + ** + ** Override this method in order to provide a new version of + ** getMax(). + ** + ** \warning Do not call this method, use getMax() instead. + */ const value_type &getMax_impl() const { return max_; }; + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ void pe_impl(const height_type &rhs) { min_ = ntg::min(min_, rhs.getMin()); @@ -448,43 +692,80 @@ value_ = max_ - min_; }; + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool less_impl(const lambda_type &lambda) const { return value_ < lambda; }; + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool ne_impl(const lambda_type &lambda) const { return lambda != value_; }; protected: - value_type value_; - value_type min_; - value_type max_; + value_type value_; ///< Current value. + value_type min_; ///< Current minimum. + value_type max_; ///< Current maximum. }; /*-----------* | maxvalue | *-----------*/ - + /*! + ** \brief Max value attribute. + ** \param T: data type. + ** \param Exact: the exact type. + */ template <class T = unsigned, class Exact = mlc::final> class maxvalue_type: public attribute<mlc_2_exact_vt_type(maxvalue_type, T, Exact)> { public: - typedef maxvalue_type<T, Exact> self_type; + typedef maxvalue_type<T, Exact> self_type; ///< Self type of the class. attr_type_decl(self_type); + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ maxvalue_type() { }; + /*! + ** \brief Ctor from a lambda_type value. + ** + ** \arg lambda: value of the attribute. + */ maxvalue_type(const lambda_type &lambda): value_(lambda) { }; + /*! + ** \brief Ctor from a point and an image. + ** + ** \param I: image exact type. + ** + ** \arg input: input image. + ** \arg p: point to consider in the image. + */ template <class I> maxvalue_type(const abstract::image<I> &input, const oln_point_type(I) &p, @@ -493,40 +774,79 @@ { }; + /*! + ** \brief Accessor to value_. + ** + ** Virtual method. + ** \see getValue_impl() + */ const value_type &getValue() const { mlc_dispatch(getValue)(); }; + /*! + ** \brief Implementation of getValue(). + ** + ** Override this method in order to provide a new version of + ** getValue(). + ** + ** \warning Do not call this method, use getValue() instead. + */ const value_type &getValue_impl() const { return value_; }; + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ void pe_impl(const maxvalue_type &rhs) { value_ = ntg::max(value_, rhs.getValue()); }; + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool less_impl(const lambda_type &lambda) const { return value_ < lambda; }; + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool ne_impl(const lambda_type &lambda) const { return lambda != value_; }; protected: - value_type value_; + value_type value_; ///< Value of the attribute. }; /*-----------* | minvalue | *-----------*/ - + /*! + ** \brief Min value attribute. + ** \param T: data type. + ** \param Exact: the exact type. + */ template <class T = unsigned, class Exact = mlc::final> class minvalue_type: public attribute<mlc_2_exact_vt_type(minvalue_type, T, Exact)> @@ -535,14 +855,33 @@ typedef minvalue_type<T, Exact> self_type; attr_type_decl(self_type); + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ minvalue_type() { }; + /*! + ** \brief Ctor from a lambda_type value. + ** + ** \arg lambda: value of the attribute. + */ minvalue_type(const lambda_type &lambda): value_(lambda) { }; + /*! + ** \brief Ctor from a point and an image. + ** + ** \param I: image exact type. + ** + ** \arg input: input image. + ** \arg p: point to consider in the image. + */ template <class I> minvalue_type(const abstract::image<I> &input, const oln_point_type(I) &p, @@ -551,62 +890,117 @@ { }; + /*! + ** \brief Accessor to value_. + ** + ** Virtual method. + ** \see getValue_impl() + */ const value_type &getValue() const { mlc_dispatch(getValue)(); }; + /*! + ** \brief Implementation of getValue(). + ** + ** Override this method in order to provide a new version of + ** getValue(). + ** + ** \warning Do not call this method, use getValue() instead. + */ const value_type &getValue_impl() const { return value_; }; + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ void pe_impl(const minvalue_type &rhs) { value_ = ntg::min(value_, rhs.getValue()); }; + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool less_impl(const lambda_type &lambda) const { return value_ > lambda; }; + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool ne_impl(const lambda_type &lambda) const { return lambda != value_; }; protected: - value_type value_; + value_type value_; ///< Value of the attribute. }; /*-----------* | ball | *-----------*/ - + /*! + ** \brief Ball attribute. + ** \param I: exact type of images to process. + ** \param Exact: the exact type. + */ template <class I, class Exact = mlc::final> class ball_type: public attribute<mlc_2_exact_vt_type(ball_type, I, Exact)> { public: - typedef ball_type<I, Exact> self_type; + typedef ball_type<I, Exact> self_type; ///< Self type of the class. attr_type_decl(self_type); - typedef abstract::image<mlc_exact_type(I)> im_type; - typedef oln_point_type(im_type) point_type; - typedef oln_dpoint_type(im_type) dpoint_type; - typedef std::vector<point_type> pts_type; - typedef typename pts_type::const_iterator cst_iter_type; + typedef abstract::image<mlc_exact_type(I)> im_type; ///< Image type. + typedef oln_point_type(im_type) point_type; ///< Point type associated to im_type. + typedef oln_dpoint_type(im_type) dpoint_type; ///< Dpoint type associated to im_type. + typedef std::vector<point_type> pts_type; ///< Point vector type. + typedef typename pts_type::const_iterator cst_iter_type; ///< const iterator on Point vector. + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ ball_type() { }; + /*! + ** \brief Ctor from a lambda_type value. + ** + ** \arg lambda: value of the attribute. + */ ball_type(const lambda_type &lambda): value_(lambda), pts_() { }; + /*! + ** \brief Ctor from a point and an image. + ** + ** \arg p: point to consider in the image. + */ ball_type(const im_type&, const point_type &p, const env_type &) : value_(ntg_zero_val(value_type)), pts_() @@ -614,28 +1008,63 @@ pts_.push_back(p); }; + /*! + ** \brief Accessor to value_. + ** + ** Virtual method. + ** \see getValue_impl() + */ const value_type &getValue() const { mlc_dispatch(getValue)(); }; + /*! + ** \brief Accessor to pts_. + ** + ** Virtual method. + ** \see getPts_impl() + */ const pts_type &getPts() const { mlc_dispatch(getPts)(); }; // impl + /*! + ** \brief Implementation of getValue(). + ** + ** Override this method in order to provide a new version of + ** getValue(). + ** + ** \warning Do not call this method, use getValue() instead. + */ const value_type &getValue_impl() const { return value_; }; + /*! + ** \brief Implementation of getValue(). + ** + ** Override this method in order to provide a new version of + ** getPts(). + ** + ** \warning Do not call this method, use getPts() instead. + */ const pts_type &getPts_impl() const { return pts_; }; + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ void pe_impl(const ball_type &rhs) { value_type last = value_; @@ -658,19 +1087,33 @@ value_ = ntg::max(value_, rhs.getValue()); }; + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool less_impl(const lambda_type &lambda) const { return value_ < lambda; }; + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool ne_impl(const lambda_type &lambda) const { return lambda != value_; }; protected: - value_type value_; - pts_type pts_; + value_type value_; ///< Value of the attribute. + pts_type pts_; ///< List of point in the ball. }; @@ -678,22 +1121,37 @@ /*-----------* | dist | *-----------*/ - + /*! + ** \brief Dist attribute. + ** \param I: exact type of images to process. + ** \param Exact: the exact type. + */ template <class I, class Exact = mlc::final> class dist_type: public attribute<mlc_2_exact_vt_type(dist_type, I, Exact)> { public: - typedef dist_type<I, Exact> self_type; + typedef dist_type<I, Exact> self_type; ///< Self type of the class. attr_type_decl(self_type); - typedef abstract::image<mlc_exact_type(I)> im_type; - typedef oln_point_type(im_type) point_type; - typedef oln_dpoint_type(im_type) dpoint_type; + typedef abstract::image<mlc_exact_type(I)> im_type; ///< Image type. + typedef oln_point_type(im_type) point_type; ///< Point type associated to im_type. + typedef oln_dpoint_type(im_type) dpoint_type; ///< Dpoint type associated to im_type. + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ dist_type() { }; + /*! + ** \brief Ctor from a point and an image. + ** + ** \arg p: point to consider in the image. + */ dist_type(const im_type&, const point_type &p, const env_type &) : @@ -702,31 +1160,71 @@ { }; + /*! + ** \brief Accessor to value_. + ** + ** Virtual method. + ** \see getValue_impl() + */ const value_type &getValue() const { mlc_dispatch(getValue)(); }; + /*! + ** \brief Ctor from a lambda_type value. + ** + ** \arg lambda: value of the attribute. + */ dist_type(const lambda_type lambda): value_(lambda) { }; + /*! + ** \brief Accessor to center_. + ** + ** Virtual method. + ** \see getCenter_impl() + */ const point_type &getCenter() const { mlc_dispatch(getCenter)(); }; // impl + /*! + ** \brief Implementation of getCenter(). + ** + ** Override this method in order to provide a new version of + ** getCenter(). + ** + ** \warning Do not call this method, use getCenter() instead. + */ const point_type &getCenter_impl() const { return center_; }; + /*! + ** \brief Implementation of getValue(). + ** + ** Override this method in order to provide a new version of + ** getValue(). + ** + ** \warning Do not call this method, use getValue() instead. + */ const value_type &getValue_impl() const { return value_; }; + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ void pe_impl(const dist_type &rhs) { value_type last = value_; @@ -740,19 +1238,33 @@ value_ = ntg::max(value_, rhs.getValue()); }; + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool less_impl(const lambda_type &lambda) const { return value_ < lambda; }; + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool ne_impl(const lambda_type &lambda) const { return value_ != lambda; }; protected: - value_type value_; - point_type center_; + value_type value_; ///< Current value of the attribute. + point_type center_; ///< Center of the attribute. }; @@ -761,24 +1273,39 @@ /*-----------* | cube | *-----------*/ - + /*! + ** \brief Cube attribute. + ** \param I: exact type of images to process. + ** \param Exact: the exact type. + */ template <class I, class Exact = mlc::final> class cube_type: public attribute<mlc_2_exact_vt_type(cube_type, I, Exact)> { public: - typedef cube_type<I, Exact> self_type; + typedef cube_type<I, Exact> self_type; ///< Self type of the class. attr_type_decl(self_type); - typedef abstract::image<mlc_exact_type(I)> im_type; - typedef oln_point_type(im_type) point_type; - typedef oln_dpoint_type(im_type) dpoint_type; + typedef abstract::image<mlc_exact_type(I)> im_type; ///< Image type. + typedef oln_point_type(im_type) point_type; ///< Point type associated to im_type. + typedef oln_dpoint_type(im_type) dpoint_type; ///< Dpoint type associated to im_type. enum {dim = point_traits<point_type>::dim}; + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ cube_type() { } + /*! + ** \brief Ctor from a lambda_type value. + ** + ** \arg lambda: value of the attribute. + */ cube_type(const lambda_type &lambda): mins_(dim), maxs_(dim), @@ -791,6 +1318,11 @@ } }; + /*! + ** \brief Ctor from a point and an image. + ** + ** \arg p: point to consider in the image. + */ cube_type(const im_type&, const point_type &p, const env_type &): @@ -800,29 +1332,68 @@ mins_[i] = maxs_[i] = p.nth(i); } + /*! + ** \brief Accessor to minimums. + ** + ** Virtual method. + ** \arg i: index of the minimum wanted. + ** \return the i th minimum. + ** \see getMin_impl() + */ int getMin(int i) const { mlc_dispatch(getMin)(i); }; + /*! + ** \brief Accessor to maximums. + ** + ** Virtual method. + ** \arg i: index of the minimum wanted. + ** \return the i th maximum. + ** \see getMax_impl() + */ int getMax(int i) const { mlc_dispatch(getMax)(i); }; // impl + /*! + ** \brief Implementation of getMin(int i). + ** + ** Override this method in order to provide a new version of + ** getMin(int i). + ** + ** \warning Do not call this method, use getMin() instead. + */ int getMin_impl(int i) const { precondition(i < dim); return mins_[i]; }; + /*! + ** \brief Implementation of getMax(int i). + ** + ** Override this method in order to provide a new version of + ** getMax(int i). + ** + ** \warning Do not call this method, use getMax() instead. + */ int getMax_impl(int i) const { precondition(i < dim); return maxs_[i]; }; + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ void pe_impl(const cube_type &rhs) { for (int i = 0; i < dim; ++i) @@ -836,11 +1407,25 @@ value_ = maxs_[i] - mins_[i]; } + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool less_impl(const lambda_type &lambda) const { return value_ < lambda; } + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool ne_impl(const lambda_type &lambda) const { return value_ != lambda; @@ -857,18 +1442,28 @@ /*------* | box | *-----*/ + /*! + ** \brief Box attribute. + ** \param I: exact type of images to process. + ** \param Exact: the exact type. + */ template <class I, class Exact = mlc::final> class box_type: public attribute<mlc_2_exact_vt_type(box_type, I, Exact)> { public: - typedef box_type<I, Exact> self_type; + typedef box_type<I, Exact> self_type; ///< Self type of the class. attr_type_decl(self_type); - typedef abstract::image<mlc_exact_type(I)> im_type; - typedef oln_point_type(im_type) point_type; - typedef oln_dpoint_type(im_type) dpoint_type; + typedef abstract::image<mlc_exact_type(I)> im_type; ///< Image type. + typedef oln_point_type(im_type) point_type; ///< Point type associated to im_type. + typedef oln_dpoint_type(im_type) dpoint_type; ///< Dpoint type associated to im_type. enum {dim = point_traits<point_type>::dim }; + /*! + ** \brief Ctor from a lambda_type value. + ** + ** \arg lambda: value of the attribute. + */ box_type(const lambda_type &lambda): maxs_(dim), mins_(dim) { for (int i = 0; i < dim; ++i) @@ -878,39 +1473,90 @@ } }; + /*! + ** \brief Basic Ctor. + ** + ** \warning After this call, the object is only instantiated + ** (not initialized). + */ box_type() { - } + }; + /*! + ** \brief Ctor from a point and an image. + ** + ** \arg p: point to consider in the image. + */ box_type(const im_type&, const point_type &p, const env_type &): maxs_(dim), mins_(dim) { for (int i = 0; i < dim; ++i) mins_[i] = maxs_[i] = p.nth(i); - } + }; + /*! + ** \brief Accessor to minimums. + ** + ** Virtual method. + ** \arg i: index of the minimum wanted. + ** \return the i th minimum. + ** \see getMin_impl() + */ value_type getMin(int i) const { mlc_dispatch(getMin)(i); }; + + /*! + ** \brief Accessor to maximums. + ** + ** Virtual method. + ** \arg i: index of the minimum wanted. + ** \return the i th maximum. + ** \see getMax_impl() + */ value_type getMax(int i) const { mlc_dispatch(getMax)(i); }; // impl + /*! + ** \brief Accessor to minimums. + ** + ** Virtual method. + ** \arg i: index of the minimum wanted. + ** \return the i th minimum. + ** \see getMin_impl() + */ value_type getMin_impl(int i) const { precondition(i < point_traits<point_type>::dim); return mins_[i]; }; + /*! + ** \brief Accessor to maximums. + ** + ** Virtual method. + ** \arg i: index of the minimum wanted. + ** \return the i th maximum. + ** \see getMax_impl() + */ value_type getMax_impl(int i) const { precondition(i < point_traits<point_type>::dim); return maxs_[i]; }; + /*! + ** \brief += operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ void pe_impl(const box_type &rhs) { for (int i = 0; i < dim; ++i) @@ -920,6 +1566,13 @@ } } + /*! + ** \brief < operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool less_impl(const lambda_type &lambda) const { for (int i = 0; i < dim; ++i) @@ -928,6 +1581,13 @@ return true; } + /*! + ** \brief != operator implementation. + ** + ** This is an implementation of the += operator. Override this + ** method to provide a new implementation of this operator. + ** \warning This method SHOULDN'T directly be called. + */ bool ne_impl(const lambda_type &lambda) const { for (int i = 0; i < dim; ++i) @@ -937,12 +1597,12 @@ }; protected: - std::vector<value_type> maxs_; - std::vector<value_type> mins_; + std::vector<value_type> maxs_; ///< List of minimums. + std::vector<value_type> mins_; ///< List of maximums. }; /*------------------------- - | traits specialisations | + | traits specializations | \------------------------*/ @@ -1039,6 +1699,20 @@ typedef attr_lambda_type(super_type) lambda_type; typedef OtherImageEnv<I> env_type; }; + +// // other_point traits +// template <class Dad, class I, class Exact> +// struct attr_traits<other_point<Dad, I, Exact> > +// { +// //typedef typename change_exact<Dad, other_image<Dad, I, Exact> >::ret super_type; +// typedef typename change_exact<Dad, +// typename mlc::exact_vt<other_point<Dad, I, Exact>, +// Exact>::ret>::ret super_type; +// typedef attr_value_type(super_type) value_type; +// typedef attr_lambda_tye(super_type) lambda_type; +// typedef OtherPointEnv<I> env_type; +// }; + // traits for other_image derivation /*! @@ -1051,6 +1725,18 @@ { typedef integral_type<T, NewExact> ret; }; + +// /*! +// ** \brief Change the exact type of an attribute. +// ** +// ** Traits to change dist_type exact type. +// */ +// template <class NewExact, class OldExact, class T> +// struct change_exact<dist_type<T, OldExact>, NewExact> +// { +// typedef dist_type<T, NewExact> ret; +// }; + } // !morpho } //!oln Index: olena/oln/morpho/attribute_closing_opening_map.hh --- olena/oln/morpho/attribute_closing_opening_map.hh Mon, 08 Mar 2004 08:12:15 +0100 palma_g (oln/j/49_attribute_ 1.3 600) +++ olena/oln/morpho/attribute_closing_opening_map.hh Wed, 10 Mar 2004 12:05:48 +0100 palma_g (oln/j/49_attribute_ 1.3 600) @@ -46,26 +46,36 @@ { namespace morpho { + /*! + ** \brief oln::morpho::slow namespace + ** + ** In this namespace you will find algorithm slower than those you + ** can find in oln::morpho::fast, but with less memory needs. + */ namespace slow { /*! Attribute closing using map. Smaller memory usage, but - * slower computation than the attribute_closing_opening - * - * See "Fast morphological attribute operations using Tarjan's union-find - * algorithm" by Michael H. F. Wilkinson and Jos B. T. M. Roerdink + ** slower computation than the attribute_closing_opening + ** + ** See "Fast morphological attribute operations using Tarjan's union-find + ** algorithm" by Michael H. F. Wilkinson and Jos B. T. M. Roerdink + ** + ** \param I: image exact type. + ** \param D: attribute exact type. + ** \param Env: type of environment. */ template <class I, class D, class Env = morpho::NullEnv> struct f_tarjan_map { public: - typedef abstract::image<I> input_type; - typedef oln_concrete_type(I) img_type; + typedef abstract::image<I> input_type; ///< Image type (abstract). + typedef oln_concrete_type(I) img_type; ///< Image type (concrete). - typedef oln_point_type(input_type) point_type; - typedef oln_value_type(input_type) value_type; - typedef typename mute<input_type, point_type>::ret parent_type; - typedef typename mute<input_type, bool>::ret is_proc_type; - typedef attr_lambda_type(D) lambda_type; + typedef oln_point_type(input_type) point_type; ///< Associated point type. + typedef oln_value_type(input_type) value_type; ///< Value type fo the image. + typedef typename mute<input_type, point_type>::ret parent_type; ///< Image of points. + typedef typename mute<input_type, bool>::ret is_proc_type; ///< Image of bool. + typedef attr_lambda_type(D) lambda_type; ///< dTthreshold type. // e.g., // when I is image2d<int_u8> and D is area_type, we've got: @@ -77,13 +87,26 @@ // | lambda_type | int | // +--------------+------------------+ + /*! + ** \brief Perform an attribute opening/closing. + ** + ** \param N: exact type of neighborhood + ** + ** \arg is_closing: choose between closing and opening. + ** \arg input: input image. + ** \arg ng: neighborhood to use. + ** \arg lambda: threshold. + ** \arg env: environment. + */ template <class N> f_tarjan_map(bool is_closing, const input_type& input, const abstract::neighborhood<N>& ng, const lambda_type& lambda, const Env & env = Env()); - + /*! + ** \brief return the result of the opening/closing. + */ oln_concrete_type(I) res() { @@ -91,43 +114,71 @@ } protected: + /*! + ** \brief Return the value of an inactive point. + */ static const point_type inactive(); + /*! + ** \brief Return the value of an active point. + */ static const point_type active(); + /*! + ** \brief Make a new component from a point. + ** \arg x: root of the component. + */ void make_set(const point_type& x); + /*! + ** \brief link two components + ** \arg x: a point of the first component. + ** \arg y: a point of the second component. + */ void link(const point_type& x, const point_type& y); + /*! + ** \brief find the root of a component. + ** \arg x: a point of the component. + */ point_type find_root(const point_type& x); + /*! + ** \brief check if two components are equivalent. + */ bool equiv(const point_type& x, const point_type& y) const; + + /*! + ** \brief link two components if they have to be linked + ** \arg n: a point of the first component. + ** \arg p: a point of the second component. + */ void do_union(const point_type& n, const point_type& p); - const bool is_closing; - const input_type& input; - lambda_type lambda; - parent_type parent; - is_proc_type is_proc; - img_type output; - std::map<point_type, D, oln::internal::default_less<point_type> > auxdata; - Env env; + const bool is_closing; ///< Do you want a closing or an openng ? + const input_type& input; ///< Input image. + lambda_type lambda; ///< Trheshold. + parent_type parent; ///< Give a parent of a point. + is_proc_type is_proc; ///< Tell if a point has already been preceded + img_type output; ///< Image to store the result + std::map<point_type, D, oln::internal::default_less<point_type> > auxdata; ///< Map to store attributes. + Env env; ///< The envronment. }; /*! Attribute closing using map. Smaller memory usage, but - * slower computation than the attribute_closing_opening - * - * See "Fast morphological attribute operations using Tarjan's union-find - * algorithm" by Michael H. F. Wilkinson and Jos B. T. M. Roerdink + ** slower computation than the attribute_closing_opening + ** + ** See "Fast morphological attribute operations using Tarjan's union-find + ** algorithm" by Michael H. F. Wilkinson and Jos B. T. M. Roerdink */ template <class D, class I, class N> oln_concrete_type(I) @@ -145,9 +196,8 @@ return t.res(); } - /*! Some macro to declare friendly function for different attributes - * opening/closing - */ +// Some macro to declare friendly function for different attributes +// opening/closing # define xxx_opening_map_decl(T) \ template <class I, class N> \ oln_concrete_type(I) \ @@ -194,23 +244,506 @@ return tarjan_map<T##_type<I>, I, N>(true, input, ng, lambda, attr_env_type(T##_type<I>)()); \ } - xxx_opening_map_decl(card); + /*! + ** \brief Perform a cardinal closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::card_closing(im1, oln::neighb_c4(), 200); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_card_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_card_closing.png + ** \image latex oln_morpho_fast_card_closing.png + ** + */ xxx_closing_map_decl(card); - xxx_opening_map_decl(integral); + + /*! + ** \brief Perform a cardinal opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::card_opening(im1, oln::neighb_c4(), 200); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_card_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_card_opening.png + ** \image latex oln_morpho_fast_card_opening.png + ** + */ + xxx_opening_map_decl(card); + + /*! + ** \brief Perform an integral closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::integral_closing(im1, oln::neighb_c4(), 200); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_integral_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_integral_closing.png + ** \image latex oln_morpho_fast_integral_closing.png + ** + */ xxx_closing_map_decl(integral); + + /*! + ** \brief Perform an integral opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::integral_opening(im1, oln::neighb_c4(), 200); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_integral_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_integral_opening.png + ** \image latex oln_morpho_fast_integral_opening.png + ** + */ + xxx_opening_map_decl(integral); + + /*! + ** \brief Perform a height closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::height_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_height_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_height_opening.png + ** \image latex oln_morpho_fast_height_opening.png + ** + */ xxx_opening_map_decl(height); + + /*! + ** \brief Perform a height closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::height_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_height_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_height_closing.png + ** \image latex oln_morpho_fast_height_closing.png + ** + */ xxx_closing_map_decl(height); - xxx_opening_map_decl(maxvalue); + + + /*! + ** \brief Perform a maxvalue closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::maxvalue_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_maxvalue_closing.png.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_maxvalue_closing.png + ** \image latex oln_morpho_fast_maxvalue_closing.png + ** + */ xxx_closing_map_decl(maxvalue); + + /*! + ** \brief Perform a maxvalue opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::maxvalue_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_maxvalue_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_maxvalue_opening.png + ** \image latex oln_morpho_fast_maxvalue_opening.png + ** + */ + xxx_opening_map_decl(maxvalue); + + /*! + ** \brief Perform a minvalue opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::minvalue_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_minvalue_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_minvalue_opening.png + ** \image latex oln_morpho_fast_minvalue_opening.png + ** + */ xxx_opening_map_decl(minvalue); + + /*! + ** \brief Perform a minvalue closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::minvalue_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_minvalue_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_minvalue_closing.png + ** \image latex oln_morpho_fast_minvalue_closing.png + ** + */ xxx_closing_map_decl(minvalue); + + /*! + ** \brief Perform a ball opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::ball_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_ball_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_ball_opening.png + ** \image latex oln_morpho_fast_ball_opening.png + ** + */ xxx_opening_im_map_decl(ball); + + /*! + ** \brief Perform a ball closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::ball_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_ball_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_ball_closing.png + ** \image latex oln_morpho_fast_ball_closing.png + ** + */ xxx_closing_im_map_decl(ball); + + /*! + ** \brief Perform a dist opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::dist_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_dist_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_dist_opening.png + ** \image latex oln_morpho_fast_dist_opening.png + ** + */ xxx_opening_im_map_decl(dist); + + /*! + ** \brief Perform a dist closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::dist_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_dist_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_dist_closing.png + ** \image latex oln_morpho_fast_dist_closing.png + ** + */ xxx_closing_im_map_decl(dist); + + /*! + ** \brief Perform a cube closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::cube_closing(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_cube_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_cube_closing.png + ** \image latex oln_morpho_fast_cube_closing.png + ** + */ xxx_closing_im_map_decl(cube); + + /*! + ** \brief Perform a cube opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::cube_opening(im1, oln::neighb_c4(), 5); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_cube_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_cube_opening.png + ** \image latex oln_morpho_fast_cube_opening.png + ** + */ xxx_opening_im_map_decl(cube); + + /*! + ** \brief Perform a box closing. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** ntg::vec<2, unsigned, mlc::final> lambda; + ** lambda[0] = lambda[1] = 50; + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::box_closing(im1, oln::neighb_c4(), lambda); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_box_closing.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_box_closing.png + ** \image latex oln_morpho_fast_box_closing.png + ** + */ xxx_closing_im_map_decl(box); + + /*! + ** \brief Perform a box opening. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/morpho/attribute_closing_opening_map.hh> + ** #include <oln/level/compare.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** int main() + ** { + ** typedef oln::image2d<ntg::int_u8> im_type; + ** ntg::vec<2, unsigned, mlc::final> lambda; + ** lambda[0] = lambda[1] = 50; + ** im_type im1(oln::load(IMG_IN "lena128.pgm")); + ** im1 = oln::morpho::slow::box_opening(im1, oln::neighb_c4(), lambda); + ** oln::save(im1, IMG_OUT "oln_morpho_fast_box_opening.ppm"); + ** return 0; + ** } + ** \endcode + ** \image html lena128.png + ** \image latex lena128.png + ** => + ** \image html oln_morpho_fast_box_opening.png + ** \image latex oln_morpho_fast_box_opening.png + ** + */ xxx_opening_im_map_decl(box); Index: olena/tests/morpho/tests/attribute --- olena/tests/morpho/tests/attribute Mon, 16 Feb 2004 19:06:24 +0100 palma_g (oln/j/51_attribute 1.2 644) +++ olena/tests/morpho/tests/attribute Mon, 08 Mar 2004 17:26:07 +0100 palma_g (oln/j/51_attribute 1.2 644) @@ -28,7 +28,7 @@ bool fail(false); typedef image2d<int_u8> img_type; - typedef oln::morpho::area_type<unsigned> area_type; + typedef oln::morpho::cart_type<unsigned> area_type; const area_type::lambda_type area = 100; const neighborhood2d nb = neighb_c8(); // const oln::morpho::NullEnv env; @@ -43,8 +43,8 @@ std::cerr << "testing tarjan_map..." << std::endl; // lena_tst_closing = morpho::slow::tarjan_map<area_type,ntg::int_u8,img_type>(true, lena, nb, area, env); // lena_tst_opening= morpho::slow::tarjan_map<area_type,ntg::int_u8,img_type>(false, lena, nb, area, env); - lena_tst_closing = morpho::slow::area_closing(lena, nb, area); - lena_tst_opening = morpho::slow::area_opening(lena, nb, area); + lena_tst_closing = morpho::slow::card_closing(lena, nb, area); + lena_tst_opening = morpho::slow::card_opening(lena, nb, area); fail = fail || !level::is_equal(lena_sure_closing, lena_tst_closing)|| @@ -60,8 +60,8 @@ std::cerr << "fail:" << fail << std::endl; std::cerr << "testing area_closin and area_opeing..." << std::endl; - lena_tst_closing = morpho::fast::area_closing(lena, nb, area); - lena_tst_opening = morpho::fast::area_opening(lena, nb, area); + lena_tst_closing = morpho::fast::card_closing(lena, nb, area); + lena_tst_opening = morpho::fast::card_opening(lena, nb, area); fail = fail || !level::is_equal(lena_sure_closing, lena_tst_closing)|| !level::is_equal(lena_sure_opening, lena_tst_opening); Index: olena/tests/morpho/tests/attr_op_cl --- olena/tests/morpho/tests/attr_op_cl Mon, 08 Mar 2004 08:12:15 +0100 palma_g (oln/k/0_attr_op_cl 1.2 644) +++ olena/tests/morpho/tests/attr_op_cl Tue, 09 Mar 2004 15:20:21 +0100 palma_g (oln/k/0_attr_op_cl 1.2 644) @@ -73,6 +73,7 @@ test_op_cl(int_u8, cube, lena, 50); ntg::vec<2, unsigned, mlc::final> lambda; + lambda[0] = lambda[1] = 50; test_op_cl(int_u8, box, lena, lambda); return fail; Index: doc/ref/img_conv.pl --- doc/ref/img_conv.pl Tue, 24 Feb 2004 16:33:38 +0100 palma_g (oln/k/6_img_conv.p 1.1 700) +++ doc/ref/img_conv.pl Wed, 10 Mar 2004 11:25:27 +0100 palma_g (oln/k/6_img_conv.p 1.1 700) @@ -31,7 +31,7 @@ opendir DIR, "$d" or die "Unable to open $d.\n"; foreach $file(readdir DIR) { - if ($file =~ /(.*)\.(pgm|ppm|ppgm|pppgm)$/) + if ($file =~ /(.*)\.(pgm|ppm|ppgm|pppgm|pbm)$/) { print "convert $d/$file to $o/$1.png\n"; system "convert $d/$file $o/$1.png"; Index: doc/ref/out/exdoc.config.in --- doc/ref/out/exdoc.config.in Mon, 08 Mar 2004 08:12:15 +0100 palma_g (oln/k/7_exdoc.conf 1.1 644) +++ doc/ref/out/exdoc.config.in Wed, 10 Mar 2004 15:18:31 +0100 palma_g (oln/k/7_exdoc.conf 1.1 644) @@ -4,7 +4,7 @@ TAG_CLOSE = endcode CAPTIONS = cxx # We want to run cxx on the extracted files (see line below) ALIAS cxx = @CXX@ # Here, cxx means g++ but you can choose other compilers - OPTIONS = @CXXFLAGS@ -I@top_srcdir@/integre -I@top_srcdir@/olena -I@top_srcdir@/metalic $1 -o $2 -DIMG_OUT=\"../img/\" -DIMG_IN=\"@top_srcdir@/olena/img/\" # tell how to use the soft, i.e. where to put input and output arguments (default if not overriden) ($1: input, $2: output) FIXME: $* should have explicit name, chek flags + OPTIONS = @CXXFLAGS_OPTIMIZE@ @CXXFLAGS_STRICT_ERRORS@ -I@top_srcdir@/integre -I@top_srcdir@/olena -I@top_srcdir@/metalic $1 -o $2 -DIMG_OUT=\"../img/\" -DIMG_IN=\"@top_srcdir@/olena/img/\" # tell how to use the soft, i.e. where to put input and output arguments (default if not overriden) ($1: input, $2: output) FIXME: $* should have explicit name, chek flags OUT = out # FIXME: should be obsolete EXT = cc # Extension of generated file STD_OUT_EXT = std # Extension of generated file standard output -- Giovanni Palma EPITA - promo 2005 - membre d'EpX - LRDE Mob. : +33 (0)6 60 97 31 74