Add gravel-like particle artifacts on the image. Number and size of particles and ROI are configurable. Simulates dirt or debris on a lens or surface.
This transform simulates the appearance of gravel or small stones scattered across specific regions of an image. It's particularly useful for augmenting datasets of road or terrain images, adding realistic texture variations.
gravel_roiRegion of interest where gravel will be added, specified as (x_min, y_min, x_max, y_max) in relative coordinates [0, 1]. Default: (0.1, 0.4, 0.9, 0.9).
number_of_patchesNumber of gravel patch regions to generate within the ROI. Each patch will contain multiple gravel particles. Default: 2.
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)
# Default usage
>>> transform = A.RandomGravel(p=1.0)
>>> augmented_image = transform(image=image)["image"]
# Custom ROI and number of patches
>>> transform = A.RandomGravel(
... gravel_roi=(0.2, 0.2, 0.8, 0.8),
... number_of_patches=5,
... p=1.0
... )
>>> augmented_image = transform(image=image)["image"]
# Combining with other transforms
>>> transform = A.Compose([
... A.RandomGravel(p=0.7),
... A.RandomBrightnessContrast(p=0.5),
... ])
>>> augmented_image = transform(image=image)["image"]