DepthSimulatedBlur#

class augraphy.augmentations.depthsimulatedblur.DepthSimulatedBlur(blur_center='random', blur_major_axes_length_range=(120, 200), blur_minor_axes_length_range=(120, 200), blur_iteration_range=(8, 10), p=1)[source]#

Bases: Augmentation

Creates a depth-simulated blur effect from a camera by blurring a small elliptical region of image.

Parameters:
  • blur_centerr – Center (x,y) of blur effect. Use “random” for random location.

  • blur_major_axes_length_range (tuple, optional) – Pair of ints determining the value of major axis in the blurring ellipse.

  • blur_minor_axes_length_range (tuple, optional) – Pair of ints determining the value of minor axis in the blurring ellipse.

  • blur_iteration_range (tuple, optional) – Pair of ints determining the value of number of blurring iterations. The higher the iteration number, the smoother the transition of blurring area to non blurring area. However, it runs slower with higher iterations number.

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

Overview#

The DepthSimulatedBlur augmentation creates a depth-simulated blur effect from a camera by blurring a small elliptical region of image

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 DepthSimulatedBlur augmentation instance is initialized and blur center is set to random location (blur_center = “random”). The blurring ellipse’s major and minor axes are to random value in between 120 and 200 (120,200).

Code example:

depthsimulatedblur = DepthSimulatedBlur(blur_center = "random",
                                        blur_major_axes_length_range = (120, 200),
                                        blur_minor_axes_length_range = (120, 200),
                                        )

img_depthsimulatedblur = depthsimulatedblur(image)
cv2.imshow("depthsimulatedblur", img_depthsimulatedblur)

Augmented image:

../../../_images/depth_simulated_blur.png