RandomGravel

Targets:
image
volume
Image Types:uint8, float32

Adds gravel-like artifacts to the input image.

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.

Arguments
gravel_roi
tuple[float, float, float, float]
[0.1,0.4,0.9,0.9]

Region 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_patches
int
2

Number of gravel patch regions to generate within the ROI. Each patch will contain multiple gravel particles. Default: 2.

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)

# 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"]
Notes
  • The gravel effect is created by modifying the saturation channel in the HLS color space.
  • Gravel particles are distributed within randomly generated patches inside the specified ROI.
  • This transform is particularly useful for:
    • Augmenting datasets for road condition analysis
    • Simulating variations in terrain for computer vision tasks
    • Adding realistic texture to synthetic images of outdoor scenes