RandomFog

Targets:
image
Image Types:uint8, float32

Simulate fog by overlaying semi-transparent circles and blending with a fog color. Good for driving or outdoor robustness to weather.

Fog is built from random circles with controllable intensity; an image-size-dependent Gaussian blur is applied to the result. Patch-based (no depth); for distance-dependent fog use AtmosphericFog.

Arguments
fog_coef_range
tuple[float, float]
[0.3,1]

Range for fog intensity coefficient in [0, 1]. Default: (0.3, 1).

alpha_coef
float
0.08

Transparency of the fog circles in [0, 1]. Default: 0.08.

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, [100, 100, 3], dtype=np.uint8)

# Default usage
>>> transform = A.RandomFog(p=1.0)
>>> foggy_image = transform(image=image)["image"]

# Custom fog intensity range
>>> transform = A.RandomFog(fog_coef_range=(0.3, 0.8), p=1.0)
>>> foggy_image = transform(image=image)["image"]

# Adjust fog transparency
>>> transform = A.RandomFog(fog_coef_range=(0.2, 0.5), alpha_coef=0.1, p=1.0)
>>> foggy_image = transform(image=image)["image"]
Notes
  • Fog is created by overlaying semi-transparent circles at random positions and with random radius; alpha is controlled by alpha_coef.
  • Higher fog_coef values give denser fog; effect is typically stronger toward center and gradually decreases toward the edges.
  • A Gaussian blur (dependent on the shorter image dimension) is applied after blending to reduce sharpness.
See Also
  • AtmosphericFog: Depth-dependent fog via scattering; use when you need distance-based haze.
  • RandomRain: Rain streaks and blur for rainy conditions.
  • RandomSnow: Snow overlay for winter conditions.