Simulate directional, corner, or local Gaussian lighting patterns to make training images more robust to varied illumination conditions.
This transform simulates different lighting conditions by applying controlled illumination patterns. It can create effects like:
These effects can be used to:
modeType of illumination pattern:
intensity_rangeRange for effect strength. Values between 0.01 and 0.2:
effect_typeType of lighting change:
angle_rangeRange for gradient angle in degrees. Controls direction of linear gradient:
center_rangeRange for spotlight position. Values between 0 and 1 representing relative position:
sigma_rangeRange for spotlight size. Values between 0.2 and 1.0:
num_spots_rangeInclusive range for the number of independently sampled Gaussian spots. Each spot has its own center, sigma, intensity, and effect sign. Overlapping spot fields are multiplied, so several spots can produce a stronger combined effect. Only used for 'gaussian' mode. Default: (1, 1)
gaussian_spotsOptional fixed Gaussian spots.
Each spot is represented as (center_x, center_y, sigma, signed_intensity). Providing this value bypasses
random spot sampling, and num_spots_range must equal the exact number of spots. Default: None
pProbability of applying the transform. Default: 0.5
>>> import numpy as np
>>> import albumentations as A
>>> image = np.full((100, 100, 3), 128, dtype=np.uint8)
>>> # Simulate sunlight through window
>>> transform = A.Illumination(
... mode='linear',
... intensity_range=(0.05, 0.1),
... effect_type='brighten',
... angle_range=(30, 60)
... )
>>> transformed_image = transform(image=image)["image"]
>>>
>>> # Create dramatic corner shadow
>>> transform = A.Illumination(
... mode='corner',
... intensity_range=(0.1, 0.2),
... effect_type='darken'
... )
>>> transformed_image = transform(image=image)["image"]
>>>
>>> # Add a random number of independently sampled bright and dark spots
>>> transform = A.Illumination(
... mode='gaussian',
... num_spots_range=(2, 4),
... intensity_range=(0.05, 0.15),
... effect_type='both',
... center_range=(0.1, 0.9),
... sigma_range=(0.2, 0.5),
... p=1.0,
... )
>>> transformed_image = transform(image=image)["image"]