How do I convert image to grayscale? I have the following quote from the wikipedia:
To convert any color to a grayscale
representation of its luminance, first
one must obtain the values of its red,
green, and blue (RGB) primaries in
linear intensity encoding, by gamma
expansion. Then, add together 30% of
the red value, 59% of the green value,
and 11% of the blue value
Do I understand this quote correctly? I would do something like this:
For each pixel P
For each color c in P
P.c = round(
(max(min((P.red^gamma), 255), 0) * 0.3) +
(max(min((P.blue^gamma), 255), 0) * 0.59) +
(max(min((P.green^gamma), 255), 0) * 0.11))
Is it correct? What should gamma be?
Yes, that is correct. I will use Gamma 2.2. Depending of what you intend to use this grayscale image after that, Gamma of 1.0 can be faster and useful too.