RandomSunFlare
Simulates a sun flare effect on the image by adding circles of light.
This transform creates a sun flare effect by overlaying multiple semi-transparent circles of varying sizes and intensities along a line originating from a "sun" point. It offers two methods: a simple overlay technique and a more complex physics-based approach.
flare_roiRegion of interest where the sun flare can appear. Values are in the range [0, 1] and represent (x_min, y_min, x_max, y_max) in relative coordinates. Default: (0, 0, 1, 0.5).
angle_rangeRange of angles (in radians) for the flare direction. Values should be in the range [0, 1], where 0 represents 0 radians and 1 represents 2π radians. Default: (0, 1).
num_flare_circles_rangeRange for the number of flare circles to generate. Default: (6, 10).
src_radiusRadius of the sun circle in pixels. Default: 400.
src_colorColor of the sun in RGB format. Default: (255, 255, 255).
methodMethod to use for generating the sun flare. "overlay" uses a simple alpha blending technique, while "physics_based" simulates more realistic optical phenomena. Default: "overlay".
pProbability of applying the transform. Default: 0.5.
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, [1000, 1000, 3], dtype=np.uint8)
# Default sun flare (overlay method)
>>> transform = A.RandomSunFlare(p=1.0)
>>> flared_image = transform(image=image)["image"]
# Physics-based sun flare with custom parameters
# Default sun flare
>>> transform = A.RandomSunFlare(p=1.0)
>>> flared_image = transform(image=image)["image"]
# Custom sun flare parameters
>>> transform = A.RandomSunFlare(
... flare_roi=(0.1, 0, 0.9, 0.3),
... angle_range=(0.25, 0.75),
... num_flare_circles_range=(5, 15),
... src_radius=200,
... src_color=(255, 200, 100),
... method="physics_based",
... p=1.0
... )
>>> flared_image = transform(image=image)["image"]- Lens flarehttps://en.wikipedia.org/wiki/Lens_flare
- Alpha compositinghttps://en.wikipedia.org/wiki/Alpha_compositing
- Diffractionhttps://en.wikipedia.org/wiki/Diffraction
- Chromatic aberrationhttps://en.wikipedia.org/wiki/Chromatic_aberration
- Screen blendinghttps://en.wikipedia.org/wiki/Blend_modes#Screen