RandomSunFlare

Targets:
image
volume
Image Types:uint8, float32

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.

Arguments
flare_roi
tuple[float, float, float, float]
[0,0,1,0.5]

Region 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_range
tuple[float, float]
[0,1]

Range 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_range
tuple[int, int]
[6,10]

Range for the number of flare circles to generate. Default: (6, 10).

src_radius
int
400

Radius of the sun circle in pixels. Default: 400.

src_color
tuple[int, ...]
[255,255,255]

Color of the sun in RGB format. Default: (255, 255, 255).

method
overlay | physics_based
overlay

Method to use for generating the sun flare. "overlay" uses a simple alpha blending technique, while "physics_based" simulates more realistic optical phenomena. Default: "overlay".

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, [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"]