Grayscale

From Wikipedia, the free encyclopedia
  (Redirected from Greyscale)
Jump to: navigation, search
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

In photography and computing, a grayscale or greyscale digital image is an image in which the value of each pixel is a single sample, that is, it carries only intensity information. Images of this sort, also known as black-and-white, are composed exclusively of shades of gray, varying from black at the weakest intensity to white at the strongest.[1]

Grayscale images are distinct from one-bit bi-tonal black-and-white images, which in the context of computer imaging are images with only the two colors, black, and white (also called bilevel or binary images). Grayscale images have many shades of gray in between. Grayscale images are also called monochromatic, denoting the presence of only one (mono) color (chrome).

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. infrared, visible light, ultraviolet, etc.), and in such cases they are monochromatic proper when only a given frequency is captured. But also they can be synthesized from a full color image; see the section about converting to grayscale.

Contents

Numerical representations [edit]

A typical grayscale image.

The intensity of a pixel is expressed within a given range between a minimum and a maximum, inclusive. This range is represented in an abstract way as a range from 0 (total absence, black) and 1 (total presence, white), with any fractional values in between. This notation is used in academic papers, but this does not define what "black" or "white" is in terms of colorimetry.

Another convention is to employ percentages, so the scale is then from 0% to 100%. This is used for a more intuitive approach, but if only integer values are used, the range encompasses a total of only 101 intensities, which are insufficient to represent a broad gradient of grays. Also, the percentile notation is used in printing to denote how much ink is employed in halftoning, but then the scale is reversed, being 0% the paper white (no ink) and 100% a solid black (full ink).

In computing, although the grayscale can be computed through rational numbers, image pixels are stored in binary, quantized form. Some early grayscale monitors can only show up to sixteen (4-bit) different shades, but today grayscale images (as photographs) intended for visual display (both on screen and printed) are commonly stored with 8 bits per sampled pixel, which allows 256 different intensities (i.e., shades of gray) to be recorded, typically on a non-linear scale. The precision provided by this format is barely sufficient to avoid visible banding artifacts, but very convenient for programming due to the fact that a single pixel then occupies a single byte.

Technical uses (e.g. in medical imaging or remote sensing applications) 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 (65,536 levels) is a convenient choice for such uses, as computers manage 16-bit words efficiently. The TIFF and the PNG (among other) image file formats support 16-bit grayscale natively, although browsers and many imaging programs tend to ignore the low order 8 bits of each pixel.

No matter what pixel depth is used, the binary representations assume that 0 is black and the maximum value (255 at 8 bpp, 65,535 at 16 bpp, etc.) is white, if not otherwise noted.

Converting color to grayscale [edit]

Conversion of a color image to grayscale is not unique; different weighting of the color channels effectively represent the effect of shooting black-and-white film with different-colored photographic filters on the cameras. A common strategy is to match the luminance of the grayscale image to the luminance of the color image.

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. For the sRGB color space, the gamma expansion is defined as

C_\mathrm{linear}=
\begin{cases}\frac{C_\mathrm{srgb}}{12.92}, & C_\mathrm{srgb}\le0.04045\\
\left(\frac{C_\mathrm{srgb}+0.055}{1.055}\right)^{2.4}, & C_\mathrm{srgb}>0.04045
\end{cases}

where C_\mathrm{srgb} is any of the three gamma-compressed sRGB primaries in range [0,1] and C_\mathrm{linear} is the corresponding linear-intensity value (also in range [0,1]). Then, luminance is calculated as a weighted sum of the three linear-intensity values. For the ITU-R BT.709 primaries, as used in sRGB, the weighting Y = 0.2126 R + 0.7152 G + 0.0722 B gives the CIE 1931 luminance, Y, as the result.[2] Linear luminance typically needs to be gamma compressed to get back to a conventional grayscale representation. To encode grayscale intensity in RGB, each of the three primaries can be set to equal the calculated luminance. For sRGB, the appropriate gamma compression is

C_\mathrm{srgb}=\begin{cases}
12.92\ C_\mathrm{linear}, & C_\mathrm{linear} \le 0.0031308\\
1.055\ C_\mathrm{linear}^{1/2.4}-0.055, & C_\mathrm{linear} > 0.0031308.
\end{cases}

This is not the method used to obtain the luma in the Y'UV and related color models, used in standard color TV and video systems as PAL, SECAM, and NTSC. These systems directly compute a gamma-compressed luma as a linear combination of gamma-compressed primary intensities, rather than use linearization via gamma expansion and compression. In the YUV and YIQ models used by PAL and NTSC, the luma (Y') component is computed as

Y' =  0.299 R + 0.587 G + 0.114 B

The coefficients represent human perception of colors, in particular that humans are more sensitive to green and least sensitive to blue. The model used for HDTV developed by the ATSC uses different color coefficients, computing the luma component as

Y' =  0.2126 R + 0.7152 G + 0.0722 B

Grayscale as single channels of multichannel color images [edit]

Color images are often built of several stacked color channels, each of them representing value levels of the given channel. For example, RGB images are composed of three independent channels for red, green and blue primary color components; CMYK images have four channels for cyan, magenta, yellow and black ink plates, etc.

Here is an example of color channel splitting of a full RGB color image. The column at left shows the isolated color channels in natural colors, while at right there are their grayscale equivalences:

Composition of RGB from 3 Grayscale images

The reverse is also possible: to build a full color image from their separate grayscale channels. By mangling channels, using offsets, rotating and other manipulations, artistic effects can be achieved instead of accurately reproducing the original image.

See also [edit]

References [edit]

  1. ^ Stephen Johnson (2006). Stephen Johnson on Digital Photography. O'Reilly. ISBN 0-596-52370-X. 
  2. ^ Michael Stokes, Matthew Anderson, Srinivasan Chandrasekar, and Ricardo Motta, "A Standard Default Color Space for the Internet - sRGB", online see matrix at end of Part 2.