CubeLut Class

An immutable color lookup table read from a .cube file, for ImageProcessingExtensions.ApplyLut: the color grades and film looks that video and photo tools export.

public sealed class CubeLut

Remarks

The format is the one of the Adobe Cube LUT Specification 1.0. A file holds either a three-dimensional table (LUT_3D_SIZE n, from 2 to 256: n^3 output colors on a regular lattice of input colors) or a one-dimensional one (LUT_1D_SIZE n, from 2 to 65,536: n output values per channel), never both. Each data line holds three numbers, red, green and blue; the lines of a three-dimensional table run with red changing fastest, then green, then blue. DOMAIN_MIN and DOMAIN_MAX give the input range of each channel (0 to 1 by default); the LUT_1D_INPUT_RANGE and LUT_3D_INPUT_RANGE keywords of DaVinci Resolve give one range for the three channels. TITLE names the table. Lines that start with # are comments, blank lines are ignored, and every keyword comes before the data. Any other line is an error.

An input value is clamped to the domain of its channel, then located on the lattice: a one-dimensional table is interpolated linearly, a three-dimensional one as LutInterpolation says. The output values are used as they are written, without clamping: values outside [0, 1] reach floating-point images, and integer images clamp them to their sample range.

The table is held in single precision, outside the allocation limits of the images: a three-dimensional table of n points per axis takes 12 n^3 bytes (3.1 MiB for the common 65, 192 MiB for the largest, 256).

Properties

NameDescription
IsThreeDimensionalGets a value indicating whether the table is three-dimensional (LUT_3D_SIZE): each output color depends on the three input samples. A one-dimensional table maps each channel on its own.
SizeGets the number of points of the table along each axis: the value of LUT_3D_SIZE or LUT_1D_SIZE.
TitleGets the title of the table (the TITLE keyword), or null when the file has none.

IsThreeDimensional

CubeLut.cs

Gets a value indicating whether the table is three-dimensional (LUT_3D_SIZE): each output color depends on the three input samples. A one-dimensional table maps each channel on its own.

public bool IsThreeDimensional { get; }

Property value

bool

Gets the number of points of the table along each axis: the value of LUT_3D_SIZE or LUT_1D_SIZE.

public int Size { get; }

Property value

int

Gets the title of the table (the TITLE keyword), or null when the file has none.

public string? Title { get; }

Property value

string?

Methods

NameDescription
Load(Stream)Reads a table from a stream that holds a .cube file, from its current position to its end. The stream is not closed.
Load(string)Reads a table from a .cube file.
Parse(string)Reads a table from the text of a .cube file.

Load overloads

Load(Stream)

CubeLut.cs

Reads a table from a stream that holds a .cube file, from its current position to its end. The stream is not closed.

public static CubeLut Load(Stream stream)
Parameters
stream Stream
The stream.
Returns

CubeLut The table.

Exceptions
ArgumentNullException
stream is null.
FormatException
The stream does not hold a valid .cube file. The message gives the line.
IOException
The stream cannot be read.

Load(string)

CubeLut.cs

Reads a table from a .cube file.

public static CubeLut Load(string path)
Parameters
path string
The path of the file.
Returns

CubeLut The table.

Exceptions
ArgumentNullException
path is null.
FormatException
The file is not a valid .cube file. The message gives the line.
IOException
The file cannot be read.

Parse(string)

CubeLut.cs

Reads a table from the text of a .cube file.

public static CubeLut Parse(string text)

Parameters

text string
The text of the file.

Returns

CubeLut The table.

Exceptions

ArgumentNullException
text is null.
FormatException
The text is not a valid .cube file. The message gives the line.