Gaussian#

class deeptrack.optical.noises.Gaussian(mu: float | Callable[[...], float] = 0, sigma: float | Callable[[...], float] = 1, **kwargs: Any)#

Bases: Noise

Add IID Gaussian noise to an image.

Gaussian noise is sampled from a normal distribution and added independently to each pixel of the input image.

Parameters#

mu: PropertyLike[float], optional

Mean of the Gaussian distribution. Defaults to 0.

sigma: PropertyLike[float], optional

Standard deviation of the Gaussian distribution. Defaults to 1.

Methods#

get(image, mu, sigma, **kwargs) -> np.ndarray | torch.Tensor

Returns the input image with Gaussian noise added.

Examples#

Add Gaussian noise to an image.

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

Create an input image:

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

Define Gaussian noise:

>>> noise = dt.Gaussian(mu=1, sigma=0.1)

Apply the noise:

>>> noisy = noise(image)
>>> print(noisy)
[[4.01965863 4.20688642]
 [4.02184982 3.87875873]]

Methods Summary

get(image, mu, sigma, **kwargs)

Add Gaussian noise to the input image.

Methods Documentation

get(image: ndarray | Tensor, mu: float, sigma: float, **kwargs: Any) ndarray | Tensor#

Add Gaussian noise to the input image.

Parameters#

image: np.ndarray | torch.Tensor

The input image to which noise will be added.

mu: float

The mean of the Gaussian distribution.

sigma: float

The standard deviation of the Gaussian distribution.

**kwargs: Any

Additional keyword arguments.

Returns#

np.ndarray | torch.Tensor

The input image with Gaussian noise added.