asi_core.visualization.masking

This module provides functions to visualize masks in all-sky imagers, like detected cloud layers.

Functions

overlay_mask(img, mask[, mask_color, alpha, asarray])

Overlays a binary mask onto an image with a specified color and transparency.

create_saturation_mask_image(img[, camera_mask, ...])

Create a saturation mask image by identifying and overlaying saturated regions on the input image.

Module Contents

asi_core.visualization.masking.overlay_mask(img, mask, mask_color=(255, 0, 0), alpha=0.5, asarray=True)

Overlays a binary mask onto an image with a specified color and transparency.

Parameters:
  • img – The input image, either as a NumPy array or a PIL Image.

  • mask – A binary mask (NumPy array) where nonzero values indicate the mask region.

  • mask_color – A tuple representing the RGB color of the mask (default is red: (255, 0, 0)).

  • alpha – A float (0 to 1) that controls the transparency of the overlay (default is 0.5).

  • asarray – If True, returns the result as a NumPy array; otherwise, returns a PIL Image.

Returns:

The image with the overlaid mask, either as a NumPy array or a PIL Image.

asi_core.visualization.masking.create_saturation_mask_image(img, camera_mask=None, text_position=(10, 10), font_size=40, asarray=True)

Create a saturation mask image by identifying and overlaying saturated regions on the input image.

Parameters:
  • img (numpy.ndarray) – The input image as a NumPy array.

  • camera_mask (numpy.ndarray, optional) – An optional binary mask specifying the valid region of the image (default is None, meaning all pixels are considered valid).

  • text_position (tuple[int, int], optional) – The position (x, y) where the saturation percentage text is drawn on the image (default is (10, 10)).

  • font_size (int, optional) – The font size of the saturation percentage text (default is 40).

  • asarray (bool, optional) – Whether to return the output as a NumPy array (default is True). If False, returns a PIL Image.

Returns:

The image with the saturation mask overlay, either as a NumPy array or a PIL Image.

Return type:

numpy.ndarray or PIL.Image.Image