Noise#
- class deeptrack.optical.noises.Noise(_input: Any | None = None, **kwargs: Any)#
Bases:
FeatureBase class for noise models.
Noise features add stochastic or deterministic perturbations to array-like data such as images. These features typically operate on NumPy arrays or PyTorch tensors and return a noisy version of the input.
Subclasses implement the .get(image, **kwargs) method, which defines how the noise is generated and applied to a single input array.
When a noise feature is evaluated, it applies the noise model to each element of the input list independently (since __distributed__ = True through inheritance from Feature).
Noise features transparently support ScatteredVolume and ScatteredField objects. If the input element is one of these objects, the noise is applied to the underlying array (element.array) while preserving the container object and its metadata.
This allows noise models to be inserted anywhere in a DeepTrack pipeline without breaking compatibility with scatterer-based simulations.
Methods#
- get(image, **kwargs) -> np.ndarray | torch.Tensor
Abstract method implemented by subclasses to generate noise for a single input array.
- _process_and_get(inputs, **properties) -> list
Internal method that applies noise to each element of the input list and preserves container objects when necessary.
Examples#
>>> import deeptrack as dt >>> import numpy as np
Add Gaussian noise to an image
>>> image = np.ones((64, 64)) >>> noise = dt.Gaussian(mu=0, sigma=0.1) >>> noisy_image = noise(image)
Apply noise inside a pipeline
>>> particle = dt.PointParticle() >>> optics = dt.Fluorescence() >>> pipeline = optics(particle) >> dt.Gaussian(sigma=0.05) >>> image = pipeline()