lentil.detector.shot_noise

lentil.detector.shot_noise(img, method='poisson', seed=None)[source]

Apply shot noise to an image

Parameters
  • img (array_like) – Array of counts. All values must be >= 0.

  • method ('poisson' or 'gaussian') – Noise method.

  • seed (None, int, or array_like, optional) – Random seed used to initialize numpy.random.RandomState. If None, then RandomState will try to read data from /dev/urandom (or the Windows analogue) if available or seed from the clock otherwise.

Returns

img – Array of noisy counts

Return type

ndarray

Notes

The output of the Poisson distribution is limited to the range of the C int64 type. A ValueError is raised when img contains values within 10 sigma of the maximum representable value (lam > 9.223372006484771e+18).

For sufficiently large values of \(\lambda\), (say \(\lambda > 1000\)), the Normal(\(\mu = \lambda\), \(\sigma^2 = \lambda\)) distribution is an excellent approximation to the Poisson(\(\lambda\)) distribution and is about 25% faster to compute.