Figure¶
-
class
show.
Figure
(image, annotation, color_map={0: (0.0, 0.0, 0.0), 1: (0.0, 0.8, 1.0), 2: (1.0, 0.8, 0.0), 3: (1.0, 0.4, 0.0)})[source]¶ An open annotated WSI.
Parameters: - image: PIL Image
Image to display; a thumbnail or region read from WSI.
- annotation: Numpy 2D array
Annotation labels for each pixel in the input
image
.- color_map: dict {label int: RGB color list}
Mapping of RGB color values to class labels. Colors are triplet lists of the R, G, and B values.
Examples
>>> from wsipre import show >>> colors = {0: (0, 0, 0), 2: (1, 0, 0)} >>> fig = show.Figure(image=image, annotation=mask, color_map=colors) >>> fig.color_map {0: (0, 0, 0), 2: (1, 0, 0)}
>>> fig.show_label_colors(height=5)
>>> fig.show_image_with_annotation()
Attributes: - image: PIL Image
The input
image
.- annotation: Numpy 2D array
The input
annotation
.- color_map: dict {label: color}
Mapping between each label and the color for visualization.
Methods
show_annotation
()Show loaded image annotation. show_image
()Show loaded image. show_image_with_annotation
([split])Show loaded image and annotation. show_label_colors
([width, height, …])Display a color bar with the colors and overlayed labels. -
show_annotation
()[source]¶ Show loaded image annotation.
Display the loaded WSI thumbnail or region annotation, corresponding to a mask of pixel-wise labels.
Returns: - Matplotlib image.
-
show_image
()[source]¶ Show loaded image.
Display the loaded WSI thumbnail or region.
Returns: - Matplotlib image.
-
show_image_with_annotation
(split=True)[source]¶ Show loaded image and annotation.
Parameters: - split: bool
Whether to display the split image and annotation side-by-side or a combined visualization of the annotation on the image.
Returns: - Matplotlib image.
-
show_label_colors
(width=20, height=6, font_color='w', font_size=14)[source]¶ Display a color bar with the colors and overlayed labels.
Parameters: - width: int
Width of each class rectangle in plot.
- height: int
Height of each class rectangle in plot.
- font_size: int
Size of the font used to display class labels.
Returns: - Matplotlib image illustrating mapping between class label and color.