
* mln/fun/v2v/rgb8_to_rgbn.hh: Turn precondition into a static assertion. Remove (dead) debugging code. Rewrite Doxygen comments. Cosmetic changes. --- milena/ChangeLog | 10 +++++++++ milena/mln/fun/v2v/rgb8_to_rgbn.hh | 43 ++++++++++++------------------------ 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 7100701..212262f 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,15 @@ 2013-08-22 Roland Levillain <roland@lrde.epita.fr> + Improve Milena's mln/fun/v2v/rgb8_to_rgbn.hh. + + * mln/fun/v2v/rgb8_to_rgbn.hh: Turn precondition into a static + assertion. + Remove (dead) debugging code. + Rewrite Doxygen comments. + Cosmetic changes. + +2013-08-22 Roland Levillain <roland@lrde.epita.fr> + * mln/core/image/dmorph/sub_image.hh: Fix indentation. 2013-08-22 Roland Levillain <roland@lrde.epita.fr> diff --git a/milena/mln/fun/v2v/rgb8_to_rgbn.hh b/milena/mln/fun/v2v/rgb8_to_rgbn.hh index 74b713e..29d0d9c 100644 --- a/milena/mln/fun/v2v/rgb8_to_rgbn.hh +++ b/milena/mln/fun/v2v/rgb8_to_rgbn.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2010, 2012, 2013 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -33,8 +33,7 @@ # include <mln/core/contract.hh> /// \file -/// -/// \brief Convert rgb8 value to rgbn, n < 8. +/// \brief Conversion from mln::value::rgb8 to mln::value::rgbn. namespace mln @@ -47,53 +46,39 @@ namespace mln { - /// \brief Convert a rgb8 value to a rgn, n < 8. + /// \brief Convert an mln::value::rgb8 to an mln::value::rgbn. /// - /// \param n defines the output quantification used for the transformation. + /// \tparam n The quantification of the output value (where n < 8). /// /// \ingroup modfunv2v - // template <unsigned n> struct rgb8_to_rgbn : Function_v2v< rgb8_to_rgbn<n> > { - typedef value::rgb8 argument; + typedef value::rgb8 argument; typedef value::rgb<n> result; - /// \brief Convert a rgb8 value to a rgn, n < 8. + /// \brief Perform the conversion. /// - /// \param[in] c the rgb8 value to convert. + /// \pre The parameter (constant) n must be lower than 8. + /// + /// \param[in] c The input value. /// /// Conversion is done by computing the size by which we /// divide each rgb component. - // result operator()(const argument& c) const; - }; # ifndef MLN_INCLUDE_ONLY - /// \brief Convert a rgb8 value to a rgn, n < 8. - /// - /// \param c defines the output quantification used for the transformation. - /// - /// \ingroup modfunv2v - // template <unsigned n> typename rgb8_to_rgbn<n>::result rgb8_to_rgbn<n>::operator()(const argument& c) const { - mln_precondition(8 > n); - - unsigned size = pow(2,(8-n)); - /* - std::cout << "c : " << c << std::endl; - std::cout << "red : " << c.red() << std::endl; - std::cout << "size : " << size << std::endl; - std::cout << "res : " << (c.red() / size) << std::endl; - std::cout << "max : " << (mln_max(mln::value::int_u<n>))<< std::endl; - */ - result res(c.red() / size, c.green() / size, c.blue() / size); + mlc_bool(n < 8)::check(); + + unsigned size = pow(2, (8 - n)); + result res(c.red() / size, c.green() / size, c.blue() / size); return res; } -- 1.7.10.4