AdditiveNoise

Targets:
image
volume

Apply random noise to image channels using various noise distributions.

This transform generates noise using different probability distributions and applies it to image channels. The noise can be generated in three spatial modes and supports multiple noise distributions, each with configurable parameters.

Arguments
noise_type
uniform | gaussian | laplace | beta
uniform

Type of noise distribution to use. Options:

  • "uniform": Uniform distribution, good for simple random perturbations
  • "gaussian": Normal distribution, models natural random processes
  • "laplace": Similar to Gaussian but with heavier tails, good for outliers
  • "beta": Flexible bounded distribution, can be symmetric or skewed
spatial_mode
constant | per_pixel | shared
constant

How to generate and apply the noise. Options:

  • "constant": One noise value per channel, fastest
  • "per_pixel": Independent noise value for each pixel and channel, slowest
  • "shared": One noise map shared across all channels, medium speed
approximation
float
1

float in [0, 1], default=1.0 Controls noise generation speed vs quality tradeoff.

  • 1.0: Generate full resolution noise (slowest, highest quality)
  • 0.5: Generate noise at half resolution and upsample
  • 0.25: Generate noise at quarter resolution and upsample Only affects 'per_pixel' and 'shared' spatial modes.
noise_params
dict[str, Any] | None

Parameters for the chosen noise distribution. Must match the noise_type:

uniform: ranges: list[tuple[float, float]] List of (min, max) ranges for each channel. Each range must be in [-1, 1]. If only one range is provided, it will be used for all channels.

    [(-0.2, 0.2)]  # Same range for all channels
    [(-0.2, 0.2), (-0.1, 0.1), (-0.1, 0.1)]  # Different ranges for RGB

gaussian: mean_range: tuple[float, float], default (0.0, 0.0) Range for sampling mean value, in [-1, 1] std_range: tuple[float, float], default (0.1, 0.1) Range for sampling standard deviation, in [0, 1]

laplace: mean_range: tuple[float, float], default (0.0, 0.0) Range for sampling location parameter, in [-1, 1] scale_range: tuple[float, float], default (0.1, 0.1) Range for sampling scale parameter, in [0, 1]

beta: alpha_range: tuple[float, float], default (0.5, 1.5) Value < 1 = U-shaped, Value > 1 = Bell-shaped Range for sampling first shape parameter, in (0, inf) beta_range: tuple[float, float], default (0.5, 1.5) Value < 1 = U-shaped, Value > 1 = Bell-shaped Range for sampling second shape parameter, in (0, inf) scale_range: tuple[float, float], default (0.1, 0.3) Smaller scale for subtler noise Range for sampling output scale, in [0, 1]

Examples
>>> # Constant RGB shift with different ranges per channel:
>>> transform = AdditiveNoise(
...     noise_type="uniform",
...     spatial_mode="constant",
...     noise_params={"ranges": [(-0.2, 0.2), (-0.1, 0.1), (-0.1, 0.1)]}
... )