Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Scptre

Converting a colored to grayscale

This topic is 5749 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

I am programming a small game for my computer science course and I was wondering if either Direct X or Windows GDI has a function that will let me convert a colored image to a grayscale image.

Share this post


Link to post
Share on other sites
Advertisement
Um... I only saw one post. Yet, I hope double clicking doesn''t post two... (Tooko runs from current thread and returns to last post) Well, that was exausting.
I wonder why I scare so many people away...

The past was unknown, the future was predicted.

Share this post


Link to post
Share on other sites
Why would you need a GDI function to do it? Just calculate the luminance of the pixels. Thats all a greyscale image is.

( Luminance = (R+G+B)/3 )

Death of one is a tragedy, death of a million is just a statistic.

Share this post


Link to post
Share on other sites
quote:
Original post by python_regious
( Luminance = (R+G+B)/3 )



I remember that you need different factors (that together summs to 1.0) for R and G and B, because one is more intense than other. But I cant remember those factors.

Share this post


Link to post
Share on other sites
quote:
luminance = 0.3*red + 0.59*green + 0.11*blue;

A long time ago, I made a test image with three regions exactly red, blue and green, and I used Photoshop to convert it to grayscale. From that test, I got the same formula, and it seems to work pretty well.

There is something else you should be careful with: Gamma correction. If you start mixing values and in the end you just send them to your VGA, your medium-intensity colors are going to be too dark.

Share this post


Link to post
Share on other sites

  • 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!