RandomFog
Targets:
image
volume
Image Types:uint8, float32
Simulates fog for the image by adding random fog-like artifacts.
This transform creates a fog effect by generating semi-transparent overlays that mimic the visual characteristics of fog. The fog intensity and distribution can be controlled to create various fog-like conditions. An image size dependent Gaussian blur is applied to the resulting image
Arguments
fog_coef_rangetuple[float, float]
[0.3,1]
Range for fog intensity coefficient. Should be in [0, 1] range.
alpha_coeffloat
0.08
Transparency of the fog circles. Should be in [0, 1] range. Default: 0.08.
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)
# Default usage
>>> transform = A.RandomFog(p=1.0)
>>> foggy_image = transform(image=image)["image"]
# Custom fog intensity range
>>> transform = A.RandomFog(fog_coef_lower=0.3, fog_coef_upper=0.8, p=1.0)
>>> foggy_image = transform(image=image)["image"]
# Adjust fog transparency
>>> transform = A.RandomFog(fog_coef_lower=0.2, fog_coef_upper=0.5, alpha_coef=0.1, p=1.0)
>>> foggy_image = transform(image=image)["image"]Notes
- The fog effect is created by overlaying semi-transparent circles on the image.
- Higher fog coefficient values result in denser fog effects.
- The fog is typically denser in the center of the image and gradually decreases towards the edges.
- Image is blurred to decrease the sharpness
- This transform is useful for:
- Simulating various weather conditions in outdoor scenes
- Data augmentation for improving model robustness to foggy conditions
- Creating atmospheric effects in image editing
References
- Foghttps://en.wikipedia.org/wiki/Fog
- Atmospheric perspectivehttps://en.wikipedia.org/wiki/Aerial_perspective