olena-2.0-172-g24fb78f Various small fixes.

* mln/canvas/labeling/video.hh: Remove a useless variable. * mln/debug/filename.hh: Add an overload. * mln/fun/v2v/abs.hh: Add the return type as template parameter. * mln/labeling/colorize.hh: Fix an include. * mln/value/intsub.hh: Add operator*(). * mln/world/k2/fill_non_primary_from_primary_2_faces.hh: Duplicate 2-faces in border. * mln/world/k1/fill_0_from_primary_faces.hh, * mln/world/kn/fill_0_from_2_faces.hh: Make the function argument const. * mln/world/k1/neighb2d.hh: Fix names. * mln/world/kn/border/adjust_duplicate_2_faces.hh, * mln/world/kn/border/duplicate_2_faces.hh: Revamp. * mln/world/kn/compute_tree_of_shapes.hh: Update reference to hqueue. * tests/value/intsub.cc: Add more tests. * tests/world/kn/display_enlarged.cc: Fix test. * tests/world/kn/fill_1_from_aux_2_faces.cc: Do not initialize borders. * tests/world/kn/fill_2_from_1_faces.cc: Use pre-defined functions. --- milena/ChangeLog | 47 +++++++ milena/mln/canvas/labeling/video.hh | 5 +- milena/mln/debug/filename.hh | 17 ++- milena/mln/fun/v2v/abs.hh | 21 ++-- milena/mln/labeling/colorize.hh | 6 +- milena/mln/value/intsub.hh | 16 +++ milena/mln/world/k1/fill_0_from_primary_faces.hh | 4 +- milena/mln/world/k1/neighb2d.hh | 51 ++++++-- .../k2/fill_non_primary_from_primary_2_faces.hh | 4 + .../world/kn/border/adjust_duplicate_2_faces.hh | 9 +- milena/mln/world/kn/border/duplicate_2_faces.hh | 6 +- ...duplicate_2_faces.hh => fill_1_from_2_faces.hh} | 47 ++++---- .../mln/world/kn/border/fill_1_from_aux_2_faces.hh | 133 ++++++++++++++++++++ milena/mln/world/kn/compute_tree_of_shapes.hh | 4 +- milena/mln/world/kn/fill_0_from_2_faces.hh | 6 +- milena/mln/world/kn/fill_1_from_aux_2_faces.hh | 14 ++- milena/tests/value/intsub.cc | 10 ++ milena/tests/world/kn/display_enlarged.cc | 34 +++--- milena/tests/world/kn/fill_1_from_aux_2_faces.cc | 2 - milena/tests/world/kn/fill_2_from_1_faces.cc | 21 +--- 20 files changed, 341 insertions(+), 116 deletions(-) copy milena/mln/world/kn/border/{adjust_duplicate_2_faces.hh => fill_1_from_2_faces.hh} (59%) create mode 100644 milena/mln/world/kn/border/fill_1_from_aux_2_faces.hh diff --git a/milena/ChangeLog b/milena/ChangeLog index f42284d..63e9d85 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,52 @@ 2012-11-01 Guillaume Lazzara <z@lrde.epita.fr> + Handle border value with auxiliary data images. + + * mln/world/kn/border/fill_1_from_2_faces.hh, + * mln/world/kn/border/fill_1_from_aux_2_faces.hh: New. + + * mln/world/k2/fill_non_primary_from_primary_2_faces.hh, + * mln/world/kn/fill_1_from_aux_2_faces.hh: Initialize borders + properly. + +2012-11-01 Guillaume Lazzara <z@lrde.epita.fr> + + Various small fixes. + + * mln/canvas/labeling/video.hh: Remove a useless variable. + + * mln/debug/filename.hh: Add an overload. + + * mln/fun/v2v/abs.hh: Add the return type as template parameter. + + * mln/labeling/colorize.hh: Fix an include. + + * mln/value/intsub.hh: Add operator*(). + + * mln/world/k1/fill_0_from_primary_faces.hh, + * mln/world/kn/fill_0_from_2_faces.hh: Make the function argument + const. + + * mln/world/k1/neighb2d.hh: Fix names. + + * mln/world/kn/border/adjust_duplicate_2_faces.hh, + * mln/world/kn/border/duplicate_2_faces.hh: Revamp. + + * mln/world/kn/compute_tree_of_shapes.hh: Update reference to + hqueue. + + * tests/value/intsub.cc: Add more tests. + + * tests/world/kn/display_enlarged.cc: Fix test. + + * tests/world/kn/fill_1_from_aux_2_faces.cc: Do not initialize + borders. + + * tests/world/kn/fill_2_from_1_faces.cc: Use pre-defined + functions. + +2012-11-01 Guillaume Lazzara <z@lrde.epita.fr> + * mln/world/kn/debug/println.hh: Handle images based on any site sets. diff --git a/milena/mln/canvas/labeling/video.hh b/milena/mln/canvas/labeling/video.hh index b46e930..7093b67 100644 --- a/milena/mln/canvas/labeling/video.hh +++ b/milena/mln/canvas/labeling/video.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development // Laboratory (LRDE) // // This file is part of Olena. @@ -87,7 +87,6 @@ namespace mln // Output. mln_ch_value(I, L) output; - bool status; // Initialization. { @@ -155,7 +154,6 @@ namespace mln { if (nlabels == mln_max(L)) { - status = false; trace::warning("labeling aborted! Too many labels for \ this label type: nlabels > \ max(label_type)."); @@ -172,7 +170,6 @@ namespace mln f.set_label_(p, lbl); } } - status = true; } f.finalize(); diff --git a/milena/mln/debug/filename.hh b/milena/mln/debug/filename.hh index 1fc268b..b49b3a2 100644 --- a/milena/mln/debug/filename.hh +++ b/milena/mln/debug/filename.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2012 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -58,6 +58,10 @@ namespace mln std::string filename(const std::string& filename, int id); + /// \overload + std::string + filename(const std::string& filename); + namespace internal { @@ -83,7 +87,7 @@ namespace mln inline std::string - filename(const std::string& filename, int id = -1) + filename(const std::string& filename, int id) { static int file_id = 1; @@ -111,6 +115,13 @@ namespace mln } + inline + std::string + filename(const std::string& name) + { + return filename(name, -1); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::debug diff --git a/milena/mln/fun/v2v/abs.hh b/milena/mln/fun/v2v/abs.hh index d5bc3be..c2b34b3 100644 --- a/milena/mln/fun/v2v/abs.hh +++ b/milena/mln/fun/v2v/abs.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2009, 2012 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -46,22 +47,24 @@ namespace mln // FIXME: Doc! - template <typename V> - struct abs : public Function_v2v< abs<V> > + template <typename V, typename R> + struct abs : public Function_v2v< abs<V,R> >, + private mlc_converts_to(R,V)::check_t { - typedef V result; - V operator()(const V& v) const; + typedef R result; + typedef V argument; + R operator()(const V& v) const; }; # ifndef MLN_INCLUDE_ONLY - template <typename V> + template <typename V, typename R> inline - V - abs<V>::operator()(const V& v) const + R + abs<V,R>::operator()(const V& v) const { - return mln::math::abs(v); + return R(mln::math::abs(v)); } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/labeling/colorize.hh b/milena/mln/labeling/colorize.hh index ba876a7..fe3f6b4 100644 --- a/milena/mln/labeling/colorize.hh +++ b/milena/mln/labeling/colorize.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010, 2011, 2012 EPITA Research and +// Development Laboratory (LRDE) // // This file is part of Olena. // @@ -40,7 +40,7 @@ # include <mln/accu/stat/max.hh> # include <mln/util/array.hh> # include <mln/util/set.hh> -# include <mln/value/next.hh> +# include <mln/value/succ.hh> namespace mln diff --git a/milena/mln/value/intsub.hh b/milena/mln/value/intsub.hh index 0a1dabc..721b4bd 100644 --- a/milena/mln/value/intsub.hh +++ b/milena/mln/value/intsub.hh @@ -192,6 +192,22 @@ namespace mln // Safety template <> struct intsub<0>; + + // Ops + + template <unsigned n1, unsigned n2> + intsub<n1*n2> operator*(const intsub<n1>& lhs, const intsub<n2>& rhs) + { + return intsub<n1*n2>::make_from_enc_(lhs.to_enc() * rhs.to_enc()); + } + + template <unsigned n, typename S> + intsub<n> operator*(const intsub<n>& lhs, const value::scalar_<S>& rhs) + { + return intsub<n>::make_from_enc_(lhs.to_enc() * rhs); + } + + // rounding /// Re-implementation of the floor function. \sa math::floor diff --git a/milena/mln/world/k1/fill_0_from_primary_faces.hh b/milena/mln/world/k1/fill_0_from_primary_faces.hh index 12dcc5f..6410c4d 100644 --- a/milena/mln/world/k1/fill_0_from_primary_faces.hh +++ b/milena/mln/world/k1/fill_0_from_primary_faces.hh @@ -59,7 +59,7 @@ namespace mln */ template <typename I, typename F> - void fill_0_from_primary_faces(Image<I>& inout, Function_vvvv2v<F>& f); + void fill_0_from_primary_faces(Image<I>& inout, const Function_vvvv2v<F>& f); /// \overload template <typename I, typename A> @@ -73,7 +73,7 @@ namespace mln template <typename I, typename F> - void fill_0_from_primary_faces(Image<I>& inout, Function_vvvv2v<F>& f) + void fill_0_from_primary_faces(Image<I>& inout, const Function_vvvv2v<F>& f) { trace::entering("mln::world::k1::fill_0_from_primary_faces"); diff --git a/milena/mln/world/k1/neighb2d.hh b/milena/mln/world/k1/neighb2d.hh index 7681af1..eaf1ea4 100644 --- a/milena/mln/world/k1/neighb2d.hh +++ b/milena/mln/world/k1/neighb2d.hh @@ -44,6 +44,8 @@ namespace mln namespace k1 { + typedef neighb< win::multiple<window2d, bool(*)(const point2d&)> > dbl_neighb2d; + /*! \brief 2 faces to 1 faces neighborhood. \verbatim @@ -52,7 +54,7 @@ namespace mln - \endverbatim */ - const neighb2d& 2to1_faces(); + const neighb2d& faces_2to1(); /*! \brief 1 faces to 2 faces neighborhood. @@ -64,7 +66,7 @@ namespace mln \endverbatim */ - const dbl_neighb2d& 1to2_faces(); + const dbl_neighb2d& faces_1to2(); /*! \brief 1 faces to 1 faces neighborhood. @@ -77,7 +79,20 @@ namespace mln | \endverbatim */ - const dbl_neighb2d& 1to1_faces() + const dbl_neighb2d& faces_1to1(); + + + /*! \brief 2 faces to 2 faces neighborhood (4-connectivity). + + \verbatim + x + - + x|o|x + - + x + \endverbatim + */ + const neighb2d& faces_2to2_c4(); # ifndef MLN_INCLUDE_ONLY @@ -93,28 +108,27 @@ namespace mln } - typedef neighb< win::multiple<window2d, bool(*)(const point2d&)> > dbl_neighb2d; - - const neighb2d& 2to1_faces() + const neighb2d& faces_2to1() { return c4(); } - const dbl_neighb2d& 1to2_faces() + const dbl_neighb2d& faces_1to2() { - static bool 1face_h[] = { 0, 1, 0, + static bool face1_h[] = { 0, 1, 0, 0, 0, 0, 0, 1, 0 }; - static bool 1face_v[] = { 0, 0, 0, + static bool face1_v[] = { 0, 0, 0, 1, 0, 1, 0, 0, 0 }; - static dbl_neighb2d nbh = make::double_neighb2d(internal::is_row_odd, e2p_h, e2p_v); + static dbl_neighb2d + nbh = make::double_neighb2d(internal::is_row_odd, face1_h, face1_v); return nbh; } - const dbl_neighb2d& 1to1_faces() + const dbl_neighb2d& faces_1to1() { static bool e2e_h[] = { 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, @@ -130,7 +144,20 @@ namespace mln return nbh; } - + const neighb2d& faces_2to2_c4() + { + static neighb2d it; + if (it.size() == 0) + { + static bool vals[] = { 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0 }; + convert::from_to(vals, it); + } + return it; + } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/world/k2/fill_non_primary_from_primary_2_faces.hh b/milena/mln/world/k2/fill_non_primary_from_primary_2_faces.hh index f218fd5..41221d0 100644 --- a/milena/mln/world/k2/fill_non_primary_from_primary_2_faces.hh +++ b/milena/mln/world/k2/fill_non_primary_from_primary_2_faces.hh @@ -35,6 +35,7 @@ # include <mln/world/k2/is_non_primary_2_face_horizontal.hh> # include <mln/world/k2/is_non_primary_2_face_center.hh> # include <mln/world/kn/safe_cast.hh> +# include <mln/world/kn/border/adjust_duplicate_2_faces.hh> namespace mln { @@ -140,6 +141,9 @@ namespace mln kn::safe_cast(ima(p + 2 * down_right)))); } + // Initialize border. + kn::border::adjust_duplicate_2_faces(ima, 1); + trace::exiting("mln::world::k2::fill_non_primary_from_primary_2_faces"); } diff --git a/milena/mln/world/kn/border/adjust_duplicate_2_faces.hh b/milena/mln/world/kn/border/adjust_duplicate_2_faces.hh index ca900f6..bb7f43c 100644 --- a/milena/mln/world/kn/border/adjust_duplicate_2_faces.hh +++ b/milena/mln/world/kn/border/adjust_duplicate_2_faces.hh @@ -59,7 +59,8 @@ namespace mln */ template <typename I> - void adjust_duplicate_2_faces(Image<I>& inout, unsigned min_thickness); + void adjust_duplicate_2_faces(const Image<I>& inout, + unsigned min_thickness); @@ -67,13 +68,13 @@ namespace mln template <typename I> - void adjust_duplicate_2_faces(Image<I>& inout_, unsigned min_thickness) + void adjust_duplicate_2_faces(const Image<I>& inout, + unsigned min_thickness) { trace::entering("mln::world::kn::adjust_duplicate_2_faces"); - mln_precondition(exact(inout_).is_valid()); + mln_precondition(exact(inout).is_valid()); mln_precondition(min_thickness > 0); - I& inout = exact(inout_); mln::border::adjust(inout, min_thickness); kn::border::duplicate_2_faces(inout); diff --git a/milena/mln/world/kn/border/duplicate_2_faces.hh b/milena/mln/world/kn/border/duplicate_2_faces.hh index b8ff7d3..ff505d0 100644 --- a/milena/mln/world/kn/border/duplicate_2_faces.hh +++ b/milena/mln/world/kn/border/duplicate_2_faces.hh @@ -56,7 +56,7 @@ namespace mln */ template <typename I> - void duplicate_2_faces(Image<I>& inout); + void duplicate_2_faces(const Image<I>& inout); @@ -64,13 +64,13 @@ namespace mln template <typename I> - void duplicate_2_faces(Image<I>& inout_) + void duplicate_2_faces(const Image<I>& inout_) { trace::entering("mln::world::kn::duplicate_2_faces"); mln_precondition(exact(inout_).is_valid()); mln_precondition(exact(inout_).border() >= 1); - I& inout = exact(inout_); + I& inout = const_cast<I&>(exact(inout_)); def::coord min_row_1 = geom::min_row(inout) + 1, diff --git a/milena/mln/world/kn/border/adjust_duplicate_2_faces.hh b/milena/mln/world/kn/border/fill_1_from_2_faces.hh similarity index 59% copy from milena/mln/world/kn/border/adjust_duplicate_2_faces.hh copy to milena/mln/world/kn/border/fill_1_from_2_faces.hh index ca900f6..9bb5bea 100644 --- a/milena/mln/world/kn/border/adjust_duplicate_2_faces.hh +++ b/milena/mln/world/kn/border/fill_1_from_2_faces.hh @@ -25,14 +25,15 @@ /// \file /// -/// \brief Adjust border size and duplicate 2 faces in Kn 2D images -/// borders. +/// \brief Duplicate 2 faces in KN 2D images borders. -#ifndef MLN_WORLD_KN_BORDER_ADJUST_DUPLICATE_2_FACES_HH -# define MLN_WORLD_KN_BORDER_ADJUST_DUPLICATE_2_FACES_HH +#ifndef MLN_WORLD_KN_BORDER_FILL_1_FROM_2_FACES_HH +# define MLN_WORLD_KN_BORDER_FILL_1_FROM_2_FACES_HH + +# include <mln/core/concept/image.hh> +# include <mln/core/concept/function.hh> +# include <mln/world/kn/border/fill_1_from_aux_2_faces.hh> -# include <mln/border/adjust.hh> -# include <mln/world/kn/border/duplicate_2_faces.hh> namespace mln @@ -47,38 +48,34 @@ namespace mln namespace border { - /*! \brief Adjust border size and duplicate 2 faces in Kn 2D - * images borders. + /*! \brief Compute 1 faces in Kn 2D images borders. \param[in,out] inout A 2D image immersed in KN. - \param[in] min_thickness The minimum border thickness of \p - inout. - - if \p inout has a border thickness higher than \p - min_thickness, the border size is not adjusted. + \param[in,out] f A function computing 1-faces values from 2 + 2-faces values. */ - template <typename I> - void adjust_duplicate_2_faces(Image<I>& inout, unsigned min_thickness); + template <typename I, typename F> + void fill_1_from_2_faces(const Image<I>& inout, + const Function_vv2v<F>& f); # ifndef MLN_INCLUDE_ONLY - template <typename I> - void adjust_duplicate_2_faces(Image<I>& inout_, unsigned min_thickness) + template <typename I, typename F> + void fill_1_from_2_faces(const Image<I>& inout, + const Function_vv2v<F>& f) { - trace::entering("mln::world::kn::adjust_duplicate_2_faces"); + trace::entering("mln::world::kn::fill_1_from_2_faces"); - mln_precondition(exact(inout_).is_valid()); - mln_precondition(min_thickness > 0); - I& inout = exact(inout_); + mln_precondition(exact(inout).is_valid()); + mln_precondition(exact(inout).border() >= 1); - mln::border::adjust(inout, min_thickness); - kn::border::duplicate_2_faces(inout); + border::fill_1_from_aux_2_faces(inout, inout, f); - trace::exiting("mln::world::kn::adjust_duplicate_2_faces"); + trace::exiting("mln::world::kn::fill_1_from_2_faces"); } @@ -92,4 +89,4 @@ namespace mln } // end of namespace mln -#endif // ! MLN_WORLD_KN_BORDER_ADJUST_DUPLICATE_2_FACES_HH +#endif // ! MLN_WORLD_KN_BORDER_FILL_1_FROM_2_FACES_HH diff --git a/milena/mln/world/kn/border/fill_1_from_aux_2_faces.hh b/milena/mln/world/kn/border/fill_1_from_aux_2_faces.hh new file mode 100644 index 0000000..629a11d --- /dev/null +++ b/milena/mln/world/kn/border/fill_1_from_aux_2_faces.hh @@ -0,0 +1,133 @@ +// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project 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. + +/// \file +/// +/// \brief Duplicate 2 faces in KN 2D images borders. + +#ifndef MLN_WORLD_KN_BORDER_FILL_1_FROM_AUX_2_FACES_HH +# define MLN_WORLD_KN_BORDER_FILL_1_FROM_AUX_2_FACES_HH + +# include <mln/core/concept/image.hh> +# include <mln/world/kn/is_2_face.hh> +# include <mln/world/kn/is_1_face_horizontal.hh> +# include <mln/world/kn/is_1_face_vertical.hh> +# include <mln/geom/min_row.hh> +# include <mln/geom/min_col.hh> +# include <mln/geom/max_row.hh> +# include <mln/geom/max_col.hh> + + +namespace mln +{ + + namespace world + { + + namespace kn + { + + namespace border + { + + /*! \brief Compute 1 faces in Kn 2D images borders. + + \param[in,out] inout A 2D image immersed in KN. + \param[in,out] aux A 2D image with the same domain as \p + inout. + \param[in,out] f A function computing 1-faces values from 2 + 2-faces values. + + */ + template <typename I, typename J, typename F> + void fill_1_from_aux_2_faces(const Image<I>& inout, + const Image<J>& aux, + const Function_vv2v<F>& f); + + + +# ifndef MLN_INCLUDE_ONLY + + + template <typename I, typename J, typename F> + void fill_1_from_aux_2_faces(const Image<I>& inout_, + const Image<J>& aux_, + const Function_vv2v<F>& f_) + { + trace::entering("mln::world::kn::fill_1_from_aux_2_faces"); + + mln_precondition(exact(inout_).is_valid()); + mln_precondition(exact(inout_).border() >= 1); + mln_precondition(exact(aux_).border() >= 1); + mln_precondition(exact(inout_).domain() == exact(aux_).domain()); + I& inout = const_cast<I&>(exact(inout_)); + J& aux = const_cast<J&>(exact(aux_)); + const F& f = exact(f_); + + def::coord + min_row_1 = geom::min_row(inout) - 1, + max_row_1 = geom::max_row(inout) + 1, + min_col_1 = geom::min_col(inout) - 1, + max_col_1 = geom::max_col(inout) + 1; + + // Fill horizontal border + for (def::coord col = min_col_1; col <= max_col_1; ++col) + if (is_1_face_vertical(min_row_1, col)) + { + // First row + inout.at_(min_row_1, col) = f(aux.at_(min_row_1, col - 1), + aux.at_(min_row_1, col + 1)); + // Last row + inout.at_(max_row_1, col) = f(aux.at_(max_row_1, col - 1), + aux.at_(max_row_1, col + 1)); + } + + // Fill vertical border + for (def::coord row = min_row_1; row <= max_row_1; ++row) + if (is_1_face_horizontal(row, min_col_1)) + { + // First col + inout.at_(row, min_col_1) = f(aux.at_(row - 1, min_col_1), + aux.at_(row + 1, min_col_1)); + // Last col + inout.at_(row, max_col_1) = f(aux.at_(row - 1, max_col_1), + aux.at_(row + 1, max_col_1)); + } + + trace::exiting("mln::world::kn::fill_1_from_aux_2_faces"); + } + + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::world::kn::border + + } // end of namespace mln::world::kn + + } // end of namespace mln::world + +} // end of namespace mln + +#endif // ! MLN_WORLD_KN_BORDER_FILL_1_FROM_AUX_2_FACES_HH diff --git a/milena/mln/world/kn/compute_tree_of_shapes.hh b/milena/mln/world/kn/compute_tree_of_shapes.hh index d6a5984..9c686f2 100644 --- a/milena/mln/world/kn/compute_tree_of_shapes.hh +++ b/milena/mln/world/kn/compute_tree_of_shapes.hh @@ -41,7 +41,7 @@ # include <mln/value/interval.hh> # include <mln/value/is_degenerated.hh> -# include <mln/world/kn/internal/hqueue.hh> +# include <mln/world/kn/hqueue.hh> # include <mln/util/tree_of_shapes.hh> # include <mln/world/kn/is_2_face.hh> @@ -95,7 +95,7 @@ namespace mln typedef mln_ch_value(I,P) T; typedef mln_ch_value(I,unsigned) U; typedef std::vector<P> Array_P; - typedef world::kn::internal::hqueue<P,EV> q_type; + typedef world::kn::hqueue<P,EV> q_type; compute_tree_of_shapes_t(); diff --git a/milena/mln/world/kn/fill_0_from_2_faces.hh b/milena/mln/world/kn/fill_0_from_2_faces.hh index 7164309..b8b9aaf 100644 --- a/milena/mln/world/kn/fill_0_from_2_faces.hh +++ b/milena/mln/world/kn/fill_0_from_2_faces.hh @@ -59,7 +59,7 @@ namespace mln */ template <typename I, typename F> - void fill_0_from_2_faces(Image<I>& inout, Function_vvvv2v<F>& f); + void fill_0_from_2_faces(Image<I>& inout, const Function_vvvv2v<F>& f); /// \overload template <typename I, typename A> @@ -73,12 +73,12 @@ namespace mln template <typename I, typename F> - void fill_0_from_2_faces(Image<I>& inout_, Function_vvvv2v<F>& f_) + void fill_0_from_2_faces(Image<I>& inout_, const Function_vvvv2v<F>& f_) { trace::entering("mln::world::kn::fill_0_from_2_faces"); I& inout = exact(inout_); - F& f = exact(f_); + const F& f = exact(f_); mln_precondition(inout.is_valid()); diff --git a/milena/mln/world/kn/fill_1_from_aux_2_faces.hh b/milena/mln/world/kn/fill_1_from_aux_2_faces.hh index d18e3c8..d1a12b6 100644 --- a/milena/mln/world/kn/fill_1_from_aux_2_faces.hh +++ b/milena/mln/world/kn/fill_1_from_aux_2_faces.hh @@ -34,8 +34,9 @@ # include <mln/core/alias/point2d.hh> # include <mln/world/kn/is_1_face_vertical.hh> # include <mln/world/kn/is_1_face_horizontal.hh> -# include <mln/world/kn/border/compute_1_faces.hh> # include <mln/world/kn/safe_cast.hh> +# include <mln/world/kn/border/fill_1_from_aux_2_faces.hh> +# include <mln/world/kn/border/duplicate_2_faces.hh> namespace mln { @@ -51,7 +52,7 @@ namespace mln \param[in,out] inout A 2D image immersed in KN. \param[in] aux A 2D image with the same domain as \p inout. - \param[in,out] f A functor computing a result from two values. + \param[in] f A functor computing a result from two values. Warning: \p aux borders must have been initialized with kn::border::duplicate_2_faces or have been immersed in Kn in @@ -77,7 +78,7 @@ namespace mln */ template <typename I, typename J, typename F> void fill_1_from_aux_2_faces(Image<I>& inout, const Image<J>& aux, - Function_vv2v<F>& f); + const Function_vv2v<F>& f); /// \overload template <typename I, typename J, typename A> @@ -93,19 +94,20 @@ namespace mln template <typename I, typename J, typename F> void fill_1_from_aux_2_faces(Image<I>& inout_, const Image<J>& aux_, - Function_vv2v<F>& f_) + const Function_vv2v<F>& f_) { trace::entering("mln::world::kn::fill_1_from_aux_2_faces"); I& inout = exact(inout_); const J& aux = exact(aux_); - F& f = exact(f_); + const F& f = exact(f_); mln_precondition(inout.is_valid()); mln_precondition(aux.is_valid()); mln_precondition(inout.domain() == aux.domain()); - kn::border::compute_1_faces(inout, f); + kn::border::duplicate_2_faces(aux); + kn::border::fill_1_from_aux_2_faces(inout, aux, f); mln_piter(I) p(inout.domain()); for_all(p) diff --git a/milena/tests/value/intsub.cc b/milena/tests/value/intsub.cc index 06b8f1a..2ec4671 100644 --- a/milena/tests/value/intsub.cc +++ b/milena/tests/value/intsub.cc @@ -107,4 +107,14 @@ int main() // median(6,2) = 4 mln_assertion(math::median(i, intsub<2>(2)) == 4); + + + // 2.5 * 3 + mln_assertion((l * 3) == 7.5); + + // 4 * 2.5 + mln_assertion((4 * l) == 10); + + // 2.5 * 10.25 + mln_assertion((l * k) == 25.625); } diff --git a/milena/tests/world/kn/display_enlarged.cc b/milena/tests/world/kn/display_enlarged.cc index 33b5909..9f73f00 100644 --- a/milena/tests/world/kn/display_enlarged.cc +++ b/milena/tests/world/kn/display_enlarged.cc @@ -53,24 +53,20 @@ int main() {1, 2, 2, 2, 1, 2, 2, 2, 1} }; - int vals5[17][17] = { - {1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2}, - {1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1} + int vals5[13][13] = { + {1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2}, + {1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1} }; image2d<int> ima = make::image(vals, point2d(-1, -1)); @@ -87,7 +83,7 @@ int main() } { - image2d<int> ref5 = make::image(vals5, point2d(-4, -4)); + image2d<int> ref5 = make::image(vals5, point2d(-3, -3)); image2d<int> enlarged = world::kn::display_enlarged(ima, 5); mln_assertion(ref5 == enlarged); } diff --git a/milena/tests/world/kn/fill_1_from_aux_2_faces.cc b/milena/tests/world/kn/fill_1_from_aux_2_faces.cc index 20e1c2a..8d41599 100644 --- a/milena/tests/world/kn/fill_1_from_aux_2_faces.cc +++ b/milena/tests/world/kn/fill_1_from_aux_2_faces.cc @@ -30,7 +30,6 @@ #include <mln/accu/math/sum.hh> #include <mln/fun/vv2v/sum.hh> #include <mln/world/kn/fill_1_from_aux_2_faces.hh> -#include <mln/world/kn/border/duplicate_2_faces.hh> int main() { @@ -44,7 +43,6 @@ int main() {0, 0, 0, 0, 0 } }; image2d<int> aux = make::image(auxvals, point2d(-1, -1)); - world::kn::border::duplicate_2_faces(aux); int vals[5][5] = { {1, 0, 1, 0, 1 }, diff --git a/milena/tests/world/kn/fill_2_from_1_faces.cc b/milena/tests/world/kn/fill_2_from_1_faces.cc index 1f0d170..d8a3bef 100644 --- a/milena/tests/world/kn/fill_2_from_1_faces.cc +++ b/milena/tests/world/kn/fill_2_from_1_faces.cc @@ -29,28 +29,11 @@ #include <mln/make/box2d.hh> #include <mln/data/compare.hh> #include <mln/accu/math/sum.hh> +#include <mln/fun/vvvv2v/sum.hh> #include <mln/world/kn/fill_2_from_1_faces.hh> #include <mln/border/fill.hh> -namespace mln -{ - - struct sum_t : Function_vvvv2v<sum_t> - { - typedef int result; - - int operator()(const int& v1, const int& v2, const int& v3, const int& v4) const - { - return v1 + v2 + v3 + v4; - } - - }; - -} - - - int main() { using namespace mln; @@ -86,7 +69,7 @@ int main() // Overload with function { - sum_t f; + fun::vvvv2v::sum<int> f; world::kn::fill_2_from_1_faces(imakn, f); mln_assertion(ref == imakn); } -- 1.7.2.5
participants (1)
-
Guillaume Lazzara