Gamma Table Measurement

Whithin the PXL library high resolution colors are defined by their CIE chromaticity coordinates and are stored in variables of type xyLcolor which actually are triples of floating point numbers. The control software converts these to RGB-coordinates and stores them in structures of type RGBcolor. These are floating point values that give the luminance of the respective color channel of the current color display device. R, G, and B actually correspond to the color device primaries whose coordinates are defined by the parameters redprimaryx, redprimaryy, ..., blueprimaryy.


Insert Table rgbtrans here.

The video color device control software converts RGB-coordinates to color palette entries of type PaletteColor. These are directly related to device coordinates. A PaletteColor is a structure of three device coordinates of type PaletteElement. Each PaletteElement is directly written to the color device to create a certain output luminance in the respective color channel. This last transformation is device dependent and needs to know how any of the color channels has to be controlled in order to generate a certain luminance. This information is contained in gamma tables.

Specifying colors by their coordinates is one thing, the second is to exactly convert theoretical coordinates to physical stimuli. This can only be done right if the device output luminance is measured precisely. The application rgb may be used to do this. It requires a photometer or any other light sensitive device whose readings can be converted to luminance. rgb is simple: It outputs a value of type PaletteElement on a color patch on the output device and records the meter reading. The computational part of rgb then converts the readings to luminance values. This may include automatic range correction or any other transformations. The current version is written to work with different photometric devices:

rgb may easily be extended to add reading luminance values from different sensor devices. This, however, requires recompilation.

Program Features

A gamma table file as it is used by PXL contains three gamma tables: one for red, green, and blue. Each table contains up to 256 luminance values of type Luminance. Each value gives the output luminance of the video tube for the respective control voltage of type PaletteElement. The gamma table for red covers the first entries in the gamma table file. Then follow the two color channels green, and blue. Luminance values are 32-bit integers. Each table contains exactly as many entries as there are possible look up table output values. These are 64 for a VGA type adaptor which has three 6 bit DACs. Higher color resolution versions of PXL like the one for TIGA or SuperVGA, contain 256 entries, since they use 8 bit DACs. The files are binary memory images and thus a single table occupies up to 1024 bytes. There also is some header information in each table.

In adition to the three gamma tables each gamma table file contains a header. This header contains information about the device where the table comes from and the size of the table. Here is the definition of the gamma table file header:

typedef struct GammaTableFileHeader {
        int             TableSize;
        double          Scale;
        Primaries       primary;
        int             NrofTables;     /* currently not used */
        int             checksum;
} GammaTableFileHeader;
The field TableSize contains the number of entries in each table it is either 64 or 256, depending on the DAC resolution. Luminance values in the tables are stored as 32 bit integer values. To convert an integer table entry to actual luminance each value has to be divided by the scaling factor Scale. The structure primary gives the chromaticity coordinates of the device primaries where the table has been measured. The definition of the type Primaries is
typedef struct Primaries {
        xyLcolor        R, G, B;
} Primaries;

typedef struct xyLcolor {
        double x, y, L;
} xyLcolor;
The checksum field is used internally by PXL to check the integrity of gamma table files. Here is how the check sum is computed:
      WORD
   GTFHcheck(h)
      GammaTableFileHeader *h;
   {
      BYTE  *p;
      int   i;
      WORD  ck;
   
      p = (BYTE *)h;
      ck = (WORD)0;
      for (i = 0; i < (sizeof(GammaTableFileHeader) - 2); i++)
         ck += (WORD)(*(p++));
      return ck;
   }
After the gamma table file header there follow three tables. Each one has TableSize entries of type DevLum which are equal to 32 bit integers. Within each table the entry with index i gives Scale times the luminance that results if the value i is written to the respective channel's look up table entry.

Program Parameters

calibrate (int)
If this variable is ON then rgb waits before starting the measurement cycle until a key is pressed. During the wait a test spot with a crosshair is displayed. This may be used to adjust the position of the photometer to the correct position.

channel (int)
Color channel: 1 = Red, 2 = Green, 4 = Blue, 7 = White.

chisquare (float)
Final deviation value of the estimated gamma function from actually measured values.

colx , coly (float)
x- ynd y-chromaticity values measured by color measurement devices.

dacvalue (int)
This is the integer value actually put into the output palette entry. It controlls the video board's output DAC.

devlumscale (float)
Factor used to convert the floating point luminance values to integer values of type DevLum as they are contained in a gamma table file. The default for devlumscale is 10000.

dspfactor (int)
Number of times that each meter reading is repeated. The actual value read is the average of the repeated readings.

flags (string)
These flags are used:

C
Print minimum during estimation.

E
Compute gamma function parameter estimates. Note that gammatype should be set properly in this case.

F
Suppress fixation cross during calibration.

G
Replace data by computed values according to estimated parameters.

L
If this flag is set then a gamma table is created. If it is not set then no results are computed. Data output files of rgb may always be converted to gamma tables by simply setting flag L and then run rgb with the data file as a parameter file and setting the flag -c to run only the computational phase of rgb.

N
Do not print estimated parameters when finished.

P
Print parameters during the estimation process.

S
Omit automatic range switch detection. This flag should be set if the sensor device does not do automatic range switching.

W
Simulates a RGB-gamma table for white colors only. If this flag is set, then the color used should be white (channel = 7), since the gamma table computed is for white colors only. The three color channels of such a table are computed by using redfactor, greenfactor, and bluefactor as the respective weights for the three channels.

gammapars (int)
Array of initial gamma function parameters for the estimation procedure.

gammatype (int)
Type of gamma function to be used for estimation. Use type 6 to get the Berns et al. (1993) function.

half (int)
Forces rgb to use a half disk instead of a whole disk. If half is 0 then a whole circular disk is used as a display. If half is positive, then only the upper half is displayed, if it is negative only the lower half is shown.

luminance (float)
Luminance value read.

colorsensor (int)
Measurement device code. Currently known devices are:

NOSENSOR (0)
No sensor available.

LMT (1)\_1000 (1)\_PITI (1)
The LMT 1000 via a custom ADC and parallel input board developed at Regensburg University.

MIRO (2)\_SENS (2)
The miro color sensor.

LUMACOLOR (11)\_xyL (11)\_COM1 (11)
The Tektronix Lumacolor II in xyL-mode via COM 1 port.

LUMACOLOR (12)\_xyL (12)\_COM2 (12)
The Tektronix Lumacolor II in xyL-mode via COM 2 port.

LUMACOLOR (13)\_XYZ (13)\_COM1 (13)
The Tektronix Lumacolor II in XYZ-mode via COM 1 port.

LUMACOLOR (14)\_XYZ (14)\_COM2 (14)
The Tektronix Lumacolor II in XYZ-mode via COM 2 port.

If 100 is added to the above constants then a transformation is applied to the measurements in order to correct deficiencies of the various devices.

radius (int)
Radius of the test spot.

redfactor , greenfactor , bluefactor (float)
If a gamma table for white signals only has to be created, then measurements should be made with white stimuli. In this case rgb is able to break down the luminance of the white stimulus into the relative contributions of the three color channels. redfactor, greenfactor, and bluefactor are the relative weights used to distribute the luminance to the three color channels. The weights have to add up to 1.0. The standard EBU phosphor weights are 0.22, 0.71, and 0.07.

scale (float)
The initial scale factor for converting the meter readings to luminance values.

xpos , ypos (int)
Position of the test spot on the screen.

Example Experiments

Gamma Table Measurement

Here is an example parameter file which has been used to create the gamma tables for various monitors.


Parameter file rgb.x from directory \pxl\app\rgb

This file starts out with some parameter defines for the output value step size, the color channels and the test spot position. The assignments define the test spot display duration to 1000 ms, the wait between blocks to 10 s and the test spot radius to 5 cm. We create a binary gamma table and start out with a scaling parameter of 1.0. calibrate, the test spot position and the color channel are block variables, the DAC output voltage, the luminance value and color coordinates are display variables. The first block measures the RED channel, then follow the GREEN and the BLUE channel. The 4th block is a white measurement which may be used to control tube additivity. There is only a single display in each block but this is expanded during run time to use all output voltage values between 0 and STEPMAX by increments of STEPSIZE. The first block sets calibrate to ON, since at the start we have to check the position of the photometer relative to the position of the test spot on the screen.

Converting an ASCII Data File to a Gamma Table File

Suppose you have an ASCII data file and want to convert it into a gamma table file. In this case the ASCII data file must have PXL's data file format. This is an example of such a file:
   var
      flags = "L"
      devlumscale = 10000.0
      redprimaryx = 0.6310
      redprimaryy = 0.3260
      greenprimaryx = 0.2610
      greenprimaryy = 0.630
      blueprimaryx = 0.1630
      blueprimaryy = 0.0670
   arg
      block( calibrate, xpos, ypos, channel )
      trial( dacvalue, luminance )
   stimuli
   B( 1, 0, 0, 1 ) 
   {
      T( 0, 0.0040 )
      T( 1, 0.0080 )
      T( 2, 0.0160 )
      T( 3, 0.0310 )
      T( 4, 0.0540 )
      T( 5, 0.0850 )
      T( 6, 0.1260 )
      T( 7, 0.1780 )
      T( 8, 0.2460 )
      T( 9, 0.3230 )
      T( 10, 0.4110 )
      T( 11, 0.5110 )
      T( 12, 0.6370 )
      T( 13, 0.7660 )
      T( 14, 0.9080 )
      T( 15, 1.0690 )
      T( 16, 1.2530 )
      T( 17, 1.4410 )
      T( 18, 1.6450 )
      T( 19, 1.8630 )
      T( 20, 0.2120 )   /* automatic volmeter range switch */
      T( 21, 0.2370 )
      T( 22, 0.2630 )
      T( 23, 0.2920 )
      T( 24, 0.3240 )
      T( 25, 0.3550 )
      T( 26, 0.3880 )
      T( 27, 0.4220 )
      T( 28, 0.4620 )
      T( 29, 0.50 )
      T( 30, 0.540 )
      T( 31, 0.5810 )
      T( 32, 0.6280 )
      T( 33, 0.6740 )
      T( 34, 0.7210 )
      T( 35, 0.770 )
      T( 36, 0.8260 )
      T( 37, 0.8790 )
      T( 38, 0.9330 )
      T( 39, 0.9910 )
      T( 40, 1.0540 )
      T( 41, 1.1150 )
      T( 42, 1.1770 )
      T( 43, 1.2430 )
      T( 44, 1.3150 )
      T( 45, 1.3850 )
      T( 46, 1.4550 )
      T( 47, 1.530 )
      T( 48, 1.6130 )
      T( 49, 1.6920 )
      T( 50, 1.7720 )
      T( 51, 1.8540 )
      T( 52, 1.9470 )
      T( 53, 0.2040 )   /* automatic volmeter range switch */
      T( 54, 0.2120 )
      T( 55, 0.2210 )
      T( 56, 0.2320 )
      T( 57, 0.2420 )
      T( 58, 0.2510 )
      T( 59, 0.2610 )
      T( 60, 0.2730 )
      T( 61, 0.2830 )
      T( 62, 0.2940 )
      T( 63, 0.3040 )
   }
   
   B( 0, 0, 0, 2 )
   {
      T( 0, 0.0040 )
      T( 1, 0.0040 )
      ...
      ...
      ...
      T( 62, 0.8480 )
      T( 63, 0.8770 )
   }
   
   B( 0, 0, 0, 4 )
   {
      T( 0, 0.0030 )
      T( 1, 0.0040 )
      ...
      ...
      ...
      T( 62, 1.1530 )
      T( 63, 1.1940 )
   }
   end
Each data line contains the look up table output value and the luminance measured. Look up table values range from 0 to 63 here. Note that there are decreasing steps in the red channel data at the transition from 19 to 20 and from 52 to 53. These are due to automatic range switching by the photometer. rgb will notice such a switch and correct for it by increasing its scaling value scale by the factor 10. In the parameter assignment section the flag L is set such that a gamma table may be computed. The assignment section also contains the chromaticities of the device primaries. The maximum luminance values are computed from the data.

To convert this file into a gamma table you simply call rgb and give it the data file as its parameter file. This is the command line, assuming that the data file's name is vga.dat and the gamma table file's name should be vga.gtb.

     rgb -f vga.dat -c -m -p vga.gtb 
To use the resulting gamma table file it has to be copied into PXL's table directory. Usually this is pxl\etc . Then in order to use the gamma table one has to set the parameter gammatable to the name of the gamma table file. This does the following line in a program's parameter file:
     gammatable = "vga.gtb"
Chapter colors contains some more hints how to use gamma table files in a high resolution color application.


Back to table of contents


Author: Hans Irtel

irtel@psychologie.uni-mannheim.de