AtmosphericFog
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))
density_rangeRange for fog density. Higher values give thicker fog. Default: (1.0, 3.0).
fog_colorFog color per channel, e.g. (R, G, B) for 3 channels. Length must match image channels. Default: (200, 200, 200).
depth_modeHow 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".
pProbability of applying the transform. Default: 0.5.
>>> 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"]- Depth is synthetic (from pixel position), not from scene geometry.
- For typical outdoor frames, "linear" matches sky far / ground near.
- 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.