BlurMask

class lib.align.aligned_mask.BlurMask(blur_type: Literal['gaussian', 'normalized'], mask: ndarray, kernel: int | float, is_ratio: bool = False, passes: int = 1)

Bases: object

Factory class to return the correct blur object for requested blur type.

Works for square images only. Currently supports Gaussian and Normalized Box Filters.

Parameters:
  • blur_type (T.Literal['gaussian', 'normalized']) – The type of blur to use

  • mask (np.ndarray) – The mask to apply the blur to

  • kernel (int | float) – Either the kernel size (in pixels) or the size of the kernel as a ratio of mask size

  • is_ratio (bool) – Whether the given kernel parameter is a ratio or not. If True then the actual kernel size will be calculated from the given ratio and the mask size. If False then the kernel size will be set directly from the kernel parameter. Default: False

  • passes (int) – The number of passes to perform when blurring. Default: 1

Example

>>> print(mask.shape)
(128, 128, 1)
>>> new_mask = BlurMask("gaussian", mask, 3, is_ratio=False, passes=1).blurred
>>> print(new_mask.shape)
(128, 128, 1)

Attributes Summary

blurred

The final mask with blurring applied.

Attributes Documentation

blurred

The final mask with blurring applied.

property blurred: ndarray

The final mask with blurring applied.