Other systems that use fixed color maps tend to sample the color cube uniformly, which has advantages-mapping from a (red, green, blue) triple to the color map and back again is easy-but ignores an important property of the human visual system: eyes are much more sensitive to small changes in intensity than to changes in hue. Sampling the color cube uniformly gives a color map with many different hues, but only a few shades of each. Continuous tone images converted into such maps demonstrate conspicuous artifacts.
Inferno's rgbv color map uses a
The following function computes the 256 3-byte entries in the color map:
void setmaprgbv(uchar cmap[256][3]) { uchar *c; int r, g, b, v; int num, den; int i, j; for(r=0,i=0; r!=4; r++) for(v=0; v!=4; v++,i+=16) for(g=0,j=v-r; g!=4; g++) for(b=0; b!=4; b++,j++){ c = cmap[255-i-(j&15)]; den = r; if(g > den) den = g; if(b > den) den = b; if(den == 0) /* would divide check; pick grey shades */ c[0] = c[1] = c[2] = 17*v; else{ num = 17*(4*den+v); c[0] = r*num/den; c[1] = g*num/den; c[2] = b*num/den; } } }There are 4 nested loops to pick the (red, green, blue) coordinates of the subcube, and the value (intensity) within the subcube, indexed by r, g, b, and v, whence the name rgbv. The order in which the color map is indexed distributes the grey shades uniformly through map-the i 'th grey shade,
The rgbv map is not gamma-corrected for two reasons.