I would like to learn more about the technical details of LUTs. Not necessarily how they currently work in software like Darktable, but how they could work to speed up editing. Specifically:
The mechanics of interpolation
I understand that a 3D LUT is an interpolation table, but that alone does not specify
the space the interpolation happens in (RGB, or some other color space),
the kind of interpolation (some interpolations, eg generalized linear, would demand a regular grid, radial bases would work with anything),
what happens to values outside the mesh/grid?
I found the .cube file format specs. It says that it is “RGB”, but does not say which RGB. The interpolation is tetrahedral, and the grid is regular.
Workflow and composition
It is unclear to me when to apply LUTs and how they compose. Naively I would think that
one would apply a LUT to get demosaiced raw data into some standard color space, scene-referred,
do various corrections (exposure, white balance, textures, maybe even color),
apply another LUT to map into a display-referred color space, for asthetic and practical purposes.
Some answers may vary between software systems. I know ImageMagick best.
In IM, a 3d clut is called a “Hald clut”, named after a developer’s grandmother. It is for images with 3 color channels, which could be RGB or HCL or JzAzBz or anything. The colorspace of the image and the HaldClut should be the same.
The HaldClut is a square image but represents a cube of colours. The three dimensions of the cube correspond to the colour channels.
Internally, it works by using the input colours of an image pixel as coordinates to fetch a color from the HaldClut. That colour is used for the output colour.
If the input color doesn’t map exactly to a HaldClut pixel, IM will interpolate, using the current “-interpolate” setting (eg linear, nearest, spline, etc).
In IM, colour channels have a nominal range of zero to QuantumRange. Informally, “black” to “white”. Values can be outside this range, and the process still works. If an input colour is outside this range, the coordinates will be to a point outside the Hald cube, so the interpolation is called “extrapolation”.
A HaldClut can be used for any colour transformation where an input colour maps to a single output colour, irrespective of the position of the input pixel or the colour of surrounding pixels. For example, suppose you need to correct colour balance, contrast etc of a thousand video frames. You can do this by appending an identity Hald clut to a single frame. Then manually edit that image with any software you want (eg darktable, Photoshop, Gimp, whatever). Then extract the modified Hald Clut. Then apply that clut to each of the thousand video frames.