
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Remove the useless '_' postfix in some accumulators. * mln/core/site_set/p_priority.hh (front): Fix. * mln/accu/min.hh (min_): Rename as... (min): ...this. * mln/accu/max.hh (max_): Rename as... (max): ...this. * mln/accu/min_max.hh (min_max_): Rename as... (min_max): ...this. * mln/accu/pair.hh (pair_): Rename as... (pair): ...this. * mln/morpho/dilation_elementary.hh, * mln/morpho/erosion.spe.hh, * mln/morpho/erosion.hh, * mln/morpho/dilation.hh, * mln/morpho/meyer_wst.hh, * sandbox/geraud/cs2d/cs2d_morpho.hh, * sandbox/folio/dt/canvas_dt.hh, * tests/level/compute_full.cc, * tests/level/compute.cc, * tests/level/update.cc, * tests/accu/pair.cc, * tests/accu/min.cc, * tests/accu/max.cc, * tests/accu/min_max.cc, * tests/accu/tuple.cc, * doc/examples/tuto_bis.cc, * mln/debug/println.spe.hh: Update. doc/examples/tuto_bis.cc | 10 ++++---- mln/accu/max.hh | 25 +++++++++++----------- mln/accu/min.hh | 24 ++++++++++----------- mln/accu/min_max.hh | 6 ++--- mln/accu/pair.hh | 42 ++++++++++++++++++------------------- mln/core/site_set/p_priority.hh | 2 - mln/debug/println.spe.hh | 2 - mln/morpho/dilation.hh | 2 - mln/morpho/dilation_elementary.hh | 2 - mln/morpho/erosion.hh | 2 - mln/morpho/erosion.spe.hh | 2 - mln/morpho/meyer_wst.hh | 24 +++++++++++---------- sandbox/folio/dt/canvas_dt.hh | 4 +-- sandbox/geraud/cs2d/cs2d_morpho.hh | 2 - tests/accu/max.cc | 4 +-- tests/accu/min.cc | 4 +-- tests/accu/min_max.cc | 22 ++++++++++--------- tests/accu/pair.cc | 4 +-- tests/accu/tuple.cc | 2 - tests/level/compute.cc | 4 +-- tests/level/compute_full.cc | 20 ++++++++--------- tests/level/update.cc | 4 +-- 22 files changed, 109 insertions(+), 104 deletions(-) Index: tests/level/compute_full.cc --- tests/level/compute_full.cc (revision 2561) +++ tests/level/compute_full.cc (working copy) @@ -113,8 +113,8 @@ { - accu::min_<I> acu_min; - accu::max_<I> acu_max; + accu::min<I> acu_min; + accu::max<I> acu_max; I min = level::compute(acu_min, ima); I max = level::compute(acu_max, ima); @@ -125,8 +125,8 @@ { sub_image<image1d<I>, box1d> sub_ima (ima, b1); - accu::min_<I> acu_min; - accu::max_<I> acu_max; + accu::min<I> acu_min; + accu::max<I> acu_max; I min = level::compute(acu_min, sub_ima); I max = level::compute(acu_max, sub_ima); @@ -138,8 +138,8 @@ f_box1d_t f_b(b1); image_if<image1d<I>, f_box1d_t> if_ima(ima, f_b); - accu::min_<I> acu_min; - accu::max_<I> acu_max; + accu::min<I> acu_min; + accu::max<I> acu_max; I min = level::compute(acu_min, if_ima); I max = level::compute(acu_max, if_ima); @@ -173,8 +173,8 @@ } { - accu::min_<I> acu_min; - accu::max_<I> acu_max; + accu::min<I> acu_min; + accu::max<I> acu_max; I min = level::compute(acu_min, ima); I max = level::compute(acu_max, ima); @@ -204,8 +204,8 @@ else real_max = (I)(slis * rows * cols); { - accu::min_<I> acu_min; - accu::max_<I> acu_max; + accu::min<I> acu_min; + accu::max<I> acu_max; I min = level::compute(acu_min, ima); I max = level::compute(acu_max, ima); Index: tests/level/compute.cc --- tests/level/compute.cc (revision 2561) +++ tests/level/compute.cc (working copy) @@ -45,11 +45,11 @@ image2d<int> ima(size, size); debug::iota(ima); - accu::min_<int> m; + accu::min<int> m; int min = level::compute(m, ima); mln_assertion(min == 1); - accu::max_<int> M; + accu::max<int> M; int max = level::compute(M, ima); mln_assertion(max == 40000); } Index: tests/level/update.cc --- tests/level/update.cc (revision 2561) +++ tests/level/update.cc (working copy) @@ -44,8 +44,8 @@ const unsigned size = 200; image2d<int> ima(size, size); - accu::min_<int> m; - accu::max_<int> M; + accu::min<int> m; + accu::max<int> M; debug::iota(ima); level::update(m, ima); Index: tests/accu/pair.cc --- tests/accu/pair.cc (revision 2561) +++ tests/accu/pair.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -42,7 +42,7 @@ using namespace mln; { - accu::pair_<accu::mean_<int>, accu::max_<int> > mean; + accu::pair<accu::mean_<int>, accu::max<int> > mean; mean.take(10); mean.take(9); Index: tests/accu/min.cc --- tests/accu/min.cc (revision 2561) +++ tests/accu/min.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -49,6 +49,6 @@ debug::iota(ima); mln_assertion(level::compute(accu::meta::min(), ima) == 1); - accu::min_<int> m; + accu::min<int> m; mln_assertion(level::compute(m, ima) == 1); } Index: tests/accu/max.cc --- tests/accu/max.cc (revision 2561) +++ tests/accu/max.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -48,6 +48,6 @@ image2d<int> ima(3, 3); debug::iota(ima); mln_assertion(level::compute(accu::meta::max(), ima) == 9); - accu::max_<int> M; + accu::max<int> M; mln_assertion(level::compute(M, ima) == 9); } Index: tests/accu/min_max.cc --- tests/accu/min_max.cc (revision 2561) +++ tests/accu/min_max.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -51,19 +51,21 @@ { mln_accu_with_(accu::meta::min_max, int) accu; - accu.take(10); - accu.take(9); - accu.take(8); - accu.take(7); + accu.take(2); + accu.take(1); + accu.take(0); + accu.take(6); accu.take(5); accu.take(4); accu.take(3); - accu.take(2); - accu.take(1); - accu.take(0); - mln_assertion(accu.to_result().first == 0); - mln_assertion(accu.to_result().second == 10); + accu.take(10); + accu.take(9); + accu.take(8); + accu.take(7); + + mln_assertion(accu.first() == 0); + mln_assertion(accu.second() == 10); } } Index: tests/accu/tuple.cc --- tests/accu/tuple.cc (revision 2561) +++ tests/accu/tuple.cc (working copy) @@ -46,7 +46,7 @@ { using namespace mln; - typedef accu::tuple_<int, 4, accu::count_<int>, accu::max_<int>, accu::min_<int>, accu::mean_<int> > teratuple; + typedef accu::tuple_<int, 4, accu::count_<int>, accu::max<int>, accu::min<int>, accu::mean_<int> > teratuple; teratuple tuple1; teratuple tuple2; Index: doc/examples/tuto_bis.cc --- doc/examples/tuto_bis.cc (revision 2561) +++ doc/examples/tuto_bis.cc (working copy) @@ -342,11 +342,11 @@ for (unsigned i = 1; i <= nbasins; ++i) std::cout << "mean value of basin #" << i << " is " << m(i) << std::endl; - level::fill(cell, level::transform(lab, m)); - debug::println(cell); - // 2 2 2 - // - // 5 5 5 +// level::fill(cell, level::transform(lab, m)); +// debug::println(cell); +// // 2 2 2 +// // +// // 5 5 5 // DONE! Index: mln/debug/println.spe.hh --- mln/debug/println.spe.hh (revision 2561) +++ mln/debug/println.spe.hh (working copy) @@ -82,7 +82,7 @@ void println(const box2d& b, const I& input) { - accu::max_<unsigned> len_; + accu::max<unsigned> len_; mln_piter(I) p(input.domain()); for_all(p) { Index: mln/core/site_set/p_priority.hh --- mln/core/site_set/p_priority.hh (revision 2561) +++ mln/core/site_set/p_priority.hh (working copy) @@ -275,7 +275,7 @@ p_priority<P,Q>::front() const { mln_precondition(! this->is_empty()); // Also test invariants. - std::map<P,Q>& q__ = const_cast< std::map<P,Q>& >(q_); + q_type_& q__ = const_cast< q_type_& >(q_); return q__[highest_priority()].front(); } Index: mln/accu/min.hh --- mln/accu/min.hh (revision 2561) +++ mln/accu/min.hh (working copy) @@ -51,18 +51,18 @@ * The parameter \c T is the type of values. */ template <typename T> - struct min_ : public mln::accu::internal::base< const T&, min_<T> > + struct min : public mln::accu::internal::base< const T&, min<T> > { typedef T argument; - min_(); + min(); /// Manipulators. /// \{ void init(); void take_as_init(const argument& t); void take(const argument& t); - void take(const min_<T>& other); + void take(const min<T>& other); /// \} /// Get the value of the accumulator. @@ -78,7 +78,7 @@ }; - template <typename I> struct min_< util::pix<I> >; + template <typename I> struct min< util::pix<I> >; @@ -92,7 +92,7 @@ template <typename T> struct with { - typedef min_<T> ret; + typedef accu::min<T> ret; }; }; @@ -104,7 +104,7 @@ template <typename T> inline - min_<T>::min_() + min<T>::min() { init(); } @@ -112,21 +112,21 @@ template <typename T> inline void - min_<T>::init() + min<T>::init() { t_ = mln_max(T); } template <typename T> inline - void min_<T>::take_as_init(const argument& t) + void min<T>::take_as_init(const argument& t) { t_ = t; } template <typename T> inline - void min_<T>::take(const argument& t) + void min<T>::take(const argument& t) { if (t < t_) t_ = t; @@ -135,7 +135,7 @@ template <typename T> inline void - min_<T>::take(const min_<T>& other) + min<T>::take(const min<T>& other) { if (other.t_ < t_) t_ = other.t_; @@ -144,7 +144,7 @@ template <typename T> inline const T& - min_<T>::to_result() const + min<T>::to_result() const { return t_; } @@ -152,7 +152,7 @@ template <typename T> inline bool - min_<T>::is_valid() const + min<T>::is_valid() const { return true; } Index: mln/accu/max.hh --- mln/accu/max.hh (revision 2561) +++ mln/accu/max.hh (working copy) @@ -51,18 +51,18 @@ * The parameter \c T is the type of values. */ template <typename T> - struct max_ : public mln::accu::internal::base< const T& , max_<T> > + struct max : public mln::accu::internal::base< const T& , max<T> > { typedef T argument; - max_(); + max(); /// Manipulators. /// \{ void init(); void take_as_init(const argument& t); void take(const argument& t); - void take(const max_<T>& other); + void take(const max<T>& other); /// \} /// Get the value of the accumulator. @@ -78,7 +78,7 @@ }; - template <typename I> struct max_< util::pix<I> >; + template <typename I> struct max< util::pix<I> >; namespace meta @@ -91,18 +91,19 @@ template <typename T> struct with { - typedef max_<T> ret; + typedef accu::max<T> ret; }; }; } // end of namespace mln::accu::meta + # ifndef MLN_INCLUDE_ONLY template <typename T> inline - max_<T>::max_() + max<T>::max() { init(); } @@ -110,7 +111,7 @@ template <typename T> inline void - max_<T>::init() + max<T>::init() { t_ = mln_min(T); } @@ -118,7 +119,7 @@ template <typename T> inline void - max_<T>::take_as_init(const argument& t) + max<T>::take_as_init(const argument& t) { t_ = t; } @@ -126,7 +127,7 @@ template <typename T> inline void - max_<T>::take(const argument& t) + max<T>::take(const argument& t) { if (t > t_) t_ = t; @@ -135,7 +136,7 @@ template <typename T> inline void - max_<T>::take(const max_<T>& other) + max<T>::take(const max<T>& other) { if (other.t_ > t_) t_ = other.t_; @@ -144,7 +145,7 @@ template <typename T> inline const T& - max_<T>::to_result() const + max<T>::to_result() const { return t_; } @@ -152,7 +153,7 @@ template <typename T> inline bool - max_<T>::is_valid() const + max<T>::is_valid() const { return true; } Index: mln/accu/min_max.hh --- mln/accu/min_max.hh (revision 2561) +++ mln/accu/min_max.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -55,12 +55,12 @@ * The parameter \c V is the type of values. */ template <typename V> - struct min_max_ : public pair_< min_<V>, max_<V> > + struct min_max : public pair< min<V>, max<V> > { }; - template <typename I> struct min_max_< util::pix<I> >; + template <typename I> struct min_max< util::pix<I> >; namespace meta Index: mln/accu/pair.hh --- mln/accu/pair.hh (revision 2561) +++ mln/accu/pair.hh (working copy) @@ -56,28 +56,28 @@ * \todo Check that, when T is not provided, A1 and A2 have the same value. */ template <typename A1, typename A2, typename T = mln_argument(A1)> - struct pair_ : public mln::accu::internal::base< std::pair< mlc_unqualif(mln_result(A1)) , mlc_unqualif(mln_result(A2)) > , pair_<A1,A2,T> > + struct pair : public mln::accu::internal::base< std::pair<mln_result(A1), mln_result(A2)>, + pair<A1,A2,T> > { typedef T argument; - typedef mlc_unqualif(mln_result(A1)) result_1; - typedef mlc_unqualif(mln_result(A2)) result_2; - typedef std::pair<result_1, result_2> result; + typedef mln_result(A1) result_1; + typedef mln_result(A2) result_2; - pair_(); - pair_(const A1& a1, const A2& a2); + pair(); + pair(const A1& a1, const A2& a2); /// Manipulators. /// \{ void init(); void take_as_init(const argument& t); void take(const argument& t); - void take(const pair_<A1,A2,T>& other); + void take(const pair<A1,A2,T>& other); /// \} /// Get the value of the accumulator. /// \{ - result to_result() const; + std::pair<mln_result(A1), mln_result(A2)> to_result() const; void get_result(result_1& r1, result_2& r2) const; /// \} @@ -107,7 +107,7 @@ { typedef mln_accu_with(A1, T) A1_T; typedef mln_accu_with(A2, T) A2_T; - typedef pair_<A1_T, A2_T, T> ret; + typedef accu::pair<A1_T, A2_T, T> ret; }; }; @@ -118,7 +118,7 @@ template <typename A1, typename A2, typename T> inline - pair_<A1,A2,T>::pair_() + pair<A1,A2,T>::pair() { init(); } @@ -126,7 +126,7 @@ template <typename A1, typename A2, typename T> inline void - pair_<A1,A2,T>::init() + pair<A1,A2,T>::init() { a1_.init(); a2_.init(); @@ -135,7 +135,7 @@ template <typename A1, typename A2, typename T> inline void - pair_<A1,A2,T>::take_as_init(const argument& t) + pair<A1,A2,T>::take_as_init(const argument& t) { a1_.take_as_init(t); a2_.take_as_init(t); @@ -144,7 +144,7 @@ template <typename A1, typename A2, typename T> inline void - pair_<A1,A2,T>::take(const argument& t) + pair<A1,A2,T>::take(const argument& t) { a1_.take(t); a2_.take(t); @@ -153,7 +153,7 @@ template <typename A1, typename A2, typename T> inline void - pair_<A1,A2,T>::take(const pair_<A1,A2,T>& other) + pair<A1,A2,T>::take(const pair<A1,A2,T>& other) { a1_.take(other.a1_); a2_.take(other.a2_); @@ -161,17 +161,17 @@ template <typename A1, typename A2, typename T> inline - typename pair_<A1,A2,T>::result - pair_<A1,A2,T>::to_result() const + std::pair<mln_result(A1), mln_result(A2)> + pair<A1,A2,T>::to_result() const { - result tmp(a1_.to_result(), a2_.to_result()); + std::pair<mln_result(A1), mln_result(A2)> tmp(a1_.to_result(), a2_.to_result()); return tmp; } template <typename A1, typename A2, typename T> inline void - pair_<A1,A2,T>::get_result(result_1& r1, + pair<A1,A2,T>::get_result(result_1& r1, result_2& r2) const { r1 = a1_.to_result(); @@ -181,7 +181,7 @@ template <typename A1, typename A2, typename T> inline mln_result(A1) - pair_<A1,A2,T>::first() const + pair<A1,A2,T>::first() const { return a1_.to_result(); } @@ -189,7 +189,7 @@ template <typename A1, typename A2, typename T> inline mln_result(A2) - pair_<A1,A2,T>::second() const + pair<A1,A2,T>::second() const { return a2_.to_result(); } @@ -197,7 +197,7 @@ template <typename A1, typename A2, typename T> inline bool - pair_<A1,A2,T>::is_valid() const + pair<A1,A2,T>::is_valid() const { return a1_.is_valid() && a2_.is_valid(); } Index: mln/morpho/dilation_elementary.hh --- mln/morpho/dilation_elementary.hh (revision 2561) +++ mln/morpho/dilation_elementary.hh (working copy) @@ -76,7 +76,7 @@ mln_concrete(I) output; initialize(output, input); - accu::min_max_<mln_value(I)> m; + accu::min_max<mln_value(I)> m; mln_piter(I) p(input.domain()); mln_niter(N) n(nbh, p); for_all(p) Index: mln/morpho/erosion.spe.hh --- mln/morpho/erosion.spe.hh (revision 2561) +++ mln/morpho/erosion.spe.hh (working copy) @@ -111,7 +111,7 @@ mln_pixter(const I) p(input); mln_pixter(O) o(output); mln_qixter(const I, W) q(p, win); - accu::min_<mln_value(I)> min; + accu::min<mln_value(I)> min; for_all_2(p, o) { min.init(); Index: mln/morpho/erosion.hh --- mln/morpho/erosion.hh (revision 2561) +++ mln/morpho/erosion.hh (working copy) @@ -78,7 +78,7 @@ mln_concrete(I) output; initialize(output, input); - accu::min_<mln_value(I)> min; + accu::min<mln_value(I)> min; mln_piter(I) p(input.domain()); mln_qiter(W) q(win, p); Index: mln/morpho/dilation.hh --- mln/morpho/dilation.hh (revision 2561) +++ mln/morpho/dilation.hh (working copy) @@ -97,7 +97,7 @@ // FIXME: border::adjust(input, win.delta()); extension::fill(input, mln_min(mln_value(I))); - accu::max_<mln_value(I)> max; + accu::max<mln_value(I)> max; mln_piter(I) p(input.domain()); mln_qiter(W) q(win, p); Index: mln/morpho/meyer_wst.hh --- mln/morpho/meyer_wst.hh (revision 2561) +++ mln/morpho/meyer_wst.hh (working copy) @@ -49,6 +49,10 @@ # include <mln/literal/zero.hh> # include <mln/labeling/regional_minima.hh> +# include <mln/core/site_set/p_queue_fast.hh> +# include <mln/core/site_set/p_priority.hh> + + namespace mln { @@ -115,6 +119,9 @@ typedef L marker; const marker unmarked = literal::zero; + typedef mln_value(I) V; + const V max = mln_max(V); + // Initialize the output with the markers (minima components). mln_ch_value(I, marker) output = labeling::regional_minima (input, nbh, nbasins); @@ -122,13 +129,8 @@ typedef mln_psite(I) psite; // Ordered queue. - /* FIXME: Milena probably already provides an ordered queue - facility via the mln::p_priority class. Try to use it - instead, and get rid of mln/util/greater_psite.hh. */ - typedef - std::priority_queue< psite, std::vector<psite>, util::greater_psite<I> > - ordered_queue_type; - ordered_queue_type queue(util::make_greater_psite(input)); + typedef p_queue_fast<psite> Q; + p_priority<mln_value(I), Q> queue; // Insert every neighbor P of every marked area in a // hierarchical queue, with a priority level corresponding to @@ -140,16 +142,16 @@ for_all(n) if (output.domain().has(n) && output(n) != unmarked) { - queue.push(p); + queue.push(max - input(p), p); break; } /* Until the queue is empty, extract a psite P from the hierarchical queue, at the highest priority level, that is, the lowest level. */ - while (!queue.empty()) + while (! queue.is_empty()) { - psite p = queue.top(); + psite p = queue.front(); queue.pop(); // Last seen marker adjacent to P. marker adjacent_marker = unmarked; @@ -180,7 +182,7 @@ output(p) = adjacent_marker; for_all(n) if (output.domain().has(n) && output(n) == unmarked) - queue.push(n); + queue.push(max - input(n), n); } } return output; Index: sandbox/geraud/cs2d/cs2d_morpho.hh --- sandbox/geraud/cs2d/cs2d_morpho.hh (revision 2561) +++ sandbox/geraud/cs2d/cs2d_morpho.hh (working copy) @@ -45,7 +45,7 @@ mln_concrete(I) output; initialize(output, input); - accu::min_max_<mln_value(I)> m; + accu::min_max<mln_value(I)> m; mln_piter(I) p(input.domain()); mln_niter(N) n(nbh, p); Index: sandbox/folio/dt/canvas_dt.hh --- sandbox/folio/dt/canvas_dt.hh (revision 2561) +++ sandbox/folio/dt/canvas_dt.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -97,7 +97,7 @@ initialize(distance, f.input); // Mod determination. - mln::accu::max_<unsigned> accu; + mln::accu::max<unsigned> accu; mln_fwd_piter(I) p(f.input.domain()); mln_qiter(N) n(f.nbh, p); for_all(n)