Commit 1307e9db authored by Yann Jacquelet's avatar Yann Jacquelet
Browse files

Add milena library components.

	* green/mln/accu/stat/histo1d.hh: New header component.
	* green/mln/fun/p2b/achromatic.hh: New header component.
	* green/mln/fun/p2b/component_equals.hh: New header component.
	* green/mln/fun/v2v/achromatism.hh: New header component.
	* green/mln/fun/v2v/hue_concentration.hh: New header component.
	* green/mln/fun/v2v/rgb_to_achromatism_map.hh: New header component.
	* green/mln/fun/v2v/rgb_to_hsv.hh: New header component.
	* green/mln/fun/v2v/rgb_to_hue_map.hh: New header component.
	* green/mln/fun/v2v/rgb_to_saturation_map.hh: New header component.
	* green/mln/fun/v2v/rgb_to_value_map.hh: New header component.
	* green/mln/img_path.hh: New header component.
	* green/mln/math/ceil.hh: New header component.
	* green/mln/math/floor.hh: New header component.
	* green/mln/math/hsv.hh: New header component.
parent 71f26fd5
......@@ -77,7 +77,37 @@
2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr>
Work on Millet saturation descriptor.
Add milena library components.
* green/mln/accu/stat/histo1d.hh: New header component.
* green/mln/fun/p2b/achromatic.hh: New header component.
* green/mln/fun/p2b/component_equals.hh: New header component.
* green/mln/fun/v2v/achromatism.hh: New header component.
* green/mln/fun/v2v/hue_concentration.hh: New header component.
* green/mln/fun/v2v/rgb_to_achromatism_map.hh: New header component.
* green/mln/fun/v2v/rgb_to_hsv.hh: New header component.
* green/mln/fun/v2v/rgb_to_hue_map.hh: New header component.
* green/mln/fun/v2v/rgb_to_saturation_map.hh: New header component.
* green/mln/fun/v2v/rgb_to_value_map.hh: New header component.
* green/mln/img_path.hh: New header component.
* green/mln/math/ceil.hh: New header component.
* green/mln/math/floor.hh: New header component.
* green/mln/math/hsv.hh: New header component.
2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr>
Work on Millet value descriptor.
* green/exp/annotating/value: New directory.
* green/exp/annotating/value/Makefile.am: New Makefile.
* green/exp/annotating/value/value.cc: New source file.
* green/exp/annotating/value/text-color.txt: New image class.
* green/exp/annotating/value/text-img.txt: New image class.
* green/exp/annotating/value/text-only.txt: New image class.
2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr>
Work on Millet hue descriptor.
* green/exp/annotating/hue: New directory.
* green/exp/annotating/hue/Makefile.am: New Makefile.
......
......@@ -76,26 +76,26 @@
namespace mln
{
namespace accu
{
namespace stat
{
// Forward declaration
template <typename V>
struct histo1d;
} // end of namespace mln::accu::stat
namespace meta
{
namespace stat
{
struct histo1d : public Meta_Accumulator<histo1d>
{
template <typename V>
......@@ -104,16 +104,16 @@ namespace mln
typedef accu::stat::histo1d<V> ret;
};
};
} // end of namespace mln::accu::meta::stat
} // end of namespace mln::accu::meta
} // end of namespace mln::accu
namespace trait
{
template <typename V>
struct accumulator_< mln::accu::stat::histo1d<V> >
{
......@@ -124,34 +124,34 @@ namespace mln
};
template <typename V>
struct set_precise_binary_<op::eq,
struct set_precise_binary_<op::eq,
accu::stat::histo1d<V>,
accu::stat::histo1d<V> >
{
typedef bool ret;
};
} // end of namespace mln::trait
namespace accu
{
namespace stat
{
{
/// \brief Define an histogram which returns an image1d .
/// \brief Define an histogram which returns an image1d .
///
/// Param V defines the space in which we count the values.
/// For instance, this histogram works with image2d<int_u8> or with
/// image1d<int_u<14> >. The histogram count the occurrence of each value.
/// The number of bins depends of the graylevel values, for 8 bits there
/// is 256 bins, for 14 bits there is 16384 bins. Note that over
/// is 256 bins, for 14 bits there is 16384 bins. Note that over
/// quantification works too (up to 14 bits).
///
/// \ingroup modaccuvalues
template <typename V>
struct histo1d :
struct histo1d :
public mln::accu::internal::base<image1d<unsigned>, histo1d<V> >
{
typedef V argument;
......@@ -162,22 +162,22 @@ namespace mln
/// \{
/// \brief Initialize the size of the resulting image1d.
///
/// Initialize the size the resulting image from the theorical dynamic
/// Initialize the size the resulting image from the theorical dynamic
/// of the graylevel values (Use V to manage it).
histo1d();
/// \}
/// Manipulators.
/// \{
/// \brief Initialize the histogram with zero value.
///
/// This method must be called just before starting the use of the
/// histogram. If it's not, resulting values won't converge to the
/// This method must be called just before starting the use of the
/// histogram. If it's not, resulting values won't converge to the
/// density.
void init();
/// \brief Update the histogram with the graylevel of the pixel t.
/// \param[in] t a graylevel pixel of type V.
///
......@@ -189,7 +189,7 @@ namespace mln
/// \brief Update the histogram with an other histogram.
/// \param[in] other the other histogram.
///
/// The end user shouldn't call this method. This is part of
/// The end user shouldn't call this method. This is part of
/// data compute interface mechanism.
void take(const histo1d<V>& other);
......@@ -234,7 +234,7 @@ namespace mln
typedef mln_trait_value_comp(V,0) comp;
typedef point<grid::tick, V> v_point1d;
typedef box<v_point1d> v_box1d;
// comp keep a trace of the dimension of the theorical image.
// mln_min(comp) --> 0
// mln_max(comp) --> 2^(n-1) [127 for n=7][255 for n=8] ...
......@@ -242,8 +242,8 @@ namespace mln
count_.init_(box1d(point1d(mln_min(comp)),
point1d(mln_max(comp))));
// std::cout << "min : " << mln_min(comp) << std::endl;
// std::cout << "max : " << mln_max(comp) << std::endl;
// std::cout << "min : " << mln_min(comp) << std::endl;
// std::cout << "max : " << mln_max(comp) << std::endl;
trace::exiting("mln::accu::stat::histo1d<V>::histo1d");
}
......@@ -264,14 +264,14 @@ namespace mln
{
trace::entering("mln::accu::stat::histo1d<V>::take");
// Just convert a graylevel value (int_u8 like) to a position for an
// Just convert a graylevel value (int_u8 like) to a position for an
// iterator on the resulting image.
++count_(point1d(t));
trace::exiting("mln::accu::stat::histo1d<V>::take");
}
template <typename V>
inline
void histo1d<V>::take(const histo1d<V>& other)
......@@ -282,7 +282,7 @@ namespace mln
trace::exiting("mln::accu::stat::histo1d<V>::take");
}
template <typename V>
inline
typename histo1d<V>::result histo1d<V>::to_result() const
......@@ -292,7 +292,7 @@ namespace mln
trace::exiting("mln::accu::stat::histo1d<V>::to_result");
return count_;
}
template <typename V>
inline
histo1d<V>::operator result() const
......@@ -301,7 +301,7 @@ namespace mln
trace::exiting("mln::accu::stat::histo1d<V>::operator result");
return count_;
}
}
template <typename V>
inline
......@@ -309,7 +309,7 @@ namespace mln
{
trace::entering("mln::accu::stat::histo1d<V>::is_valid");
bool result = count_.is_valid();
trace::exiting("mln::accu::stat::histo1d<V>::is_valid");
return result;
}
......@@ -322,7 +322,7 @@ namespace mln
bool result = true;
const image1d<unsigned>& res1 = histo1.to_result();
const image1d<unsigned>& res2 = histo2.to_result();
mln_precondition(res1.is_valid());
mln_precondition(res2.is_valid());
......
// Copyright (C) 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_FUN_P2B_ACHROMATIC_HH
# define MLN_FUN_P2B_ACHROMATIC_HH
/// \file
///
/// In the vectorial image context (as RGB, HSL, HSV), compare one component
/// to a specific value.
# include <mln/core/alias/point2d.hh>
# include <mln/core/concept/function.hh>
# include <mln/trait/value/comp.hh>
namespace mln
{
namespace fun
{
namespace p2b
{
/// \brief Functor that compare the i-th component of a value.
// V is for the type of the value received
// i is the ith component to select
template <typename T_rgb>
struct achromatic : public Function_v2b< achromatic<T_rgb> >
{
typedef bool result;
bool operator()(const point2d& p) const;
achromatic(const image2d<T_rgb>& img, const float threshold);
const float threshold_;
const image2d<T_rgb>& img_;
};
# ifndef MLN_INCLUDE_ONLY
template <typename T_rgb>
achromatic<T_rgb>::achromatic(const image2d<T_rgb>& img,
const float threshold)
: threshold_(threshold), img_(img)
{
}
template <typename T_rgb>
bool achromatic<T_rgb>::operator()(const point2d& p) const
{
typedef typename T_rgb::red_t t_red;
typedef typename T_rgb::green_t t_green;
typedef typename T_rgb::blue_t t_blue;
const T_rgb rgb = img_(p);
// To obtain red between 0 and 1
const float max_red = mln_max(t_red);
const float min_red = mln_min(t_red);
const float red = (rgb.red() - min_red)/(max_red - min_red);
// To obtain green between 0 and 1
const float max_green = mln_max(t_green);
const float min_green = mln_min(t_green);
const float green = (rgb.green()-min_green)/(max_green-min_green);
// To obtain blue between 0 and 1
const float max_blue = mln_max(t_blue);
const float min_blue = mln_min(t_blue);
const float blue = (rgb.blue()-min_blue)/(max_blue-min_blue);
bool result = (threshold_ > math::abs(red - green) &&
threshold_ > math::abs(red - blue) &&
threshold_ > math::abs(green - blue));
return result;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::fun::p2b
} // end of namespace mln::fun
} // end of namespace mln
#endif // ! MLN_FUN_P2B_ACHROMATIC_HH
// Copyright (C) 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_FUN_P2B_COMPONENT_EQUALS_HH
# define MLN_FUN_P2B_COMPONENT_EQUALS_HH
/// \file
///
/// In the vectorial image context (as RGB, HSL, HSV), compare one component
/// to a specific value.
# include <mln/core/alias/point2d.hh>
# include <mln/core/concept/function.hh>
# include <mln/trait/value/comp.hh>
namespace mln
{
namespace fun
{
namespace p2b
{
/// \brief Functor that compare the i-th component of a value.
// V is for the type of the value received
// i is the ith component to select
template <typename I, unsigned i>
struct component_equals : public Function_v2b< component_equals<I,i> >
{
typedef bool result;
bool operator()(const point2d& p) const;
component_equals(const I& img,
const mln_trait_value_comp(mln_value(I),i)& ref);
const mln_trait_value_comp(mln_value(I),i) _ref;
const I& _img;
};
# ifndef MLN_INCLUDE_ONLY
template <typename I, unsigned i>
inline
component_equals<I,i>::
component_equals(const I& img,
const mln_trait_value_comp(mln_value(I),i)& ref)
: _ref(ref), _img(img)
{
}
template <typename I, unsigned i>
inline
bool
component_equals<I,i>::operator()(const point2d& p) const
{
typedef mln_value(I) t_value;
typedef mln_trait_value_comp(t_value,i) mln_value_comp;
t_value v = _img(p);
mln_value_comp c = trait::value::internal::comp<t_value,i>::on(v);
return (c == _ref);
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::fun::p2b
} // end of namespace mln::fun
} // end of namespace mln
#endif // ! MLN_FUN_P2B_COMPONENT_EQUALS_HH
// Copyright (C) 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_FUN_V2V_ACHROMATISM_HH
# define MLN_FUN_V2V_ACHROMATISM_HH
# include <mln/value/rgb8.hh>
namespace mln
{
namespace fun
{
namespace v2v
{
struct achromatism : public Function_v2v< achromatism >
{
typedef float result;
float operator()(const value::rgb8 rgb) const;
};
# ifndef MLN_INCLUDE_ONLY
float achromatism::operator()(const value::rgb8 rgb) const
{
return (math::abs(rgb.red() - rgb.green())
+ math::abs(rgb.red() - rgb.blue())
+ math::abs(rgb.green() - rgb.blue()))/3.0;
}
# endif // !MLN_INCLUDE_ONLY
} // end of namespace fun::v2v
} // end of namespace fun
} // end of namespace mln
#endif // ! MLN_FUN_V2V_ACHROMATISM_HH
// Copyright (C) 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_FUN_V2V_HUE_CONCENTRATION_HH
# define MLN_FUN_V2V_HUE_CONCENTRATION_HH
# include <mln/core/image/image1d.hh>
# include <mln/math/abs.hh>
# include <mln/opt/at.hh>
# include <mln/value/hsv.hh>
# include <mln/value/rgb8.hh>
namespace mln
{
namespace fun
{
namespace v2v
{
unsigned peak_histo(const mln::image1d<unsigned>& hue_histo);
struct hue_concentration : public Function_v2v< hue_concentration >
{
typedef float result;
float operator()(const float hue) const;
hue_concentration(const mln::image1d<unsigned>& hue_histo)
{
peak = peak_histo(hue_histo);
}
unsigned peak;
};
# ifndef MLN_INCLUDE_ONLY
unsigned peak_histo(const mln::image1d<unsigned>& hue_histo)
{
mln_precondition(hue_histo.is_valid());
// Find the peak of the histogram
unsigned v_max = mln::opt::at(hue_histo, 0);
short p_max = 0;
mln_piter_(mln::image1d<unsigned>) p(hue_histo.domain());
for_all(p)
{
if (v_max < hue_histo(p))
{
v_max = hue_histo(p);
p_max = p.ind();
}
}
return p_max;
}
float hue_concentration::operator()(float hue) const
{
return mln::math::abs(peak - hue);
}
# endif // !MLN_INCLUDE_ONLY