Gamma correction:
Assuming it acts as a simple output device, we’d expect it to display, say, a black pixel
wherever we specify a pixel intensity value of zero (0), and a white pixel wherever we
specify an intensity value of one (1). All values in between 0 and 1 are shades of gray.
With many (if not all) graphical display devices, this is not the case. Although we have
specified that we want a specific color at a certain pixel location, due to imperfections in
the display device, the actual color we see on-screen is not the exact color we desire.
The diagram below shows a grayscale spectrum, along with the “transfer function” of an
ideal display device to its right. For the transfer function plot to the right, consider the x-
axis to be the color we want to appear on-screen, while the y-axis represents the color
intensity value that is actually displayed.
For a more mathematical analysis, consider any arbitrary pixel on a display device. The
grayscale intensity value we actually see is defined as , and the intensity value we want
to appear on the screen (in our code) is defined as . Finally, the gamma value is
defined as . The relationship between the input and output intensity values can be
described by the equation below. A table of figures representing the transfer function of
gamma correction for varying values of gamma is shown below for emphasis.
In the ideal case, with , our input and output intensity values match perfectly, as in
the case of the ideal display described at the top of the page. As the gamma value
deviates from unity, we begin to notice a significant difference in the input and output
intensity values. As gamma approaches zero, the output pixels become brighter, while
as gamma approaches infinity, the pixels become darker. Gamma correction essentially
carries out the inverse function of the exponential operation caused by imperfections in
the display device.