Image Processing in C#: Part 2 - Converting an Image to Greyscale
Converting an image to greyscale is a relatively easy effect to apply to an image. For each pixel in the image, we take the three colour components (red, green and blue), and then combine the values.
Most people would think that you just take the average of the three colours, but the problem with that is the human eye has different sensitivities to different frequencies, so what we need to do is add in the colours at different ratios.
So, to make the colour ratios correct, we multiply the red, green and blue components by 0.299, 0.587 and 0.114 respectively. We then assign the value to all the components of the pixel.
The full source used in the series is available from https://github.com/sjmeunier/image-processor.
Originally posted on my old blog, Smoky Cogs, on 19 Nov 2009