ReflectedLight#

class augraphy.augmentations.reflectedlight.ReflectedLight(reflected_light_smoothness=0.8, reflected_light_internal_radius_range=(0.0, 0.2), reflected_light_external_radius_range=(0.1, 0.8), reflected_light_minor_major_ratio_range=(0.9, 1.0), reflected_light_color=(255, 255, 255), reflected_light_internal_max_brightness_range=(0.9, 1.0), reflected_light_external_max_brightness_range=(0.75, 0.9), reflected_light_location='random', reflected_light_ellipse_angle_range=(0, 360), reflected_light_gaussian_kernel_size_range=(5, 310), p=1)[source]#

Bases: Augmentation

Creates reflected light effect by drawing ellipses of different brightness.

Parameters:
  • reflected_light_smoothness (float, optional) – Pair of floats determining the smoothness of ellipse. The value should be in range of 0 to 1. It runs slower when the smoothness value is higher.

  • reflected_light_internal_radius_range (tuple, optional) – Pair of ints determining the major length of non fading area (centroid) of ellipse.

  • reflected_light_external_radius_range (tuple, optional) – Pair of ints determining the major length of fading area of ellipse.

  • reflected_light_minor_major_ratio_range (tuple, optional) – Pair of floats determining the ratio of minor length to major length of the ellipse.

  • reflected_light_color (tuple, optional) – Color of the effect in BGR.

  • reflected_light_internal_max_brightness_range – Pair of floats determining the max brightness of the internal ellipse.

  • reflected_light_external_max_brightness_range (tuple, optional) – Pair of floats determining the max brightness of the external ellipse.

  • reflected_light_location (tuple, optional) – The location of the effect.

  • reflected_light_ellipse_angle_range (tuple, optional) – Pair of ints determining the angle of the ellipse.

  • reflected_light_gaussian_kernel_size_range (tuple, optional) – Pair of ints determining the Gaussian kernel value.

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

Overview#

The ReflectedLight augmentation creates a reflected light effect by drawing ellipses of different brightness.

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 ReflectedLight augmentation instance is initialized. The smoothness of the effect is set at 0.8 (0.8). The internal radius of ellipse is set to any value in between 0% to 20% of the image minimum size (0.0, 0.2). The external radius of ellipse is set to any value in between 10% to 80% of the image minimum size (0.1, 0.8). The ratio of minor to major axes of ellipse is set to any value in between 10% to 80%. (0.1, 0.8). The reflect light color is set to white color (255,255,255). The internal ellipse max brightness is set to any value in between 90% to 100% brightness (0.9, 1.0). The external ellipse max brightness is set to 90% brightness (0.9, 0.9). The reflected light location is set to random location (“random”). The ellipse of reflected light effect is set to random angle (0, 360). The Gaussian kernel in blurring the effect is set to any value in between 5 to 310 (5, 310).

Code example:

reflected_light = NoiseTexturize(reflected_light_smoothness = 0.8,
                                 reflected_light_internal_radius_range=(0.0, 0.2),
                                 reflected_light_external_radius_range=(0.1, 0.8),
                                 reflected_light_minor_major_ratio_range = (0.9, 1.0),
                                 reflected_light_color = (255,255,255),
                                 reflected_light_internal_max_brightness_range=(0.9,1.0),
                                 reflected_light_external_max_brightness_range=(0.9,0.9),
                                 reflected_light_location = "random",
                                 reflected_light_ellipse_angle_range = (0, 360),
                                 reflected_light_gaussian_kernel_size_range = (5,310),
                                 )

img_reflected_light = reflected_light(image)
cv2.imshow("reflected_light", img_reflected_light

Augmented image:

../../../_images/reflected_light.png