3359: Add new meta functions to retrieve HSL components.

* mln/fun/all.hh: include meta/all.hh. * mln/fun/meta/all.hh: new. Includes meta/*.hh. * mln/fun/meta/hue.hh: add new specialization for value::hsl. * mln/fun/meta/lum.hh, * mln/fun/meta/sat.hh: new. Introduce new meta functions to retrieve HSL components. --- milena/ChangeLog | 14 +++++++++ milena/mln/fun/all.hh | 2 +- milena/mln/fun/{ => meta}/all.hh | 47 +++++++++++-------------------- milena/mln/fun/meta/hue.hh | 32 +++++++++++++++++++++- milena/mln/fun/meta/{hue.hh => lum.hh} | 35 +++++++++++------------ milena/mln/fun/meta/sat.hh | 34 ++++++++++++++++++++++- 6 files changed, 113 insertions(+), 51 deletions(-) copy milena/mln/fun/{ => meta}/all.hh (64%) copy milena/mln/fun/meta/{hue.hh => lum.hh} (74%) diff --git a/milena/ChangeLog b/milena/ChangeLog index 126f352..7cf4e5b 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,19 @@ 2009-02-12 Guillaume Lazzara <z@lrde.epita.fr> + Add new meta functions to retrieve HSL components. + + * mln/fun/all.hh: include meta/all.hh. + + * mln/fun/meta/all.hh: new. Includes meta/*.hh. + + * mln/fun/meta/hue.hh: add new specialization for value::hsl. + + * mln/fun/meta/lum.hh, + * mln/fun/meta/sat.hh: new. Introduce new meta functions to retrieve + HSL components. + +2009-02-12 Guillaume Lazzara <z@lrde.epita.fr> + Fix from_to overloads and add missing operators in value::hsl. * mln/convert/from_to.hxx: Update forward declarations to from_to diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/all.hh index 62c6a45..8e9ddad 100644 --- a/milena/mln/fun/all.hh +++ b/milena/mln/fun/all.hh @@ -61,7 +61,7 @@ namespace mln # include <mln/fun/x2p/all.hh> # include <mln/fun/x2v/all.hh> # include <mln/fun/x2x/all.hh> - +# include <mln/fun/meta/all.hh> #endif // ! MLN_FUN_ALL_HH diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/meta/all.hh similarity index 64% copy from milena/mln/fun/all.hh copy to milena/mln/fun/meta/all.hh index 62c6a45..23d7bc2 100644 --- a/milena/mln/fun/all.hh +++ b/milena/mln/fun/meta/all.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008, 2009 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,43 +26,29 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_FUN_ALL_HH -# define MLN_FUN_ALL_HH - -/*! \file mln/fun/all.hh - * - * \brief File that includes all fun-related routines. - */ - +#ifndef MLN_FUN_META_ALL_HH +# define MLN_FUN_META_ALL_HH namespace mln { - /// Namespace of image processing routines related to functions. - namespace fun + namespace meta { - /// Internal namespace of functions. - namespace internal - { - } - } - -} + } // end of namespace mln::meta +} // end of namespace mln -# include <mln/fun/c.hh> -# include <mln/fun/ops.hh> -# include <mln/fun/i2v/all.hh> -# include <mln/fun/p2b/all.hh> -# include <mln/fun/p2v/all.hh> -# include <mln/fun/v2b/all.hh> -# include <mln/fun/v2v/all.hh> -# include <mln/fun/vv2v/all.hh> -# include <mln/fun/x2p/all.hh> -# include <mln/fun/x2v/all.hh> -# include <mln/fun/x2x/all.hh> +#include<mln/fun/meta/red.hh> +#include<mln/fun/meta/hue.hh> +#include<mln/fun/meta/lum.hh> +#include<mln/fun/meta/all.hh> +#include<mln/fun/meta/green.hh> +#include<mln/fun/meta/inty.hh> +#include<mln/fun/meta/blue.hh> +#include<mln/fun/meta/sat.hh> +#include<mln/fun/meta/to_enc.hh> +#endif // ! MLN_FUN_META_ALL_HH -#endif // ! MLN_FUN_ALL_HH diff --git a/milena/mln/fun/meta/hue.hh b/milena/mln/fun/meta/hue.hh index a1db15f..018348f 100644 --- a/milena/mln/fun/meta/hue.hh +++ b/milena/mln/fun/meta/hue.hh @@ -33,6 +33,7 @@ /// /// Meta function to retrieve/modify the color hue. +# include <mln/value/hsl.hh> # include <mln/value/hsi.hh> # include <mln/core/concept/meta_fun.hh> @@ -63,9 +64,21 @@ namespace mln H& write(value& h); }; + template <class H, class S, class L> + struct function< meta::hue< value::hsl_<H, S, L> > > + : public Function_v2w_w2v<function< meta::hue < value::hsl_<H, S, L> > > > + { + typedef value::hsl_<H, S, L> value; + + typedef H result; + H read(const value& h); + + typedef H& lresult; + H& write(value& h); + }; -# ifndef MLN_INCLUDE_ONLY +# ifndef MLN_INCLUDE_ONLY template <class H, class S, class I> inline @@ -84,6 +97,23 @@ namespace mln } + template <class H, class S, class L> + inline + H + function< meta::hue< value::hsl_<H, S, L> > >::read(const value& h) + { + return h.hue(); + } + + template <class H, class S, class L> + inline + H& + function< meta::hue< value::hsl_<H, S, L> > >::write(value& h) + { + return h.hue(); + } + + # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/fun/meta/hue.hh b/milena/mln/fun/meta/lum.hh similarity index 74% copy from milena/mln/fun/meta/hue.hh copy to milena/mln/fun/meta/lum.hh index a1db15f..2c987b9 100644 --- a/milena/mln/fun/meta/hue.hh +++ b/milena/mln/fun/meta/lum.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2009 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 @@ -26,14 +26,14 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_FUN_META_HUE_HH -# define MLN_FUN_META_HUE_HH +#ifndef MLN_FUN_META_LUM_HH +# define MLN_FUN_META_LUM_HH -/// \file mln/fun/meta/hue.hh +/// \file mln/fun/meta/infy.hh /// -/// Meta function to retrieve/modify the color hue. +/// Meta function to retrieve/modify the color luminosity. -# include <mln/value/hsi.hh> +# include <mln/value/hsl.hh> # include <mln/core/concept/meta_fun.hh> namespace mln @@ -43,18 +43,19 @@ namespace mln { template <class H> - struct hue : impl< hue<H> > + struct lum : impl< lum<H> > { typedef H value; }; } // end of namespace mln::meta + template <class H, class S, class I> - struct function< meta::hue< value::hsi_<H, S, I> > > - : public Function_v2w_w2v<function< meta::hue < value::hsi_<H, S, I> > > > + struct function< meta::lum< value::hsl_<H, S, I> > > + : public Function_v2w_w2v<function< meta::lum < value::hsl_<H, S, I> > > > { - typedef value::hsi_<H, S, I> value; + typedef value::hsl_<H, S, I> value; typedef H result; H read(const value& h); @@ -66,27 +67,25 @@ namespace mln # ifndef MLN_INCLUDE_ONLY - template <class H, class S, class I> inline H - function< meta::hue< value::hsi_<H, S, I> > >::read(const value& h) + function< meta::lum< value::hsl_<H, S, I> > >::read(const value& h) { - return h.hue(); + return h.lum(); } template <class H, class S, class I> inline H& - function< meta::hue< value::hsi_<H, S, I> > >::write(value& h) + function< meta::lum< value::hsl_<H, S, I> > >::write(value& h) { - return h.hue(); + return h.lum(); } - # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln -#endif // MLN_FUN_META_HUE_HH +#endif // MLN_FUN_META_LUM_HH diff --git a/milena/mln/fun/meta/sat.hh b/milena/mln/fun/meta/sat.hh index bf4c74a..16fe0fd 100644 --- a/milena/mln/fun/meta/sat.hh +++ b/milena/mln/fun/meta/sat.hh @@ -33,6 +33,7 @@ /// /// Meta function to retrieve/modify the color saturation. +# include <mln/value/hsl.hh> # include <mln/value/hsi.hh> # include <mln/core/concept/meta_fun.hh> @@ -65,8 +66,21 @@ namespace mln }; -# ifndef MLN_INCLUDE_ONLY + template <class H, class S, class L> + struct function< meta::sat< value::hsl_<H, S, L> > > + : public Function_v2w_w2v<function< meta::sat < value::hsl_<H, S, L> > > > + { + typedef value::hsl_<H, S, L> value; + typedef H result; + H read(const value& h); + + typedef H& lresult; + H& write(value& h); + }; + + +# ifndef MLN_INCLUDE_ONLY template <class H, class S, class I> inline @@ -85,6 +99,24 @@ namespace mln } + + template <class H, class S, class L> + inline + H + function< meta::sat< value::hsl_<H, S, L> > >::read(const value& h) + { + return h.sat(); + } + + template <class H, class S, class L> + inline + H& + function< meta::sat< value::hsl_<H, S, L> > >::write(value& h) + { + return h.sat(); + } + + # endif // ! MLN_INCLUDE_ONLY -- 1.5.6.5
participants (1)
-
Guillaume Lazzara