write_probability_heatmap_as_ome_tiff¶
- write_probability_heatmap_as_ome_tiff(image_path, probability, tile_size=(64, 64), levels=2, mpp=(0.25, 0.25), colormap=2)[source]¶
Saves output probability maps from segmentation models as heatmaps.
This function converts the probability maps from individual classes to heatmaps and saves them as pyramidal ome tiffs.
- Parameters:
image_path (Path) – File path (including extension) to save image to.
probability (np.ndarray or zarr.core.Array) – The input image data in YXC (Height, Width, Channels) format.
tile_size (tuple) – Tile/Chunk size (YX/HW) for writing the tiff file. Only allows tile shapes allowed by tifffile. Default is (64, 64).
levels (int) – Number of levels for saving pyramidal ome tiffs. Default is 2.
mpp (tuple[float, float]) – Tuple of mpp values in y and x (YX/HW). Default is (0.25, 0.25).
colormap (int) – Colormap to save the heatmaps. Default is 2 (cv2.COLORMAP_JET).
- Raises:
TypeError – If the input img is not a NumPy or Zarr array or does not have 3 dimensions.
ValueError – If input dimensions is not 3 (HWC) dimensions.
- Return type:
None
Examples
>>> probability_map = imread("path/to/probability_map") >>> write_probability_heatmap_as_ome_tiff( ... image_path=image_path, ... probability=probability_map, ... tile_size=(64, 64), ... class_name="tumor", ... levels=2, ... mpp=(0.5, 0.5), ... colormap=cv2.COLORMAP_JET, ... )