tf.keras.visualization.draw_segmentation_masks

Draws segmentation masks on images.

The function overlays segmentation masks on the input images. The masks are blended with the images using the specified alpha value.

images A batch of images as a 4D tensor or NumPy array. Shape should be (batch_size, height, width, channels).
segmentation_masks A batch of segmentation masks as a 3D or 4D tensor or NumPy array. Shape should be (batch_size, height, width) or (batch_size, height, width, 1). The values represent class indices starting from 1 up to num_classes. Class 0 is reserved for the background and will be ignored if ignore_index is not 0.
num_classes The number of segmentation classes. If None, it is inferred from the maximum value in segmentation_masks.
color_mapping A dictionary mapping class indices to RGB colors. If None, a default color palette is generated. The keys should be integers starting from 1 up to num_classes.
alpha The opacity of the segmentation masks. Must be in the range [0, 1].
blend Whether to blend the masks with the input image using the alpha value. If False, the masks are drawn directly on the images without blending. Defaults to True.
ignore_index The class index to ignore. Mask pixels with this value will not be drawn. Defaults to -1.
data_format Image data format, either "channels_last" or "channels_first". Defaults to the image_data_format value found in your Keras config file at ~/.keras/keras.json. If you never set it, then it will be "channels_last".

A NumPy array of the images with the segmentation masks overlaid.

ValueError If the input images is not a 4D tensor or NumPy array.
TypeError If the input segmentation_masks is not an integer type.