Grayscale

In digital photography, computer-generated imagery, and colorimetry, a greyscale (more common in Commonwealth English) or grayscale (more common in American English) image is one in which the value of each pixel is a single sample representing only an amount of light; that is, it carries only intensity information.

The contrast ranges from black at the weakest intensity to white at the strongest.

The frequencies can in principle be from anywhere in the electromagnetic spectrum (e.g. infrared, visible light, ultraviolet, etc.).

A colorimetric (or more specifically photometric) grayscale image is an image that has a defined grayscale colorspace, which maps the stored numeric sample values to the achromatic channel of a standard colorspace, which itself is based on measured properties of human vision.

This notation is used in academic papers, but this does not define what "black" or "white" is in terms of colorimetry.

Some early grayscale monitors can only display up to sixteen different shades, which would be stored in binary form using 4 bits.

[citation needed] But today grayscale images intended for visual display are commonly stored with 8 bits per sampled pixel.

However, if these intensities were spaced equally in proportion to the amount of physical light they represent at that pixel (called a linear encoding or scale), the differences between adjacent dark shades could be quite noticeable as banding artifacts, while many of the lighter shades would be "wasted" by encoding a lot of perceptually-indistinguishable increments.

[2] 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 reduce rounding errors in computations.

Sixteen bits per sample (65,536 levels) is often a convenient choice for such uses, as computers manage 16-bit words efficiently.

Internally for computation and working storage, image processing software typically uses integer or floating-point numbers of size 16 or 32 bits.

Conversion of an arbitrary color image to grayscale is not unique in general; 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 use the principles of photometry or, more broadly, colorimetry to calculate the grayscale values (in the target grayscale colorspace) so as to have the same luminance (technically relative luminance) as the original color image (according to its colorspace).

[3][4] In addition to the same (relative) luminance, this method also ensures that both images will have the same absolute luminance when displayed, as can be measured by instruments in its SI units of candelas per square meter, in any given area of the image, given equal whitepoints.

Luminance itself is defined using a standard model of human vision, so preserving the luminance in the grayscale image also preserves other perceptual lightness measures, such as L* (as in the 1976 CIE Lab color space) which is determined by the linear luminance Y itself (as in the CIE 1931 XYZ color space) which we will refer to here as Ylinear to avoid any ambiguity.

To convert a color from a colorspace based on a typical gamma-compressed (nonlinear) RGB color model to a grayscale representation of its luminance, the gamma compression function must first be removed via gamma expansion (linearization) to transform the image to a linear RGB colorspace, so that the appropriate weighted sum can be applied to the linear color components (

) to calculate the linear luminance Ylinear, which can then be gamma-compressed back again if the grayscale result is also to be encoded and stored in a typical nonlinear colorspace.

The sRGB color space is defined in terms of the CIE 1931 linear luminance Ylinear, which is given by[6]

These three particular coefficients represent the intensity (luminance) perception of typical trichromat humans to light of the precise Rec.

to get this linear grayscale), which then typically needs to be gamma compressed to get back to a conventional non-linear representation.

[7] For sRGB, each of its three primaries is then set to the same gamma-compressed Ysrgb given by the inverse of the gamma expansion above as

This is how it will normally be stored in sRGB-compatible image formats that support a single-channel grayscale representation, such as JPEG or PNG.

For images in color spaces such as Y'UV and its relatives, which are used in standard color TV and video systems such as PAL, SECAM, and NTSC, a nonlinear luma component (Y′) is calculated directly from gamma-compressed primary intensities as a weighted sum, which, although not a perfect representation of the colorimetric luminance, can be calculated more quickly without the gamma expansion and compression used in photometric/colorimetric calculations.

In the Y'UV and Y'IQ models used by PAL and NTSC, the rec601 luma (Y′) component is computed as

The ITU-R BT.709 standard used for HDTV developed by the ATSC uses different color coefficients, computing the luma component as

The ITU-R BT.2100 standard for HDR television uses yet different coefficients, computing the luma component as

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.

The column at left shows the isolated color channels in natural colors, while at right there are their grayscale equivalences: 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.

Grayscale image of a parrot
Examples of conversion from a full-color image to grayscale using Adobe Photoshop 's Channel Mixer , compared to the original image and colorimetric conversion to grayscale
Composition of RGB from three grayscale images