mask_tools module#

class selective_blur.masking.mask_tools.MaskEditor(mask: ndarray)[source]#

Bases: object

Class to refine the mask generated automatically with SAM2.

auto_denoise()[source]#

Function to clean automatically the mask by removing small segmented areas. The principle is the following:

  1. dimension of the closed True areas in the mask is computed

  2. the areas are placed in increasing order and divided into deciles

  3. small areas are converted into False, so that they wil no be included in the mask anymore. The parameter that defines the threshold (selected via interactive slider) under which areas are considered “small” is threshold, which refers to the decile of the area distribution.

manual_edit()[source]#

Allows to manually remove or add elements from the mask using bounding boxes (Jupyter widget)

selective_blur.masking.mask_tools.show_image_and_mask(image: ndarray, mask: ndarray)[source]#

Plot image and its masked version.

Parameters:
  • image (np.ndarray)

  • mask (np.ndarray)