Poisson#

class deeptrack.optical.noises.Poisson(*args: Any, snr: float | Callable[[...], float] = 100, background: float | Callable[[...], float] = 0, max_val: float | Callable[[...], float] = 100000000.0, **kwargs)#

Bases: Noise

Add Poisson-distributed noise to an image.

Poisson noise is generated according to the pixel intensity of the input image and scaled to achieve a desired signal-to-noise ratio (snr).

Parameters#

snr: PropertyLike[float], optional

Target signal-to-noise ratio of the output image. The signal is determined by the peak value of the input image. Defaults to 100.

background: PropertyLike[float], optional

Background level used when computing the signal amplitude. Defaults to 0.

max_val: PropertyLike[float], optional

Maximum allowable value used to prevent overflow during noise computation. Defaults to 1e8.

Methods#

get(image, snr, background, max_val, …) -> np.ndarray | torch.Tensor

Returns the input image with Poisson noise added.

Examples#

>>> import deeptrack as dt
>>> import numpy as np

Create an input image:

>>> image = np.ones((2, 2))

Define Poisson noise:

>>> noise = dt.Poisson(snr=1)

Apply the noise:

>>> noisy = noise(image)
>>> print(noisy)
[[2. 1.]
 [0. 4.]]

Methods Summary

get(image, snr, background, max_val, **kwargs)

Add Poisson noise to the input image.

Methods Documentation

get(image: ndarray | Tensor, snr: float, background: float, max_val: float, **kwargs: Any) ndarray | Tensor#

Add Poisson noise to the input image.

Parameters#

image: np.ndarray | torch.Tensor

Input image to which noise will be added.

snr: float

Target signal-to-noise ratio of the output image.

background: float

Background level used when computing the signal amplitude.

max_val: float

Maximum allowable value used to prevent overflow during noise computation.

**kwargs: Any

Additional keyword arguments passed through the feature pipeline.

Returns#

np.ndarray | torch.Tensor

The input image with Poisson noise added.