Tetrapod Project
color_interp.cpp
Go to the documentation of this file.
2 
3 Eigen::Matrix3Xd interpolateColors(Eigen::Vector3d begin_rgb, Eigen::Vector3d end_rgb, int nsteps)
4 {
5  Eigen::Vector3d begin_hsv;
6 
7  Eigen::Vector3d end_hsv;
8 
9  RGBtoHSV(begin_rgb(0), begin_rgb(1), begin_rgb(2), begin_hsv(0), begin_hsv(1), begin_hsv(2));
10 
11  RGBtoHSV(end_rgb(0), end_rgb(1), end_rgb(2), end_hsv(0), end_hsv(1), end_hsv(2));
12 
13  Eigen::Matrix3Xd res;
14  res.conservativeResize(Eigen::NoChange, nsteps);
15 
16  double interp;
17 
18  double h, s, v;
19 
20  for (int i = 0; i < nsteps; ++i)
21  {
22  interp = double(i)/(nsteps - 1);
23 
24  h = interp*end_hsv(0) + (1 - interp)*begin_hsv(0);
25 
26  s = interp*end_hsv(1) + (1 - interp)*begin_hsv(1);
27 
28  v = interp*end_hsv(2) + (1 - interp)*begin_hsv(2);
29 
30  HSVtoRGB(res(0, i), res(1, i), res(2, i), h, s, v);
31  }
32 
33  return res;
34 }
Eigen::Matrix3Xd interpolateColors(Eigen::Vector3d begin_rgb, Eigen::Vector3d end_rgb, int nsteps)
Definition: color_interp.cpp:3
void RGBtoHSV(double &fR, double &fG, double fB, double &fH, double &fS, double &fV)
Convert RGB to HSV color space.
Definition: hsvrgb.cpp:49
void HSVtoRGB(double &fR, double &fG, double &fB, double &fH, double &fS, double &fV)
Convert HSV to RGB color space.
Definition: hsvrgb.cpp:96
Eigen::Vector3d Vector3d
Definition: kinematics.h:49