SegmentationImage

An image made up of integer class-ids.

The shape of the TensorData must be mappable to an HxW tensor. Each pixel corresponds to a class-id that will be mapped to a color based on annotation context.

In the case of floating point images, the label will be looked up based on rounding to the nearest integer value.

Leading and trailing unit-dimensions are ignored, so that 1x640x480x1 is treated as a 640x480 image.

Components components

Required: TensorData

Optional: DrawOrder

Shown in shown-in

Example example

Simple segmentation image simple-segmentation-image

"""Create and log a segmentation image."""

import numpy as np
import rerun as rr

# Create a segmentation image
image = np.zeros((8, 12), dtype=np.uint8)
image[0:4, 0:6] = 1
image[4:8, 6:12] = 2

rr.init("rerun_example_segmentation_image", spawn=True)

# Assign a label and color to each class
rr.log("/", rr.AnnotationContext([(1, "red", (255, 0, 0)), (2, "green", (0, 255, 0))]), static=True)

rr.log("image", rr.SegmentationImage(image))