histo_kit.utils.apply_mask

Functions

apply_mask(img, mask, inv)

Apply a binary mask to an RGB image.

histo_kit.utils.apply_mask.apply_mask(img, mask, inv)[source]

Apply a binary mask to an RGB image.

Parameters:
  • img (ndarray, shape (H, W, 3)) – Input RGB image as a NumPy array.

  • mask (ndarray of bool, shape (H, W)) – Binary mask to apply to the image.

  • inv (bool) – If True, invert the mask before applying it.

Returns:

img_out – Image with the mask applied. Pixels outside the mask are set to 255.

Return type:

ndarray, shape (H, W, 3)

Notes

  • If the mask has no active pixels (all False), the original image is returned.

  • The mask is applied independently to each color channel.

  • Pixels corresponding to False in the mask are replaced by 255.