Full search page →

DLCV 09C · How big must a 3D LUT be?

AdvancedDLCV 09C · Low-Light Image EnhancementImage lab

Description

Bake one smooth color enhancement into an M × M × M table and apply it with a nearest-node lookup or with trilinear interpolation. Compare both with the exact transform.

Try this: At the default (M = 9, the smooth gradient) the nearest lookup shows clear bands and the trilinear result looks like the exact one. Switch the error map to trilinear: where is the error largest, and why there? Then raise M to 33 for the nearest lookup: are the bands gone? Finally set M = 3 and compare the two interpolations.

Predict first

A nearest-node table with M = 33 has about 49 times as many entries as a trilinear table with M = 9 (35,937 against 729 nodes). Which one reproduces the exact transform more closely on the smooth gradient?

Hints

The chapter section that uses this lab:

Explanation

Answer the prediction first, or open the explanation when you are ready.

Show the explanation

A nearest lookup replaces every color by the stored color of one node, so the output is a staircase: even with M = 33 the steps are several levels tall, and they show up as bands on a smooth gradient. Trilinear interpolation turns the staircase into a continuous, piecewise-linear surface that follows a smooth transform closely even with 9 nodes. On the gradient the nearest table with M = 33 has a mean error of 2.46 levels and a maximum of 7; the trilinear table with M = 9 has a mean error of 0.32 levels and a maximum of 4.

Lab · DLCV 09C · How big must a 3D LUT be?

Predict first

A nearest-node table with M = 33 has about 49 times as many entries as a trilinear table with M = 9 (35,937 against 729 nodes). Which one reproduces the exact transform more closely on the smooth gradient?

Loading image…

Exact transform (the target)
LUT, nearest node
LUT, trilinear
Error map of the chosen lookup (8×, bright: wrong)

Try this: At the default (M = 9, the smooth gradient) the nearest lookup shows clear bands and the trilinear result looks like the exact one. Switch the error map to trilinear: where is the error largest, and why there? Then raise M to 33 for the nearest lookup: are the bands gone? Finally set M = 3 and compare the two interpolations.

The true enhancement is defined in code (src/lib/playground/labs/lut-trilinear.ts) and is the lab’s own toy: on each channel t, a tone curve g = t^0.9 followed by the S-curve (1 − a) g + a (3g² − 2g³) with a = 0.5; then a saturation gain of 1.15 that scales each color’s distance from its luma gray (luma 0.299 R + 0.587 G + 0.114 B); then a hue turn of 8° (a rotation of the RGB cube about its gray axis); then clipping to [0, 1]. The table has one entry per node of an M × M × M lattice over the RGB cube: node (i, j, k) stores the exact transform of the color (i/(M−1), j/(M−1), k/(M−1)), so it holds 3M³ numbers. A nearest lookup returns the stored color of the closest node. Trilinear interpolation blends the 8 corners of the cell around the color with weights that are products of the offsets, as in the chapter. Both results and the exact transform are rounded to 8-bit levels (0 to 255) before the errors are measured, and the error map is magnified 8 times. The photo is the astronaut test image reduced to 256 × 256; the gradient is a smooth blend of four corner colors computed in the lab, so it has no texture to hide banding.

Method and image sources

Open in the Playground →