Commit 0a757997 authored by Yann Jacquelet's avatar Yann Jacquelet
Browse files

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.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4623 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 36df02b2
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.
......
// 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
// 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
// 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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment