LensFlare#

class augraphy.augmentations.lensflare.LensFlare(lens_flare_location='random', lens_flare_color='random', lens_flare_size=(0.5, 5), numba_jit=1, p=1)[source]#

Bases: Augmentation

Creates a lens flare effect by drawing a bright spot light with darker background.

Parameters:
  • lens_flare_location (tuple, optional) – Location (x,y) for the lens flare spot light location. Use “random” for random location.

  • lens_flare_color (tuple, optional) – Color of lens flare effect in BGR.

  • lens_flare_size (tuple, optional) – Tuple of floats in determining the size of the lens flare spot light.

  • numba_jit (int, optional) – The flag to enable numba jit to speed up the processing in the augmentation.

  • p (float, optional) – The probability that this Augmentation will be applied.

static generate_lens_flare(image, noise_mask, color_input, light_spot_size, resolution, flare_location)[source]#

Core function to generate lens flare effect.

Parameters:
  • image (numpy array) – The canvas of the lens flare effect.

  • noise_mask (numpy array) – The mask of noise for randomization.

  • color_input (numpy array) – Color in BGR format.

  • light_spot_size (float) – The size of spot light in lens flare effect.

  • resolution – The resolution of the lens flare effect.

  • flare_location (numpy array) – The location of the lens flare effect.

Overview#

The LensFlare augmentation creates a lens flare effect by drawing a bright spot light with darker background.

Initially, a clean image with single line of text is created.

Code example:

# import libraries
import cv2
import numpy as np
from augraphy import *


# create a clean image with single line of text
image = np.full((500, 1500,3), 250, dtype="uint8")
cv2.putText(
    image,
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
    (80, 250),
    cv2.FONT_HERSHEY_SIMPLEX,
    1.5,
    0,
    3,
)

cv2.imshow("Input image", image)

Clean image:

../../../_images/input.png

Example 1#

In this example, a LensFlare augmentation instance is initialized and location of the lens flare effect is set to random. The color of the effect is set to random too. For the size of spot light in lens flare effect, it is set to random value in between 0.5 and 5 (0.5, 5).

Code example:

lensflare = LensFlare(lens_flare_location = "random",
                      lens_flare_color = "random",
                      lens_flare_size = (0.5, 5),
                      )

img_lensflare = lensflare(image)
cv2.imshow("lensflare", img_lensflare)

Augmented image:

../../../_images/lens_flare.png