Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to convert gray image to color image(rgb)...
is there ant way to convert?

Marc A. Brown 4-Nov-10 9:54am    
Um... perhaps I'm dense but I don't understand where the color information would come from to convert from greyscale to color.
CPallini 4-Nov-10 10:07am    
Such problem is undetermined. There are many, many, many different ways to do that (unfortunately most of them are meningless...).

The following example is the other way around. You simply create an image with the desired pixel format and use it to store the existing image. When you convert a gray scale image to a color image you only add the color channels but of course no actual color is added because that information was lost when the image was stored as gray scale image.[^]

Good luck!
Share this answer
As others have stated, you can't know what colors the grey was originally supposed to be. But when I read your question I thought you were asking for how to perform some kind of colorwash. Like to see instead of greyscale to have it in a yellowscale or something. If that is the case try researching with the key word colorwash. I found some articles about the process on google[^] including this CP Article[^].
Share this answer
You could make some guesses and try and convert the gray shades into specific colors. What some photo apps do is they show the gray scale image, and allows the user to pick a specific shade of gray and then replace it with a color. Say you have a grayscale image of a guy in a t-shirt. We don't really know what color t-shirt he's actually wearing, but if we let an user choose a color, and say he chooses blue (just an example), you then replace that specific shade of gray into blue. And not just on the t-short, you do it everywhere. So if the image also had a different person wearing a cap of the same color as the other guy's t-shirt, then that cap becomes blue too. Obviously you'll never get the original colors, but you can come pretty close.

With certain images, you can do some guessing to figure out the colors. For example, using some kind of face detection, you can assume that the skin tone would be a skin color shade (anything from very light brown to very dark brown). Trees would be a mix of green (for the leaves) and brown (for the wood). Once you figure out a few such colors, you can use that to make better guesses as to the other colors. It will be quite non-trivial, so be prepared for a lot of work, trial and error, and research.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900