images format
Color LUTs — Cube, 3dl and PNG
Read color mappings as numerical tables with explicit domains, precision and image layouts.
Color LUT feature card
Three encodings, one numerical table contract.
Choose the source format explicitly; retain domains, grid knots and precision before applying a color transform.
Cube
Single 1D or 3D text table with explicit domain bounds
3dl
Grid-first integer samples; caller supplies output bit depth
PNG
Opaque 8-bit samples with explicit blue-slice tile layout
Output
Float32 RGB with red input varying fastest
Precision
Float64 input knots and retained source encoding precision
Boundary
No interpolation, color-space conversion or GPU objects
A color lookup table maps input values to output RGB samples. The loaders below produce a common renderer-independent ColorLUT contract, while retaining each format's domain, grid, and precision information. Choose a source encoding first; interpolation and applying the table to an image remain application work.
:::note Availability
These loaders are introduced by PR #4411. Use a version containing that change.
:::
| Input | Loader | Required format options |
|---|---|---|
| Cube | CubeLUTLoader | None |
| Grid-first 3dl | ThreeDLLUTLoader | lut.outputBitDepth |
| PNG tiling | ImageLUTLoader | lut.size and lut.tilesPerRow |
Output contract
| Field | Meaning |
|---|---|
dimension, size | One or three input dimensions and samples per axis |
data | Interleaved Float32 RGB output samples |
domainMinimum, domainMaximum | Input bounds for each channel |
title | Optional authored title |
inputGrid | Optional normalized Float64 input knots for nonuniform grids |
sourceInputGrid | Optional original integer grid knots |
sourceOutputBitDepth | Source precision where explicitly known |
For a 3D table, red input varies fastest, followed by green, then blue. The RGB triple at integer grid coordinates (red, green, blue) starts at 3 * (red + size * (green + size * blue)). The table is data: interpolation, gamut conversion, transfer functions, tone mapping, and GPU upload belong to the application. Float32 storage can round authored decimal values.
Cube text tables
What is a .cube LUT?
A Cube file stores a sampled mapping from input color values to output RGB values. A 1D table defines channel curves; a 3D table samples an RGB input cube. Titles, table size, and optional domain bounds describe how to interpret the sample rows. A LUT is not itself a color-space declaration, a shader, or an image filter implementation.
Load a table
import {load} from '@loaders.gl/core';
import {CubeLUTLoader} from '@loaders.gl/images/color-lut';
const table = await load('grade.cube', CubeLUTLoader);
console.log(table.dimension, table.size, table.domainMinimum, table.domainMaximum);
Supported features and limits
The loader accepts a single 1D or 3D table with TITLE, DOMAIN_MIN, and DOMAIN_MAX. Defaults are an input domain of zero to one per channel. Output samples are preserved without clamping, so authored values can lie outside that interval. Comments and quoted titles are scanned without an ambiguous backtracking expression.
Combined shaper-plus-3D files, unknown vendor directives, inconsistent dimensions, incomplete tables, non-finite numbers, and invalid domains reject. There is no writer or automatic interpolation. Know which color encoding the producer expects before applying the table to an image.
Direct parsing and related formats
Import CubeLUTLoaderWithParser from @loaders.gl/images/color-lut for synchronous core parseSync. There are no Cube-specific options. The root loader is metadata-only and async core APIs preload its parser.
Compare grid-first 3dl for integer samples and nonuniform knots, or PNG image LUTs for explicit blue-slice tilings. All three produce the same ColorLUT sample ordering.
Grid-first 3dl tables
What is a .3dl LUT?
The supported 3dl layout starts with a row of integer input-grid knots followed by integer RGB output rows. Input knots can be nonuniform. Files sharing the .3dl extension can use other vendor headers and conventions, so the extension alone is not a complete interoperability contract.
The first row determines the cube edge size. The supported source rows vary blue fastest; the loader reorders them into the shared red-fastest ColorLUT layout. The input knots and output encoding have separate meanings. An input-grid maximum is not an output-bit-depth declaration.
Supply the output bit depth
import {load} from '@loaders.gl/core';
import {ThreeDLLUTLoader} from '@loaders.gl/images/color-lut';
const table = await load('grade.3dl', ThreeDLLUTLoader, {
lut: {outputBitDepth: 12}
});
console.log(table.sourceInputGrid, table.inputGrid, table.sourceOutputBitDepth);
Choose the bit depth from the producer's format contract. It is not guessed from the brightest sample. Output channels are normalized by 2 ** outputBitDepth - 1; original input knots remain in sourceInputGrid, and their normalized coordinates use Float64 storage in inputGrid.
Supported features and limits
Only grid-first integer files with a complete cubic set of RGB rows are supported. Input knots must be valid and ordered, and output samples must fit the explicit bit depth. Vendor mesh headers, implicit precision guessing, missing output rows, and malformed samples reject. The normalized input domain is zero to one; preserve and use inputGrid when interpolating a nonuniform table.
Loader options and direct parsing
| Option | Required | Meaning |
|---|---|---|
lut.outputBitDepth | ✅ | Integer output-channel encoding precision, 1 through 24; no inferred default |
Import ThreeDLLUTLoaderWithParser from @loaders.gl/images/color-lut for synchronous core parsing, passing the same options. The root export is metadata-only. No renderer object, interpolation implementation, or new codec dependency is added.
See Cube for text tables with domain directives and image LUTs for PNG tilings.
PNG image layouts
What is an image LUT?
An image LUT lays out slices of a 3D color cube in a 2D image. Red changes within each tile horizontally, green vertically, and each tile represents a blue slice. A horizontal strip, vertical strip, and rectangular tiling can contain the same mapping with different image dimensions.
A PNG does not identify which layout its producer used or whether it is a LUT at all. Select ImageLUTLoader explicitly and supply the layout rather than relying on generic PNG detection.
Load an explicitly tiled PNG
import {load} from '@loaders.gl/core';
import {ImageLUTLoader} from '@loaders.gl/images/color-lut';
// A 16-edge cube with 16 blue slices in one horizontal row: 256 × 16 pixels.
const table = await load('grade.png', ImageLUTLoader, {
lut: {size: 16, tilesPerRow: 16}
});
The required dimensions are width = size * tilesPerRow and height = size * (size / tilesPerRow). The tile count must divide size exactly, with 1 ≤ tilesPerRow ≤ size and 2 ≤ size ≤ 256. Blue slices advance left to right and then to the next tile row. Pixel row zero is the source's top row; there is no application orientation flip.
Image outputs have dimension 3, a zero-to-one input domain, and sourceOutputBitDepth 8. Each channel is divided by 255. The image is a data container; the loader does not interpret its samples as a photographic image that needs a display transform.
Precision, metadata and runtime
Only opaque 8-bit samples are supported. Dimensions, cube edge size (at most 256), PNG signature and bit depth are checked before bitmap decoding. The encoded path permits only IHDR, PLTE, IDAT, IEND, tRNS, and sRGB chunks. Other metadata, including ICC profiles, gamma/chromaticity, significant-bit hints, and EXIF orientation, rejects before generic image APIs can rewrite the samples. Transparency rejects after decode.
The parser requests no bitmap color conversion or premultiplication and closes its temporary bitmap. Browser image facilities are required in the browser. Node uses the existing images bitmap/polyfill backend and its optional Sharp peer; this feature adds no dependency, but encoded PNG decoding is not a standalone Node PNG codec. See Node image codecs.
High-bit-depth, nonopaque, metadata-bearing, or differently arranged images need a separate data-preserving decoder and the raw-pixel utility below. JPEG is unsuitable for exact LUT samples because it is lossy and is not accepted by this loader.
Convert already decoded pixels
import {parseImageLUT} from '@loaders.gl/images/color-lut';
const table = parseImageLUT(opaqueRgbOrRgbaBytes, width, height, {
size: 16,
tilesPerRow: 16
});
The utility accepts Uint8Array or Uint8ClampedArray RGB/RGBA samples and validates layout and opacity. The caller is responsible for keeping encoded sample values intact during decoding; decoding with a color profile or alpha premultiplication and then passing those pixels cannot recover the original values.
Loader API
Both lut.size and lut.tilesPerRow are required. The metadata export lives at the images root; ImageLUTLoaderWithParser lives at @loaders.gl/images/color-lut. Encoded parsing is async, not parseSync. The raw-pixel utility is synchronous.
Compare Cube and 3dl when a text LUT carries the mapping more directly.