
* mln/geom/crop.hh, * mln/geom/crop_without_localization.hh: New. --- milena/ChangeLog | 7 +++ milena/mln/geom/{nsites.hh => crop.hh} | 43 ++++++++--------- .../{nsites.hh => crop_without_localization.hh} | 50 +++++++++++--------- 3 files changed, 56 insertions(+), 44 deletions(-) copy milena/mln/geom/{nsites.hh => crop.hh} (66%) copy milena/mln/geom/{nsites.hh => crop_without_localization.hh} (56%) diff --git a/milena/ChangeLog b/milena/ChangeLog index 5a3b501..549694b 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,12 @@ 2011-10-14 Guillaume Lazzara <z@lrde.epita.fr> + Add new crop routines. + + * mln/geom/crop.hh, + * mln/geom/crop_without_localization.hh: New. + +2011-10-14 Guillaume Lazzara <z@lrde.epita.fr> + * mln/value/builtin/floatings.hh: Fix string name for builtin double type. diff --git a/milena/mln/geom/nsites.hh b/milena/mln/geom/crop.hh similarity index 66% copy from milena/mln/geom/nsites.hh copy to milena/mln/geom/crop.hh index 9c7868f..99398a7 100644 --- a/milena/mln/geom/nsites.hh +++ b/milena/mln/geom/crop.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -23,16 +23,16 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef MLN_GEOM_NSITES_HH -# define MLN_GEOM_NSITES_HH - /// \file /// -/// Compute the number of sites of an image or a site set. +/// Crop an image. -# include <mln/core/concept/image.hh> -# include <mln/set/card.hh> +#ifndef MLN_GEOM_CROP_HH +# define MLN_GEOM_CROP_HH +# include <mln/core/concept/image.hh> +# include <mln/core/concept/box.hh> +# include <mln/data/paste.hh> namespace mln { @@ -40,28 +40,28 @@ namespace mln namespace geom { - /// Compute the number of sites of the image \p input. - template <typename I> - unsigned nsites(const Image<I>& input); + template <typename I, typename B> + mln_concrete(I) crop(const Image<I>& input, const Box<B>& b); # ifndef MLN_INCLUDE_ONLY - template <typename I> - inline - unsigned nsites(const Image<I>& input_) + template <typename I, typename B> + mln_concrete(I) crop(const Image<I>& input_, const Box<B>& b_) { - trace::entering("geom::nsites"); - const I& input = exact(input_); + trace::entering("mln::geom::crop"); + const I& input = exact(input_); + const B& b = exact(b_); mln_precondition(input.is_valid()); - mln_precondition(input.domain().is_valid()); + mln_precondition(b.is_valid()); + mln_precondition(b <= input.domain()); - // Relies on the card routine on a site set. - unsigned n = mln::set::internal::card_dispatch(input.domain()); + mln_concrete(I) output(b); + data::paste(input | b, output); - trace::exiting("geom::nsites"); - return n; + trace::exiting("mln::geom::crop"); + return output; } # endif // ! MLN_INCLUDE_ONLY @@ -70,5 +70,4 @@ namespace mln } // end of namespace mln - -#endif // ! MLN_GEOM_NSITES_HH +#endif // ! MLN_GEOM_CROP_HH diff --git a/milena/mln/geom/nsites.hh b/milena/mln/geom/crop_without_localization.hh similarity index 56% copy from milena/mln/geom/nsites.hh copy to milena/mln/geom/crop_without_localization.hh index 9c7868f..ed80c56 100644 --- a/milena/mln/geom/nsites.hh +++ b/milena/mln/geom/crop_without_localization.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -23,16 +23,17 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef MLN_GEOM_NSITES_HH -# define MLN_GEOM_NSITES_HH - /// \file /// -/// Compute the number of sites of an image or a site set. +/// Crop an image. Localization between input and output may not be +/// preserved. -# include <mln/core/concept/image.hh> -# include <mln/set/card.hh> +#ifndef MLN_GEOM_CROP_WITHOUT_LOCALIZATION_HH +# define MLN_GEOM_CROP_WITHOUT_LOCALIZATION_HH +# include <mln/core/concept/image.hh> +# include <mln/core/concept/box.hh> +# include <mln/data/paste_without_localization.hh> namespace mln { @@ -40,35 +41,40 @@ namespace mln namespace geom { - /// Compute the number of sites of the image \p input. - template <typename I> - unsigned nsites(const Image<I>& input); + template <typename I, typename B> + mln_concrete(I) crop_without_localization(const Image<I>& input, + const Box<B>& b_in, const Box<B>& b_out); # ifndef MLN_INCLUDE_ONLY - template <typename I> - inline - unsigned nsites(const Image<I>& input_) + template <typename I, typename B> + mln_concrete(I) + crop_without_localization(const Image<I>& input_, + const Box<B>& b_in_, const Box<B>& b_out_) { - trace::entering("geom::nsites"); - const I& input = exact(input_); + trace::entering("mln::geom::crop_without_localization"); + const I& input = exact(input_); + const B& b_in = exact(b_in_); + const B& b_out = exact(b_out_); mln_precondition(input.is_valid()); - mln_precondition(input.domain().is_valid()); + mln_precondition(b.is_valid()); + mln_precondition(b_in <= input.domain()); + mln_precondition(b_in.nsites() == b_out.nsites()); - // Relies on the card routine on a site set. - unsigned n = mln::set::internal::card_dispatch(input.domain()); + mln_concrete(I) output(b_out); + data::paste_without_localization(input | b_in, output); - trace::exiting("geom::nsites"); - return n; + trace::exiting("mln::geom::crop_without_localization"); + return output; } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::geom } // end of namespace mln - -#endif // ! MLN_GEOM_NSITES_HH +#endif // ! MLN_GEOM_CROP_WITHOUT_LOCALIZATION_HH -- 1.7.2.5
participants (1)
-
Guillaume Lazzara