Weather augmentations in Albumentations¶
This notebook demonstrates weather augmentations that are supported by Albumentations.
Import the required libraries¶
Define a function to visualize an image¶
Load the image from the disk¶
Python
image = cv2.imread('images/weather_example.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
Visualize the original image¶
RandomRain¶
We fix the random seed for visualization purposes, so the augmentation will always produce the same result. In a real computer vision pipeline, you shouldn't fix the random seed before applying a transform to the image because, in that case, the pipeline will always output the same image. The purpose of image augmentation is to use different transformations each time.
Python
transform = A.Compose(
[A.RandomRain(brightness_coefficient=0.9, drop_width=1, blur_value=5, p=1)],
)
random.seed(7)
transformed = transform(image=image)
visualize(transformed['image'])
RandomSnow¶
Python
transform = A.Compose(
[A.RandomSnow(brightness_coeff=2.5, snow_point_lower=0.3, snow_point_upper=0.5, p=1)],
)
random.seed(7)
transformed = transform(image=image)
visualize(transformed['image'])
RandomSunFlare¶
Python
transform = A.Compose(
[A.RandomSunFlare(flare_roi=(0, 0, 1, 0.5), angle_lower=0.5, p=1)],
)
random.seed(7)
transformed = transform(image=image)
visualize(transformed['image'])
RandomShadow¶
Python
transform = A.Compose(
[A.RandomShadow(num_shadows_lower=1, num_shadows_upper=1, shadow_dimension=5, shadow_roi=(0, 0.5, 1, 1), p=1)],
)
random.seed(7)
transformed = transform(image=image)
visualize(transformed['image'])