How to convert 8-bit GrayScale to RGB format (and have it still "look" gray!!!)?
Posted on 2004-11-02
I have an image processing app that I am working on and ran into a snag trying to convert from 8-bit grayscale to RGB. The reason I want to do this is so that I can store my image data in the format that I want to use (.XPM).
I noticed alot of people are asking this same question but are coming from the standpoint of wanting to add color to grayscale image. Think Turner broadcast colorization of an old western or something. I don't want this at all. I want my RGB equivalent image to look exactly like my grayscale image.
My input is gray values between 0->FF (0-255).
My output is RGB of the gray value (3 values between 0->FF (0-255))
For example, I know that white is FF in grayscale. After the conversion it should be R=FF, G=FF, B=FF in RBG format. Likewise black is 00: it should be R=00, G=00, B=00. But how do I convert the other 254 values?
Is this possible? Does anyone know the conversion formula?