Grayscale

From Wikipedia, the free encyclopedia

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

In computing, a grayscale or greyscale digital image is an image in which the value of each pixel is a single sample. Displayed images of this sort are typically composed of shades of gray, varying from black at the weakest intensity to white at the strongest, though in principle the samples could be displayed as shades of any color, or even coded with various colors for different intensities. Grayscale images are distinct from black-and-white images, which in the context of computer imaging are images with only two colors, black and white; grayscale images have many shades of gray in between. In most contexts other than digital imaging, however, the term "black and white" is used in place of "grayscale"; for example, photography in shades of gray is typically called "black-and-white photography". The term monochromatic in some digital imaging contexts is synonymous with grayscale, and in some contexts synonymous with black-and-white.

Grayscale images are often the result of measuring the intensity of light at each pixel in a single band of the electromagnetic spectrum (e.g. visible light).

4096 gray levels
4096 gray levels

Grayscale images intended for visual display are typically stored with 8 bits per sampled pixel, which allows 256 intensities (i.e., shades of gray) to be recorded, typically on a non-linear scale. The accuracy provided by this format is barely sufficient to avoid visible banding artifacts, but very convenient for programming. Technical uses (e.g. in medical imaging or remote sensing applications) which often require more levels, to make full use of the sensor accuracy (typically 10 or 12 bits per sample) and to guard against roundoff errors in computations. Sixteen bits per sample (65536 levels) appears to be a popular choice for such uses. The PNG image format supports 16 bit grayscale natively, although browsers and many imaging programs tend to ignore the low order 8 bits of each pixel.


A photograph of a Neighborhood Watch sign in color A photograph of a Neighborhood Watch sign in grayscale A photograph of a Neighborhood Watch sign in black and white
The same picture in three different color modes. The picture on the left is the original photograph, in full color. The picture in the center is in grayscale; all the colors contained in it are black, white, or any shade of gray. The picture on the right is in black and white, or monochrome; the only colors used in the picture are black and white, with no intermediary grays.

[edit] Converting color to grayscale

To convert any color to its most approximate level of gray, first one must to obtain the values of its red, green and blue (RGB) primaries.

Then it is sufficient to add the 30% of the red value plus the 59% of that of the green plus the 11% of that of the blue, no matter whatever scale is employed (0.0 to 1.0, 0 to 255, 0% to 100%, etc.) The resultant level is the desired gray value. These percentages are chosen due to the different relative sensibility of the normal human eye to every of the primary colors (higher to the green, lower to the blue).

This is the method used to obtain the luminance in the YUV and related color models, used in standard color TV and video systems as PAL and NTSC, as well as in the L*a*b color model.

[edit] See also

[edit] External links