Skip to main content
Skip table of contents

Gamma-Correct the Luminance of a Display

This guide is an introduction to using the X-Rite i1Display Pro colorimeter or the X-Rite i1 Pro spectrophotometer to linearize the luminance of a visual display. You will use a MATLAB script to sample the luminance of a display at various pixel values, characterize and gamma-correct the non-linearity of your display.

By default, the relationship between the programmed pixel values and the luminance of most displays is non-linear.

To store an image on a computer, the image data is broken down into smaller ‘picture elements’ called pixels. Each pixel represents one colour in a specific location of the screen. An image presented on a full high-definition screen (i.e., 1920 x 1080) will contain millions of these pixels. The pixels are encoded in terms of an RGB triplet. The higher the pixel value, the greater the measured luminance.

Vision scientists attempt to characterize the relationship between the physical properties of a stimulus and its visual perception, and expect to find that pixel value would be linearly related to luminance.

The Comission Internationale de l’Énergie (CIE) defines luminance as a measurement of luminous intensity radiating from a surface, weighted by the sensitivities of human photoreceptors wavelengths in the visible light spectrum, expressed in candelas per square meter (cd/m2).

However, it is not typically the case: the relationship between pixel value and luminance typically follows a positive power function of the form y = xγ, where  y is the normalized luminance value, x the pixel value, and gamma (γ) is the power that characterizes the relationship between the two values. ​

Historically, cathode-ray tube screens (CRTs) were the first types of screens used to visualize video content, and different luminance levels were produced by varying the number of electrons fired from an electron gun. This electron gun responded to voltage input according to a power function of 2.5, known as gamma.

Other display technologies are also non-linear, such as the LCD panels of commercial displays, but also those of the VIEWPixx and VIEWPixx/3D screens. Here are some examples of gamma in visual displays used in vision research: 

The relationship between the pixel colour value (the signal) and the luminance of a display typically follows a power function. Notably, the gamma of a PROPixx projector is 1, and requires no correction.

This non-linear relationship happens to have a very useful practical application in video recording. Indeed, the amount of information that can conveyed through a video signal is typically rather limited, where each colour of an RBG triplet is encoded with 8 bits of information. In other words, the specific amount of red, green and blue of a given pixel can only be set at one of 2^8 = 256 levels, between the minimum and maximum luminance level that a screen can display. However, humans are much more sensitive to small increases of light at low-luminance levels, than they are to similar increases of light at high-light levels. If the relationship between the colour value and the luminance was perfectly linear, then most of the bits used to encode the high-luminances would be essentially wasted, since viewers could not tell the difference between the different values, while there might be very obvious differences at the low-light levels.

It turns out that a CRT response is almost exactly the inverse of human lightness sensitivity, a property that can be neatly exploited in computer graphics. In the early days, it was recognized that if video data was recorded with a transfer function that compresses video signal to maximize human perception, then the CRT could be used to essentially ‘decompress’ the signal, without requiring any further transformation on the video signal. The general principle behind video compression is still used today. Sequence A, below, illustrates the associated process.

Luminance measurements that might be stored in an image or a video file are transformed such that the content of the file is optimized for human perception. The information encoded is no longer the same as the original recording. When the file is loaded and is ready to be processed by the computer’s graphic card, it is typically encoded in the form of an 8-bit RGB colour value. Normally, these 8-bit RGB values would be converted into a signal compatible for the video display, with no further modification to the colour signal. The monitor’s gamma would naturally decompress the video signal. The result is a measured luminance similar to the originally recorded signal.

As vision scientists, we typically generate entirely new images and wish to send them directly to the graphic card’s video buffer. However, as seen in Sequence B, below, bypassing an encoding transfer function means that the monitor’s gamma will de-linearize our stimuli, greatly altering our intended stimulus. 

Notice how, compared to Sequence A, programming a stimulus without compensating for the monitor response results in a non-linear relationship between input colour value and measured luminance.

For vision scientists, the simplest and most computationally efficient method of applying a gamma correction to our monitor, i.e., of compensating for the monitor’s non-linear response, is to instruct the graphics card to modify the relationship between the pixel input value and the signal that is actually sent to the monitor. To do so, it is possible to apply a custom gamma-correction colour lookup table (gamma-correction CLUT) that is the inverse of the monitor’s gamma.

A gamma-correction colour lookup table can be applied to the video signal out of the graphic card, compensating for the monitor’s gamma.

A colour lookup table (CLUT) is essentially a matrix that converts (or remaps) a pixel value input to a different output, according to your own preference. For an 8-bit RGB video signal, such as the signal typically sent to a VIEWPixx/3D or a VIEWPixx, the CLUT will always take the form of a 28 = 256 row by 3 column matrix, where the rows represent each of the possible colour values the signal can contain, and where the columns correspond to the red, green and blue components of the video signal. For example, in MATLAB and Psychtoolbox, it is expected that each of the cells contains a decimal number ranging from 0 to 1. When applied by the software, this value is converted to a format usable by the display device. On VPixx hardware, this decimal number is stored internally as a 16-bit int.

By default, for each of the 256 levels of an 8-bit video signal, the implicit luminance ramp contains linearly increasing values, uncompensated for any non-linearity in the monitor:






























Attention! In this tutorial, we assume that no other modification is made to the CLUT. This tutorial may not be compatible with some special VIEWPixx and PROPixx video modes and sequencers that also modify CLUTs.

The crux of the problem rests on the practical difficulty of obtaining the proper inverse gamma function and using it to generate the gamma-correction CLUT that should be applied for any given experiment. There are three methods to gamma correct a display:

  1. One approach is to simply use the gamma value provided by display manufacturers to generate the gamma-correction CLUT, typically 2.2. This can often be adjusted in the options of advanced graphic cards.

  2. Measure luminance on greyscale luminance patches, encompassing the minimum and maximum pixel values. Apply the resulting gamma equally to all colour channels.

  3. Measure luminance independently for the red, green and blue colour channel, encompassing the minimum and maximum pixel values. Apply the resulting gamma independently to all colour channels.

Practically, greyscale and colour-dependent gamma-correction CLUTs can be obtained with the same procedure:

  • Measure the luminance of your display at equally spaced pixel values, including the minimum and maximum displayed luminance of your screen. A non-linear curve would typically be obtained.

  • Fit a power function to the experimental data, plot the inverse function, and compute the gamma-correction CLUT values for each of the 256 potential RGB pixel values.

  • Apply the gamma-correction CLUT and measure the luminance of your display at equally spaced pixel values. The new measurements should now be linear.

Display non-linearity is not a new problem, and indeed, there are already several tools available online for vision scientists. Notably, for those who use MATLAB and Psychtoolbox, there exists a FitGamma function (and the associated FitGammaDemo.m) that can guide you through the greyscale gamma-correction process. However, a notable difficulty is that it depends on the Mathworks Optimization Toolbox, to which not all MATLAB users have access. The demo also uses ‘typical’ display data, and understandably, does not include the measurement procedure, as this depends on the hardware used.

With this guide, if you have purchased an X-Rite i1Pro spectrophotometer or X-Rite i1Display Pro colorimeter from VPixx Technologies, you will be able to:

  • Use MATLAB and Psychtoolbox to automate greyscale luminance measurements and plot the results.

  • Enter the data into a web app to obtain an estimate of gamma.

  • Generate and apply the associated greyscale gamma-correction CLUT in MATLAB.

  • Confirm that the new gamma-correction CLUT linearized the display luminance as expected.


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.