histo_kit.grand_qc.visualisation

Functions

make_artifacts_color_map(mask)

Convert a labeled mask into an RGB image using the Artifact Enum colors.

make_overlay(slide, wsi_heatmap_im, bg_mask, ...)

Overlay GrandQC artifact detection results on a downscaled WSI thumbnail.

histo_kit.grand_qc.visualisation.make_artifacts_color_map(mask)[source]

Convert a labeled mask into an RGB image using the Artifact Enum colors.

Each label in the mask must correspond to an integer value of Artifact.

Parameters:

mask (numpy.ndarray of shape (H, W)) – Mask image with integer labels corresponding to Artifact Enum values.

Returns:

rgb – RGB image with each artifact mapped to its specified color.

Return type:

numpy.ndarray of shape (H, W, 3), dtype uint8

Notes

  • Any label in the mask not present in Artifact will be displayed in black.

  • Colors are defined in the Artifact Enum via Artifact.color().

Examples

>>> import numpy as np
>>> mask = np.array([[0, 1], [2, 3]])
>>> rgb_image = make_artifacts_color_map(mask)
>>> import matplotlib.pyplot as plt
>>> plt.imshow(rgb_image)
>>> plt.show()
histo_kit.grand_qc.visualisation.make_overlay(slide, wsi_heatmap_im, bg_mask, vis_size)[source]

Overlay GrandQC artifact detection results on a downscaled WSI thumbnail.

This function combines the original slide thumbnail with the artifact heatmap, highlights tissue boundaries, and ensures that background regions remain visible.

Parameters:
  • slide (ndarray of shape (H, W, 3)) – RGB image of the WSI region (full resolution or pre-downsampled).

  • wsi_heatmap_im (PIL.Image.Image) – RGB mask image showing artifact detection results (e.g., colored by class).

  • bg_mask (ndarray of shape (H, W)) – Binary mask indicating tissue regions (1 - tissue, 0 - background).

  • vis_size (tuple of int (width, height)) – Desired size of the output thumbnail.

Returns:

overlay – RGB overlay image where artifact heatmap is created on the slide thumbnail. Tissue boundaries are drawn in blue, and background regions retain the original slide appearance.

Return type:

ndarray of shape (height, width, 3), dtype uint8

Notes

  • Uses cv2.addWeighted to blend the slide and heatmap with a fixed alpha (0.25 for slide, 0.75 for heatmap).

Examples

>>> overlay_image = make_overlay(slide_np, heatmap_image, tissue_mask, vis_size=(512, 512))
>>> plt.imshow(overlay_image)
>>> plt.show()