Jump to content
  • Advertisement
Sign in to follow this  
OpenGL_Guru

OpenGL Converting a Grayscale image to RGB(A)

This topic is 3775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all i was wondering if anyone knew of a way in OpenGL to take a grayscale image in memory and use an OpenGL function or set of functions to convert it into an RGB(A) image? Disclaimer: i don't have the means right now to support shaders so i cannot solve this using shaders. the problem is is that for every grayscale bit i have to convert each set to its rgb(a) equivalent and that is a serious waste of processor time. It would be nice to be able to dump the whole image and do the conversion that way if its possible. i hope that all that makes sense. thanks in advance for your time!

Share this post


Link to post
Share on other sites
Advertisement
You could just upload the data as luminance values (GL_LUMINANCE)
Why convert to an RGBA image?

Share this post


Link to post
Share on other sites
what u ask is impossible, theres no way the image can workout what the color hue a pixel is based on its luminance.
if there was a way all the black+white films would be converted

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
You could just upload the data as luminance values (GL_LUMINANCE)
Why convert to an RGBA image?


well i am writing this software that we store images from a camera and save them in grayscale to begin with. we want to be able to convert the images into its color equivalent(if possible) while still keeping the original grayscale images.

Share this post


Link to post
Share on other sites
It's unclear what you mean. If you simply want to convert the image's internal format to RGB, just copy the grayscale value of each pixel into the colour channels. But if you want to recover the RGB values from a grayscale image, so it actually looks like it's in colour - well, as zedz says, that's obviously pretty near impossible. It'd be like being given a number, and then being expected to derive the two numbers that were added together to create that sum. There's nothing in the result to tell you how it was arrived at.

Perhaps an algorithm to put colour back into a greyscale image could be developed (I mean, if OCR can be...) - but it'd be ridiculously complicated, would require lots of hints, and would probably yield extremely dodgy results.

Share this post


Link to post
Share on other sites
Assuming you do want to magically introduce colour information into an image that has none, and you are feeling adventurous, there has been lots of research into colourization of grey scale images.

One such example is by Ying-Qing Xu - "Natural Image Colorization"

Regards,
ViLiO

Share this post


Link to post
Share on other sites
I had a quick look at one of the autocolor papers,
but its no magicm, as in is still requires an artist to come along + say those flowers are red or yellow whatever.

actually this is a good example of how 'stopid' computers are (WRT to programming), it seems as if we're getting nowhere fast WRT AI

Share this post


Link to post
Share on other sites
If you want a computer to be smart enough to do that kind of work, then you have to duplicate a small part of the human mind in a software program. It would have to recognize all objects, possible colors certain objects would have (a car can be blue, red, metallic and a tomota is almost always red), in the scene and make artistic guesses.
And OpenGL_Guru is expecting OpenGL to be able to do this? LOL

Share this post


Link to post
Share on other sites
LOL? Oh the impertinence.
Quote:

actually this is a good example of how 'stopid' computers are (WRT to programming), it seems as if we're getting nowhere fast WRT AI


computers (WRT to programming)..are just masses of logic..yeah?
WRT AI: it's probably even a better example of the true position of AI in the whole scheme of things: Artificial Intelligence is just like artificial sweetener; It never tastes as good as the real thing and there is generally a bitter after taste. Gee..AI might even be just as carcinogenic as aspartame!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!