
* green/mln/value/rg.hh: New library file. * green/mln/fun/v2v/rgb_to_rg.hh: New library file. * green/mln/fun/v2v/rg_to_rgb.hh: New library file. --- trunk/milena/sandbox/ChangeLog | 8 ++ .../milena/sandbox/green/mln/fun/v2v/rg_to_rgb.hh | 70 ++++++++++++ .../milena/sandbox/green/mln/fun/v2v/rgb_to_rg.hh | 70 ++++++++++++ trunk/milena/sandbox/green/mln/value/rg.hh | 116 ++++++++++++++++++++ 4 files changed, 264 insertions(+), 0 deletions(-) create mode 100644 trunk/milena/sandbox/green/mln/fun/v2v/rg_to_rgb.hh create mode 100644 trunk/milena/sandbox/green/mln/fun/v2v/rgb_to_rg.hh create mode 100644 trunk/milena/sandbox/green/mln/value/rg.hh diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog index 9c03dec..8c48c64 100644 --- a/trunk/milena/sandbox/ChangeLog +++ b/trunk/milena/sandbox/ChangeLog @@ -1,5 +1,13 @@ 2009-10-08 Yann Jacquelet <jacquelet@lrde.epita.fr> + Add a new (red,green) value type. + + * green/mln/value/rg.hh: New library file. + * green/mln/fun/v2v/rgb_to_rg.hh: New library file. + * green/mln/fun/v2v/rg_to_rgb.hh: New library file. + +2009-10-08 Yann Jacquelet <jacquelet@lrde.epita.fr> + Add histogram accumulator which produce a 2d image result. * green/mln/accu/stat/histo2d.hh: New library file. diff --git a/trunk/milena/sandbox/green/mln/fun/v2v/rg_to_rgb.hh b/trunk/milena/sandbox/green/mln/fun/v2v/rg_to_rgb.hh new file mode 100644 index 0000000..ca7ba51 --- /dev/null +++ b/trunk/milena/sandbox/green/mln/fun/v2v/rg_to_rgb.hh @@ -0,0 +1,70 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project 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. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +#ifndef MLN_FUN_V2V_RG_TO_RGB_HH +# define MLN_FUN_V2V_RG_TO_RGB_HH + +# include <mln/value/rgb.hh> +# include <mln/value/rg.hh> +# include <mln/core/contract.hh> + +/// \file +/// +/// \brief Convert rg value to rgb + +namespace mln +{ + + namespace fun + { + + namespace v2v + { + + /// \brief Convert rg value to rgb. + /// + /// \ingroup modfunv2v + + template <unsigned n> + struct rg_to_rgb : Function_v2v< rg_to_rgb<n> > + { + typedef value::rg<n> argument; + typedef value::rgb<n> result; + + result operator()(const argument& v) const + { + return value::rgb<n>(v.red(), v.green(), 127); + } + }; + + } // end of namespace mln::fun::v2v + + } // end of namespace mln::fun + +} // end of namespace mln + +#endif // ! MLN_FUN_V2V_RG_TO_RGB_HH diff --git a/trunk/milena/sandbox/green/mln/fun/v2v/rgb_to_rg.hh b/trunk/milena/sandbox/green/mln/fun/v2v/rgb_to_rg.hh new file mode 100644 index 0000000..f5163ad --- /dev/null +++ b/trunk/milena/sandbox/green/mln/fun/v2v/rgb_to_rg.hh @@ -0,0 +1,70 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project 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. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +#ifndef MLN_FUN_V2V_RGB_TO_RG_HH +# define MLN_FUN_V2V_RGB_TO_RG_HH + +# include <mln/value/rgb.hh> +# include <mln/value/rg.hh> +# include <mln/core/contract.hh> + +/// \file +/// +/// \brief Convert rgb value to rg + +namespace mln +{ + + namespace fun + { + + namespace v2v + { + + /// \brief Convert rgb value to rg. + /// + /// \ingroup modfunv2v + + template <unsigned n> + struct rgb_to_rg : Function_v2v< rgb_to_rg<n> > + { + typedef value::rgb<n> argument; + typedef value::rg<n> result; + + result operator()(const argument& v) const + { + return value::rg<n>(v); + } + }; + + } // end of namespace mln::fun::v2v + + } // end of namespace mln::fun + +} // end of namespace mln + +#endif // ! MLN_FUN_V2V_RGB_TO_RG_HH diff --git a/trunk/milena/sandbox/green/mln/value/rg.hh b/trunk/milena/sandbox/green/mln/value/rg.hh new file mode 100644 index 0000000..f7205fc --- /dev/null +++ b/trunk/milena/sandbox/green/mln/value/rg.hh @@ -0,0 +1,116 @@ +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project 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. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +#ifndef MLN_VALUE_RG_HH +# define MLN_VALUE_RG_HH + + +#include <mln/value/concept/vectorial.hh> +# include <mln/value/int_u.hh> + +#include <mln/trait/value_.hh> +# include <mln/algebra/vec.hh> + +namespace mln +{ + + namespace value + { + + // Forward declaration. + template <unsigned n> struct rg; + + } // end of namespace mln::value + + namespace trait + { + + template <unsigned n> + struct value_< mln::value::rg<n> > + { + enum { + dim = 2, + nbits = dim * n, + card = mln_value_card_from_(nbits) + }; + + typedef trait::value::nature::vectorial nature; + typedef trait::value::kind::color kind; + typedef trait::value::quant::high quant; + + typedef void comp; + typedef mln::value::int_u<n> comp_0; + typedef mln::value::int_u<n> comp_1; + + static comp_0 get_comp_0(const mln::value::rg<n>& v){return v.red(); } + static comp_1 get_comp_1(const mln::value::rg<n>& v){return v.green();} + + typedef algebra::vec<dim, float> sum; + + static const char* name() + { + static std::string s = std::string("rg").append(1, 8 + '0'); + return s.c_str(); + } + }; + + } // end of namespace mln::trait + + namespace value + { + template <unsigned n> + struct rg :public mln::value::Vectorial< rg<n> >, + public internal::value_like_< + algebra::vec< 2, int_u<n> >, // Equivalent. + algebra::vec< 2, int_u<n> >, // Encoding. + algebra::vec< 2, int >, // Interoperation. + rg<n> > // Exact. + { + typedef int_u<n> t_red; + typedef int_u<n> t_green; + + int_u<n> red() const {return this->v_[0];} + int_u<n>& red() {return this->v_[0];} + int_u<n> green() const {return this->v_[1];} + int_u<n>& green() {return this->v_[1];} + + rg(){} + rg(const rgb8& val){this->v_[0] = val.red(); this->v_[1] = val.green();} + + rg operator=(const rg& rhs) + { + if (&rhs != this) + this->v_ = rhs.v_; + + return *this; + } + }; + + } // end of namespace mln::value + +} // end of namespace mln + +#endif // ! MLN_VALUE_RG_HH -- 1.5.6.5