# map 16-bit integers to RGB colors with monotonic relative luminosity

Red, Green and Blue apparently contribute differently to the luminosity perceived by humans:

https://en.wikipedia.org/wiki/Relative_luminance

I am trying to find an algorithm to map unsigned 16 bit integers into RGB values such that the relative luminance of the RGB values to which the integers map respects their order (with integer 0 being black, integer 2^16-1 white and all other integers mapped to some RGB color).

I don't really care about how the colors evolve as one walks up from 0 to 2^16-1 as long as luminosity always increases and a reasonably large swathe of the RGB space is used.

Apparently I am missing the right words to describe what I am trying to accomplish as I've failed to google anything pertinent. A couple of weeks ago I had stumbled upon a paper that described such an algorithm in the form of a helix that is arranged diagonally in the three dimensional RGB space such that when one starts at the base of the helix and works his way towards the other end, luminosity always increases and a large variety of color is used. Alas, I can't find it any more.

# update

Found the algorithm I was looking for. It is known as the 'cubehelix' color scheme by Dave Green and is described here: http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/. The original paper is here: http://astron-soc.in/bulletin/11June/289392011.pdf

• There are infinitely many solutions to your problem, you may want to impose extra constraints. Commented Sep 5, 2019 at 15:01

Start by setting $$Y' = N / (2^{16} - 1)$$, where N is your input 16-bit integer. Now you just need to make up some function to use for the U and V components.
It wasn't clear to me if you want the chroma part of the color to vary continuously with the input N, or be pseudo-random. For a continuous curve, you could just have it be a circle in UV space: $$U = 0.5 \cos(2\pi N/2^{16}) \\ V = 0.5 \sin(2\pi N/2^{16})$$ or whatever other curve you feel like coming up with. For a pseudo-random chroma, you could use a hash function, or a Halton sequence or another low-discrepancy sequence.