draw_thing_contours
Overlay coloured contours on a background image from an instance labelled raster mask.
Note
If a semantic type_map
is provided, the contours will be coloured according to the type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
ndarray
|
Original image. Shape (H, W, 3). |
required |
inst_map
|
ndarray
|
Instance segmentation map. Shape (H, W). |
required |
type_map
|
ndarray
|
Semantic segmentation map. Shape (H, W). |
required |
thickness
|
int
|
Thickness of the contour lines |
2
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The contours overlaid on top of original image. Shape: (H, W, 3). |
Examples:
>>> import matplotlib.pyplot as plt
>>> from histolytics.utils.plot import draw_thing_contours
>>> from histolytics.data import (
... hgsc_cancer_he,
... hgsc_cancer_inst_mask,
... hgsc_cancer_type_mask,
... )
>>> # Load the HE image, instance mask and type mask
>>> he_image = hgsc_cancer_he()
>>> inst_mask = hgsc_cancer_inst_mask()
>>> type_mask = hgsc_cancer_type_mask()
>>> # Draw contours of the instance segmentation mask
>>> overlay = draw_thing_contours(
... he_image,
... inst_mask,
... type_mask,
... thickness=2,
... )
>>> # Display the overlay
>>> fig, ax = plt.subplots(figsize=(5, 5))
>>> ax.imshow(overlay)
>>> ax.set_axis_off()