Gamma correction
From Wikipedia, the free encyclopedia
Gamma correction, gamma nonlinearity, gamma encoding, or often simply gamma, is the name of a nonlinear operation used to code and decode luminance or tristimulus values in video or still image systems. Gamma correction is, in the simplest cases, defined by the following power-law expression:
where the input and output values are non-negative real values, typically in a predetermined range such as 0 to 1. The case is often called gamma compression and is called gamma expansion.
Contents |
[edit] Explanation
Gamma compression, also known as gamma encoding, is used to encode linear luminance or RGB values into video signals or digital file values; gamma expansion is the inverse, or decoding, process, and occurs largely in the nonlinearity of the electron-gun current–voltage curve in CRT monitor systems. Gamma encoding helps to map data into a more perceptually uniform domain, so as to optimize perceptual performance of a limited signal range, such as a limited number of bits in each RGB component.
A gamma value is sometimes used to quantify contrast, for example of photographic film. It is the slope of an input–output curve in log–log space, that is:
which is consistent with the power-law relation above, but applicable to more general nonlinearities. In the case of film, such nonlinearities are called Hurter–Driffield curves, where gamma values less than 1 are typical of negative film, and values greater than 1 are typical of slide (reversal) film.
[edit] PC, Mac, and sRGB standard gammas
In PC video, images are encoded with a gamma of about 0.45 and decoded with a gamma of 2.2; in Mac systems, the corresponding typical values are 0.55 and 1.8.
The sRGB color space standard used with most cameras, PCs, and printers does not use a simple power-law nonlinearity as above, but has a decoding gamma value near 2.2 over much of its range, as shown in the plot to the right.
CRT-based television receivers do not usually need gamma correction, since the standard video signals that are transmitted incorporate gamma compression that matches the gamma expansion of the receiver's CRT.
[edit] Simple monitor tests
To see whether your computer monitor is properly hardware adjusted and can display shadow detail in standard sRGB images properly, you should see the left half of the circle in the large black square very faintly (or not at all), but the right half should be clearly visible. If not, you can adjust your monitor's contrast and/or brightness setting. This alters the monitor's perceived gamma.
This procedure is not suitable for calibrating or print-proofing a monitor. It can be useful for making your monitor display sRGB images approximately correctly, on systems in which profiles are not used (for example, the Firefox browser and many others) or in systems that assume untagged source images are in the sRGB colorspace.
On operating systems running the X Window System you can change gamma-correction settings, by issuing the command xgamma -gamma 2.1
for setting gamma value to 2.1, and xgamma
for querying current value.
In this other example, the linear intensity of each solid square is the average of the linear intensities in the surrounding dither, therefore, ideally, the solid squares and the dithers should appear equally bright.
[edit] Power law for video display
A gamma characteristic is a power-law relationship that approximates the relationship between the encoded luminance in a television system and the actual desired image brightness.
With this nonlinear relationship, equal steps in encoded luminance correspond to subjectively approximately equal steps in brightness. Computer graphics systems that require a linear relationship between these quantities use gamma correction. The following illustration shows the difference between a scale with linearly-increasing intensity (i.e., gamma-corrected) scale and a scale with linearly-increasing encoded luminance signal.
Linear intensity | I = | 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 |
Linear encoding | VS = | 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 |
On most displays (i.e., those with a standard gamma of 2.2), one can observe that the linear-intensity scale has a large jump in perceived brightness between the intensity values 0.0 and 0.1, while the steps at the higher end of the scale are hardly perceptible. The linearly-encoded scale, which has a nonlinearly-increasing intensity, will show much more even steps in perceived brightness.
On a monitor with an analog input, the limited signal bandwidth may cause vertical black and white stripes to have a different brightness than horizontal black and white stripes. This problem will cause the squares on the image on the left to appear at different brightnesses.
A cathode ray tube (CRT), for example, converts a video signal to light in a nonlinear way, because the electron gun it contains is a nonlinear device. The light intensity I is related to the source voltage VS according to
where γ is the Greek letter gamma. For a computer CRT, γ is about 2.2. By coincidence, this results in the perceptually homogeneous scale as shown in the diagram on the top of this page.
For simplicity, consider the example of a monochrome CRT. In this case, when a video signal of 0.5 (representing mid-grey) is fed to the display, the intensity or brightness is about 0.22 (resulting in a dark grey). Pure black (0.0) and pure white (1.0) are the only shades that are unaffected by gamma.
To compensate for this effect, the inverse transfer function (gamma correction) is sometimes applied to the video signal so that the end-to-end response is linear. In other words, the transmitted signal is deliberately distorted so that, after it has been distorted again by the display device, the viewer sees the correct brightness. The inverse of the function above is:
where VC is the corrected voltage and VS is the source voltage (e.g. from a camera or VCR). In our CRT example 1/γ is 1/2.2 or 0.45.
A color CRT receives three video signals (red, green and blue) and in general each color has its own value of gamma, denoted γR, γG or γB. However, in simple display systems, a single value of γ is used for all three colors.
Other display devices have different values of gammas: for example, a Game Boy Advance display has a gamma between 3 and 4 depending on lighting conditions. In LCDs such as those on laptop computers, the relation between the signal voltage VS and the intensity I is very nonlinear and cannot be described with gamma value. However, such displays apply a correction onto the signal voltage in order to approximately get a standard γ=2.5 behaviour. In NTSC television recording, γ is 2.2.
The power-law function, or its inverse, has a slope of infinity at zero. This leads to problems in converting from and to a gamma colorspace. For this reason most formally defined colorspaces such as sRGB will define a straight-line segment near zero and add raising x+K (where K is a constant) to a power so the curve has continuous slope. This straight line does not represent what the CRT does, but does make the rest of the curve more closely match the effect of ambient light on the CRT. In such expressions the exponent is not the gamma, for instance the sRGB function uses a power of 2.4 in it, but more closely resembles the 2.2 gamma function.
[edit] Photography
The same term — gamma — has long been used in photography to describe an analogous nonlinearity. The photographic term refers to the slope of the straight-line region of the Hurter–Driffield curve, which is a plot of density (or the logarithm of opacity) of the film image versus the logarithm of the film's exposure to light.
Photographic film has a much greater ability to record fine differences in shade than can be reproduced on photographic paper. Similarly, a video screen is not as capable of displaying the range of brightness which can be captured by electronic cameras. For this reason, a considerable amount of artistic effort in photography can be invested in choosing what reduced form of the original image should be presented. The gamma correction, or contrast selection, is part of the photographic repertoire used to adjust the recorded image.
[edit] Confusing terminology
The names of the various quantities are somewhat confusing. The term intensity refers strictly to the amount of light that is emitted per unit of time and per unit of surface, in units of lux. Note, however, that in many fields of science this quantity is called luminous emittance, as opposed to luminous intensity, which is a different quantity. These distinctions, however, are largely irrelevant to gamma compression, which is applicable to any sort of normalized linear intensity-like scale.
Luminance can mean several things even within the context of video:
- Luminance is the photometric brightness of an object, taking into account the wavelength-dependent sensitivity of the human eye (in units of cd/m2);
- Luminance (video) is the encoded video signal, i.e. similar to the signal voltage VS.
Likewise, brightness can refer to the amount of light either before or after application of the gamma power law.
The gamma function described above is completely unrelated to the mathematical Gamma function. The two are merely represented using the same Greek letter, Γ or γ (gamma).
[edit] See also
[edit] External links
[edit] General information
- Rehabilitation of Gamma by Poynton
- Color List shows vast improvements of gamma correction (2,000+ color comparison)
- Gamma tutorial (from the PNG specification)
- Frequently Asked Questions about Gamma
[edit] Monitor gamma tools
- Measuring Gamma for Monitors (Gernot Hoffman)
- Monitor test pattern for correct gamma correction (by Norman Koren)
- Links browser Gamma Calibration page
- Monitor Calibration Wizard
- Advanced Gamma Corrector
- QuickGamma