I have an array of pixels with an associated intensity (as a float between 0 and 1) that I would like to convert to a RGB image.
The easiest way would be to just multiply each value by 255 and assign it to R+G+B to obtain a greyscale image, but I think it would be better to use a whole range of colors to show finer differences.
As far as I know this is called a pseudo/false color image, but I am having a hard time finding algorithms for it. Right now I am using this code, but I was wondering if there was a smarter/faster way to do it:
if(intensity <= 0.25) {
p->r = 0;
p->g = 0;
p->b = (intensity) * 4 * 255;
return;
}
if(intensity <= 0.5) {
p->r = 0;
p->g = (intensity - 0.25) * 4 * 255;
p->b = 255;
return;
}
if(intensity <= 0.75) {
p->r = 0;
p->g = 255;
p->b = (0.75 - intensity) * 4 * 255;
return;
}
if(intensity <= 1.0) {
p->r = (intensity - 0.75) * 4 * 255;
p->g = (1.0 - intensity) * 4 * 255;
p->b = 0;
return;
}
Also, are there any standard color palettes I should use for this?