
https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Fix many tests. * mln/core/decorated_image.hh (mln::decorated_image<I, D>::rvalue): New typedef. (mln::decorated_image<I, D>::lvalue): Set to impl_::lvalue. (mln::decorated_image<I, D>::read_): Have it return a rvalue, not a value. (mln::decorated_image<I, D>::operator()(const psite&) const) (mln::decorated_image<I, D>::operator()(const psite&)): New operators (mln::internal::decorated_image_impl_<I, E>::write_): Fix access to delegatee's data. * mln/math/abs.hh (mln::level::abs(const value::int_u<n>&)): Declare this overload. (mln::math::abs(int)) (mln::math::abs(long)) (mln::math::abs(float)) (mln::math::abs(double)) (mln::math::abs(long double)): New overloads. * mln/border/fill.hh, * mln/level/memset_.hh: Include header cstring for std::memset. * mln/make/w_window.hh: Wrap long lines. * mln/convert/to_image.hh: Likewise. (mln::convert::to_image(const Weighted_Window<W>&)): Fill the image with zeros before copying weights. * mln/convert/to_p_array.hh: Include missing header mln/core/concept/image.hh for mln::Image. * mln/win/line.hh (mln::win::line<M,i,C>::line): Replace a dynamic assertion by a static one. * mln/value/float01_.hh (mln::trait::value< mln::value::float01_<n> >::min) (mln::trait::value< mln::value::float01_<n> >::max) (mln::trait::value< mln::value::float01_<n> >::epsilon) * mln/value/float01_f.hh (mln::trait::value< mln::value::float01_f >::min) (mln::trait::value< mln::value::float01_f >::max) (mln::trait::value< mln::value::float01_f >::epsilon) * mln/value/internal/gray_.hh (mln::trait::value< mln::value::internal::gray_<n> >::min) (mln::trait::value< mln::value::internal::gray_<n> >::max) (mln::trait::value< mln::value::internal::gray_<n> >::epsilon) * mln/value/internal/gray_f.hh (mln::trait::value< mln::value::internal::gray_f >::min) (mln::trait::value< mln::value::internal::gray_f >::max) (mln::trait::value< mln::value::internal::gray_f >::epsilon): Remove useless `const' qualifier on return type. * mln/value/proxy.hh (mln::value::proxy<I>::~proxy) (mln::value::proxy<const I>::~proxy): Change the return type of checked `read_' routine to mln_rvalue(I). * mln/value/stack.hh (mln::value::stack_image<n, I>::read_) (mln::value::stack_image<n, I>::operator()(const psite&)): Set return type to rvalue. * mln/fun/v2v/rgb_to_hsi.hh: Add missing copyright header. Add missing header guards. Wrap long lines. (mln::fun::v2v::f_rgb_to_hsi_<T_hsi>): Remove useless variable. * mln/geom/seeds2tiling.hh (mln::geom::impl::seeds2tiling): Add braces around inner `if' to avoid (visual) ambiguity w.r.t. a dangling `else'. * mln/core/fi_adaptor.hh (mln::fi_adaptor<I>::load): Ensure the image is correctly loaded. * tests/core/decorated_image.cc: Exercise mln::decorated_image< const I, D >. * tests/core/fi_adaptor.cc: Use a smaller kernel for the median filter. Use tests/data.hh and MLN_IMG_DIR to find the img/ dir. Don't call display::show. * tests/core/w_window1d_int.cc: Use meaninful input. Update documentation. * tests/linear/log.cc: Update expected values. mln/border/fill.hh | 4 +- mln/convert/to_image.hh | 11 +++++-- mln/convert/to_p_array.hh | 3 + mln/core/decorated_image.hh | 64 +++++++++++++++++++++++++++++++----------- mln/core/fi_adaptor.hh | 17 +++++++---- mln/fun/v2v/rgb_to_hsi.hh | 52 ++++++++++++++++++++++++++++++---- mln/geom/seeds2tiling.hh | 4 +- mln/io/pfm/save.hh | 1 mln/level/memset_.hh | 4 +- mln/make/w_window.hh | 8 ++--- mln/math/abs.hh | 33 ++++++++++++++++++++- mln/value/float01_.hh | 9 +++-- mln/value/float01_f.hh | 9 +++-- mln/value/internal/gray_.hh | 15 +++++---- mln/value/internal/gray_f.hh | 9 +++-- mln/value/proxy.hh | 6 +-- mln/value/stack.hh | 9 +++-- mln/win/line.hh | 4 +- tests/core/decorated_image.cc | 19 ++++++++---- tests/core/fi_adaptor.cc | 25 ++++++---------- tests/core/w_window1d_int.cc | 16 +++------- tests/linear/log.cc | 4 -- 22 files changed, 224 insertions(+), 102 deletions(-) Index: tests/core/w_window1d_int.cc --- tests/core/w_window1d_int.cc (revision 2150) +++ tests/core/w_window1d_int.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,10 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/core/w_window1d_int.cc - * - * \brief Tests on mln::w_window1d_int. - */ +/// \file tests/core/w_window1d_int.cc +/// \brief Tests on mln::w_window1d_int. #include <mln/core/w_window1d_int.hh> #include <mln/win/segment1d.hh> @@ -51,9 +49,7 @@ using namespace mln; { - int ws[] = { -1, 0, 1, - -2, 0, 2, - -1, 0, 1 }; + int ws[] = { -1, 0, 1 }; w_window1d_int w_win = make::w_window1d(ws); image1d<int> ima = convert::to_image(w_win); @@ -64,9 +60,7 @@ { w_window1d_int w_win = make::w_window(win::segment1d(3), convert::to_fun(f)); - // -3 -2 -1 0 +1 - // -2 -1 0 +1 +2 - // -1 0 +1 +2 +3 + // -1 0 +1 image1d<int> ima = convert::to_image(w_win); mln_assertion(estim::sum(ima) == 0); } Index: tests/core/fi_adaptor.cc --- tests/core/fi_adaptor.cc (revision 2150) +++ tests/core/fi_adaptor.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,10 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/core/fi_adaptor.cc - * - * \brief Test on mln::fi_adaptor. - */ +/// \file tests/core/fi_adaptor.cc +/// \brief Test on mln::fi_adaptor. #include <mln/core/fi_adaptor.hh> #include <mln/core/image2d.hh> @@ -43,7 +41,7 @@ #include <mln/display/show.hh> #include <mln/display/save.hh> -#include <FreeImagePlus.h> +#include "tests/data.hh" using namespace mln; @@ -64,13 +62,14 @@ (*.so)). */ //FreeImage_Initialise(); - win::rectangle2d rect(51, 51); + win::rectangle2d rect(3, 3); fi_adaptor< image2d< int_u<8> > > adaptor; - adaptor.load("../img/lena.pgm"); + adaptor.load(MLN_IMG_DIR "/lena.pgm"); display::save (adaptor); - display::show (adaptor, "xv"); + // FIXME: Don't use display::show in batch tests. +// display::show (adaptor, "xv"); image2d<int_u8> ima(adaptor.domain()); @@ -79,16 +78,12 @@ level::paste(ima, adaptor); display::save (adaptor); - display::show (adaptor, "xv"); + // FIXME: Don't use display::show in batch tests. +// display::show (adaptor, "xv"); // FIXME: Likewise. /* Check if this statement holds in our case. Maybe we need to involve Libtool in to handle FreeImagePlus properly. */ //FreeImage_DeInitialise(); } - - { - - } - } Index: tests/core/decorated_image.cc --- tests/core/decorated_image.cc (revision 2150) +++ tests/core/decorated_image.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,11 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/core/decorated_image.cc - * - * \brief Tests on mln::decorated_image. - * \todo Make this test work. - */ +/// \file tests/core/decorated_image.cc +/// \brief Tests on mln::decorated_image. #include <mln/core/image2d.hh> #include <mln/core/decorated_image.hh> @@ -65,4 +62,14 @@ const I& imac = ima; decorated_image< const I, counter<I> > cima_ = decorate(imac, counter<I>()); + /* Note that the statement + + cima_(p); + + alone would *not* trigger a read. It seems the compiler + optimizes in our back... */ + int v = cima_(p); + // Avoid a warning on unused value V. + v = v; + mln_assertion(count_read == 2 && count_write == 2); } Index: tests/linear/log.cc --- tests/linear/log.cc (revision 2150) +++ tests/linear/log.cc (working copy) @@ -60,9 +60,7 @@ { int min, max; estim::min_max(tmp, min, max); - // FIXME: This assertion fails. (Maybe the input file has been - // changed, but this line was not updated?) - mln_assertion(min == -929 && max == 1458); + mln_assertion(min == -929 && max == 1260); } image2d<int_u8> out(lena.domain()); Index: mln/core/fi_adaptor.hh --- mln/core/fi_adaptor.hh (revision 2150) +++ mln/core/fi_adaptor.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -37,7 +37,8 @@ * FreeImagePlus's ones. * * For compatibility reasons, images from FreeImage library which - * doesn't take more than 7bits per pixel are converted to fill 8 bits per pixel. + * doesn't take more than 7bits per pixel are converted to fill 8 bits + * per pixel. * * * COMPILATION: @@ -47,13 +48,13 @@ */ +# include <FreeImagePlus.h> + # include <mln/core/internal/image_primary.hh> # include <mln/core/box2d.hh> # include <mln/core/line_piter.hh> # include <mln/value/set.hh> -# include <FreeImagePlus.h> - namespace mln { // Fwd decl. @@ -101,7 +102,8 @@ { template <typename I> - struct image_< fi_adaptor<I> > : default_image_< mln_value(I), fi_adaptor<I> > + struct image_< fi_adaptor<I> > + : default_image_< mln_value(I), fi_adaptor<I> > { typedef trait::image::category::primary category; @@ -244,7 +246,9 @@ data_< fi_adaptor<I> >::sync_with_adaptee_() { mln_precondition(fi_ima_.isValid()); - //FIXME: doesnt work for rgb: mln_precondition(fi_ima_.getBitsPerPixel() == 8 * sizeof(mln_value(I))); + // FIXME: doesnt work for rgb: + // mln_precondition(fi_ima_.getBitsPerPixel() == + // 8 * sizeof(mln_value(I))); deallocate_(); b_ = make::box2d(fi_ima_.getHeight(), @@ -437,6 +441,7 @@ { init_(); BOOL r = this->data_->fi_ima_.load(lpszPathName, flag); + mln_assertion(this->data_->fi_ima_.isValid()); if (this->data_->fi_ima_.getBitsPerPixel() < 8) this->data_->fi_ima_.convertTo8Bits(); this->data_->sync_with_adaptee_(); Index: mln/core/decorated_image.hh --- mln/core/decorated_image.hh (revision 2150) +++ mln/core/decorated_image.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -52,6 +52,7 @@ struct decorated_image_impl_ { typedef mln::value::proxy<E> lvalue; + /// Actual write routine. void write_(const mln_psite(I)& p, const mln_value(I)& v); }; @@ -89,8 +90,13 @@ typedef decorated_image<I, D> self_; typedef internal::decorated_image_impl_< I, self_ > impl_; + /// Type of the psite. + typedef mln_psite(I) psite; + + /// Return type of read-only access. + typedef mln_rvalue(I) rvalue; /// Return type of read-write access. - typedef typename internal::morpher_lvalue_<I>::ret lvalue; + typedef typename impl_::lvalue lvalue; /// Ctors decorated_image(); @@ -105,7 +111,14 @@ /// Skeleton. typedef decorated_image< tag::image_<I>, tag::data_<D> > skeleton; - mln_value(I) read_(const mln_psite(I)& p) const; + /// Read-only access of pixel value at point site \p p. + rvalue operator()(const psite& p) const; + + /// Read-write access of pixel value at point site \p p. + lvalue operator()(const psite& p); + + /// Actual read routine. + rvalue read_(const mln_psite(I)& p) const; /// Const promotion via convertion. operator decorated_image<const I, D>() const; @@ -115,7 +128,6 @@ /// Give the decoration. D& decoration(); - }; @@ -168,34 +180,54 @@ void (D::*mr)(const I&, const mln_psite(I)&) const = & D::reading; mr = 0; typedef mlc_unconst(I) I_; - void (D::*mw)(I_&, const mln_psite(I_)&, const mln_value(I_)&) = & D::writing; + void (D::*mw)(I_&, const mln_psite(I_)&, const mln_value(I_)&) = + & D::writing; mw = 0; } - namespace internal - { - /// \internal - template <typename I, typename E> + template <typename I, typename D> inline - void - decorated_image_impl_<I,E>::write_(const mln_psite(I)& p, const mln_value(I)& v) + typename decorated_image<I,D>::rvalue + decorated_image<I,D>::operator()(const mln_psite(I)& p) const { - E& ima = internal::force_exact<E>(*this); - ima.decoration().writing(ima.data_->ima_, p, v); - ima.data_->ima_(p) = v; + mln_precondition(this->delegatee_() != 0); + return read_(p); } - } // end of namespace mln::internal + template <typename I, typename D> + inline + typename decorated_image<I,D>::lvalue + decorated_image<I,D>::operator()(const mln_psite(I)& p) + { + mln_precondition(this->delegatee_() != 0); + // Return a proxy. + return lvalue(*this, p); + } template <typename I, typename D> inline - mln_value(I) + mln_rvalue(I) decorated_image<I,D>::read_(const mln_psite(I)& p) const { this->data_->deco_.reading(this->data_->ima_, p); return this->data_->ima_(p); } + namespace internal + { + template <typename I, typename E> + inline + void + decorated_image_impl_<I,E>::write_(const mln_psite(I)& p, + const mln_value(I)& v) + { + E& ima = internal::force_exact<E>(*this); + ima.decoration().writing(*ima.delegatee_(), p, v); + (*ima.delegatee_())(p) = v; + } + + } // end of namespace mln::internal + template <typename I, typename D> inline decorated_image<I,D>::operator decorated_image<const I, D>() const Index: mln/math/abs.hh --- mln/math/abs.hh (revision 2150) +++ mln/math/abs.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -34,6 +34,7 @@ */ # include <cmath> +# include <cstdlib> # include <mln/value/all.hh> @@ -44,9 +45,30 @@ namespace math { + /// Generic version. template <typename T> T abs(const T& v); + /// Specializations for existing overloads of std::abs. + /// + /// Reference: + /// ISO/IEC 14882:2003 C++ standard, section 26.5 + /// (C Library, [lib.c.math]). + /// + /// \{ + int abs(int v); + long abs(long v); + + float abs(float v); + double abs(double v); + long double abs(long double v); + /// \} + + /// Specialization for mln::value::int_u. + template <unsigned n> + value::int_u<n> abs(const value::int_u<n>& v); + + # ifndef MLN_INCLUDE_ONLY @@ -54,9 +76,16 @@ inline T abs(const T& v) { - return std::abs(v); + return v >= 0 ? v : -v; } + inline int abs(int v) { return std::abs(v); } + inline long abs(long v) { return std::abs(v); } + + inline float abs(float v) { return std::abs(v); } + inline double abs(double v) { return std::abs(v); } + inline long double abs(long double v) { return std::abs(v); } + template <unsigned n> inline value::int_u<n> abs(const value::int_u<n>& v) Index: mln/level/memset_.hh --- mln/level/memset_.hh (revision 2150) +++ mln/level/memset_.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -33,6 +33,8 @@ * \brief Same as std::memset but for fastest images. */ +# include <cstring> + # include <mln/core/concept/image.hh> # include <mln/core/pixel.hh> # include <mln/metal/is_not_const.hh> Index: mln/value/proxy.hh --- mln/value/proxy.hh (revision 2150) +++ mln/value/proxy.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -208,7 +208,7 @@ inline proxy<I>::~proxy() { - mln_value(I) (I::*mr)(const mln_psite(I)&) const = & I::read_; + mln_rvalue(I) (I::*mr)(const mln_psite(I)&) const = & I::read_; mr = 0; void (I::*mw)(const mln_psite(I)&, const mln_value(I)&) = & I::write_; mw = 0; @@ -280,7 +280,7 @@ inline proxy<const I>::~proxy() { - mln_value(I) (I::*mr)(const mln_psite(I)&) const = & I::read_; + mln_rvalue(I) (I::*mr)(const mln_psite(I)&) const = & I::read_; mr = 0; } Index: mln/value/float01_.hh --- mln/value/float01_.hh (revision 2150) +++ mln/value/float01_.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -71,9 +72,9 @@ typedef trait::value::kind::data kind; typedef mln_value_quant_from_(card) quant; - static const float min() { return 0.f; } - static const float max() { return 1.f; } - static const float epsilon() { return 0.f; } + static float min() { return 0.f; } + static float max() { return 1.f; } + static float epsilon() { return 0.f; } typedef float sum; }; Index: mln/value/internal/gray_.hh --- mln/value/internal/gray_.hh (revision 2150) +++ mln/value/internal/gray_.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -107,9 +108,9 @@ typedef trait::value::kind::gray kind; typedef trait::value::quant::high quant; - static const self_ min(); - static const self_ max(); - static const self_ epsilon(); + static self_ min(); + static self_ max(); + static self_ epsilon(); typedef self_ sum; // FIXME: OK?. }; @@ -688,7 +689,7 @@ template <unsigned n> inline - const mln::value::internal::gray_<n> + mln::value::internal::gray_<n> value_< mln::value::internal::gray_<n> >::min() { return mln::value::internal::gray_<n>(1, 0); @@ -696,7 +697,7 @@ template <unsigned n> inline - const mln::value::internal::gray_<n> + mln::value::internal::gray_<n> value_< mln::value::internal::gray_<n> >::max() { return mln::value::internal::gray_<n>(1, 1); @@ -704,7 +705,7 @@ template <unsigned n> inline - const mln::value::internal::gray_<n> + mln::value::internal::gray_<n> value_< mln::value::internal::gray_<n> >::epsilon() { return mln::value::internal::gray_<n>(1, 0); // Means '0'. Index: mln/value/internal/gray_f.hh --- mln/value/internal/gray_f.hh (revision 2150) +++ mln/value/internal/gray_f.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -125,9 +126,9 @@ typedef trait::value::kind::gray kind; typedef mln_trait_value_quant_(equiv_) quant; - static const equiv_ min() { return 0; } - static const equiv_ max() { return 1; } - static const equiv_ epsilon() { return mln_epsilon(equiv_); } + static equiv_ min() { return 0; } + static equiv_ max() { return 1; } + static equiv_ epsilon() { return mln_epsilon(equiv_); } typedef float sum; }; Index: mln/value/stack.hh --- mln/value/stack.hh (revision 2150) +++ mln/value/stack.hh (working copy) @@ -158,6 +158,9 @@ typedef algebra::vec<n, mln_value(I)> value; /// Return type of read-only access. + /// + /// The rvalue type is not a const reference, since the value + /// type is built on the fly, and return by value (copy). typedef value rvalue; /// Return type of read-write access. @@ -183,7 +186,7 @@ /// Read-only access of pixel value at point site \p p. rvalue operator()(const psite& p) const; - value read_(const psite& p) const; + rvalue read_(const psite& p) const; /// Read-write access of pixel value at point site \p p. lvalue operator()(const psite&); @@ -256,7 +259,7 @@ template <unsigned n, typename I> inline - algebra::vec<n, mln_value(I)> + typename stack_image<n,I>::rvalue stack_image<n,I>::read_(const psite& p) const { mln_precondition(this->owns_(p)); @@ -268,7 +271,7 @@ template <unsigned n, typename I> inline - algebra::vec<n, mln_value(I)> + typename stack_image<n,I>::rvalue stack_image<n,I>::operator()(const psite& p) const { return read_(p); Index: mln/value/float01_f.hh --- mln/value/float01_f.hh (revision 2150) +++ mln/value/float01_f.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -65,9 +66,9 @@ card = 0 }; - static const float min() { return 0; } - static const float max() { return 1; } - static const float epsilon() { return mln_epsilon(float); } + static float min() { return 0; } + static float max() { return 1; } + static float epsilon() { return mln_epsilon(float); } typedef float sum; }; Index: mln/border/fill.hh --- mln/border/fill.hh (revision 2150) +++ mln/border/fill.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -33,6 +33,8 @@ * \brief Define function that fills border using a given value. */ +# include <cstring> + # include <mln/core/concept/image.hh> Index: mln/make/w_window.hh --- mln/make/w_window.hh (revision 2150) +++ mln/make/w_window.hh (working copy) @@ -53,16 +53,16 @@ * \return A weighted window. */ template <typename W, typename F> - mln::w_window<mln_dpoint(W), mln_result(F)> w_window(const Window<W>& win, - const Function_p2v<F>& wei); + mln::w_window<mln_dpoint(W), mln_result(F)> + w_window(const Window<W>& win, const Function_p2v<F>& wei); # ifndef MLN_INCLUDE_ONLY template <typename W, typename F> inline - mln::w_window<mln_dpoint(W), mln_result(F)> w_window(const Window<W>& win_, - const Function_p2v<F>& wei_) + mln::w_window<mln_dpoint(W), mln_result(F)> + w_window(const Window<W>& win_, const Function_p2v<F>& wei_) { const W& win = exact(win_); const F& wei = exact(wei_); Index: mln/convert/to_image.hh --- mln/convert/to_image.hh (revision 2150) +++ mln/convert/to_image.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -42,6 +42,8 @@ # include <mln/core/concept/weighted_window.hh> # include <mln/core/concept/neighborhood.hh> +# include <mln/literal/zero.hh> + # include <mln/convert/to_window.hh> # include <mln/geom/bbox.hh> # include <mln/level/fill.hh> @@ -106,7 +108,8 @@ /// Convert a point set \p pset into a binary image. Width of the /// converted image will be pset.bbox + 2 * \p border. template <typename S> - mln_image_from(S, bool) to_image(const Point_Set<S>& pset, unsigned border = 1); + mln_image_from(S, bool) to_image(const Point_Set<S>& pset, + unsigned border = 1); /// Convert a window \p win into a binary image. template <typename W> @@ -175,6 +178,10 @@ typedef mln_point(W) P; box_<P> b = geom::bbox(w_win); mln_image_from(W, mln_weight(W)) ima(b); + // Fill the image with zeros, as (weighted) windows are not + // necessarily box-shaped (there might be holes corresponding to + // null weights). + level::fill(ima, literal::zero); mln_qiter(W) q(w_win, P::origin); for_all(q) ima(q) = q.w(); Index: mln/convert/to_p_array.hh --- mln/convert/to_p_array.hh (revision 2150) +++ mln/convert/to_p_array.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -32,6 +32,7 @@ /// \brief Conversions to mln::p_array. # include <mln/core/p_array.hh> +# include <mln/core/concept/image.hh> # include <mln/core/concept/window.hh> Index: mln/geom/seeds2tiling.hh --- mln/geom/seeds2tiling.hh (revision 2150) +++ mln/geom/seeds2tiling.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -101,6 +101,7 @@ mln_niter(N) n(nbh, p); for_all(n) if (ima.has(n)) + { if (out(n) != 0) out(p) = out(n); else @@ -108,6 +109,7 @@ // yet we then queue again this psite } } + } trace::exiting("geom::impl::seed2tiling"); return out; Index: mln/fun/v2v/rgb_to_hsi.hh --- mln/fun/v2v/rgb_to_hsi.hh (revision 2150) +++ mln/fun/v2v/rgb_to_hsi.hh (working copy) @@ -1,3 +1,32 @@ +// Copyright (C) 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. +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_FUN_V2V_RGB_TO_HSI_HH +# define MLN_FUN_V2V_RGB_TO_HSI_HH #include <cmath> @@ -7,6 +36,7 @@ #include <mln/value/hsi.hh> +// FIXME: Split interface and implementation. namespace mln { @@ -34,17 +64,21 @@ T_hsi hsi; double alpha = inv_sqrt2 * rgb.green() - inv_sqrt2 * rgb.blue(); - double beta = 2 * inv_sqrt6 * rgb.red() - inv_sqrt6 * rgb.green() - inv_sqrt6 * rgb.blue(); - + double beta = + 2 * inv_sqrt6 * rgb.red() - + inv_sqrt6 * rgb.green() - + inv_sqrt6 * rgb.blue(); - float tmp = atan2(beta, alpha) / 3.1415 * 180.0; hsi.hue() = atan2(beta, alpha) / 3.1415 * 180.0; if (hsi.hue() < 0) hsi.hue() = hsi.hue() + 360.0; mln_invariant(hsi.hue() >= 0); hsi.sat() = std::sqrt(alpha * alpha + beta * beta); - hsi.inty() = sqrt3_3 * rgb.red() + sqrt3_3 * rgb.green() + sqrt3_3 * rgb.blue(); + hsi.inty() = + sqrt3_3 * rgb.red() + + sqrt3_3 * rgb.green() + + sqrt3_3 * rgb.blue(); return hsi; } @@ -52,6 +86,7 @@ typedef f_rgb_to_hsi_<value::hsi_f> f_rgb_to_hsi_f_t; + // FIXME: Warning: global object. f_rgb_to_hsi_f_t f_rgb_to_hsi_f; @@ -83,8 +118,10 @@ red_t r = to_r(sqrt3_3 * hsi.inty() + 2 * inv_sqrt6 * beta); - green_t g = to_g(sqrt3_3 * hsi.inty() + inv_sqrt2 * alpha - inv_sqrt6 * beta); - blue_t b = to_b(sqrt3_3 * hsi.inty() - inv_sqrt2 * alpha - inv_sqrt6 * beta); + green_t g = + to_g(sqrt3_3 * hsi.inty() + inv_sqrt2 * alpha - inv_sqrt6 * beta); + blue_t b = + to_b(sqrt3_3 * hsi.inty() - inv_sqrt2 * alpha - inv_sqrt6 * beta); T_rgb rgb(r, g, b); @@ -94,6 +131,7 @@ typedef f_hsi_to_rgb_<value::rgb8> f_hsi_to_rgb_3x8_t; + // FIXME: Warning: global object. f_hsi_to_rgb_3x8_t f_hsi_to_rgb_3x8; } // end of namespace fun::v2v @@ -101,3 +139,5 @@ } // end of namespace fun } // end of namespace mln + +#endif // ! MLN_FUN_V2V_RGB_TO_HSI_HH Index: mln/win/line.hh --- mln/win/line.hh (revision 2150) +++ mln/win/line.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -138,7 +138,7 @@ line<M,i,C>::line(unsigned length) : length_(length) { - mln_precondition(i < M::dim); + metal::bool_< i < M::dim >::check(); mln_precondition(length % 2 == 1); const int dc = length / 2; for (int c = - dc; c <= dc; ++c) Index: mln/io/pfm/save.hh --- mln/io/pfm/save.hh (revision 2150) +++ mln/io/pfm/save.hh (working copy) @@ -68,6 +68,7 @@ namespace impl { + // FIXME: Argument FILENAME is not used; remove? template <typename I> inline void save_header_(const I& ima, const std::string& filename,