Skip to content

Add Poisson noise

Fact Value
Also called Photon noise, Shot noise
Status Implemented and tested
Family Utilities
Engine Browser
Type Nonlinear, statistical, Poisson sampling
Output Image
Operator shown as random-process (exact)
Support radius 0
Code web/src/core/filters/utility/noise.ts, poissonNoiseFilter
Operator code web/src/core/math/poisson.ts, poissonSample
Channels RGB

Overview

Add Poisson noise simulates photon counting, the main noise of low-light photos. Each value becomes a random photon count with a mean proportional to the value, and the count is scaled back. Fewer photons at white mean a darker scene and more noise. The noise grows with the square root of the brightness.

A plot of one row of the gray ramp, with Poisson noise for 20 and for 200 photons at white. Both are noisier on the bright side, and the 20-photon line is much noisier. A plot of one row of the gray ramp, with Poisson noise for 20 and for 200 photons at white. Both are noisier on the bright side, and the 20-photon line is much noisier.
Fewer photons give more noise. The noise grows with the square root of the brightness.

How it works

  1. Turn the value into a mean photon count.
  2. Draw a random Poisson count with that mean.
  3. Scale the count back to 0 to 255.

Mathematical foundation

\[ k \sim \operatorname{Poisson}\Bigl(\frac{I\, P}{255}\Bigr), \qquad I_{\text{out}} = \frac{255\, k}{P} \]

The formula shows the default parameter values.

where

  • \(P\): The photon count at white
  • \(k\): The random photon count

P is the photon count at white. The value I is turned into a mean photon count, a random count k is drawn with that mean, and k is scaled back to 0 to 255. A Poisson count with mean lambda has variance lambda, so the noise standard deviation in levels is the square root of 255 I / P. Bright areas get more noise in levels, but less relative to their value.

A Poisson count with mean lambda has variance lambda. So the noise standard deviation in levels is sqrt(lambda) times 255 / P, which grows with the square root of the value. The signal-to-noise ratio, mean over standard deviation, is sqrt(lambda): more photons give a cleaner image. Counts are whole numbers, so the noisy image has at most P + 1 distinct levels.

Kernel or operator

There is no kernel. The Inspector describes the random process with the current photon count.

Algorithm

  1. For each pixel and channel, compute the mean count I P / 255.
  2. Draw a Poisson count from uniform numbers that depend only on the seed, the position and the channel.
  3. Means below 10 use the multiplication method of Knuth. Larger means use the PTRS method of Hörmann.
  4. Scale the count back by 255 / P, clip to 0 to 255 and round.

Parameters

Parameter Default Values Meaning
Photons at white peak 50 1 to 1000 The mean photon count of a white pixel. A value v has the mean v times peak / 255.
Seed seed 1 0 to 999999 The starting number of the random generator.

Implementation

poissonNoiseFilter in web/src/core/filters/utility/noise.ts draws each count with poissonSample in web/src/core/math/poisson.ts, as NumPy's legacy generator does: the multiplication method of Knuth below a mean of 10, and the PTRS method of Hörmann above. The uniform numbers come from the position-based generator, so a strip gives the same noise as the whole image.

Worked example

Value Mean photons Photon spread Noise in levels
10 1.96 1.400 7.14
128 25.10 5.010 25.55
255 50 7.071 36.06

With 50 photons at white, a value of 128 has a mean of 25.10 photons. A Poisson count has a standard deviation equal to the square root of its mean. Scaled back by 255 / 50, that is the noise in levels. The bright value has more noise in levels, but less relative to its value.

Complexity

  • Time: \(O(N)\)
  • Memory: \(O(N)\)

N is the number of pixels. Each draw uses about lambda + 1 uniform numbers below a mean of 10, and about two above.

Artifacts and limitations

Limitations

  • Real cameras add read noise and other effects on top of photon noise.
  • The output has only peak + 1 distinct levels before clipping.

Artifacts

  • Visible steps between levels when the photon count is small.

Tests

Unit tests draw 40000 counts for six means from 0.5 to 300 and check that the mean and the variance both match the mean. They also check the log-gamma function against exact values. A filter test adds Poisson noise to a flat gray image and checks the expected standard deviation in levels.

References