
Index: olena/ChangeLog from Niels Van Vliet <niels@lrde.epita.fr> * olena/oln/level/compare.hh: Add comments. * olena/oln/level/connected.hh: Add comments. * olena/oln/level/fill.hh: Add comments. * olena/oln/level/invert.hh: Add comments. * olena/oln/level/lut.hh: Add comments. * olena/oln/level/set_level.hh: Add comments. * olena/oln/level/threshold.hh: Add comments. +2004-03-10 Niels Van Vliet <niels@lrde.epita.fr> + + * olena/oln/snakes/snakes_base.hh: Add comments. + * olena/oln/snakes/energies.hh: Add comments. + * olena/oln/snakes/greedy.hh: Add comments. + * olena/oln/snakes/node.hh: Add comments. + * olena/oln/snakes/segment.hh: Add comments. + * olena/oln/snakes/snakes_base.hh: Add comments. + * olena/oln/morpho/attribute_closing_opening.hh: Fix bug in doc. + * olena/oln/morpho/attribute_closing_opening_map.hh: Fix bug in doc. 2004-03-10 Giovanni Palma <giovanni@lrde.epita.fr> Index: olena/oln/level/cc.hh --- olena/oln/level/cc.hh Fri, 07 Nov 2003 17:26:19 +0100 burrus_n (oln/e/20_cc.hh 1.11.1.9 640) +++ olena/oln/level/cc.hh Thu, 11 Mar 2004 15:45:41 +0100 van-vl_n (oln/e/20_cc.hh 1.11.1.9 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 @@ -40,49 +40,75 @@ # include <oln/level/fill.hh> # include <oln/level/invert.hh> # include <oln/level/compare.hh> + # include <set> # include <list> # include <vector> +# include <ntg/core/macros.hh> +# include <mlc/is_a.hh> namespace oln { + /*! \namespace oln::level + ** \brief level namespace. + */ namespace level { // optional behavior for this algorithm. struct update_label; - /*=processing frontp_connected_component - * ns: level - * what: Connected Component. - * arg: const abstract::image<I>&, marker, IN, marker image - * arg: const abstract::neighborhood<E>&, se, IN, neighbourhood - * arg: numeric_value&, nb, IN, nb_label (optional) - * ret: typename mute<I, DestType>::ret - * doc: It removes the small (in area) connected components of the upper - * level sets of \var{input} using \var{se} as structural element. - * The implementation - * uses front propagation. - * see: level::connected_component - * ex: - * $ image2d<int_u8> light = load("light.pgm"); - * $ save(level::frontp_connected_component<int_u16>(light, win_c8p()), - * $ "out.pgm"); - * exi: light.pgm - * exo: out.pgm - * wontcompile: fixme - =*/ - - - // Number the connected components i.e label true. background(i.e - // label false) has the label 0; in the output - // FIXME: Should probably be turned into a class. + /*! \brief Processing frontp_connected_component extract + ** the connected components. + ** + ** It removes the small (in area) connected components of the upper + ** level sets of \var{input} using \var{se} as structural element. + ** + ** \ref The implementation uses front propagation. + ** + ** \pre the input must be a binary image. + ** + ** \arg input Image of markers. + ** \arg se Neighbourhood. + ** \arg nb_label Returns the number of label (optional). + ** + ** \return An image of type \a DestType. + ** + ** + ** \see level::connected_component + ** \todo FIXME: Should probably be turned into a class. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/level/cc.hh> + ** #include <ntg/all.hh> + ** #include <iostream> + ** + ** int main() + ** { + ** unsigned card; + ** oln::image2d<ntg::bin> light = oln::load(IMG_IN "face_se.pbm"); + ** save(oln::level::frontp_connected_component<ntg::int_u8>(light, + ** oln::neighb_c8(), + ** card), + ** IMG_OUT "oln_level_frontp_connected_component.pgm"); + ** std::cout << card << " connected components" << std::endl; + ** } + ** \endcode + ** \image html face_se.png + ** \image latex face_se.png + ** => + ** \image html oln_level_frontp_connected_component.png + ** \image latex oln_level_frontp_connected_component.png + */ + template <class DestType, class I, class E> typename mute<I, DestType>::ret frontp_connected_component(const abstract::image<I>& input, const abstract::neighborhood<E>& se, unsigned& nb_label) { - // FIXME: ensure the oln_value_type(I) is ntg::bin. + ntg_is_a(oln_value_type(I), ntg::binary)::ensure(); + typename mute<I, DestType>::ret output(input.size()); level::fill(output, 0); Index: olena/oln/level/compare.hh --- olena/oln/level/compare.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/31_compare.hh 1.8 640) +++ olena/oln/level/compare.hh Thu, 11 Mar 2004 15:45:41 +0100 van-vl_n (oln/31_compare.hh 1.8 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 @@ -34,6 +34,10 @@ namespace level { + /*! \brief Tests if all pixels of input1 are greater or equal than input2. + ** + ** \pre input1.size() == input2.size() + **/ template<class I1, class I2> inline bool is_greater_or_equal(const abstract::image<I1>& input1, @@ -47,6 +51,10 @@ return true; } + /*! \brief Tests if all pixels of input1 are greater than input2. + ** + ** \pre input1.size() == input2.size() + **/ template<class I1, class I2> inline bool is_greater(const abstract::image<I1>& input1, @@ -60,6 +68,10 @@ return true; } + /*! \brief Tests if all pixels of input1 are lower or equal than input2. + ** + ** \pre input1.size() == input2.size() + **/ template<class I1, class I2> inline bool is_lower_or_equal(const abstract::image<I1>& input1, @@ -73,6 +85,10 @@ return true; } + /*! \brief Tests if all pixel of input1 are lower than input2. + ** + ** \pre input1.size() == input2.size() + **/ template<class I1, class I2> inline bool is_lower(const abstract::image<I1>& input1, @@ -86,6 +102,11 @@ return true; } + + /*! \brief Tests if input1 is equal to input2. + ** + ** \pre input1.size() == input2.size() + **/ template<class I1, class I2> inline bool is_equal(const abstract::image<I1>& input1, Index: olena/oln/level/connected.hh --- olena/oln/level/connected.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/30_connected. 1.9.1.11 640) +++ olena/oln/level/connected.hh Thu, 11 Mar 2004 15:45:41 +0100 van-vl_n (oln/30_connected. 1.9.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 @@ -38,27 +38,24 @@ namespace level { - /*=processing connected_component - * ns: level - * what: Connected Component. - * arg: const abstract::image<I1>&, marker, IN, marker image - * arg: const abstract::neighborhood<E>&, se, IN, structural element - * ret: typename mute<I, DestType>::ret - * doc: It removes the small (in area) connected components of the upper - * level sets of \var{input} using \var{se} as structural element. The - * implementation comes from \emph{Cocquerez et Philipp, Analyse d'images, - * filtrages et segmentations} p.62. - * see: level::frontp_connected_component - * ex: - * $ image2d<int_u8> light = load("light.pgm"); - * $ save(level::connected_component<int_u8>(light, win_c8p()), "out.pgm"); - * exi: light.pgm - * exo: out.pgm - * wontcompile: fixme - =*/ - + /* \brief Processing connected_component extract the connected components. + ** + ** \arg: input image + ** \arg: Ng neighborhood + ** + ** \return Returns a labeled image + ** + ** It removes the small (in area) connected components of the upper + ** level sets of \var{input} using \var{se} as structural element. + ** + ** \ref The implementation comes from Cocquerez et Philipp, Analyse + ** d'images, filtrages et segmentations p.62. + ** + ** \see level::frontp_connected_component + ** \todo FIXME: The type of input shoud be a binary 2d image. + */ // Number the connected components i.e label true. background(i.e - // label false) has the label 0; This algorithm works only for 2D images + // label false) has the label 0; This algorithm works only for 2D images. template <class DestType, class I, class N> typename mute<I, DestType>::ret connected_component(const abstract::image<I>& input, Index: olena/oln/level/fill.hh --- olena/oln/level/fill.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/32_fill.hh 1.9 640) +++ olena/oln/level/fill.hh Thu, 11 Mar 2004 15:45:41 +0100 van-vl_n (oln/32_fill.hh 1.9 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 @@ -34,6 +34,8 @@ namespace level { + /*! \brief Fill the image with a value. + */ template <class I> oln_concrete_type(I) fill(abstract::image<I>& im, const oln_value_type(I)& val) Index: olena/oln/level/invert.hh --- olena/oln/level/invert.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/33_invert.hh 1.5.2.2.1.10 640) +++ olena/oln/level/invert.hh Thu, 11 Mar 2004 15:45:41 +0100 van-vl_n (oln/33_invert.hh 1.5.2.2.1.10 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 @@ -39,8 +39,11 @@ namespace level { - // ftors - + /*! \brief Fctor to invert a value + ** + ** \see invert. + ** \note FIXME: the specialisation is done within the class. + */ template<class T> struct f_invert : public std::unary_function<const ntg::value<T>&, T> { @@ -90,8 +93,7 @@ } }; - // procs - + /*! \brief Return the image inverted. */ template<class I> inline oln_concrete_type(I) invert(const abstract::image<I>& input) @@ -99,6 +101,7 @@ return apply(f_invert<oln_value_type(I)>(), input); } + /*! \brief Invert an image. */ template<class I> inline void invert_self(abstract::image<I>& input) Index: olena/oln/level/lut.hh --- olena/oln/level/lut.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/29_lut.hh 1.9 640) +++ olena/oln/level/lut.hh Thu, 11 Mar 2004 15:45:41 +0100 van-vl_n (oln/29_lut.hh 1.9 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,9 +36,20 @@ namespace level { - // few values -> new values - // otherwise -> id - + /*! \brief Look up table "id" version. + ** + ** If the value has not been set, return id (see the example). + ** + ** \see hlut_def + ** \verbatim + ** hlut<int> l; + ** + ** l.set(16, 64); + ** + ** cout << l(16) << "," // print 64, + ** << l(51) << endl; // print 51 + ** \endverbatim + */ template<class T, class T2 = T> class hlut { @@ -50,6 +61,11 @@ hlut() {} + /*! Register a value. + ** + ** \arg val Key. + ** \arg newval Value corresponding to the key. + */ hlut& set(const T& val, const T2& newval) { @@ -57,6 +73,10 @@ return *this; } + /*! Get the value corresponding to the key. + ** + ** Return the key if the key has not been set. + **/ const T2 operator()(const T& val) const { @@ -70,9 +90,23 @@ }; - // few values -> new values - // otherwise -> default value - + /*! \brief Look up table "default" version. + ** + ** If the value has not been set, return the default value. + ** \note The default value can be redefined. + ** + ** \see hlut_def + ** \verbatim + ** hlut_def<int> l; + ** + ** l.set(16, 64); + ** + ** cout << l(16) << "," // print "64," + ** << l(51) << endl; // print "0" + ** l.set_default(42); + ** cout << l(51) << endl; // print "42" + ** \endverbatim + */ template<class T, class T2 = T> class hlut_def { @@ -86,6 +120,11 @@ defaultval_ = T2(); } + /*! Register a value. + ** + ** \arg val Key. + ** \arg newval Value corresponding to the key. + */ hlut_def& set(const T& val, const T2& newval) { @@ -93,6 +132,7 @@ return *this; } + //! Set a default value. hlut_def& set_default(const T2& defaultval) { @@ -100,6 +140,10 @@ return *this; } + /*! Get the value corresponding to the key. + ** + ** Return defaultval_ if the key has not been set. + */ const T2 operator()(const T& val) const { Index: olena/oln/level/set_level.hh --- olena/oln/level/set_level.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/p/1_set_level. 1.9 640) +++ olena/oln/level/set_level.hh Thu, 11 Mar 2004 15:45:41 +0100 van-vl_n (oln/p/1_set_level. 1.9 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 @@ -35,6 +35,49 @@ namespace level { + + /*! + ** \brief Draw a line between two points in the image. + ** + ** \arg inout a 2d image. + ** \arg p1 A point in the image. + ** \arg p2 A point in the image (p1 and p2 can be swaped). + ** \arg level Value of the line. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/level/set_level.hh> + ** #include <ntg/all.hh> + ** + ** int main() + ** { + ** oln::image2d<ntg::int_u8> in = oln::load(IMG_IN "lena256.pgm"); + ** oln::coord R = in.nrows(); + ** oln::coord C = in.ncols(); + ** + ** //Draw the line + ** oln::level::set_level(in, + ** oln::point2d(R * 1/4, C* 1/2), + ** oln::point2d(R * 4/5, C* 7/8), + ** 0); + ** + ** + ** oln::box<oln::point2d> b; + ** b.add(oln::point2d(R * 1/6, C * 1/6)); + ** b.add(oln::point2d(R * 4/5, C * 1/3)); + ** + ** //Draw the box + ** oln::level::set_level(in, b, 255); + ** + ** save(in, IMG_OUT "oln_level_set_level.pgm"); + ** } + ** \endcode + ** \image html lena256.png + ** \image latex lena256.png + ** => + ** \image html oln_level_set_level.png + ** \image latex oln_level_set_level.png + */ template <class I> void set_level(abstract::image_with_dim<2,I>& inout, @@ -89,7 +132,10 @@ inout(iRow,iCol) = level; } - + /*! Draw a box in the image. + ** + ** \see set_level for an example. + */ template <class I, class BoxType> void set_level(abstract::image_with_dim<2,I>& inout, Index: olena/oln/level/threshold.hh --- olena/oln/level/threshold.hh Tue, 09 Sep 2003 13:53:41 +0200 palma_g (oln/f/15_threshold. 1.12 640) +++ olena/oln/level/threshold.hh Thu, 11 Mar 2004 15:45:41 +0100 van-vl_n (oln/f/15_threshold. 1.12 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 @@ -35,11 +35,42 @@ namespace level { - /* Threshold the value of the image. */ + /*! \brief Threshold the value of the image. + ** + ** \code + ** #include <oln/basics2d.hh> + ** #include <oln/level/threshold.hh> + ** #include <ntg/all.hh> + ** using namespace ntg; + ** int main() + ** { + ** oln::image2d<int_u8> in = oln::load(IMG_IN "lena256.pgm"); + ** int_u8 th = 127; + ** rgb_8 low = rgb_8(100, 0, 0); + ** rgb_8 height = rgb_8(0, 200, 255); + ** + ** oln::image2d<rgb_8> out + ** = apply(oln::level::threshold<int_u8, rgb_8 >(th, low, height), + ** in); + ** save(out, IMG_OUT "oln_level_threshold.ppm"); + ** } + ** \endcode + ** \image html lena256.png + ** \image latex lena256.png + ** => + ** \image html oln_level_threshold.png + ** \image latex oln_level_threshold.png + */ template<class Input, class Output, class Exact = mlc::final> class threshold : public std::unary_function<const Input&, Output> { public: + /*! \arg Threshold any value heigher or equal to this value will + ** return \a min. + ** \arg min Value returned if the input is smaller than threshold. + ** \arg max Value returned if the input is greater or equal to the + ** threshold. + */ threshold(const Input& threshold, const Output& min = ntg_min_val(Output), const Output& max = ntg_max_val(Output)) :