In video, computer graphics and image processing, gamma represents a numerical parameter that describes the nonlinearity of intensity reproduction. Having a good understanding of the theory and practice of gamma will enable you to get good results when you create, process and display pictures.
I am the proprietor of the document Frequently asked questions about gamma, the GammaFAQ. But there are so many misconceptions concerning gamma that I thought it would also be informative to post, in addition, the frequently-questioned answers about gamma, the GammaFQA. In the left column of the table below is the so-called answer. In the right column are the facts that bring the "answer" into question.
Fallacy
| Fact
|
---|---|
A
CRT's phosphor has a nonlinear response to beam current.
|
The
electron gun of a CRT is responsible for its nonlinearity, not the
phosphor.
|
The
nonlinearity of a CRT monitor is a defect that needs to be corrected.
|
The
nonlinearity of a CRT is very nearly the inverse of the lightness sensitivity
of human vision. The nonlinearity causes a CRT's response to be roughly
perceptually uniform. Far from being a defect, this feature is highly desirable.
|
The
main purpose of gamma correction is to compensate the nonlinearity of the CRT.
|
The
main purpose of gamma correction in video, desktop graphics, prepress, JPEG,
and MPEG is to code light power into a perceptually-uniform domain, so as to
obtain the best perceptual performance from a limited number of bits in each of
the R, G, and B (or C, M, Y, and K) components.
|
Ideally,
linear-light representations should be used to represent image data.
|
If
linear-light coding is used to represent image data, then from 12 to 14 bits
are necessary in each component to achieve high-quality image reproduction.
With nonlinear (gamma-corrected) coding, 8 or 10 bits suffice.
|
A
CRT is characterized by a power function that relates luminance to voltage:
L = V [gamma] .
|
A
CRT is characterized by a power function, but including a black-level offset
term: L = (V + epsilon ) gamma.
|
The
exponent gamma varies anywhere from about 1.4 to 3.5.
|
In studio video, the
exponent itself varies over a rather narrow range, about 2.35 to 2.45. In consumer use, the range is somewhat wider, say 2.0 to 2.3. Digital cinema is standardized at 2.6. The
alleged wide variation comes from variation in offset term of the
equation, not the exponent: Wide variation is due to failure to correctly set
the black level.
|
Gamma
correction is accomplished by inverting this equation.
|
Gamma
correction is roughly the inverse of this equation, but two corrections must be
introduced to achieve good performance. First, a linear segment is introduced
into the transfer function in order to minimize the introduction of noise in very dark
areas of the image. Second, the exponent at the encoder is made somewhat
greater than the mathematical value, in order to impose picture
rendering that compensates for appearance at image display: Displayed images are nearly always presented at absolute luminance level lower than the original scene, and compensation is necessary to achieve the intended perceptual result.
|
CRT
variation is responsible for wide variability in tone scale reproduction when
images are exchanged among computers.
|
Poor
performance in image exchange is generally due to lack of control over transfer
functions that are applied when image data is acquired, processed, stored, and
displayed.
|
Macintosh
monitors have nonstandard values of gamma.
|
All
CRT monitors, including those used with Macintosh computers, produce
essentially identical response to voltage. Historically, though, the Macintosh QuickDraw graphics
subsystem involved a lookup table loaded by default with an unusual
transfer function. It is not the monitor but the lookup table that imposes the
nonstandard Macintosh gamma characteristic: Historically, luminance or tristimulus (proportional to intensity, proportional to light power) at the display screen was approximately proportional to RGB code raised to the 1.8 power. This all changed as of Mac OS X 10.6 ("Snow Leopard"), which adopts the classic PC scheme where luminance at the display screen is approximately proportional to RGB code raised to the 2.2 power.
|
Gamma
problems can be circumvented by loading a lookup table having a suitable gamma
value.
|
Loading
a particular lookup table, or a particular value of gamma, alters the
luminance interpretation of data in the frame buffer. This may have the
intended effect on a particular image. However, loading a new lookup table will
disturb the code-to-luminance mapping that is assumed by the graphics subsystem,
other windows, or other images. This is liable to alter color values that are supposed to
stay fixed.
|
Macintosh
computers are shipped from the factory with gamma set to 1.8. SGI machines
default to gamma of 1.7. To make an SGI machine display pictures like a Mac,
set SGI gamma to 1.8.
|
On
the Macintosh, setting a numerical gamma setting of g loads into the
framebuffer's lookup table a power function with the exponent
g/2.6. On an SGI, setting a numerical gamma setting of
g loads into the lookup table a power function with the exponent
1/g. To make an SGI machine behave like
a Mac, you must set SGI gamma
to 1.45.
|
Gamma
problems can be avoided when exchanging images by tagging every image file with
a suitable gamma value.
|
Various
tag schemes have been standardized; some tags are coded into image files.
However, application software today often pays no attention to the tags, so
tagging image files is not necessarily helpful today. It is obviously a good idea to avoid
subjecting an image file to cascaded transfer functions during processing.
However, the tag approach fails to recognize that image data should be
originated and maintained in a perceptually-based code.
|
JPEG
compresses RGB data, and reproduces RGB data upon decompression.
The JPEG algorithm itself is completely independent of whatever transfer
function is used.
|
JPEG
and other lossy image compression algorithms depend on discarding information
that won't be perceived. It is vital that the data presented to a JPEG
compressor be coded in a perceptually-uniform manner, so that the information
discarded has minimal perceptual impact. Also, although standardized as an
image compression algorithm, JPEG is so popular that it is now
effectively an image interchange standard. Standardization of the
transfer function is necessary in order for JPEG to meet its users'
expectations.
|