Concept

Transfer function — where it appears

The curve between a code value and a luminance, which is where a number stops being a ratio and starts being an amount of light. Encoding and decoding are separate curves and their mismatch is deliberate, since a display in a dim room is expected to add contrast.

Named by 19 essays across 5 fields — each of them below, with the objects they name alongside it.

A gamma probe: which grey matches a half-white dither?. The striped block on the left is half white and half black, so it carries half the luminance of white. Stand back until the stripes blur and find the patch that matches it. On an sRGB display the answer is code 188, not 128 — code 128 has only 22 per cent of white's luminance.

The display is an unknown

This site is displayed on the very apparatus it is about, and it knows almost nothing about that apparatus. Two figures here stop assuming and ask instead — a probe for the transfer function and a probe for the gamut.

limits · Limits
The sRGB transfer function, and the gamma 2.2 curve it is not. Code value against relative luminance. The sRGB function is piecewise — a short linear segment near black, then a 2.4 power law with an offset — and it is close to but not the same as a plain 2.2 power law. Half-way along the axis of stored values sits at 21 per cent luminance, and half the luminance of white is at code 188.

The midpoint is not half

Code 128 sits halfway along the sRGB scale and carries about a fifth of white's luminance. Half the luminance is code 188. Almost every gradient, blur and resize on the web gets this wrong, and the errors are visible once known.

difference · Metric
The sRGB transfer function, and the gamma 2.2 curve it is not. Code value against relative luminance. The sRGB function is piecewise — a short linear segment near black, then a 2.4 power law with an offset — and it is close to but not the same as a plain 2.2 power law. Half-way along the axis of stored values sits at 21 per cent luminance, and half the luminance of white is at code 188.

A hex code is not a colour

Six hexadecimal digits identify three numbers. Turning three numbers into a colour needs a colour space, a transfer function, a white point and a display, and leaving any of them unstated is the everyday version of every confusion in colour management.

matching · Gamut
Three ways to spend a thousand code values. Normalised code value against luminance, for PQ, HLG and a conventional gamma curve, all covering 0.001 to 10000 cd/m². PQ spends 51% of its range below 100 cd/m² — roughly where a picture lives — and the gamma curve spends 15%, leaving the rest for highlights. A PQ code is the only one of the three that names a luminance rather than a fraction of whatever the display can manage.

How bright is white

An sRGB value says a pixel is some fraction of whatever the display can manage. A PQ value says it is two hundred candelas. The change is the largest in display encoding since gamma, and what it removed was the honest admission that nobody knew.

limits · Limits
sRGB, Display P3 and Rec. 2020 compared on the chromaticity diagram. Three nested triangles inside the horseshoe. sRGB covers 74 per cent of the area P3 covers. Rec. 2020's red and green primaries sit on the spectral locus itself, within 0.000 and 0.006 of it, meaning they are monochromatic.

Six numbers make a space

An RGB colour space is eight numbers — three primary chromaticities, a white point, and a transfer function — and everything else about it is derived. Deriving it rather than copying the matrix is the difference between having a colour space and having a table somebody else computed.

matching · Gamut
Everything between the photons and the picture, and what each stage decides. The 8 stages of a camera pipeline. Only the second is physics; every one after it is a decision somebody made, and the reason two cameras pointed at the same scene disagree is that they made different ones.

Raw is not a picture

A raw file is three integrals per site and a list of decisions nobody has taken yet. Every one of those decisions has a defensible answer and none of them has a correct one, which is why two converters open the same file and disagree.

imaging · Capture
One pair of colours, blended in four spaces. Every row starts and ends at the same two colours and visits different ones in between. The chroma of the middle falls furthest in linear light, by 83 units below the straight line between the endpoints' chromas — the grey dead zone that every blue-to-yellow gradient has and that no endpoint mentions. Any colour a route visits that this display cannot show is hatched rather than clipped.

A gradient is a path

Two colours fix the ends of a blend and nothing else. The middle is decided by the space the interpolation happens in, and four spaces in daily use put the halfway point of one ordinary gradient as much as thirty-seven units of colour difference apart.

matching · Gamut
A 8-bit ramp from 0.0008 to 0.006 of white, 12° wide. The top strip is the ramp as delivered: 16 distinct levels, each a step of one code value. Below it is the quantisation error as a Weber contrast against the local luminance, filtered by the luminance sensitivity function. The largest response is 8.51 per cent contrast against a threshold of 0.3, which is 28.4 times over — and it occurs at 0.09 per cent of white, at the dark end, because a code step is a Weber contrast and the same step is a larger fraction of less light.

Banding is not a bit depth

Eight bits bands at thirty times threshold in the shadows and at under three at mid grey, on the same ramp with the same encoding. What decides is where in the tone scale the gradient sits, how sharp each step's edge is, and how far away the reader is — and a bit count contains none of the three.

limits · Limits
What a dither mask is worth, read as components, in two dimensions. Five luminance ramps, each quantised to 8 bits with and without a high-passed mask of the same power. The bars are the most visible single sinusoidal component of the error, as a multiple of the contrast that component needs to be seen: above the line at one it is visible. The mask lowers it by 20–22×, on every ramp — which the one-dimensional model on this site says it does not, and that disagreement is the finding.

Every threshold was measured with a grating

An earlier essay here claimed that the model cannot explain why dither works, and named two missing pieces. One of them was real and worth thirteen times the guess; the other was not needed. The piece nobody named was the detector — and reading the same model two ways changes the answer by a factor of fifty.

limits · Limits
What a code lattice costs, and where. Twelve thousand colours quantised to 8 bits per channel through the sRGB transfer function and read back, with lightness across the bottom and the colour difference the rounding cost up the side. The mean is 0.191 and the worst case is 1.15, a factor of 6.0. The bars are band means, and they rise: the encoding spends its codes in the shadows, so the top of the ramp is where the lattice is coarsest against a metric that does not compress as hard.

A lattice has no derivative

Every departure priced here was priced by perturbing something and reading the answer, which requires the thing being perturbed to have a derivative. A file written on a code lattice does not have one — its output is flat almost everywhere and jumps on a set of measure zero — so quantisation can be bounded and never propagated. The bound is 1.15 colour differences at eight bits per channel against a mean of 0.19, and it is worst where the encoding spends fewest codes.

matching · Gamut
Three exchanges, two of which move the colour. The documented pipeline is a white balance, a colour matrix, a tone curve and a clip. Each bar is what happens when two neighbours change places, over 30 surfaces the modelled sensor captures: the filled bar is the mean and the tick is the worst patch. Exchanging the balance and the matrix costs 9.2 colour differences at the mean and 13.2 at the worst. Exchanging the curve and the clip costs exactly nothing, and that is a theorem rather than a small number: a monotone curve onto the unit interval commutes with clamping to it.

The order is not in the documentation

A raw converter performs a white balance, a colour matrix, a tone curve and a clip, and every account of the process lists them in that order without saying the order decides anything. Exchanging the first two moves the picture by nine colour differences at the mean and thirteen at the worst patch. The twenty-four arrangements collapse into five outcomes running out to sixty-five, and nothing a converter ships says which of them it is.

imaging · Capture
Where the mosaic is filled in, along one row through an edge. A Bayer row across a step from 0.9 to 0.08, in units of the sensor's own ceiling, reconstructed in linear light and reconstructed after the tone curve, with the second undone so the two are compared at the same point in the chain. Away from the edge they agree to 8.3e-14, because a constant interpolates to itself under any curve. At the edge they differ by 5.78 colour differences. Interpolating encoded values pulls an edge towards its dark side.

One step has no choice

Four of a raw converter's operations can be arranged twenty-four ways. The reconstruction cannot be arranged at all — a colour matrix needs three numbers and a mosaic site has one, so filling in the mosaic is forced to the front by arithmetic rather than by convention. What is not forced is whether it happens in linear light or after the curve, and that decision costs 5.8 colour differences at an ordinary edge and nothing at all four sites away from it.

imaging · Capture
A hue circle through a per-channel curve. 28 colours on a circle of constant lightness 55 and chroma 38, each put through the tone curve one channel at a time and read back. The curve is a function of a single number and has no idea what hue is, and it rotates the circle by up to 4.4 degrees — largest at hue 260 — while raising chroma by a factor of 1.27 and lightness by about 1 units.

A contrast control is three controls

A tone curve is a function of one number at a time and knows nothing about hue. Applied to each channel separately it rotates a hue circle by up to seventeen degrees, raises chroma by a factor of 1.27 at ordinary strength, and lifts lightness — so a photographer who moves a contrast slider has moved three things and the interface names one of them. All three scale with the curve's strength, monotonically, and the hue rotation depends on which hue it is.

imaging · Capture
A stop taken in raw, and the same lightness reached afterwards. Each row is a stop of exposure applied to the raw values, against a gain applied after the whole pipeline and solved so that an eighteen per cent grey comes out at the same lightness. The two are then the same brightness by construction and differ by 4.2 colour differences at the mean and 11.1 at the worst patch. A stop is a scalar in front of the curve and is not a scalar behind it.

A stop is not a stop afterwards

Doubling the light is exactly a factor of two in raw values and in tristimulus values, which is the one thing about exposure everybody is sure of. A stop taken after the tone curve is a factor of something else, and matching the two on an eighteen per cent grey leaves the rest of the frame between three and four colour differences apart at the mean and up to eleven at the worst patch. The gain that matches one stop is 2.47 rather than 2.

imaging · Capture
The same highlight, clipped in two places. A ramp running from inside the sensor's range to 1.6 times over it, clipped at the sensor and clipped after the matrix. Below the ceiling the two are identical to the floating-point floor. Above it they part, reaching 21.0 colour differences and 78 degrees of hue. Clipping late keeps a highlight neutral and clipping early keeps its hue, and converters do both.

Two converters and one highlight

The clip is the only step in a raw pipeline that destroys information rather than moving it, and it is the step whose position varies most between converters. Below the sensor's ceiling its position changes nothing at all, exactly. Above it, clipping at the sensor and clipping after the matrix land twenty-one colour differences and seventy-eight degrees of hue apart, and which hues are affected is a property of the camera's own dyes.

imaging · Capture
The same blend, taken on the stored values and on the light. Six pairs blended at 50 per cent, once by averaging the values as they are stored and once by averaging the light they stand for. Every resize, every antialiased edge and every transparency composite in an ordinary pipeline does the first. The two land 15.8 colour differences apart at the mean and 19.3 on a red against a green, and the stored-value blend is the darker on all six, by up to 23 units of lightness.

An average on the stored values

A resize, an antialiased edge, a transparency composite and a chroma subsample are all averages, and in almost every pipeline they are taken on the numbers as stored. The numbers as stored are encoded, the encoding is a compression, and a half-and-half blend of black and white taken that way lands 18.7 colour differences from the half-and-half blend of the light — 22.7 units of lightness darker, on every pair, always in the same direction.

applied · Delivery
One edge magnified four times, three ways: text on a page. A step between the two colours of text on a page, magnified four times by linear interpolation, by bicubic and by a three-lobe Lanczos kernel, once on the stored values and once on the light. The curves are the stored-value result's lightness minus the light's, sample by sample across the edge; below the line the stored-value resize is darker. Linear interpolation is darker everywhere it differs. The two kernels with negative lobes swing above the line beside the edge, where their negative weights fall — bicubic by up to 1.8 colour differences and Lanczos by 3.7.

A resize with a negative weight in it

A blend taken on stored values is always darker than the blend of the light, because the encoding is concave and a convex combination of a concave function's values lies below the function of the combination. A bicubic or Lanczos resize is not a convex combination. Beside an edge its negative weights make the stored-value result lighter than the light's own — by up to 6.1 colour differences with bicubic and 12.2 with Lanczos on skin against its shadow — and on edges between full-scale values the clip hides the overshoot and the old guarantee appears to hold.

applied · Delivery
The corner of a patch of skin against its own shadow, magnified four times by Lanczos, three lobes. A map of the neighbourhood of one corner of a square patch — the patch fills the lower right, the field the rest — once it has been magnified four times by Lanczos, three lobes. Each cell is shaded by how much lighter (warm) or darker (cool) the stored-value result is than the light's, the deepest shade 18.2 units of lightness. Within three source pixels of the corner the stored-value result is up to 14.5 colour differences lighter, 14.5 outside the patch against 3.1 inside it, and up to 7.3 darker.

The corner of a resized patch is lighter than its edges

A resize taken on stored values is darker than the resize of the light wherever its weights are positive, and lighter beside an edge where a kernel's negative lobes fall. In two dimensions the kernel is a product, and just outside a patch's corner a Lanczos magnification of skin against its shadow comes out 14.5 colour differences lighter — more than along either edge. A reduction to a quarter is mostly an average and errs lighter by at most two. And an unsharp mask, whose negative weights are its whole purpose, is lighter on the stored values at every amount on every pair, and never darker.

applied · Delivery
Where an unsharp mask errs, per pixel and as seen: print, 40 cm. The upper-left corner of a patch of skin against its shadow after an unsharp mask, as two maps of the colour difference between the result taken on stored values and taken on light. Left, pixel by pixel: the corner peaks at 16.8 and the middle of the edge at 16.6. Right, after the eye's three spatial channels at a print at 40 cm: the corner is seen at 17.1 and the edge at 7.1, a ratio of 2.40. Darker is larger, on one scale for both maps.

The eye counts a corner's error, not its peak

A Lanczos-magnified patch errs a fifth more at its corner than along its edges, pixel by pixel, and an unsharp mask errs almost exactly as much at its corner as along its edges. Filtered by the eye over the plane rather than along a line, the two swap: the magnified corner is seen exactly as its edge is, and on a printed page the sharpened corner is seen at 2.4 times its edge. What decides it is whether the error changes sign. Ringing averages away and a one-sided halo does not, and a corner is where two edges' halos land on the same patch of retina.

applied · Delivery

Named alongside it

The objects these essays reach for when they reach for this one.

Colour managementSpecificationDeclared inputClippingLightnessStructural choiceGammaInterpolationQuantisationSpatial frequencyColour spaceGamut

All concepts