What a camera does

Clipped noise does not average away

Noise on a raw reading is as likely to fall below the true value as above it, which is why averaging an area removes it. A converter that sets negative readings to zero keeps the upper half and throws the lower away, and the mean of what is left is the signal plus a pedestal. With no black level error anywhere, a half per cent grey under a tungsten lamp comes out 1.04 colour differences off at high gain, 8.98 after a four-stop push — and a blur that removes every trace of the noise leaves the tint where it was.

Assumes A black level is multiplied by the balance, Correcting colour costs noise and Two converters and one highlight.

A black level is multiplied by the balance measured what an offset left in the raw channels becomes after a white balance, and it set noise aside with a test for telling the two apart: blur the shadow, and whatever survives the blur is not noise, because noise averages away and an offset does not. That test has a condition in it, and the condition fails in the most ordinary converter there is. Noise averages away only if nothing between the reading and the average has bent it — and the first thing most converters do to a shadow is bend it at zero.

Noise clipped at zero, averaged over a shadow, under tungsten. A grey ramp from black to ten per cent reflectance under tungsten, captured at three illustrative noise levels, with every negative raw reading set to zero before the readings are averaged over an area. Each line is the colour difference between that average and the noiseless grey. At high gain a half per cent grey is 1.04 off and a black frame 0.79; at very high gain the worst is 2.95, at 1.0 per cent. The same readings averaged before any clip come back exactly, at every level. The tint is gone once every channel sits several deviations above zero.
Fig. 1 A grey ramp from black to ten per cent under a tungsten lamp, at three noise levels, with negative raw readings set to zero before an area is averaged. The lines are how far the average lands from the noiseless grey. Nothing was wrong with the black level.

Noise that averages to a tint

Noise clipped at zero has a positive mean, so an average over an area is the signal plus a pedestal — equal in every channel on a black frame, largest in the lamp’s weakest channel on a lit shadow — and the white balance turns it into the colour of the lamp’s inverse.

  • At a high amplification, with no black level error at all, a half per cent grey under tungsten averages 1.04 colour differences from the noiseless grey, and a black frame 0.79, almost all of it chroma.
  • At a very high amplification a one per cent grey is 2.95 off, with 3.27 units of chroma, and under daylight the same grey is 1.59 off.
  • Averaged over sixteen thousand pixels, signed noise falls to 0.28 and clipped noise stays at 3.0. A blur cannot tell the clip’s bias from a pedestal error.
  • Pushed four stops in editing, the half per cent grey’s 1.04 becomes 8.98 — the size the pedestal essay found for a black level two thousandths of white too high.

A shadow’s readings straddle zero

A photosite’s count is the light it received plus noise, and the noise has two parts. Photon arrival is random, so the count scatters around its mean by the square root of the mean. The readout electronics add a further scatter of a few electrons that does not depend on the light at all. A sensor adds a fixed pedestal to every reading so that this scatter, near zero light, is not cut off by the analogue-to-digital converter, and raw is not a picture until a converter has subtracted the pedestal again.

After the subtraction, a shadow’s readings are centred on its signal and spread on both sides of it. For a deep shadow the spread is wider than the signal, so a large share of the readings are negative. Nothing is wrong with a negative reading. It is a sample of a distribution whose mean is small and positive, and averaged with its neighbours it contributes exactly what it should.

What happens next is a decision the converter makes, and most converters make it silently. A value stored as an unsigned integer cannot be negative, so it becomes zero. A pipeline written in floating point may keep the negative values through the white balance and then meet a step that assumes its input is non-negative — a logarithm, a power, a lookup table indexed from zero — and clamp there. Either way the lower half of the noise is discarded and the upper half is kept, and what was a symmetric scatter is now a scatter with a positive mean.

Half a normal curve has a mean

The size of that mean has a closed form, and it depends on one number: how many standard deviations the true signal sits above zero.

How much of its noise a reading loses to a clip at zero. The average amount a clip at zero adds to a noisy reading, in units of the noise, against how many standard deviations the true signal sits above zero. It is 0.399 of a deviation at zero signal, 0.083 one deviation up, and 0.0004 by three. The dots are the three raw channels of a 2 per cent grey at high gain: under daylight they sit at 3.6, 3.3, 2.4 deviations, under a tungsten lamp at 3.6, 2.5, 1.0 — the blue channel, which the lamp starves, is on the steep part of the curve, and it is the channel the white balance then multiplies most.
Fig. 2 What a clip at zero adds to the average of a noisy reading, in units of the noise, against how far the true signal sits above zero. The dots are one grey’s three raw channels under two lamps; under tungsten the blue one sits on the steep part.

For a reading with a true value ss and a normal scatter of standard deviation σ\sigma, the mean after setting negative readings to zero is sΦ(s/σ)+σφ(s/σ)s\,\Phi(s/\sigma) + \sigma\,\varphi(s/\sigma), where Φ\Phi and φ\varphi are the normal distribution’s cumulative and density functions. At zero signal that is σ/2π\sigma/\sqrt{2\pi}, which is 0.399 of a standard deviation. One deviation up it is 0.083 of a deviation, two deviations up 0.008, and three deviations up under half a thousandth.

So the bias is a feature of the bottom few deviations of every channel. A channel whose signal sits four deviations above zero is untouched by the clip, and a channel whose signal sits at one deviation loses a twelfth of its noise’s width to it — a small number in counts, and a large one once a white balance has multiplied it.

The computation above was checked against the integral it stands for, taken numerically over a band twelve deviations wide on either side, and the two agree to a few parts in ten billion of a deviation at five different signal levels.

The channel the lamp starves is nearest the floor

The three raw channels of one grey do not sit at the same distance from zero. A tungsten lamp has little power in the blue, so the blue channel of any grey it lights records a small fraction of what the red channel records — the white balance’s blue gain under that lamp is 6.15 times its red for exactly that reason.

At a high amplification, a two per cent grey under daylight has its three channels at 3.6, 3.3 and 2.4 standard deviations above zero. Under tungsten they are at 3.6, 2.5 and 1.0. The red channels agree because each lamp’s grey is normalised to its own largest channel. The blue channel under tungsten sits on the steep part of the curve, where the clip adds about a twelfth of a deviation to its mean, while its red channel sits where the clip adds nothing measurable.

Then the white balance divides each channel by the lamp’s response in that channel, which multiplies the blue channel by six. The channel that lost the most to the clip is the channel the balance amplifies most, so a clipped shadow under tungsten goes blue for two reasons that compound: it had a larger bias to begin with, and the bias was multiplied by the largest gain.

On a one per cent grey at a very high amplification the three channels’ biases, as shares of the black frame’s bias, are 0.30, 0.51 and 0.82. A lit shadow is not an equal offset at all. It is an offset shaped like the inverse of the lamp, which is the one shape the pedestal essay found the balance cannot leave neutral — and it is worse than the equal offset that essay measured, because it leans the same way the gains do.

A black frame is a pedestal exactly

At zero signal the three channels are equally close to zero, and read noise — added in the electronics after the colour filters — is the same size in counts in all three. So a black frame with its noise clipped carries an offset of exactly σ/2π\sigma/\sqrt{2\pi} in every channel, equal to the last digit, which is the pedestal error of the earlier essay arriving from noise rather than from a mis-estimated black level.

At a high amplification the read noise here is 2.5 thousandths of white, and the equivalent pedestal is a thousandth. At a very high amplification the read noise is 7.5 thousandths and the equivalent pedestal three thousandths — the size the pedestal essay used for its headline, where it turned a two per cent grey 2.4 colour differences away under daylight.

How the tint on a 0.5% grey grows with the error, under two lamps. The colour difference on a 0.5 per cent grey against the size of a pedestal error, from nothing to one per cent of white, under daylight and under a tungsten lamp. Both start at exactly zero. At one per cent the grey is 7.2 off under daylight and 8.7 off under tungsten. Both grow nearly in proportion, and tungsten's grows faster as the error rises, because its blue gain is six times its red.
Fig. 3 A pedestal error from nothing to one per cent of white on a half per cent grey, under two lamps, from the essay on black levels. A clipped black frame at a very high amplification carries an offset of three tenths of a per cent of white with its black level exactly right.

Nothing about the tint distinguishes them, and nothing could. The clipped black frame’s tint lies at −76 degrees of hue under daylight and −99 under tungsten, pointing the same way as the pedestal essay’s tints on a two per cent grey, −77 and −110, which lean further into the blue because a lit grey’s blue channel carries less signal of its own to dilute them. On a black frame the two errors cannot be told apart by their colour, because on a black frame the input to the balance is the same three numbers in both cases.

The blur test, corrected

The pedestal essay offered a test: noise averages away over an area and a pedestal error does not, so a tint that survives a heavy blur is not noise. The premise of the test is the symmetric noise it began with. Clipped noise is not symmetric.

A blur removes noise and leaves what the clip added. A 1 per cent grey under tungsten at very high gain, averaged over more and more pixels, with the colour difference of the average from the noiseless grey on a logarithmic scale — the root mean square over 24 seeded trials. One pixel alone is 15.9 off either way. Kept signed, the average falls as the square root of the count and reaches 0.28 at 16,384 pixels. Clipped at zero first, it stops falling near 3.0: a tint that survives a heavy blur can be noise, if something clipped the noise before the blur.
Fig. 4 A one per cent grey under tungsten at a very high amplification, averaged over more and more pixels. Kept signed, the average keeps falling. Clipped at zero, it stops near three colour differences and stays there.

One pixel of a one per cent grey at a very high amplification is 15.9 colour differences from the noiseless grey, whichever way the negative readings are handled, because a single pixel’s noise is enormous at that level. Averaged over sixty-four pixels the two are 4.3 and 4.6; over two hundred and fifty-six, 1.8 and 3.3. From there they part completely. The signed average keeps falling as the square root of the count — 1.15 at a thousand pixels, 0.28 at sixteen thousand — and the clipped average stops falling near 3.0, the value its closed form predicts.

So the test sorts errors correctly into two kinds, and the kinds are not noise and pedestal. They are zero-mean and not zero-mean. A tint that survives a blur has a non-zero mean, and a clip has given the noise one. A tint that survives a heavy blur can be noise, if anything clipped the noise before the blur.

A test that does separate the two uses the property the two errors do not share. A pedestal error is set by the black level estimate and does not depend on how much the sensor’s signal was amplified. A clip’s bias is a fraction of the noise, and the noise in units of white rises with the amplification. The same scene photographed at two amplifications, with the exposure adjusted to match, keeps a pedestal error’s tint and changes a clip’s.

Daylight halves it and does not remove it

A daylight balance spreads its gains much less than a tungsten one, and the tint follows.

Noise clipped at zero, averaged over a shadow, under daylight. A grey ramp from black to ten per cent reflectance under daylight, captured at three illustrative noise levels, with every negative raw reading set to zero before the readings are averaged over an area. Each line is the colour difference between that average and the noiseless grey. At high gain a half per cent grey is 0.39 off and a black frame 0.64; at very high gain the worst is 2.01, on the black frame. The same readings averaged before any clip come back exactly, at every level. The tint is gone once every channel sits several deviations above zero.
Fig. 5 The same ramp and the same three noise levels under daylight. The tints are smaller than under tungsten at every lit level and fall away sooner as the grey brightens.

Under daylight at a high amplification the half per cent grey is 0.39 off, against 1.04 under tungsten, and the two per cent grey 0.03 against 0.47. At a very high amplification the one per cent grey is 1.59 against 2.95. Two things account for the difference and both are the lamp: daylight’s blue channel sits further above zero, so less of its noise is clipped, and its blue gain is 1.85 rather than 6.15, so what was clipped is multiplied less.

The black frame is the exception, 0.64 under daylight against 0.79 under tungsten at a high amplification. On a black frame every channel is equally close to zero whatever the lamp, so only the gains differ, and the difference is smaller.

The low-amplification sensor state makes the other end of the argument. With the read noise at three ten-thousandths of white the largest tint anywhere on either ramp is 0.08, on the black frame. The clip’s bias belongs to high amplification and deep shadow together, which is exactly the combination a night photograph under artificial light provides.

A push finds it

A tint of one colour difference in a shadow at lightness two is not a visible fault. Shadows are where the eye resolves colour least, and a shadow that stays a shadow keeps its bias out of sight. The trouble begins when the shadow is moved.

A 0.5 per cent grey pushed up in editing, after a clip at zero. A 0.5 per cent grey under tungsten at high gain, with its negative readings clipped and the shadow brightened by up to four stops before the rest of the pipeline runs. There is no black level error anywhere. Unpushed the average is 1.04 colour differences from the noiseless grey; pushed four stops, to lightness 29, it is 8.98.
Fig. 6 A half per cent grey under tungsten at a high amplification, clipped at zero and then brightened in editing by up to four stops. The bias is multiplied with the signal and carried into the midtones.

A raw editor brightens a shadow by multiplying its raw values before the pipeline runs, which is the right place for an exposure change — a stop is not a stop afterwards established why. It multiplies the clipped mean along with the signal. Unpushed the half per cent grey is 1.04 colour differences off; pushed one stop, 2.05; two stops, 3.44; three, 6.58; four stops, to a lightness of 29, it is 8.98.

That is the lifted-shadow cast the pedestal essay described, reached with a black level that was exactly right. An underexposed night frame at a high amplification, under tungsten, brightened four stops in editing, is a machine for producing it — and the correction the pedestal essay recommended, estimating the black level per frame from the masked photosites, removes none of it, because the black level was never the problem.

The picture clips too

A converter that keeps its raw values signed has not escaped. Every step after the white balance is written for non-negative input somewhere, and the delivered image is certainly non-negative. The average is only safe if it is taken before the first clip, wherever that is.

Four places to take the same average. A 1 per cent grey under tungsten at very high gain, averaged over an area at four points in the chain. Averaged in signed raw it comes back exactly. Clipped at zero first it is 2.95 off, almost all chroma. Run through the whole pipeline pixel by pixel and averaged on the delivered values — which is what a resized or viewed picture is — it is 3.50 off from signed raw and 2.82 from clipped, and now 3.7 units lighter as well, because the pipeline's own steps clamp at zero.
Fig. 7 One shadow averaged at four points: in signed raw, in raw after a clip, and on the delivered picture from signed and from clipped raw. Only the first returns the grey.

Averaged in signed raw, a one per cent grey under tungsten at a very high amplification comes back exactly. Clipped and then averaged in raw, it is 2.95 off, with lightness nearly unchanged. Run through the whole pipeline one pixel at a time and averaged on the delivered values — which is what a resize, a thumbnail or a viewer standing back from a print does — it is 3.50 off from signed raw and 2.82 from clipped raw, and now 3.7 and 2.6 units lighter as well. The pipeline’s tone curve clamps its input at zero, the delivered value cannot be negative, and the negative excursions a signed raw value survived are clipped one step later.

The lightening is the same inequality at work on a different axis. An average on the stored values is darker than the average of the light because the encoding is concave; here the average of clipped values is lighter than the value of the average because a clip at zero is convex. The average surface does not look average for the same reason: the order of an average and a nonlinearity decides the answer, and the sign is set by which way the nonlinearity bends.

That places it among the decisions a raw pipeline makes without recording them. One step has no choice found that the reconstruction of the mosaic is forced to the front of the chain; two converters and one highlight found that where the clip at the top of the range sits decides a highlight’s hue, which is why a blown highlight turns rather than simply whitening. The clip at the bottom of the range is the same decision, and what it decides is whether an average taken anywhere later is an average of the scene.

Where a converter can put the average

Three placements return the grey and every other placement does not, so the repair is a matter of order rather than of better estimation.

Average before any clip. A denoiser, a downsampler or a binning step that works on signed raw values — after the black level is subtracted and before anything assumes non-negative input — removes the noise and leaves the signal, exactly, whatever the amplification. A denoiser run on the delivered picture removes the noise and keeps the bias it found there.

Keep the values signed as far as the arithmetic allows. The white balance and the colour matrix are linear, and a negative input passes through both honestly — the matrix enlarges the noise, as correcting colour costs noise measured, but it enlarges both halves of it alike and leaves its mean at zero. The first step that cannot take one is usually the tone curve, and every pixel that reaches it negative has already had its average spoiled for any later operation.

Clip once, late, and after the averages. A picture has to be non-negative in the end. A pipeline that performs its spatial averages first and its clips last has the same delivered pixels for every region that is not averaged, and correct ones for every region that is.

And record where the clip was. A converter’s output does not say whether its shadows were clipped before or after its noise reduction, which is a declared input of exactly the kind a converter’s documentation leaves out. The file that could say so would let a later edit tell a clipped shadow’s cast from a pedestal error’s, which a push and a blur alone cannot.

How the averages were computed

The camera is the same modelled raw pipeline the essays on raw conversion use: a silicon sensor with three dye filters and an infrared-cut filter, a white balance dividing each channel by its response to the lamp, a colour matrix fitted to a chart under that lamp, a tone curve and a clip. Greys are flat reflectances under D65 or illuminant A.

Noise is normal, with a variance of the read noise squared plus the signal divided by the number of photoelectrons at the raw white. The three sensor states are 10,000 photoelectrons at white with 3 of read noise, 800 with 2, and 200 with 1.5 — sizes of the right order for a large sensor at a low and a high amplification and a small one pushed hard, not any particular camera’s datasheet. The clipped means use the closed form above, channel by channel. The blur’s averages are sampled, twenty-four seeded trials at each count, and reported as a root mean square. The per-pixel placements are forty thousand seeded pixels each. Colour differences are ΔE₀₀ against the pipeline’s output for the noiseless grey.

What the model leaves out

The noise is normal to the bottom. At a few photoelectrons the photon count is Poisson rather than normal, and read noise in real sensors has heavier tails than a normal curve, including a scatter of hot and flickering pixels; both change the clip’s bias at the deepest levels, in directions this model does not compute.

The converter is idealised. Real converters clip at different steps, some keep negative values through their noise reduction and some do not, and the mosaic reconstruction — here set aside — mixes neighbouring channels before any clip can act on them one channel at a time, which is the step that makes a grey edge arrive coloured and would spread a clipped channel’s bias into its neighbours.

And the tints are area averages. A picture viewed at full size shows the noise as well as its bias, and whether the cast is noticed through the speckle depends on how far the viewer stands back — which is itself an average, taken by the eye, after every clip.

The habit: a zero-mean error keeps its mean only until it is clipped

Averaging removes an error whose mean is zero, and the claim that a particular error has a zero mean is a claim about everything that has happened to it since it was made. A symmetric scatter stays symmetric through a gain, a matrix and a sum. It does not stay symmetric through a floor, a ceiling, a square, a logarithm or any function that bends.

The move is to find the first nonlinear step between an error’s source and the average that is supposed to remove it, and to ask which side of the average it sits on. If the step comes first, the average is of a biased quantity.

The failure mode is to reason about the error at its source and trust the average at its destination. An average removes noise only if nothing between the noise and the average has bent it, and a clip at zero bends everything below it.

Where the idea comes from

The bias of a truncated normal distribution is textbook statistics, and that clipping negative values in dark frames biases the black level upwards is well known in astronomical imaging, where calibration frames are averaged in quantity and kept in signed or floating-point arithmetic for that reason. Coloured casts in lifted shadows are among the most discussed faults of raw processing.

That the clipped bias lands in the lamp’s starved channel and is multiplied by its largest gain, that it survives the blur test the pedestal essay proposed, and how large it is under two lamps at three amplifications, are worked out here on one modelled sensor.

Still open: what real converters clip, and where

The model shows what a clip costs at each place it could sit. Which place real raw converters actually use — whether their noise reduction runs on signed raw values, where their first clamp is, and whether they treat the masked photosites’ readings the same way — is a property of each converter that its documentation does not state. Measured with a black frame and a dim grey card at a high amplification, the average of the delivered picture against the average of the signed raw values would place each converter on the figure above, and would say which of them deliver a shadow’s cast along with its detail.

What this makes readable

Essays that name this one as a prerequisite.

Named alongside this one

Essays reaching for the same objects. Nobody chose these; they are what the index of named objects makes visible.

What links here

Every essay whose body links to this one.

The objects this essay names

Each one links to every other essay that touches it.

Camera rawClippingDeclared inputDynamic rangeExposureMeanNoiseSignal-to-noiseStructural choiceWhite balance