3056: Move some files to trunk.

https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox Index: ChangeLog from Alexandre Abraham <abraham@lrde.epita.fr> Move some files to trunk. * abraham/mln/morpho/autarkical_leveling.hh: Update. * abraham/mln/morpho/vmt.hh: New For test purpose. * abraham/mln/morpho/vector_median.hh: Update. * abraham/mln/core/concept/meta_fun.hh: Move to trunk. * abraham/mln/math/cos.hh: Move to trunk. * abraham/mln/math/acos.hh: Move to trunk. * abraham/mln/value/shell.hh: Move to trunk. core/concept/meta_fun.hh | 79 ----------------- math/acos.hh | 65 -------------- math/cos.hh | 65 -------------- morpho/autarkical_leveling.hh | 67 ++++++++------ morpho/vector_median.hh | 2 morpho/vmt.hh | 126 +++++++++++++++++++++++++++ value/shell.hh | 190 ------------------------------------------ 7 files changed, 166 insertions(+), 428 deletions(-) Index: abraham/mln/morpho/autarkical_leveling.hh --- abraham/mln/morpho/autarkical_leveling.hh (revision 3055) +++ abraham/mln/morpho/autarkical_leveling.hh (working copy) @@ -37,11 +37,8 @@ # include <mln/morpho/includes.hh> # include <mln/morpho/general.hh> -# include <mln/accu/land.hh> -# include <mln/accu/land_basic.hh> -# include <mln/accu/min.hh> -# include <mln/accu/min_h.hh> # include <mln/norm/l2.hh> +# include <mln/level/paste.hh> namespace mln { @@ -74,23 +71,27 @@ const W& win = exact(win_); O output; + O ref; output = clone(input); - - bool modification = true; + ref = clone(input); mln_piter(I) p(input.domain()); mln_qiter(W) q(win, p); mln_qiter(W) r(win, p); + bool stable = false; + while (!stable) + { + stable = true; for_all(p) { mln_psite(W) v; double min_dist = std::numeric_limits<double>::infinity(); bool same_side = true; - for_all(q) if (input.domain().has(q)) + for_all(q) if (ref.domain().has(q)) { - for_all(r) if (input.domain().has(r) && q!=r) - if ((marker(q) - input(p)) * (marker(r) - input(p)) < 0) + for_all(r) if (ref.domain().has(r) && q!=r) + if ((marker(q) - ref(p)) * (marker(r) - ref(p)) < 0) { same_side = false; break; @@ -99,7 +100,7 @@ if (!same_side) break; - double dist = norm::l2(input(p) - marker(q)); + double dist = norm::l2(ref(p) - marker(q)); if (dist < min_dist) { min_dist = dist; @@ -107,9 +108,19 @@ } } if (same_side) + { + if (output(p) != marker(v)) + stable = false; output(p) = marker(v); + } else - output(p) = input(p); + { + if (output(p) != ref(p)) + stable = false; + output(p) = ref(p); + } + } + level::paste(output, ref); } trace::exiting("morpho::impl::general_on_set_centered__autarkical_leveling"); Index: abraham/mln/morpho/vmt.hh --- abraham/mln/morpho/vmt.hh (revision 0) +++ abraham/mln/morpho/vmt.hh (revision 0) @@ -0,0 +1,126 @@ +// 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 +// 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_MORPHO_VMT_HH +# define MLN_MORPHO_VMT_HH + +/// \file mln/morpho/vector_median.hh +/// +/// Morphological vector median filter. +/// +/// \todo The overloads are hidden and I don't know why! + +# include <mln/morpho/includes.hh> +# include <mln/morpho/general.hh> +# include <mln/accu/land.hh> +# include <mln/accu/land_basic.hh> +# include <mln/accu/min.hh> +# include <mln/accu/min_h.hh> +# include <mln/norm/l2.hh> + +namespace mln +{ + + namespace morpho + { + + /// Morphological vector_median. + template <typename I, typename W> + mln_concrete(I) + vmt(const Image<I>& input, const Window<W>& win); + + +# ifndef MLN_INCLUDE_ONLY + + namespace impl + { + + // On set with centered window (overloads). + + template <typename I, typename W> + mln_concrete(I) + vmt(const Image<I>& input_, const Window<W>& win_) + { + trace::entering("morpho::impl::general_on_set_centered__vector_median"); + + typedef mln_concrete(I) O; + const I& input = exact(input_); + const W& win = exact(win_); + + O output; + output = clone(input); + + mln_piter(I) p(input.domain()); + mln_qiter(W) q(win, p); + for_all(p) + { + mln_psite(W) v; + double min_dist = std::numeric_limits<double>::infinity(); + for_all(q) if (input.domain().has(q)) + { + double dist = norm::l2(input(p) - input(q)); + if (dist < min_dist) + { + min_dist = dist; + v = q; + } + } + output(p) = input(v); + } + + trace::exiting("morpho::impl::general_on_set_centered__vector_median"); + return output; + } + + + } // end of namespace morpho::impl + + + template <typename I, typename W> + inline + mln_concrete(I) + vmt(const Image<I>& input, const Window<W>& win) + { + trace::entering("morpho::vector_median"); + mln_precondition(exact(input).has_data()); + mln_precondition(! exact(win).is_empty()); + + mln_concrete(I) output = impl::vector_median(input, win); + + trace::exiting("morpho::vector_median"); + return output; + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::morpho + +} // end of namespace mln + + +#endif // ! MLN_MORPHO_VMT_HH Index: abraham/mln/morpho/vector_median.hh --- abraham/mln/morpho/vector_median.hh (revision 3055) +++ abraham/mln/morpho/vector_median.hh (working copy) @@ -84,7 +84,7 @@ double min_dist = std::numeric_limits<double>::infinity(); for_all(q) if (input.domain().has(q)) { - double dist = 0; + double dist = norm::l2(input(p) - input(q)); for_all(r) if (input.domain().has(r) && q!=r) dist += norm::l2(input(r) - input(q)); if (dist < min_dist)
participants (1)
-
Alexandre Abraham