3345: Various small fixes.

* mln/convert/from_to.hxx * mln/value/label.hh: add a missing from_to(int_u, label). * mln/core/alias/neighb3d.hh: add c4_3d(). * mln/core/concept/function.hh * mln/labeling/regional_maxima.hh * mln/labeling/regional_minima.hh: fix warnings. * mln/util/timer.hh: fix unit test. * mln/value/rgb.hh: remove a useless exact(). --- milena/ChangeLog | 17 +++++++++++++ milena/mln/convert/from_to.hxx | 5 ++++ milena/mln/core/alias/neighb3d.hh | 33 +++++++++++++++++++++++++ milena/mln/core/concept/function.hh | 3 +- milena/mln/labeling/regional_maxima.hh | 6 +++- milena/mln/labeling/regional_minima.hh | 2 +- milena/mln/util/timer.hh | 2 +- milena/mln/value/label.hh | 42 ++++++++++++++++++++++++++++++++ milena/mln/value/rgb.hh | 3 +- 9 files changed, 106 insertions(+), 7 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 6222bdb..fb64ae9 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,20 @@ +2009-02-11 Guillaume Lazzara <z@lrde.epita.fr> + + Various small fixes. + + * mln/convert/from_to.hxx + * mln/value/label.hh: add a missing from_to(int_u, label). + + * mln/core/alias/neighb3d.hh: add c4_3d(). + + * mln/core/concept/function.hh + * mln/labeling/regional_maxima.hh + * mln/labeling/regional_minima.hh: fix warnings. + + * mln/util/timer.hh: fix unit test. + + * mln/value/rgb.hh: remove a useless exact(). + 2009-02-11 Thierry Geraud <thierry.geraud@lrde.epita.fr> Add morpho algebraic closing. diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx index 160acaa..4649932 100644 --- a/milena/mln/convert/from_to.hxx +++ b/milena/mln/convert/from_to.hxx @@ -84,6 +84,7 @@ namespace mln template <unsigned n> struct rgb; template <typename H, typename S, typename L> class hsl_; template <unsigned n> struct int_u; + template <unsigned n> struct label; } // end of Forward declarations. @@ -155,6 +156,10 @@ namespace mln template <unsigned m> void from_to_(const value::int_u<m>& from, value::rgb<m>& to); + // int_u -> label + template <unsigned n> + void from_to_(const value::int_u<n>& from, value::label<n>& to_); + // hsl -> rgb8. template <typename H, typename S, typename L> void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to); diff --git a/milena/mln/core/alias/neighb3d.hh b/milena/mln/core/alias/neighb3d.hh index c023172..59d72bb 100644 --- a/milena/mln/core/alias/neighb3d.hh +++ b/milena/mln/core/alias/neighb3d.hh @@ -50,6 +50,23 @@ namespace mln */ typedef neighb<window3d> neighb3d; + /// 4-connectivity neighborhood on the 3D grid. + /// + /// . . . + /// . . . + /// . . . + /// + /// . o . + /// o x o + /// . o . + /// + /// . . . + /// . . . + /// . . . + /// + /// \return A neighb3d. + /// + const neighb3d& c4_3d(); /*! \brief 6-connectivity neighborhood on the 3D grid. * @@ -126,6 +143,22 @@ namespace mln # ifndef MLN_INCLUDE_ONLY inline + const neighb3d& c4_3d() + { + static neighb3d it; + if (it.size() == 0) + { + window3d& win = it.hook_win_(); + win + .insert(0, 1, 0) + .insert(0, 0, 1); + win + .insert(win::sym(win)); + } + return it; + } + + inline const neighb3d& c6() { static neighb3d it; diff --git a/milena/mln/core/concept/function.hh b/milena/mln/core/concept/function.hh index 8aada68..2d8baff 100644 --- a/milena/mln/core/concept/function.hh +++ b/milena/mln/core/concept/function.hh @@ -537,7 +537,8 @@ namespace mln template <typename E> inline Function_p2p<E>::Function_p2p(const Function_p2p<E>& rhs) - : Function_p2v<E>(rhs) + : Function_v2v<E>(rhs), + Function_p2v<E>(rhs) { } diff --git a/milena/mln/labeling/regional_maxima.hh b/milena/mln/labeling/regional_maxima.hh index 595b6ce..37ac428 100644 --- a/milena/mln/labeling/regional_maxima.hh +++ b/milena/mln/labeling/regional_maxima.hh @@ -87,7 +87,7 @@ namespace mln input(p); } void do_no_union(const P& n, const P& p) { mln_invariant(input(n) > input(p)); - attr(p) = false; } + attr(p) = false; (void)n; } void init_attr(const P&) {} void merge_attr(const P& r, const P& p) { attr(p) = attr(p) && attr(r); } @@ -101,7 +101,9 @@ namespace mln input.element(p); } void do_no_union_(unsigned n, unsigned p) { mln_invariant(input.element(n) > input.element(p)); - attr.element(p) = false; } + attr.element(p) = false; + (void) n; + } void init_attr_(unsigned) {} void merge_attr_(unsigned r, unsigned p) { attr.element(p) = attr.element(p) && attr.element(r); } diff --git a/milena/mln/labeling/regional_minima.hh b/milena/mln/labeling/regional_minima.hh index a70f1c7..a804cad 100644 --- a/milena/mln/labeling/regional_minima.hh +++ b/milena/mln/labeling/regional_minima.hh @@ -101,7 +101,7 @@ namespace mln // Fastest implementation void init_() { data::fill(attr, true); } - bool handles_(unsigned p) const { return true; } + bool handles_(unsigned) const { return true; } bool labels_(unsigned p) const { return attr.element(p); } bool equiv_(unsigned n, unsigned p) const { return input.element(n) == input.element(p); } diff --git a/milena/mln/util/timer.hh b/milena/mln/util/timer.hh index 49b0b2e..6ef3256 100644 --- a/milena/mln/util/timer.hh +++ b/milena/mln/util/timer.hh @@ -44,7 +44,7 @@ namespace mln /// Timer structure. class timer : public Proxy< timer >, - public internal::proxy_impl<float, timer> + public mln::internal::proxy_impl<float, timer> { public: diff --git a/milena/mln/value/label.hh b/milena/mln/value/label.hh index 4a97a5c..3aa473b 100644 --- a/milena/mln/value/label.hh +++ b/milena/mln/value/label.hh @@ -81,6 +81,20 @@ namespace mln } // end of namespace trait + namespace convert + { + + namespace over_load + { + + // int_u -> label. + template <unsigned n> + void + from_to_(const value::int_u<n>& from, value::label<n>& to_); + + } // end of namespace mln::convert::over_load + + } // end of namespace mln::convert namespace value { @@ -148,8 +162,36 @@ namespace mln std::ostream& operator<<(std::ostream& ostr, const label<n>& l); + } // end of namespace mln::value + + # ifndef MLN_INCLUDE_ONLY + + namespace convert + { + + namespace over_load + { + + // int_u -> label. + template <unsigned n> + inline + void + from_to_(const value::int_u<n>& from, value::label<n>& to_) + { + to_ = from; + } + + } // end of namespace mln::convert::over_load + + } // end of namespace mln::convert + + + + namespace value + { + template <unsigned n> inline label<n>::label() diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh index 6b2a479..9c64936 100644 --- a/milena/mln/value/rgb.hh +++ b/milena/mln/value/rgb.hh @@ -723,9 +723,8 @@ namespace mln template <typename T, unsigned m> inline void - from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to_) + from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to) { - value::rgb<m>& to = exact(to_); algebra::vec<3, unsigned> tmp; for (unsigned i = 0; i < 3; ++i) tmp[i] = static_cast<unsigned>(from[i]); // FIXME: Use from_to_ instead of cast. -- 1.5.6.5
participants (1)
-
Guillaume Lazzara