pysdic.add_poisson_noise#

add_poisson_noise(image, *, gain, seed=None)[source]#

Add a Poisson noise to an image (photon noise of a sensor): the variance of the noise grows with the gray level.

The gray levels are converted to a number of electrons with the gain \(k\) (gray levels per electron), a Poisson count is drawn, and converted back:

\[g' = k \, \mathcal{P}\left(\frac{g}{k}\right), \qquad \mathbb{E}[g'] = g, \qquad \text{Var}[g'] = k \, g\]

A smaller gain gives more electrons per gray level, hence a smaller relative noise.

See also

add_gaussian_noise() for the usual order of the simulation of an acquisition.

Parameters:
  • image (ArrayLike) – The image, an array of any shape with finite and non-negative values.

  • gain (Real) – The gain \(k > 0\) of the sensor, in gray levels per electron.

  • seed (Optional[Integral], optional (default: None)) – The seed of the random generator (numpy.random.default_rng), non-negative. If None, the noise is different at each call.

Returns:

The noisy image, a float64 array with the shape of image (multiples of \(k\), not rounded).

Return type:

numpy.ndarray

Raises:

ValueError – If the image has non-finite or negative values, or an input has a wrong value.