AtmosphericFog

Targets:
image
Image Types:uint8, float32

Add depth-dependent fog via the atmospheric scattering equation and a synthetic depth map. Use for outdoor and driving robustness to haze.

Unlike RandomFog (which overlays circular fog patches), this transform uses a physically-based scattering model: farther pixels (by synthetic depth) get more fog, producing realistic distance-dependent haze. Depth is derived from image position (linear, diagonal, or radial), not from a real depth map.

Formula: result = image * exp(-density * depth) + fog_color * (1 - exp(-density * depth))

Arguments
density_range
tuple[float, float]
[1,3]

Range for fog density. Higher values give thicker fog. Default: (1.0, 3.0).

fog_color
tuple[int, ...]
[200,200,200]

Fog color per channel, e.g. (R, G, B) for 3 channels. Length must match image channels. Default: (200, 200, 200).

depth_mode
linear | diagonal | radial
linear

How synthetic depth is generated:

  • "linear": top of image = far, bottom = near (sky vs ground).
  • "diagonal": top-left = far.
  • "radial": center = near, edges = far. Default: "linear".
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)
>>> transform = A.AtmosphericFog(density_range=(1.0, 2.5), depth_mode="linear", p=1.0)
>>> result = transform(image=image)["image"]
>>> # Radial fog (center clear, edges foggy)
>>> transform_radial = A.AtmosphericFog(density_range=(1.5, 3.0), depth_mode="radial", p=1.0)
>>> result_radial = transform_radial(image=image)["image"]
Notes
  • Depth is synthetic (from pixel position), not from scene geometry.
  • For typical outdoor frames, "linear" matches sky far / ground near.
See Also
  • RandomFog: Patch-based fog without depth; simpler and faster when distance-dependent haze is not needed.
  • RandomRain: Rain streaks and blur for rainy-scene robustness.
  • RandomSnow: Snow overlay (bleach or texture) for winter conditions.
  • LensFlare: Starburst and ghost reflections for optical artifacts.