We are about to switch to a new forum software. Until then we have removed the registration on this forum.
The code below is my answer to getting "finer" color resolution on the heat Map, ie., adding more colors to choose from.
Is there a more elegant and/or more efficient solution in Processing to do this? Hues, saturation ??
Thanks,
Ken
void applyColor() { // Generate the heat map
color c1 = color(0, 0, 255); // Blue color
color c2 = color(0, 255, 255); // color Cyan
color c3 = color(0, 255, 0); // Green color
color c4 = color(255, 255, 0); // Yellow color
color c5 = color(240, 150, 5); // Orange color
color c6 = color(255, 0, 0); // Red color
loadPixels();
int p = 0;
color c;
float fraction;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
float value = interp_array[i][j];
if (value>= 25 && value<26) {
fraction = value;
c = lerpColor(c1, c2, fraction);
} else if (value>=26 && value<27) {
fraction = value;
c = lerpColor(c2, c3, fraction);
} else if (value>=27 && value<28) {
fraction = value;
c = lerpColor(c3, c4, fraction);
} else if (value>=28 && value<29) {
fraction = value;
c = lerpColor(c4, c5, fraction);
} else if (value>=29 && value<30) {
fraction = value;
c = lerpColor(c5, c6, fraction);
} else
c = c6;
pixels[p++] = c;
}
}
updatePixels();
Answers
Use hsb colours and map() the temp to the hue value.
Thanks for your reply and advice. I have tried a few examples but don't understand how these functions go together and also how they fit with the program. Do I eliminate the lerpcolor function? If you could provide me some direction on this it would be greatly appreciated. Thanks, Ken
The sketch below produces random heat maps like this one. The code should be self explanatory but you might want to investigate the colorMode() method.
Thanks, I will dig into it and see if I can understand well enough to make it work . . . . I may be back though. :)>-
Nice! Works GREAT! . . . . Thanks again Mr. Quark.
Hey I know this is 2017 but I was wondering if someone could help me out with a related problem. I'm trying to make a real time heat map using data from an arduino using the serial library. I'm sensing temperature from 16 locations on a 4x4 grid and need to extrapolate the measurements between each point. Do you know how i can adapt this to suit my purposes?
What resolution are you mapping your 4x4 onto -- 256x256?
Are your measurements at the outside edges of the grid (eg a tic-tac-toe board of 4x4 points) or in the center of a set of checkerboard squares?
Can you use linear interpellation, or are you trying to model something about the real properties of temperature?
https://en.wikipedia.org/wiki/Diamond-square_algorithm ?
that uses 4 seed points (and random points) to generate a terrain. i guess the random bits might make this unsuitable (because it's different every time) but you could use noise or seed the random numbers to make it stable.