This is just a simple MFC application that demonstrates how you can use the
ATL::CImage class to do color-to-grayscale conversion.
Conversion is done by:
- obtaining the red, green, and blue values in each pixel's color information,
- adding together 30% of the red value, 59% of the green value, and 11% of the blue value,
- using the sum obtained in step 2 as the new red, green, and blue values.
Using the Code
There are two implementations for doing the conversion:
MakeGrayscale_Slow() --> simple but slow
MakeGrayscale_Fast() --> a little complicated but fast
Points of Interest
MakeGrayscale_Fast() produce different grayscales for the same color image. I have no idea why this happens. Anyone who knows?
- 2009/11/06 - Uploaded this article