Questions can be sent to: [email protected]


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.


Automate luminance measurements and plot the results

First, because operating temperature influences the luminance of a display, ensure that the display you want to linearize has reached a stable operating temperature. This information can typically be found in the user manual of your display. For example, VPixx Technologies strongly recommends that a VIEWPixx display should be operated at an ambient room temperature between 20°C and 28°C. The optimal display uniformity is obtained after a warm-up period of around 20 minutes. Ideally, the screen will be warmed up while displaying a full-white screen, as this will drive the highest amount of current through the electronic components. This should be taken into consideration before taking photometric measurements and before running experiments. After warm-up, the measurements made on a given luminance patch should remain stable over time.

When you are ready, download the tutorial materials and open the i1D_SampleLuminance.m MATLAB script. Install your calibration device according to the instructions in its user manual, and connect it  to a USB port with sufficient power supply.  

In this script, luminance measurements will be made on a series of monotonically increasing greyscale luminance patches which will be visible for a few seconds at a time.

There are three variables that you may want to modify: 


%% User set variables are: 
ModeMeasure = 'sample'; %'linearize'
nPatches = 32; % 32 luminance patches will be measured
preparationTime = 5; % 5 seconds

When you first execute i1_SampleLuminance.m in MATLAB, ModeMeasure should be set to ‘sample’. This will ensure that all luminance measurements are made on an uncorrected visual display. 

By default, the script will execute with nPatches = 32. You can modify this value as desired, as long as you keep a large enough number of patches to adequately estimate the power function coefficient. 

The number of luminance measurements will influence the estimated gamma value. To illustrate this,128 luminance measurements were taken at equally spaced pixel values. Gamma was also estimated with subsambles of the original signals, with 64, 32, 16 and 8 samples. Estimated gamma of subsampled signals appear sensibly similar to the original measurements, except for an obvious underestimation when only 8 samples are used.

When you first execute the script, you will have 5 seconds to confirm that the measurement device is setup on the screen and that the lights of the room are turned off. You can shorten or lengthen this duration by editing preparationTime.

When the script is concluded a figure will be produced and will show you the sampled luminance (in candelas per square meter) as a function of the linearily-spaced programmed pixel values. It should be obvious that the luminance data is highly non-linear. A file with intermediary results will be saved under the name ‘mySampledLuminance.mat’, containing  normalizedLum, the zero-corrected and normalized luminance data, as well as PatchesPixels, the original pixel values used to produce each luminance patch.

Raw luminance measurements from a commercial LCD panel. Luminance patches were recorded from an uncorrected monitor at 32 linearily-spaced pixel values. These luminances are then normalized to vary between 0-1, and are stored in mySampledLuminance.mat.

Estimate gamma

Navigate to and upload ‘mySampledLuminance.mat’ to the web application using the ‘Browse’ button situated on the left panel. Write down the gamma value displayed underneath the title, and return to MATLAB.

Step-by-step instructions on how to use the web app to estimate gamma

Generate a gamma-correction CLUT

Open MATLAB again, and this time, load GenerateInverseCLUTFromGamma.m. There is only one user set variable, gamma, where you should replace the stand-in value with the estimated gamma coefficient obtained in the previous step.

When you execute the script, it will load all relevant results from mySampledLuminance.mat and use the estimated gamma to return a pre-formatted gamma-correction CLUT. The result will be automatically presented in a new figure. This gamma-correction CLUT will be saved in inverseCLUT.mat.

You can now close GenerateInverseCLUTFromGamma.m and reopen i1_SampleLuminance.m.

Using the estimated gamma, we generate the inverse gamma function that will be used to linearize the luminance of the display.


Apply the gamma-correction CLUT and inspect the results

To apply the inverse CLUT, reopen i1_SampleLuminance.m, but this time, change ModeMeasure to ‘linearize’. This will ensure that all relevant results from previous steps are loaded. This will also ensure that the gamma-correction CLUT is applied to the stimulus window before taking any luminance measurements.


%% User set variables are: 
ModeMeasure = 'linearize'; %'linearize'
nPatches = 32; % 32 luminance patches will be measured
preparationTime = 5; % 5 seconds

Execute the script. A new figure will appear, and it should now be obvious that the raw luminance of your display was linearized during the measurements. 

You can use MATLAB’s built-in linear curve-fitting tools (tools –>  basic fitting -> plot fit linear) to look at your results, and examine the linear fit and the magnitude of the residuals. Ensure that any remaining non-linearity is acceptable for your research.

After executing i1_SampleLuminance.m with ModeMeasure = ‘linearize’, examine the results of the linearization with MATLAB’s built-in linear fit tools.

Note that after the measurements were acquired on the linearized display, i1_SampleLuminance.m removes the gamma-correction CLUT. If the gamma-correction CLUT was still active after the measurements were taken, your desktop environment would appear as if the colours had been slightly washed-out.

Using the gamma-correction CLUT in your experiments

If you wish to apply the gamma correction CLUT in your experiments, you can simply add a copy of inverseGamma.mat to your local folder, and execute these lines of code:


%% Insert these lines after opening your stimulus window
load inverseCLUT; %Load the results of GenerateInverseClutFromGamma.m
originalCLUT = Screen('LoadNormalizedGammaTable',window,inverseCLUT);
%% Insert this line before closing your stimulus window
Screen('LoadNormalizedGammaTable',window,repmat(linspace(0,1, 256)',1,3));

Cite this guide

Kenny, S. (2020, May 15). Gamma-correct the luminance of a display. Retrieved [Month, Day, Year], from