13 #include <Eigen/Dense> 26 h = max(0.0f, min(1.0f, h));
27 s = max(0.0f, min(1.0f, s));
28 v = max(0.0f, min(1.0f, v));
30 int Hi = ((int)floor(h * 6)) % 6;
31 float f = (h * 6) - Hi;
32 float p = v * (1 - s);
33 float q = v * (1 - f * s);
34 float t = v * (1 - (1 - f) * s);
77 r = max(0.0f, min(1.0f, r));
78 g = max(0.0f, min(1.0f, g));
79 b = max(0.0f, min(1.0f, b));
81 float Max =
max3(r, g, b);
82 float Min =
min3(r, g, b);
93 h = (g - b) / (6 * (Max - Min));
95 h = 1 - (g - b) / (6 * (Max - Min));
98 h = 1 / 3.0f + (b - r) / (6 * (Max - Min));
100 h = 2 / 3.0f + (r - g) / (6 * (Max - Min));
115 const TColormap& color_map,
const float col_indx_in,
float& r,
float& g,
120 const float color_index = std::min(1.0f, std::max(.0f, col_indx_in));
128 r = g = b = color_index;
144 static bool jet_table_done =
false;
145 static Eigen::VectorXf jet_r, jet_g, jet_b;
150 jet_table_done =
true;
153 float JET_R[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
154 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
155 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
156 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
157 0.0625f, 0.125f, 0.1875f, 0.250f, 0.3125f, 0.375f,
158 0.4375f, 0.5f, 0.5625f, 0.625f, 0.6875f, 0.750f,
159 0.8125f, 0.875f, 0.9375f, 1.0f, 1.0f, 1.0f,
160 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
161 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
162 1.0f, 1.0f, 0.9375f, 0.875f, 0.8125f, 0.750f,
163 0.6875f, 0.625f, 0.5625f, 0.500000};
164 float JET_G[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
165 0.0f, 0.0f, 0.0625f, 0.125f, 0.1875f, 0.250f,
166 0.3125f, 0.375f, 0.4375f, 0.5f, 0.5625f, 0.625f,
167 0.6875f, 0.750f, 0.8125f, 0.875f, 0.9375f, 1.0f,
168 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
169 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
170 1.0f, 1.0f, 1.0f, 1.0f, 0.9375f, 0.875f,
171 0.8125f, 0.750f, 0.6875f, 0.625f, 0.5625f, 0.5f,
172 0.4375f, 0.375f, 0.3125f, 0.250f, 0.1875f, 0.125f,
173 0.0625f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
174 0.0f, 0.0f, 0.0f, 0.000000};
175 float JET_B[] = {0.5625f, 0.625f, 0.6875f, 0.750f, 0.8125f, 0.875f,
176 0.9375f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
177 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
178 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
179 0.9375f, 0.875f, 0.8125f, 0.750f, 0.6875f, 0.625f,
180 0.5625f, 0.5f, 0.4375f, 0.375f, 0.3125f, 0.250f,
181 0.1875f, 0.125f, 0.0625f, 0.0f, 0.0f, 0.0f,
182 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
183 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
184 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
185 0.0f, 0.0f, 0.0f, 0.000000};
186 const int N =
sizeof(JET_B) /
sizeof(JET_B[0]);
191 for (
int i = 0; i < N; i++)
207 static bool table_done =
false;
208 static Eigen::VectorXf hot_r, hot_g, hot_b;
216 float HOT_R[] = {0.041667f, 0.0833f, 0.125f, 0.166667f, 0.2083f, 0.250f,
217 0.291667f, 0.3333f, 0.375f, 0.416667f, 0.4583f, 0.5f,
218 0.541667f, 0.5833f, 0.625f, 0.666667f, 0.7083f, 0.750f,
219 0.791667f, 0.8333f, 0.875f, 0.916667f, 0.9583f, 1.0f,
220 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
221 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
222 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
223 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
224 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
225 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
226 1.0f, 1.0f, 1.0f, 1.0f};
227 float HOT_G[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
228 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
229 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
230 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
231 0.041667f, 0.0833f, 0.125f, 0.166667f, 0.2083f, 0.250f,
232 0.291667f, 0.3333f, 0.375f, 0.416667f, 0.4583f, 0.5f,
233 0.541667f, 0.5833f, 0.625f, 0.666667f, 0.7083f, 0.750f,
234 0.791667f, 0.8333f, 0.875f, 0.916667f, 0.9583f, 1.0f,
235 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
236 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
237 1.0f, 1.0f, 1.0f, 1.0f};
239 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
240 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
241 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
242 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
243 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
244 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
245 0.0625f, 0.125f, 0.1875f, 0.250f, 0.3125f, 0.375f, 0.4375f, 0.5f,
246 0.5625f, 0.625f, 0.6875f, 0.750f, 0.8125f, 0.875f, 0.9375f, 1.0f};
247 const int N =
sizeof(HOT_B) /
sizeof(HOT_B[0]);
252 for (
int i = 0; i < N; i++)
267 const TColormap& color_map,
const float color_index)
270 colormap(color_map, color_index, r, g, b);
void colormap(const TColormap &color_map, const float color_index, float &r, float &g, float &b)
Transform a float number in the range [0,1] into RGB components.
TColormap
Different colormaps for use in mrpt::img::colormap()
#define THROW_EXCEPTION(msg)
T interpolate(const T &x, const VECTOR &ys, const T &x0, const T &x1)
Interpolate a data sequence "ys" ranging from "x0" to "x1" (equally spaced), to obtain the approximat...
const T min3(const T &A, const T &B, const T &C)
void hot2rgb(const float color_index, float &r, float &g, float &b)
Computes the RGB color components (range [0,1]) for the corresponding color index in the range [0...
void jet2rgb(const float color_index, float &r, float &g, float &b)
Computes the RGB color components (range [0,1]) for the corresponding color index in the range [0...
void rgb2hsv(float r, float g, float b, float &h, float &s, float &v)
Transform RGB color components to HSV, all of them in the range [0,1].
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void hsv2rgb(float h, float s, float v, float &r, float &g, float &b)
Transform HSV color components to RGB, all of them in the range [0,1].
An RGBA color - floats in the range [0,1].
TColor asTColor() const
Returns the 0-255 integer version of this color: RGBA_u8.
const T max3(const T &A, const T &B, const T &C)