Intro to Lookup Tables

A quick intro to lookup tables in imaging, how they are used and what to look our for…

hdcolin

The LUT is a way to store the result of a colour space transformation or creative look in a way that does not require the system applying the LUT to calculate the transformation each time.

This is achieved through the use of a lookup table, hence the name. The general process for applying a LUT to a pixel is as follows:

  1. Source normalised RGB pixel values (0.25, 0.125, 0.5)
  2. The RGB values are treated as XYZ co-ordinates within the 3D cube.
  3. The lookup function finds the corresponding point in the cube and returns the new RGB value

The lookup process is far quicker and efficient than a computer having to manually perform each colour space transformation on every single pixel per frame of video.

LUT formats #

1D and 3D and their differences

The LUT in essence is a file that contains some header information and three columns of numbers that represent R, G and B colour channels. In most cases the colour values are normalised between a range of 0 and 1.

There are two distinct types of lookup table, The first is a 1D LUT. When applying this type of table, the scope of the transform is limited. A 1D LUT can only apply it’s transform on a per-channel basis, targeting each, R, G and B channel individually.

Secondly, We have a 3D LUT, this is more common for storing and applying colour space transforms, I.E converting a camera log format to a display format or applying a creative grade. The 3D LUT differs from the 1D LUT in the sense that it can manipulate each channel simultaneously, giving it the capability to represent complex colour space transformations such as cross-channel effects and hue rotations.

A common format for the LUT is the .cube This is a text based format that contains some header info about the LUT and three columns of numbers representing R, G and B channel output.

Other formats of LUT do exist, though they are all variations on the same process. Text based files can become quite large, some cameras will convert this format into a binary representation that can be applied and stored much more efficiently with limited hardware capability.

LUT Sizes and Accuracy #

A key piece of information that comes with both 1D and 3D LUT’s is it’s size. The size represents the number of samples within the lattice.

The most common 3D LUT sizes are 17x, 33x and 65x. This gives you an indication of the number of samples, and size (of file) the LUT will be. A 17x LUT will contain 17^3 RGB triplets, which is 4913 lines on file in a .cube format. Where as, a 65x LUT will contain 274,625 lines which is substantially bigger.

1D LUTs tend to be much smaller in size, as the transforms they describe are much simpler. They usually are transferred and used around a size of 4096 entries, A 1D LUT with 4096 entries contains 4096 values per channel which can be seen in the .cube file of a 1D LUT.

The size of the LUT is used to gauge its accuracy. The LUT does not contain every single RGB value that might need to be looked up, as the LUT file itself would become huge and it’s application inefficient. Instead it relies on interpolation to fill in the gaps between samples. The smaller the size of the LUT, the larger the gaps between samples. Fewer samples means the interpolation process has to work harder, increasing the margin of error. These errors can be seen in the image and usually show up as banding, blockiness and artefacts.

Things to Watch Out For #

There are a few things noted below that are worth watching out for when working with LUTs.

Smaller sized LUTs struggle with aggressive transforms. If applying a transform that is aggressive with a small LUT there will be more risk of interpolation errors as noted above. Where possible, always use sizes of at least 33x on hardware that can support it.

Cameras and monitors have limited hardware capability and often only accept a 17x LUT. To avoid image degradation at this size, smooth transitions in the LUT are preferred. Some cameras have their own binary LUT format that enables limited hardware to apply small LUTs more efficiently, For example, Sony Venice and Arri Alexa.

Exposing through a LUT that pushes or pulls the exposure of the image for creative effect. This can be risky as directors of photography will often light off the lutted image. If the lutted image is significantly brighter or darker than the underlying log image then there is a risk of over or under exposure of the original camera media.

Passing in the wrong source format to the LUT. LUTs describe the result of a colour space transform from source A to destination B. If the wrong input source is passed through the LUT, an incorrect output will be generated. For example, passing Arri LogC4 through a Sony Slog3 to Rec709 LUT will give incorrect results.