blur module#

class selective_blur.blurring.blur.Selector(image_path: str, model: str, mask: ndarray = None)[source]#

Bases: SimpleBlur

Class to interactively select blur level from an image

select_kernel_size()[source]#

Select max kernel for gaussian blur, applied with SimpleBlur, with Jupyter widget slider

class selective_blur.blurring.blur.SimpleBlur(image_path: str, model: str, mask: ndarray = None)[source]#

Bases: object

Class to apply depth-aware blur to an image using MiDaS model by Intel

blur(kernel: int)[source]#

Applies gaussian blur based on the depth decile in which the pixel falls into. The process is the following:

  1. The pixel depth values obtained with MiDaS are divided into deciles.

  2. If user has provided a mask array for the image, its average depth value is computed. If it is greater or equal to the median overall depth value of the image (subject near the camera objective) the blur will be higher for more distant subjects, if less or equal, and vice versa.

  3. If the mask has not been provided, more far objects will have a higher blur level by default (increasing filter size corresponds to lower deciles).

Parameters:

kernel (int) – the max kernel size dimension for gaussian blur

show_depth_map()[source]#
show_image(image: array)[source]#