In
digital photography
Digital photography uses cameras containing arrays of electronic photodetectors interfaced to an analog-to-digital converter (ADC) to produce images focused by a lens, as opposed to an exposure on photographic film. The digitized image is sto ...
,
computer-generated imagery
Computer-generated imagery (CGI) is the use of computer graphics to create or contribute to images in art, printed media, video games, simulators, and visual effects in films, television programs, shorts, commercials, and videos. The images may ...
, and
colorimetry
Colorimetry is "the science and technology used to quantify and describe physically the human color perception".
It is similar to spectrophotometry, but is distinguished by its interest in reducing spectra to the physical correlates of color ...
, a grayscale
image
An image is a visual representation of something. It can be two-dimensional, three-dimensional, or somehow otherwise feed into the visual system to convey information. An image can be an artifact, such as a photograph or other two-dimensiona ...
is one in which the value of each
pixel
In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a raster image, or the smallest point in an all points addressable display device.
In most digital display devices, pixels are the smal ...
is a single
sample
Sample or samples may refer to:
Base meaning
* Sample (statistics), a subset of a population – complete data set
* Sample (signal), a digital discrete sample of a continuous analog signal
* Sample (material), a specimen or small quantity of s ...
representing only an ''amount'' of
light
Light or visible light is electromagnetic radiation that can be perceived by the human eye. Visible light is usually defined as having wavelengths in the range of 400–700 nanometres (nm), corresponding to frequencies of 750–420 tera ...
; that is, it carries only
intensity information. Grayscale images, a kind of
black-and-white
Black-and-white (B&W or B/W) images combine black and white in a continuous spectrum, producing a range of shades of grey.
Media
The history of various visual media began with black and white, and as technology improved, altered to color. ...
or gray
monochrome
A monochrome or monochromatic image, object or palette is composed of one color (or values of one color). Images using only shades of grey are called grayscale (typically digital) or black-and-white (typically analog). In physics, monochrom ...
, are composed exclusively of
shades of gray
Variations of gray or grey include achromatic grayscale shades, which lie exactly between white and black, and nearby colors with low colorfulness. A selection of a number of these various colors is shown below.
Chart of computer web color ...
. The
contrast ranges from
black
Black is a color which results from the absence or complete absorption of visible light. It is an achromatic color, without hue, like white and grey. It is often used symbolically or figuratively to represent darkness. Black and white have o ...
at the weakest intensity to
white
White is the lightest color and is achromatic (having no hue). It is the color of objects such as snow, chalk, and milk, and is the opposite of black. White objects fully reflect and scatter all the visible wavelengths of light. White on ...
at the strongest.
Grayscale images are distinct from one-bit bi-tonal black-and-white images, which, in the context of computer imaging, are images with only two
color
Color (American English) or colour (British English) is the visual perceptual property deriving from the spectrum of light interacting with the photoreceptor cells of the eyes. Color categories and physical specifications of color are associ ...
s: black and white (also called ''bilevel'' or ''
binary image
A binary image is one that consists of pixels that can have one of exactly two colors, usually black and white. Binary images are also called ''bi-level'' or ''two-level'', Pixelart made of two colours is often referred to as ''1-Bit'' or ''1b ...
s''). Grayscale images have many shades of gray in between.
Grayscale images can be the result of measuring the intensity of light at each pixel according to a particular weighted combination of frequencies (or wavelengths), and in such cases they are
monochromatic
A monochrome or monochromatic image, object or color scheme, palette is composed of one color (or lightness, values of one color). Images using only Tint, shade and tone, shades of grey are called grayscale (typically digital) or Black and wh ...
proper when only a single
frequency
Frequency is the number of occurrences of a repeating event per unit of time. It is also occasionally referred to as ''temporal frequency'' for clarity, and is distinct from ''angular frequency''. Frequency is measured in hertz (Hz) which is eq ...
(in practice, a narrow band of frequencies) is captured. The frequencies can in principle be from anywhere in the
electromagnetic spectrum
The electromagnetic spectrum is the range of frequencies (the spectrum) of electromagnetic radiation and their respective wavelengths and photon energies.
The electromagnetic spectrum covers electromagnetic waves with frequencies ranging from ...
(e.g.
infrared
Infrared (IR), sometimes called infrared light, is electromagnetic radiation (EMR) with wavelengths longer than those of visible light. It is therefore invisible to the human eye. IR is generally understood to encompass wavelengths from around ...
,
visible light
Light or visible light is electromagnetic radiation that can be perceived by the human eye. Visible light is usually defined as having wavelengths in the range of 400–700 nanometres (nm), corresponding to frequencies of 750–420 te ...
,
ultraviolet
Ultraviolet (UV) is a form of electromagnetic radiation with wavelength from 10 nanometer, nm (with a corresponding frequency around 30 Hertz, PHz) to 400 nm (750 Hertz, THz), shorter than that of visible light, but longer than ...
, etc.).
A
colorimetric
Colorimetry is "the science and technology used to quantify and describe physically the human color perception".
It is similar to spectrophotometry, but is distinguished by its interest in reducing spectra to the physical correlates of color ...
(or more specifically
photometric) grayscale image is an image that has a defined grayscale
colorspace
A color space is a specific organization of colors. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a digital represen ...
, 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
Visual perception is the ability to interpret the surrounding environment through photopic vision (daytime vision), color vision, scotopic vision (night vision), and mesopic vision (twilight vision), using light in the visible spectrum reflec ...
.
If the original color image has no defined colorspace, or if the grayscale image is not intended to have the same human-perceived achromatic intensity as the color image, then there is no unique
mapping from such a color image to a grayscale image.
Numerical representations
![Grayscale 8bits palette sample image](https://upload.wikimedia.org/wikipedia/commons/f/fa/Grayscale_8bits_palette_sample_image.png)
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 (or 0%) (total absence, black) and 1 (or 100%) (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
Colorimetry is "the science and technology used to quantify and describe physically the human color perception".
It is similar to spectrophotometry, but is distinguished by its interest in reducing spectra to the physical correlates of color ...
. Sometimes the scale is reversed, as in
printing
Printing is a process for mass reproducing text and images using a master form or template. The earliest non-paper products involving printing include cylinder seals and objects such as the Cyrus Cylinder and the Cylinders of Nabonidus. The ea ...
where the numeric intensity denotes how much ink is employed in
halftoning
Halftone is the reprographic technique that simulates continuous-tone imagery through the use of dots, varying either in size or in spacing, thus generating a gradient-like effect.Campbell, Alastair. The Designer's Lexicon. ©2000 Chronicle, S ...
, with 0% representing the paper white (no ink) and 100% being a solid black (full ink).
In computing, although the grayscale can be computed through
rational numbers
In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (e.g. ). The set of all rationa ...
, image pixels are usually
quantized to store them as unsigned integers, to reduce the required storage and computation. Some early grayscale monitors can only display up to sixteen different shades, which would be stored in
binary
Binary may refer to:
Science and technology Mathematics
* Binary number, a representation of numbers using only two digits (0 and 1)
* Binary function, a function that takes two arguments
* Binary operation, a mathematical operation that t ...
form using 4
bit
The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
s. But today grayscale images intended for visual display are commonly stored with 8 bits per sampled pixel. This pixel
depth allows 256 different intensities (i.e., shades of gray) to be recorded, and also simplifies computation as each pixel sample can be accessed individually as one full
byte
The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit ...
. 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. Therefore, the shades are instead typically spread out evenly on a
gamma-compressed nonlinear scale, which better approximates uniform perceptual increments for both dark and light shades, usually making these 256 shades enough to avoid noticeable increments.
Technical uses (e.g. in
medical imaging
Medical imaging is the technique and process of imaging the interior of a body for clinical analysis and medical intervention, as well as visual representation of the function of some organs or tissues (physiology). Medical imaging seeks to rev ...
or
remote sensing
Remote sensing is the acquisition of information about an object or phenomenon without making physical contact with the object, in contrast to in situ or on-site observation. The term is applied especially to acquiring information about Earth ...
applications) often require more levels, to make full use of the
sensor
A sensor is a device that produces an output signal for the purpose of sensing a physical phenomenon.
In the broadest definition, a sensor is a device, module, machine, or subsystem that detects events or changes in its environment and sends ...
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
A word is a basic element of language that carries an objective or practical meaning, can be used on its own, and is uninterruptible. Despite the fact that language speakers often have an intuitive grasp of what a word is, there is no consen ...
efficiently. The
TIFF
Tag Image File Format, abbreviated TIFF or TIF, is an image file format for storing raster graphics images, popular among graphic artists, the publishing industry, and photographers. TIFF is widely supported by scanning, faxing, word processin ...
and
PNG (among other)
image file formats
An Image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be c ...
support 16-bit grayscale natively, although browsers and many imaging programs tend to ignore the low order 8 bits of each pixel. Internally for computation and working storage, image processing software typically uses integer or floating-point numbers of size 16 or 32 bits.
Converting color to grayscale
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 filter
In photography and cinematography, a filter is a camera accessory consisting of an optical filter that can be inserted into the optical path. The filter can be of a square or oblong shape and mounted in a holder accessory, or, more commonly, a ...
s on the cameras.
Colorimetric (perceptual luminance-preserving) conversion to grayscale
A common strategy is to use the principles of
photometry Photometry can refer to:
* Photometry (optics), the science of measurement of visible light in terms of its perceived brightness to human vision
* Photometry (astronomy), the measurement of the flux or intensity of an astronomical object's electro ...
or, more broadly,
colorimetry
Colorimetry is "the science and technology used to quantify and describe physically the human color perception".
It is similar to spectrophotometry, but is distinguished by its interest in reducing spectra to the physical correlates of color ...
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). 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
whitepoint
A white point (often referred to as reference white or target white in technical documents) is a set of CIE 1931 color space, tristimulus values or chromaticity coordinates that serve to define the color "white" in image capture, encoding, or repr ...
s. 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 (as in the 1976 CIE
''L''ab color space) which is determined by the linear luminance itself (as in the
CIE 1931 ''XYZ'' color space) which we will refer to here as to avoid any ambiguity.
To convert a color from a colorspace based on a typical
gamma-compressed (nonlinear)
RGB color model
The RGB color model is an additive color model in which the red, green and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additiv ...
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
A weight function is a mathematical device used when performing a sum, integral, or average to give some elements more "weight" or influence on the result than other elements in the same set. The result of this application of a weight function is ...
can be applied to the linear color components (
) to calculate the linear luminance , which can then be gamma-compressed back again if the grayscale result is also to be encoded and stored in a typical nonlinear colorspace.
For the common
sRGB
sRGB is a standard RGB (red, green, blue) color space that HP and Microsoft created cooperatively in 1996 to use on monitors, printers, and the World Wide Web. It was subsequently standardized by the International Electrotechnical Commission ( ...
color space, gamma expansion is defined as
:
where represents any of the three gamma-compressed sRGB primaries (, , and , each in range
,1 and is the corresponding linear-intensity value (, , and , also in range
,1. Then, linear luminance is calculated as a weighted sum of the three linear-intensity values. The
sRGB
sRGB is a standard RGB (red, green, blue) color space that HP and Microsoft created cooperatively in 1996 to use on monitors, printers, and the World Wide Web. It was subsequently standardized by the International Electrotechnical Commission ( ...
color space is defined in terms of the
CIE 1931 linear luminance , which is given by
:
.
These three particular coefficients represent the intensity (luminance) perception of typical
trichromat
Trichromacy or trichromatism is the possessing of three independent channels for conveying color information, derived from the three different types of cone cells in the eye. Organisms with trichromacy are called trichromats.
The normal exp ...
humans to light of the precise
Rec. 709
Rec. 709, also known as Rec.709, BT.709, and ITU 709, is a standard developed by ITU-R for image encoding and signal characteristics of high-definition television.
The most recent version is BT.709-6 released in 2015. BT.709-6 defines the P ...
additive primary colors (chromaticities) that are used in the definition of sRGB. Human vision is most sensitive to green, so this has the greatest coefficient value (0.7152), and least sensitive to blue, so this has the smallest coefficient (0.0722). To encode grayscale intensity in linear RGB, each of the three color components can be set to equal the calculated linear luminance
(replacing
by the values
to get this linear grayscale), which then typically needs to be
gamma compressed to get back to a conventional non-linear representation.
For sRGB, each of its three primaries is then set to the same gamma-compressed given by the inverse of the gamma expansion above as
:
Because the three sRGB components are then equal, indicating that it is actually a gray image (not color), it is only necessary to store these values once, and we call this the resulting grayscale image. 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. Web browsers and other software that recognizes sRGB images should produce the same rendering for such a grayscale image as it would for a "color" sRGB image having the same values in all three color channels.
Luma coding in video systems
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
Phase Alternating Line (PAL) is a colour encoding system for analogue television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields (25 ...
,
SECAM
SECAM, also written SÉCAM (, ''Séquentiel de couleur à mémoire'', French for ''color sequential with memory''), is an analog color television system that was used in France, some parts of Europe and Africa, and Russia. It was one of th ...
, and
NTSC
The first American standard for analog television broadcast was developed by National Television System Committee (NTSC)National Television System Committee (1951–1953), Report and Reports of Panel No. 11, 11-A, 12–19, with Some supplement ...
, a nonlinear
luma
Luma or LUMA may refer to:
Arts
* La Trobe University Museum of Art, Melbourne, Australia
* LUMA Projection Arts Festival, an annual event featuring building-scale projection mapping and light installations in Binghamton, NY
* LUMA Foundation, ...
component 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
Luma or LUMA may refer to:
Arts
* La Trobe University Museum of Art, Melbourne, Australia
* LUMA Projection Arts Festival, an annual event featuring building-scale projection mapping and light installations in Binghamton, NY
* LUMA Foundation, ...
component is computed as
:
where we use the prime to distinguish these nonlinear values from the sRGB nonlinear values (discussed above) which use a somewhat different gamma compression formula, and from the linear RGB components. The
ITU-R BT.709 standard used for
HDTV
High-definition television (HD or HDTV) describes a television system which provides a substantially higher image resolution than the previous generation of technologies. The term has been used since 1936; in more recent times, it refers to the g ...
developed by the
ATSC
Advanced Television Systems Committee (ATSC) standards are an American set of standards for digital television transmission over terrestrial, cable and satellite networks. It is largely a replacement for the analog NTSC standard and, like that ...
uses different color coefficients, computing the luma component as
:
.
Although these are numerically the same coefficients used in sRGB above, the effect is different because here they are being applied directly to gamma-compressed values rather than to the linearized values. The
ITU-R BT.2100 standard for
HDR television uses yet different coefficients, computing the luma component as
:
.
Normally these colorspaces are transformed back to nonlinear R'G'B' before rendering for viewing. To the extent that enough precision remains, they can then be rendered accurately.
But if the luma component Y' itself is instead used directly as a grayscale representation of the color image, luminance is not preserved: two colors can have the same luma but different CIE linear luminance (and thus different nonlinear as defined above) and therefore appear darker or lighter to a typical human than the original color. Similarly, two colors having the same luminance (and thus the same ) will in general have different luma by either of the luma definitions above.
[Charles Poynton]
The magnitude of nonconstant luminance errors
in Charles Poynton, A Technical Introduction to Digital Video. New York: John Wiley & Sons, 1996.
Grayscale as single channels of multichannel color images
Color images are often built of several stacked
color channels, each of them representing value levels of the given channel. For example,
RGB
The RGB color model is an additive color model in which the red, green and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three addi ...
images are composed of three independent channels for red, green and blue
primary color
A set (mathematics), set of primary colors or primary colours (see American and British English spelling differences#-our, -or, spelling differences) consists of colorants or colored lights that can be mixed in varying amounts to produce a gamu ...
components;
CMYK
The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself. The abbreviation ''CMYK'' refers ...
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:
![Beyoglu 4671 tricolor](https://upload.wikimedia.org/wikipedia/commons/3/33/Beyoglu_4671_tricolor.png)
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
*
Channel (digital image)
Color digital images are made of pixels, and pixels are made of combinations of primary colors represented by a series of code. A channel in this context is the grayscale image of the same size as a color image, made of just one of these primary co ...
*
Halftone
Halftone is the reprographic
Reprography (a portmanteau of ''reproduction'' and ''photography'') is the reproduction of graphics through mechanical or electrical means, such as photography or xerography. Reprography is commonly used in catal ...
*
Duotone
Duotone (sometimes also known as ''Duplex'') is a halftone reproduction of an image using the superimposition of one contrasting color halftone over another color halftone. This is most often used to bring out middle tones and highlights of an ...
*
False-color
False color (or pseudo color) refers to a group of color rendering methods used to display images in color which were recorded in the visible or non-visible parts of the electromagnetic spectrum. A false-color image is an image that depicts ...
*
Sepia tone
In photography, toning is a method of altering the color of black-and-white photographs. In analog photography, it is a chemical process carried out on metal salt-based prints, such as silver prints, iron-based prints (cyanotype or Van Dyke b ...
*
Cyanotype
The cyanotype (from Ancient Greek κυάνεος - ''kuáneos'', “dark blue” + τύπος - ''túpos'', “mark, impression, type”) is a slow-reacting, economical photographic printing formulation sensitive to a limited near ultraviolet ...
*
Morphological image processing
*
Mezzotint
Mezzotint is a monochrome printmaking process of the '' intaglio'' family. It was the first printing process that yielded half-tones without using line- or dot-based techniques like hatching, cross-hatching or stipple. Mezzotint achieves tonali ...
*
List of monochrome and RGB color formats
This list of monochrome and RGB palettes includes generic repertoires of colors ( color palettes) to produce black-and-white and RGB color pictures by a computer's display hardware. RGB is the most common method to produce colors for displays; ...
–
Monochrome palettes section
*
List of software palettes This is a list of software palettes used by computers. Systems that use a 4-bit or 8-bit pixel depth can display up to 16 or 256 colors simultaneously. Many personal computers in the early 1990s displayed at most 256 different colors, freely s ...
–
Color gradient palettes and
false color palettes sections
*
Achromatopsia
Achromatopsia, also known as Rod monochromacy, is a medical syndrome that exhibits symptoms relating to five conditions, most notably monochromacy. Historically, the name referred to monochromacy in general, but now typically refers only to an au ...
, total
color blindness
Color blindness or color vision deficiency (CVD) is the decreased ability to color vision, see color or differences in color. It can impair tasks such as selecting ripe fruit, choosing clothing, and reading traffic lights. Color blindness may ...
, in which vision is limited to a grayscale
*
Zone System
The Zone System is a photographic technique for determining optimal film exposure and development, formulated by Ansel Adams and Fred Archer. Adams described the Zone System as " ..not an invention of mine; it is a codification of the principles o ...
References
{{color topics
Imaging
Color depths
Shades of gray