What is Gamma Correction?

In the field of Computer Graphics, one often hears the phrase "gamma correction." What is this strange sounding thing and why does it matter to you?

Gamma correction matters if you have any interest in displaying an image accurately on a computer screen. Gamma correction controls the overall brightness of an image. Images which are not properly corrected can look either bleached out, or too dark. Trying to reproduce colors accurately also requires some knowledge of gamma. Varying the amount of gamma correction changes not only the brightness, but also the ratios of red to green to blue. (Example of this color phenomenon).Gamma correction also plays a big role in making images for the WWW.

Computer Monitor

To explain gamma correction we will begin with where you are looking - your computer monitor.

Almost every computer monitor, from whatever manufacturer, has one thing in common. They all have a intensity to voltage response curve which is roughly a 2.5 power function. Don't be afraid, this just means that if you send your computer monitor a message that a certain pixel should have intensity equal to x, it will actually display a pixel which has intensity equal to x ^ 2.5 Because the range of voltages sent to the monitor is between 0 and 1, this means that the intensity value displayed will be less than what you wanted it to be. (0.5 ^ 2.5 = 0.177 for example) Monitors, then, are said to have a gamma of 2.5

 Sample Input to Monitor  Graph of Input
Output from Monitor Graph of Output L = V ^ 2.5

Note: The grayscale images will not look very good on 8-bit color computers. Also the gamma correction for these images is 1.0 so they were actually designed to be viewed on a system such as a Sun or a PC with no hardware correction. They may appear brighter on other systems. The important thing here is the relative difference that you see.

Gamma correction of the input

To correct this annoying little problem, the input signal to the monitor (the voltage) must be "gamma corrected".

The solution, fortunately, is a simple one. Since we know the relationship between the voltage sent to the monitor and the intensity which it produces, we can correct the signal before it gets to the monitor. The signal is adjusted so that it is essentially the complement of the curve shown above. There are other considerations as well when one speaks of a "correct" image. These include the ambient light in a room where the computer is, the brightness and contrast settings on the monitor, and finally personal taste.

 Sample Input           Graph of Input
Gamma Corrected Input Graph of Correction L' = L ^ (1/2.5)
Monitor Output Graph of Output

If gamma correction is done properly for the computer system, then the output should accurately reflect the image input.

Note that the task of gamma correction is accomplished by raising the input value to the 1/2.5 power. This is referred to as a gamma correction of 2.5. because we are correcting the input for a monitor whose gamma is 2.5

Real World Application

In the real world, it isn't quite this simple, especially when an image needs to look good on different systems, or platforms.

As we mentioned above, most monitors work in about the same way with respect to gamma correction. Most computers, or more specifically, most computer systems, do not work in exactly the same way, however.

By computer systems we mean everything from the software that is running (like Netscape) to the graphics cards installed, to the standard hardware on the motherboard. Different computers do different things and many "systems" have different configurations of all of the above things.

Macintoshes, for example, have partial gamma correction built-in to their hardware. Silicon Graphics computers also have built-in gamma correction, but it is different from the Macintosh. Suns and PCs have no standard built-in gamma correction but some graphics cards installed in these computers may provide this functionality.

System Gamma

The idea of system gamma, is the gamma correction that should be applied in the software to reproduce an accurate image on the monitor for an uncorrected image on a particular computer "system."

Macintosh

The Macintosh has built-in gamma correction of 1.4. This means that after the software sends the signal to the framebuffer, there are internal hardware corrections which will further process the signal, specifically by gamma correcting it another 1.4 - That is, the signal is raised to the 1/1.4. Therefore, to get full correction, the software itself should first adjust the signal by raising it to the 1/1.8 power. (2.5/1.4 = 1.8) Thus the system gamma on a Macintosh is 1.8.

Note some graphics cards in Macintoshes may have their own software to change the standard gamma and Adobe Photoshop 3.0 is now released with a gamma control panel from Knoll software which allows the user to change the system gamma of their Macintosh. The 1.8 standard is still accepted as the universal Mac System Gamma, but users should be aware that a Mac can be set differently. The Knoll software control panel for the Mac rewrites the look up table, (LUT) with a value of g/2.5 where g is the gamma the user selects. Thus selecting 1.8 will rewrite the LUT with 1.8/2.5 = 1/1.4 - the default setting. (The values in the LUT are 1/1.4 and this is called a 1.4 correction)

SGI
The SGI is similar to the Macintosh but instead of a hardware correction of 1.4 the SGI applies gamma correction of 1.7. Thus the system gamma for an SGI is 2.5/1.7 or roughly 1.5. Sometimes you may see that an SGI has a system gamma of 1.4. This calculation is made on the assumption that monitors have a response curve closer to a 2.4 power function.

SGI's also come with a utility to rewrite the internal hardware correction. These values are stored in a look up table, (LUT) and can be altered. The default is 1/1.7 as mentioned above. (The values in the table are 1/1.7, so we call this a 1.7 correction) Sometimes the value in the LUT may be referred to as the SGI system gamma. This is not the definition used on other platforms. Unlike the Mac gamma control panel, the SGI gamma utility will rewrite the LUT with the actual value set by the user.

Suns and PCs
Suns and PCs have no standard hardware correction (although certain graphics cards for these platforms may) and therefore their system gammas are roughly 2.5. (More about Sun's SX hardware and gamma)

Common graphics software such as Adobe Photoshop allows the user to set the gamma correction value they want. (In Photoshop it is found in Monitor Setup under Preferences under the File Menu.)

Extract from : CGSD - Gamma Correction Explained : http://www.cgsd.com/papers/gamma_intro.html