URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-04-22 Caroline Vigouroux <vigour_c(a)epita.fr>
Add green and blue getters.
* cmy/get_blue.hh, cmy/get_green.hh,
hsi/get_blue.hh, hsi/get_green.hh,
xyz/get_blue.hh, xyz/get_green.hh,
yiq/get_blue.hh, yiq/get_green.hh,
yuv/get_blue.hh, yuv/get_green.hh: New green and blue getters.
* yuv/get_red.hh: New red getter.
* yuv/fun.hh: Remove.
---
cmy/get_blue.hh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
cmy/get_green.hh | 56 +++++++++++++++++++++++++++++++++++++++++++++
hsi/get_blue.hh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
hsi/get_green.hh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
xyz/get_blue.hh | 56 +++++++++++++++++++++++++++++++++++++++++++++
xyz/get_green.hh | 56 +++++++++++++++++++++++++++++++++++++++++++++
yiq/get_blue.hh | 56 +++++++++++++++++++++++++++++++++++++++++++++
yiq/get_green.hh | 55 +++++++++++++++++++++++++++++++++++++++++++++
yuv/get_blue.hh | 56 +++++++++++++++++++++++++++++++++++++++++++++
yuv/get_green.hh | 56 +++++++++++++++++++++++++++++++++++++++++++++
yuv/get_red.hh | 58 +++++++++++++++++++++++++++++++++++++++++++++++
11 files changed, 650 insertions(+)
Index: trunk/milena/sandbox/vigouroux/yuv/fun.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/vigouroux/yuv/get_blue.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/yuv/get_blue.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/yuv/get_blue.hh (revision 1883)
@@ -0,0 +1,56 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_yuv.hh"
+
+#ifndef MLN_YUV_BLUE_HH
+# define MLN_YUV_BLUE_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_blue_yuv_ : public Function_v2v< f_blue_yuv_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_yuv>
+ T_rgb operator()(const T_yuv& yuv) const
+ {
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<blue_t> to_b;
+
+ blue_t b = to_b(yuv.y() + 2.03211 * yuv.u());
+
+ T_rgb rgb(0, 0, b);
+
+ return rgb;
+ }
+ };
+
+ typedef f_blue_yuv_<value::rgb8> f_yuv_blue_t;
+
+ f_yuv_blue_t f_yuv_blue;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_YUV_BLUE_HH
Index: trunk/milena/sandbox/vigouroux/yuv/get_red.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/yuv/get_red.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/yuv/get_red.hh (revision 1883)
@@ -0,0 +1,58 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "my_yuv.hh"
+
+#ifndef MLN_YUV_FUN_HH
+# define MLN_YUV_FUN_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_yuv_ : public Function_v2v< f_yuv_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_yuv>
+ T_rgb operator()(const T_yuv& yuv) const
+ {
+ int r;
+ int g;
+ int b;
+
+ r = int(yuv.y() + 1.13983 * yuv.v());
+ g = int(yuv.y() - 0.39465 * yuv.u() - 0.58060 * yuv.v());
+ b = int(yuv.y() + 2.03211 * yuv.u());
+
+ struct value::rgb<8> rgb(r, g, b);
+
+ return (rgb);
+ }
+ };
+
+ typedef f_yuv_<value::rgb8> f_yuv_3x8_t;
+
+ f_yuv_3x8_t f_yuv_3x8;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_VALUE_YUV_HH
Index: trunk/milena/sandbox/vigouroux/yuv/get_green.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/yuv/get_green.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/yuv/get_green.hh (revision 1883)
@@ -0,0 +1,56 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_yuv.hh"
+
+#ifndef MLN_YUV_GREEN_HH
+# define MLN_YUV_GREEN_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_green_yuv_ : public Function_v2v< f_green_yuv_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_yuv>
+ T_rgb operator()(const T_yuv& yuv) const
+ {
+ typedef typename T_rgb::green_t green_t;
+
+ static math::round<green_t> to_g;
+
+ green_t g = to_g(yuv.y() - 0.39465 * yuv.u() - 0.58060 * yuv.v());
+
+ T_rgb rgb(0, g, 0);
+
+ return rgb;
+ }
+ };
+
+ typedef f_green_yuv_<value::rgb8> f_yuv_green_t;
+
+ f_yuv_green_t f_yuv_green;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_YUV_GREEN_HH
Index: trunk/milena/sandbox/vigouroux/hsi/get_blue.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/hsi/get_blue.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/hsi/get_blue.hh (revision 1883)
@@ -0,0 +1,67 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_hsi.hh"
+
+#ifndef MLN_HSI_BLUE_HH
+# define MLN_HSI_BLUE_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_blue_hsi_ : public Function_v2v< f_blue_hsi_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_hsi>
+ T_rgb operator()(const T_hsi& hsi) const
+ {
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<blue_t> to_b;
+
+ static const float
+ sqrt3_3 = std::sqrt(3) / 3,
+ inv_sqrt6 = 1 / std::sqrt(6),
+ inv_sqrt2 = 1 / std::sqrt(2);
+
+ float
+ h = hsi.hue() / 180.0 * 3.1415,
+ alpha = hsi.sat() * std::cos(h),
+ beta = hsi.sat() * std::sin(h);
+
+
+ blue_t b = to_b(sqrt3_3 * hsi.inty() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
+
+ T_rgb rgb(0, 0, b);
+
+ return rgb;
+ }
+ };
+
+ typedef f_blue_hsi_<value::rgb8> f_hsi_blue_t;
+
+ f_hsi_blue_t f_hsi_blue;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_HSI_BLUE_HH
Index: trunk/milena/sandbox/vigouroux/hsi/get_green.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/hsi/get_green.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/hsi/get_green.hh (revision 1883)
@@ -0,0 +1,67 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_hsi.hh"
+
+#ifndef MLN_HSI_GREEN_HH
+# define MLN_HSI_GREEN_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_green_hsi_ : public Function_v2v< f_green_hsi_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_hsi>
+ T_rgb operator()(const T_hsi& hsi) const
+ {
+ typedef typename T_rgb::green_t green_t;
+
+ static math::round<green_t> to_g;
+
+ static const float
+ sqrt3_3 = std::sqrt(3) / 3,
+ inv_sqrt6 = 1 / std::sqrt(6),
+ inv_sqrt2 = 1 / std::sqrt(2);
+
+ float
+ h = hsi.hue() / 180.0 * 3.1415,
+ alpha = hsi.sat() * std::cos(h),
+ beta = hsi.sat() * std::sin(h);
+
+
+ green_t g = to_g(sqrt3_3 * hsi.inty() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
+
+ T_rgb rgb(0, g, 0);
+
+ return rgb;
+ }
+ };
+
+ typedef f_green_hsi_<value::rgb8> f_hsi_green_t;
+
+ f_hsi_green_t f_hsi_green;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_HSI_GREEN_HH
Index: trunk/milena/sandbox/vigouroux/cmy/get_blue.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/cmy/get_blue.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/cmy/get_blue.hh (revision 1883)
@@ -0,0 +1,67 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_cmy.hh"
+
+#ifndef MLN_CMY_BLUE_HH
+# define MLN_CMY_BLUE_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_blue_cmy_ : public Function_v2v< f_blue_cmy_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_cmy>
+ T_rgb operator()(const T_cmy& cmy) const
+ {
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<blue_t> to_b;
+
+ static const float
+ sqrt3_3 = std::sqrt(3) / 3,
+ inv_sqrt6 = 1 / std::sqrt(6),
+ inv_sqrt2 = 1 / std::sqrt(2);
+
+ float
+ h = cmy.hue() / 180.0 * 3.1415,
+ alpha = cmy.sat() * std::cos(h),
+ beta = cmy.sat() * std::sin(h);
+
+
+ blue_t b = to_b(1 - cmy.yellow());
+
+ T_rgb rgb(0, 0, b);
+
+ return rgb;
+ }
+ };
+
+ typedef f_blue_cmy_<value::rgb8> f_cmy_blue_t;
+
+ f_cmy_blue_t f_cmy_blue;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_CMY_BLUE_HH
Index: trunk/milena/sandbox/vigouroux/cmy/get_green.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/cmy/get_green.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/cmy/get_green.hh (revision 1883)
@@ -0,0 +1,56 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_cmy.hh"
+
+#ifndef MLN_CMY_GREEN_HH
+# define MLN_CMY_GREEN_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_green_cmy_ : public Function_v2v< f_green_cmy_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_cmy>
+ T_rgb operator()(const T_cmy& cmy) const
+ {
+ typedef typename T_rgb::green_t green_t;
+
+ static math::round<green_t> to_g;
+
+ green_t g = to_g(1 - cmy.magenta());
+
+ T_rgb rgb(0, g, 0);
+
+ return rgb;
+ }
+ };
+
+ typedef f_green_cmy_<value::rgb8> f_cmy_green_t;
+
+ f_cmy_green_t f_cmy_green;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_CMY_GREEN_HH
Index: trunk/milena/sandbox/vigouroux/xyz/get_blue.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/xyz/get_blue.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/xyz/get_blue.hh (revision 1883)
@@ -0,0 +1,56 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_xyz.hh"
+
+#ifndef MLN_XYZ_BLUE_HH
+# define MLN_XYZ_BLUE_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_blue_xyz_ : public Function_v2v< f_blue_xyz_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_xyz>
+ T_rgb operator()(const T_xyz& xyz) const
+ {
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<blue_t> to_b;
+
+ blue_t b = to_b(0.005 * xyz.x() - 0.014 * xyz.y() + 1.01 * xyz.z());
+
+ T_rgb rgb(0, 0, b);
+
+ return rgb;
+ }
+ };
+
+ typedef f_blue_xyz_<value::rgb8> f_xyz_blue_t;
+
+ f_xyz_blue_t f_xyz_blue;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_XYZ_BLUE_HH
Index: trunk/milena/sandbox/vigouroux/xyz/get_green.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/xyz/get_green.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/xyz/get_green.hh (revision 1883)
@@ -0,0 +1,56 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_xyz.hh"
+
+#ifndef MLN_XYZ_GREEN_HH
+# define MLN_XYZ_GREEN_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_green_xyz_ : public Function_v2v< f_green_xyz_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_xyz>
+ T_rgb operator()(const T_xyz& xyz) const
+ {
+ typedef typename T_rgb::green_t green_t;
+
+ static math::round<green_t> to_g;
+
+ green_t g = to_g(-0.515 * xyz.x() + 1.425 * xyz.y() + 0.089 * xyz.z());
+
+ T_rgb rgb(0, g, 0);
+
+ return rgb;
+ }
+ };
+
+ typedef f_green_xyz_<value::rgb8> f_xyz_green_t;
+
+ f_xyz_green_t f_xyz_green;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_XYZ_GREEN_HH
Index: trunk/milena/sandbox/vigouroux/yiq/get_blue.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/yiq/get_blue.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/yiq/get_blue.hh (revision 1883)
@@ -0,0 +1,56 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_yiq.hh"
+
+#ifndef MLN_YIQ_BLUE_HH
+# define MLN_YIQ_BLUE_HH
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_blue_yiq_ : public Function_v2v< f_blue_yiq_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_yiq>
+ T_rgb operator()(const T_yiq& yiq) const
+ {
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<blue_t> to_b;
+
+ blue_t b = to_b(1.186 * yiq.y() - 1.2620 * yiq.i() + 1.8795 * yiq.q());
+
+ T_rgb rgb(0, 0, b);
+
+ return rgb;
+ }
+ };
+
+ typedef f_blue_yiq_<value::rgb8> f_yiq_blue_t;
+
+ f_yiq_blue_t f_yiq_blue;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_YIQ_BLUE_HH
Index: trunk/milena/sandbox/vigouroux/yiq/get_green.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/yiq/get_green.hh (revision 0)
+++ trunk/milena/sandbox/vigouroux/yiq/get_green.hh (revision 1883)
@@ -0,0 +1,55 @@
+#include <cmath>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/inplace.hh>
+#include <mln/core/w_window2d_int.hh>
+#include <mln/display/show.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/display/save_and_show.hh>
+#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
+
+#include "../color/my_yiq.hh"
+
+#ifndef MLN_YIQ_GREEN_HH
+# define MLN_YIQ_GREEN_HH
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+ template <typename T_rgb>
+ struct f_green_yiq_ : public Function_v2v< f_green_yiq_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_yiq>
+ T_rgb operator()(const T_yiq& yiq) const
+ {
+ typedef typename T_rgb::green_t green_t;
+
+ static math::round<green_t> to_g;
+
+ green_t g = to_g(1.026 * yiq.y() - 0.2718 * yiq.i() - 0.1458 * yiq.q());
+
+ T_rgb rgb(0, g, 0);
+
+ return rgb;
+ }
+ };
+
+ typedef f_green_yiq_<value::rgb8> f_yiq_green_t;
+
+ f_yiq_green_t f_yiq_green;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_YIQ_GREEN_HH