FilmGrain
Targets:
image
volume
Image Types:uint8, float32
Simulate analog film grain noise.
Unlike GaussNoise or ShotNoise, film grain is:
- Luminance-dependent: darker areas show more visible grain
- Spatially correlated: grain is clumped, not i.i.d. per-pixel
- Optionally chromatic: separate grain patterns per channel
Arguments
intensity_rangetuple[float, float]
[0.1,0.3]
Range for grain intensity. Higher values produce more prominent grain. Default: (0.1, 0.3).
grain_size_rangetuple[int, int]
[1,3]
Range for the grain generation resolution as a divisor of image size. 1 = full resolution (fine grain), 4 = quarter resolution (coarse, clumped grain). Default: (1, 3).
pfloat
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, (100, 100, 3), dtype=np.uint8)
>>> transform = A.FilmGrain(intensity_range=(0.1, 0.3), grain_size_range=(1, 3), p=1.0)
>>> result = transform(image=image)["image"]Notes
Grain is generated at a lower resolution and upscaled, which creates the natural spatial correlation (clumping) seen in real film. The grain visibility is modulated by inverse luminance — darker regions show more grain, matching how silver halide crystals behave in real film emulsion.