Thursday, 5 January 2012

Grayscale.

A grayscale digital image is an image in which the value of each pixel is a single sample, this means it carries only intensity information. These types of images are also commonly known as black-and-white and are composed exclusively of shades of gray, varying from black at the weakest intensity to white at the strongest. The grayscale has many different shades of gray in between the two extremes.



Conversion of a colour image to grayscale is not unique; different weighting of the colour channels successfully portray the effect of shooting black-and-white film with different coloured photographic filters on the cameras. A common approach is to match the luminance of the grayscale image to the luminance of the colour image.

Wikipedia says that to convert any colour to grayscale you need to work out the values of its red, green, and blue (RGB) primaries in linear intensity encoding, by gamma expansion. Then you add together 30% of the red value, 59% of the green value, and 11% of the blue value (these weights depend on the exact choice of the RGB primaries, but are typical). Regardless of the scale employed (0.0 to 1.0, 0 to 255, 0% to 100%, etc.) the resulting number is the desired linear luminance value. This usually needs to be gamma compressed to get back to a conventional grayscale representation.

To convert a gray intensity value to RGB, set all the three primary colours red, green and blue to the gray value, correcting to a different gamma if required.






No comments:

Post a Comment