GaussNoise

Targets:
image
volume
Image Types:uint8, float32

Apply Gaussian noise to the input image.

Arguments
std_range
tuple[float, float]
[0.2,0.44]

Range for noise standard deviation as a fraction of the maximum value (255 for uint8 images or 1.0 for float images). Values should be in range [0, 1]. Default: (0.2, 0.44).

mean_range
tuple[float, float]
[0,0]

Range for noise mean as a fraction of the maximum value (255 for uint8 images or 1.0 for float images). Values should be in range [-1, 1]. Default: (0.0, 0.0).

per_channel
bool
false

If True, noise will be sampled for each channel independently. Otherwise, the noise will be sampled once for all channels. Default: False.

noise_scale_factor
float
1

Scaling factor for noise generation. Value should be in the range (0, 1]. When set to 1, noise is sampled for each pixel independently. If less, noise is sampled for a smaller size and resized to fit the shape of the image. Smaller values make the transform faster. Default: 1.0.

p
float
0.5

Probability of applying the transform. Default: 0.5.

Examples
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, (224, 224, 3), dtype=np.uint8)
>>>
>>> # Apply Gaussian noise with normalized std_range
>>> transform = A.GaussNoise(std_range=(0.1, 0.2), p=1.0)  # 10-20% of max value
>>> noisy_image = transform(image=image)['image']
Notes
  • The noise parameters (std_range and mean_range) are normalized to [0, 1] range:
    • For uint8 images, they are multiplied by 255
    • For float32 images, they are used directly
  • Setting per_channel=False is faster but applies the same noise to all channels
  • The noise_scale_factor parameter allows for a trade-off between transform speed and noise granularity
  • pr_channel=False (default) is faster and applies same noise to all channels
  • per_channel=True is slower but creates more diverse noise patterns across channels
  • For RGB images: per_channel=False creates grayscale-like noise, per_channel=True creates colored noise