
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Make 2 x 1D convolution work again. * mln/linear/line_x2_convolve.hh: Rename as... * mln/linear/convolve_2x1d.hh: ...this. Revamp. * tests/linear/convolve_2x1d.cc: New. * tests/linear/Makefile.am: Update. * mln/linear/convolve_directional.hh: . * mln/border/resize.hh (todo): Remove; we use level::fill. (include): Fix missing level/fill. (resize_): Remove useless code. * mln/border/duplicate.hh: Update doc style. * mln/border/adjust.hh: Likewise. (adjust): Remove useless code; add postcondition. * mln/extension/adjust.hh: New. * mln/extension/duplicate.hh: New. * mln/extension/adjust_duplicate.hh: Update. * mln/extension/adjust_fill.hh: Update. * mln/extension/all.hh: Update. * mln/util/ord.hh: Add doc. * mln/util/max.hh: New. mln/border/adjust.hh | 22 ++---- mln/border/duplicate.hh | 7 - mln/border/resize.hh | 20 +---- mln/extension/adjust.hh | 130 +++++++++++++------------------------ mln/extension/adjust_duplicate.hh | 70 +++++-------------- mln/extension/adjust_fill.hh | 72 +++++--------------- mln/extension/all.hh | 16 ++-- mln/extension/duplicate.hh | 74 +++++++++++++++++++++ mln/linear/convolve_2x1d.hh | 69 ++++++++++--------- mln/linear/convolve_directional.hh | 3 mln/util/max.hh | 67 +++++++++++++++++++ mln/util/ord.hh | 15 ++-- tests/linear/Makefile.am | 2 tests/linear/convolve_2x1d.cc | 19 +++-- 14 files changed, 315 insertions(+), 271 deletions(-) Index: tests/linear/Makefile.am --- tests/linear/Makefile.am (revision 2813) +++ tests/linear/Makefile.am (working copy) @@ -7,6 +7,7 @@ check_PROGRAMS = \ convolve \ convolve_directional \ + convolve_2x1d \ gaussian \ lap \ log \ @@ -16,6 +17,7 @@ gaussian_SOURCES = gaussian.cc lap_SOURCES = lap.cc convolve_directional_SOURCES = convolve_directional.cc +convolve_2x1d_SOURCES = convolve_2x1d.cc log_SOURCES = log.cc sobel_SOURCES = sobel.cc Index: tests/linear/convolve_2x1d.cc --- tests/linear/convolve_2x1d.cc (revision 2807) +++ tests/linear/convolve_2x1d.cc (working copy) @@ -26,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/linear/convolve_directional.cc - * - * \brief Tests on mln::linear::convolve_directional. - */ +/// \file tests/linear/convolve_2x1d.cc +/// +/// Tests on mln::linear::convolve_2x1d. #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> @@ -41,7 +40,7 @@ #include <mln/core/alias/w_window2d_float.hh> #include <mln/border/thickness.hh> -#include <mln/linear/convolve_directional.hh> +#include <mln/linear/convolve_2x1d.hh> #include "tests/data.hh" @@ -51,13 +50,17 @@ using namespace mln; using value::int_u8; - border::thickness = 4; + border::thickness = 5; image2d<int_u8> lena; io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); - float ws[] = { .11, .11, .11, .11, .11, .11, .11, .11, .11 }; - image2d<float> tmp = linear::convolve_directional(lena, 1, ws); + float + w = 1.f / 11, + v = 1.f / 3; + float hws[] = { w, w, w, w, w, w, w, w, w, w, w }; + float vws[] = { v, v, v }; + image2d<float> tmp = linear::convolve_2x1d(lena, hws, vws); io::pgm::save(level::transform(tmp, math::round<int_u8>()), "out.pgm"); Index: mln/linear/convolve_directional.hh --- mln/linear/convolve_directional.hh (revision 2813) +++ mln/linear/convolve_directional.hh (working copy) @@ -70,6 +70,9 @@ convolve_directional(const Image<I>& input, unsigned dir, W (&weights)[S]) { trace::entering("linear::convolve_directional"); + + mlc_bool(S % 2 == 1)::check(); + mln_precondition(exact(input).has_data()); typedef mln_site(I) P; mln_precondition(dir < P::dim); Index: mln/linear/convolve_2x1d.hh --- mln/linear/convolve_2x1d.hh (revision 2807) +++ mln/linear/convolve_2x1d.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -25,16 +26,16 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_LINEAR_LINE_X2_CONVOLVE_HH -# define MLN_LINEAR_LINE_X2_CONVOLVE_HH +#ifndef MLN_LINEAR_CONVOLVE_2X1D_HH +# define MLN_LINEAR_CONVOLVE_2X1D_HH -/*! \file mln/linear/line_x2_convolve.hh - * - * \brief 2D convolution by a couple of line kernels. - */ - -# include <mln/linear/line_convolve.hh> -# include <mln/core/image/t_image.hh> +/// \file mln/linear/convolve_2x1d.hh +/// +/// 2D convolution by a couple of line kernels. + +# include <mln/linear/convolve_directional.hh> +# include <mln/extension/adjust.hh> +# include <mln/util/max.hh> @@ -47,40 +48,44 @@ /*! Convolution of an image \p input by two weighted line-shapes * windows. * - * \warning Computation of \p output(p) is performed with the - * value type of \p output. - * * \warning The weighted window is used as-is, considering that * its symmetrization is handled by the client. * - * \pre output.domain = input.domain + * \pre input.has_data */ template <typename I, - typename W, unsigned Nr, unsigned Nc, - typename O> - void line_x2_convolve(const Image<I>& input, - W (&row_weights)[Nr], W (&col_weights)[Nc], - Image<O>& output); + typename W, unsigned Sh, unsigned Sv> + mln_ch_convolve(I, W) + convolve_2x1d(const Image<I>& input, + W (&horizontal_weights)[Sh], + W (& vertical_weights)[Sv]); # ifndef MLN_INCLUDE_ONLY template <typename I, - typename W, unsigned Nr, unsigned Nc, - typename O> - inline - void line_x2_convolve(const Image<I>& input, - W (&row_weights)[Nr], W (&col_weights)[Nc], - Image<O>& output) + typename W, unsigned Sh, unsigned Sv> + mln_ch_convolve(I, W) + convolve_2x1d(const Image<I>& input, + W (&horizontal_weights)[Sh], + W (& vertical_weights)[Sv]) { - // FIXME: Check 2D. - mln_precondition(exact(output).domain() == exact(input).domain()); + trace::entering("linear::convolve_2x1d"); + + mlc_bool(Sh % 2 == 1)::check(); + mlc_bool(Sv % 2 == 1)::check(); + + mln_precondition(exact(input).has_data()); + + extension::adjust(input, util::max(Sh / 2, Sv / 2)); - O tmp(exact(output).domain()); - linear::line_convolve(input, row_weights, tmp); + mln_ch_convolve(I, W) tmp, output; + // Horizontal kernel so columns (index 1) are varying. + tmp = linear::convolve_directional(input, 1, horizontal_weights); + output = linear::convolve_directional( tmp, 0, vertical_weights); - t_image<O> swap_output = swap_coords(output, 0, 1); - linear::line_convolve(swap_coords(tmp, 0, 1), col_weights, swap_output); + trace::exiting("linear::convolve_2x1d"); + return output; } # endif // ! MLN_INCLUDE_ONLY @@ -90,4 +95,4 @@ } // end of namespace mln -#endif // ! MLN_LINEAR_LINE_X2_CONVOLVE_HH +#endif // ! MLN_LINEAR_CONVOLVE_2X1D_HH Property changes on: mln/linear/convolve_2x1d.hh ___________________________________________________________________ Added: svn:mergeinfo Index: mln/border/resize.hh --- mln/border/resize.hh (revision 2813) +++ mln/border/resize.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -33,8 +34,6 @@ * \brief Define a function that resizes the virtual border of an * image. * - * \todo Use level::fill!!! - * * \todo Test with a primary image with no notion of border; I guess * it does not work. */ @@ -42,8 +41,7 @@ # include <mln/core/concept/image.hh> # include <mln/core/routine/clone.hh> # include <mln/border/get.hh> -// # include <mln/level/fill.hh> -// # include <mln/level/paste.hh> +# include <mln/level/fill.hh> namespace mln @@ -110,26 +108,16 @@ template <typename I> inline void resize_(trait::image::ext_domain::none, - const I& ima, unsigned thickness) + const I&, unsigned) { - // Avoid a warning about an undefined variable when NDEBUG - // is not defined. - (void) ima; - (void) thickness; - // No-op. } template <typename I> inline void resize_(trait::image::ext_domain::fixed, - const I& ima, unsigned thickness) + const I&, unsigned) { - // Avoid a warning about an undefined variable when NDEBUG - // is not defined. - (void) ima; - (void) thickness; - // No-op. } Index: mln/border/duplicate.hh --- mln/border/duplicate.hh (revision 2813) +++ mln/border/duplicate.hh (working copy) @@ -29,10 +29,9 @@ #ifndef MLN_BORDER_DUPLICATE_HH # define MLN_BORDER_DUPLICATE_HH -/*! \file mln/border/duplicate.hh - * - * \brief Define function that fills border using nearest pixels. - */ +/// \file mln/border/duplicate.hh +/// +/// Define function that fills border using nearest pixels. # include <mln/core/concept/image.hh> # include <mln/core/routine/primary.hh> Index: mln/border/adjust.hh --- mln/border/adjust.hh (revision 2813) +++ mln/border/adjust.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,14 +29,13 @@ #ifndef MLN_BORDER_ADJUST_HH # define MLN_BORDER_ADJUST_HH -/*! \file mln/border/adjust.hh - * - * \brief Define a function that adjusts the thickness of an image - * virtual border. - */ +/// \file mln/border/adjust.hh +/// +/// Define a function that adjusts the thickness of an image +/// virtual border. # include <mln/border/resize.hh> -# include <mln/metal/is.hh> + namespace mln { @@ -62,18 +62,16 @@ template <typename I> inline - void adjust(const Image<I>& ima_, unsigned min_thickness) + void adjust(const Image<I>& ima, unsigned min_thickness) { trace::entering("border::adjust"); - if (min_thickness != 0) - { - const I& ima = exact(ima_); - mln_precondition(ima.has_data()); + mln_precondition(exact(ima).has_data()); if (border::get(ima) < min_thickness) border::resize(ima, min_thickness); - } + + mln_postcondition(border::get(ima) >= min_thickness); trace::exiting("border::adjust"); } Index: mln/extension/adjust_duplicate.hh --- mln/extension/adjust_duplicate.hh (revision 2813) +++ mln/extension/adjust_duplicate.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,17 +28,15 @@ #ifndef MLN_CORE_EXTENSION_ADJUST_DUPLICATE_HH # define MLN_CORE_EXTENSION_ADJUST_DUPLICATE_HH -/*! \file mln/extension/adjust_duplicate.hh - * - * \brief Adjust the size of the domain extension then duplicate the - * image inner boundary. - * - * \todo Fix doc. - */ - -# include <mln/border/adjust.hh> -# include <mln/border/duplicate.hh> -# include <mln/geom/delta.hh> +/// \file mln/extension/adjust_duplicate.hh +/// +/// Adjust the size of the domain extension then duplicate the image +/// inner boundary. +/// +/// \todo Fix doc. + +# include <mln/extension/adjust.hh> +# include <mln/extension/duplicate.hh> namespace mln @@ -47,13 +45,7 @@ namespace extension { - /*! Fill the domain extension of image \p ima by duplicating the - * image inner boundary. - * - * \param[in,out] ima The image whose domain extension is to be filled. - * - * \pre \p ima has to be initialized. - */ + /// Adjust then duplicate. template <typename I, typename W> void adjust_duplicate(const Image<I>& ima, const Window<W>& win); @@ -74,34 +66,6 @@ # ifndef MLN_INCLUDE_ONLY - namespace impl - { - - template <typename I> - void do_adjust_duplicate(const I& ima, - unsigned delta) - { - mln_precondition(exact(ima).has_data()); - // mln_precondition(exact(win_like).is_valid()); - - border::adjust(ima, delta); - border::duplicate(ima); - } - - template <typename I, typename W> - void do_adjust_duplicate(const I& ima, - const W& win_like) - { - mln_precondition(exact(ima).has_data()); - // mln_precondition(exact(win_like).is_valid()); - - border::adjust(ima, geom::delta(win_like)); - border::duplicate(ima); - } - - } // end of namespace mln::extension::impl - - // Facades. template <typename I, typename W> @@ -109,7 +73,8 @@ const Window<W>& win) { trace::entering("extension::adjust_duplicate"); - impl::do_adjust_duplicate(ima, win); + extension::adjust(ima, win); + extension::duplicate(ima); trace::exiting("extension::adjust_duplicate"); } @@ -118,7 +83,8 @@ const Weighted_Window<W>& wwin) { trace::entering("extension::adjust_duplicate"); - impl::do_adjust_duplicate(ima, wwin); + extension::adjust(ima, wwin); + extension::duplicate(ima); trace::exiting("extension::adjust_duplicate"); } @@ -127,7 +93,8 @@ const Neighborhood<N>& nbh) { trace::entering("extension::adjust_duplicate"); - impl::do_adjust_duplicate(ima, nbh); + extension::adjust(ima, nbh); + extension::duplicate(ima); trace::exiting("extension::adjust_duplicate"); } @@ -136,7 +103,8 @@ unsigned delta) { trace::entering("extension::adjust_duplicate"); - impl::do_adjust_duplicate(ima, delta); + extension::adjust(ima, delta); + extension::duplicate(ima); trace::exiting("extension::adjust_duplicate"); } Index: mln/extension/all.hh --- mln/extension/all.hh (revision 2813) +++ mln/extension/all.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,12 +28,11 @@ #ifndef MLN_EXTENSION_ALL_HH # define MLN_EXTENSION_ALL_HH -/*! \file mln/extension/all.hh - * - * \brief File that includes all extension materials. - * - * \todo Also include "extension images" + "extended"? - */ +/// \file mln/extension/all.hh +/// +/// \brief File that includes all extension materials. +/// +/// \todo Also include "extension images" + "extended"? namespace mln @@ -45,8 +44,11 @@ } // end of namespace mln +# include <mln/extension/adjust.hh> # include <mln/extension/fill.hh> # include <mln/extension/adjust_fill.hh> +# include <mln/extension/duplicate.hh> +# include <mln/extension/adjust_duplicate.hh> #endif // ! MLN_EXTENSION_ALL_HH Index: mln/extension/adjust.hh --- mln/extension/adjust.hh (revision 2807) +++ mln/extension/adjust.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -25,18 +25,19 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_CORE_EXTENSION_ADJUST_FILL_HH -# define MLN_CORE_EXTENSION_ADJUST_FILL_HH +#ifndef MLN_CORE_EXTENSION_ADJUST_HH +# define MLN_CORE_EXTENSION_ADJUST_HH -/*! \file mln/extension/adjust_fill.hh - * - * \brief Adjust then fill the domain extension. - * - * \todo Fix doc. - */ +/// \file mln/extension/adjust.hh +/// +/// Adjust the domain extension to a minimum thickness border. +/// +/// \todo Fix doc. # include <mln/border/adjust.hh> -# include <mln/extension/fill.hh> +# include <mln/core/concept/window.hh> +# include <mln/core/concept/weighted_window.hh> +# include <mln/core/concept/neighborhood.hh> # include <mln/geom/delta.hh> @@ -46,63 +47,39 @@ namespace extension { - /*! Fill the domain extension of image \p ima with the - * single value \p v. - * - * \param[in,out] ima The image whose domain extension is to be filled. - * \param[in] val The value to assign. - * - * \pre \p ima has to be initialized. - * - * \todo Optimize with memset if possible. - */ + /// Adjust the domain extension of image \p ima with the + /// size of the window \p win. template <typename I, typename W> - void adjust_fill(const Image<I>& ima, - const Window<W>& win, - const mln_value(I)& val); + void adjust(const Image<I>& ima, const Window<W>& win); + /// Adjust the domain extension of image \p ima with the + /// size of the weighted window \p wwin. template <typename I, typename W> - void adjust_fill(const Image<I>& ima, - const Weighted_Window<W>& wwin, - const mln_value(I)& val); + void adjust(const Image<I>& ima, const Weighted_Window<W>& wwin); + /// Adjust the domain extension of image \p ima with the + /// size of the neighborhood \p nbh. template <typename I, typename N> - void adjust_fill(const Image<I>& ima, - const Neighborhood<N>& nbh, - const mln_value(I)& val); + void adjust(const Image<I>& ima, const Neighborhood<N>& nbh); + /// Adjust the domain extension of image \p ima with the + /// size \p delta. template <typename I> - void adjust_fill(const Image<I>& ima, - unsigned delta, - const mln_value(I)& val); + void adjust(const Image<I>& ima, unsigned delta); + + # ifndef MLN_INCLUDE_ONLY namespace impl { - template <typename I, typename V> - void do_adjust_fill(const I& ima, - unsigned delta, - const V& val) + template <typename I> + void adjust(const I& ima, unsigned delta) { mln_precondition(exact(ima).has_data()); - // mln_precondition(exact(win_like).is_valid()); - + // FIXME: Is-it right? border::adjust(ima, delta); - extension::fill(ima, val); - } - - template <typename I, typename W, typename V> - void do_adjust_fill(const I& ima, - const W& win_like, - const V& val) - { - mln_precondition(exact(ima).has_data()); - // mln_precondition(exact(win_like).is_valid()); - - border::adjust(ima, geom::delta(win_like)); - extension::fill(ima, val); } } // end of namespace mln::extension::impl @@ -111,46 +88,37 @@ // Facades. template <typename I, typename W> - void adjust_fill(const Image<I>& ima, - const Window<W>& win, - const mln_value(I)& val) - { - trace::entering("extension::adjust_fill"); - impl::do_adjust_fill(ima, win, val); - trace::exiting("extension::adjust_fill"); + void adjust(const Image<I>& ima, const Window<W>& win) + { + trace::entering("extension::adjust"); + impl::adjust(ima, geom::delta(win)); + trace::exiting("extension::adjust"); } template <typename I, typename W> - void adjust_fill(const Image<I>& ima, - const Weighted_Window<W>& wwin, - const mln_value(I)& val) - { - trace::entering("extension::adjust_fill"); - impl::do_adjust_fill(ima, wwin, val); - trace::exiting("extension::adjust_fill"); + void adjust(const Image<I>& ima, const Weighted_Window<W>& wwin) + { + trace::entering("extension::adjust"); + impl::adjust(ima, geom::delta(wwin)); + trace::exiting("extension::adjust"); } template <typename I, typename N> - void adjust_fill(const Image<I>& ima, - const Neighborhood<N>& nbh, - const mln_value(I)& val) - { - trace::entering("extension::adjust_fill"); - impl::do_adjust_fill(ima, nbh, val); - trace::exiting("extension::adjust_fill"); + void adjust(const Image<I>& ima, const Neighborhood<N>& nbh) + { + trace::entering("extension::adjust"); + impl::adjust(ima, geom::delta(nbh)); + trace::exiting("extension::adjust"); } template <typename I> - void adjust_fill(const Image<I>& ima, - unsigned delta, - const mln_value(I)& val) - { - trace::entering("extension::adjust_fill"); - impl::do_adjust_fill(ima, delta, val); - trace::exiting("extension::adjust_fill"); + void adjust(const Image<I>& ima, unsigned delta) + { + trace::entering("extension::adjust"); + impl::adjust(ima, delta); + trace::exiting("extension::adjust"); } - # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::extension @@ -158,4 +126,4 @@ } // end of namespace mln -#endif // ! MLN_CORE_EXTENSION_FILL_HH +#endif // ! MLN_CORE_EXTENSION_ADJUST_HH Property changes on: mln/extension/adjust.hh ___________________________________________________________________ Added: svn:mergeinfo Index: mln/extension/duplicate.hh --- mln/extension/duplicate.hh (revision 0) +++ mln/extension/duplicate.hh (revision 0) @@ -0,0 +1,74 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_CORE_EXTENSION_DUPLICATE_HH +# define MLN_CORE_EXTENSION_DUPLICATE_HH + +/// \file mln/extension/duplicate.hh +/// +/// Duplicate the values of the image inner boundary in the domain +/// extension. +/// +/// \todo Fix doc. + +# include <mln/border/duplicate.hh> + + +namespace mln +{ + + namespace extension + { + + /// Assign the contents of the domain extension by duplicating the + /// values of the inner boundary of image \p ima. + template <typename I> + void duplicate(const Image<I>& ima); + + + +# ifndef MLN_INCLUDE_ONLY + + + // Facade. + + template <typename I> + void duplicate(const Image<I>& ima) + { + trace::entering("extension::duplicate"); + border::duplicate(ima); + trace::exiting("extension::duplicate"); + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::extension + +} // end of namespace mln + + +#endif // ! MLN_CORE_EXTENSION_DUPLICATE_HH Index: mln/extension/adjust_fill.hh --- mln/extension/adjust_fill.hh (revision 2813) +++ mln/extension/adjust_fill.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,16 +28,14 @@ #ifndef MLN_CORE_EXTENSION_ADJUST_FILL_HH # define MLN_CORE_EXTENSION_ADJUST_FILL_HH -/*! \file mln/extension/adjust_fill.hh - * - * \brief Adjust then fill the domain extension. - * - * \todo Fix doc. - */ +/// \file mln/extension/adjust_fill.hh +/// +/// Adjust then fill the domain extension. +/// +/// \todo Fix doc. -# include <mln/border/adjust.hh> +# include <mln/extension/adjust.hh> # include <mln/extension/fill.hh> -# include <mln/geom/delta.hh> namespace mln @@ -46,16 +44,7 @@ namespace extension { - /*! Fill the domain extension of image \p ima with the - * single value \p v. - * - * \param[in,out] ima The image whose domain extension is to be filled. - * \param[in] val The value to assign. - * - * \pre \p ima has to be initialized. - * - * \todo Optimize with memset if possible. - */ + /// Adjust then fill. template <typename I, typename W> void adjust_fill(const Image<I>& ima, const Window<W>& win, @@ -76,37 +65,8 @@ unsigned delta, const mln_value(I)& val); -# ifndef MLN_INCLUDE_ONLY - - namespace impl - { - - template <typename I, typename V> - void do_adjust_fill(const I& ima, - unsigned delta, - const V& val) - { - mln_precondition(exact(ima).has_data()); - // mln_precondition(exact(win_like).is_valid()); - - border::adjust(ima, delta); - extension::fill(ima, val); - } - - template <typename I, typename W, typename V> - void do_adjust_fill(const I& ima, - const W& win_like, - const V& val) - { - mln_precondition(exact(ima).has_data()); - // mln_precondition(exact(win_like).is_valid()); - - border::adjust(ima, geom::delta(win_like)); - extension::fill(ima, val); - } - - } // end of namespace mln::extension::impl +# ifndef MLN_INCLUDE_ONLY // Facades. @@ -116,7 +76,8 @@ const mln_value(I)& val) { trace::entering("extension::adjust_fill"); - impl::do_adjust_fill(ima, win, val); + extension::adjust(ima, win); + extension::fill(ima, val); trace::exiting("extension::adjust_fill"); } @@ -126,7 +87,8 @@ const mln_value(I)& val) { trace::entering("extension::adjust_fill"); - impl::do_adjust_fill(ima, wwin, val); + extension::adjust(ima, wwin); + extension::fill(ima, val); trace::exiting("extension::adjust_fill"); } @@ -136,7 +98,8 @@ const mln_value(I)& val) { trace::entering("extension::adjust_fill"); - impl::do_adjust_fill(ima, nbh, val); + extension::adjust(ima, nbh); + extension::fill(ima, val); trace::exiting("extension::adjust_fill"); } @@ -146,7 +109,8 @@ const mln_value(I)& val) { trace::entering("extension::adjust_fill"); - impl::do_adjust_fill(ima, delta, val); + extension::adjust(ima, delta); + extension::fill(ima, val); trace::exiting("extension::adjust_fill"); } @@ -158,4 +122,4 @@ } // end of namespace mln -#endif // ! MLN_CORE_EXTENSION_FILL_HH +#endif // ! MLN_CORE_EXTENSION_ADJUST_FILL_HH Index: mln/util/ord.hh --- mln/util/ord.hh (revision 2813) +++ mln/util/ord.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +28,10 @@ #ifndef MLN_UTIL_ORD_HH # define MLN_UTIL_ORD_HH -/*! \file mln/util/ord.hh - * - * \brief Definition of an ordering type and routine. - */ +/// \file mln/util/ord.hh +/// +/// Definition of an ordering type and routine. + # include <mln/core/concept/object.hh> # include <mln/trait/op/ord.hh> @@ -45,7 +45,7 @@ { /// Function-object that defines an ordering between objects with - /// type \p T. + /// type \p T: \a lhs R \a rhs. Its meaning is "lhs less-than rhs." template <typename T> struct ord { @@ -54,9 +54,12 @@ + /// Routine to test if \a lhs is strictly "less-than" \a rhs. template <typename T> bool ord_strict(const T& lhs, const T& rhs); + + /// Routine to test if \a lhs is "less-than or equal-to" \a rhs. template <typename T> bool ord_weak(const T& lhs, const T& rhs); Index: mln/util/max.hh --- mln/util/max.hh (revision 0) +++ mln/util/max.hh (revision 0) @@ -0,0 +1,67 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_UTIL_MAX_HH +# define MLN_UTIL_MAX_HH + +/// \file mln/util/max.hh +/// +/// Definition of a binary max based on the ordering relationship. + +# include <mln/util/ord.hh> + + + +namespace mln +{ + + namespace util + { + + + template <typename T> + bool max(const T& lhs, const T& rhs); + + + +# ifndef MLN_INCLUDE_ONLY + + template <typename T> + inline + bool max(const T& lhs, const T& rhs) + { + return ord_strict(lhs, rhs) ? lhs : rhs; + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::util + +} // end of namespace mln + + +#endif // ! MLN_UTIL_MAX_HH