esc
Start typing to search the docs
Navigate Open

SegmentationImage

An image made up of integer components.ClassIds.

Each pixel corresponds to a components.ClassId that will be mapped to a color based on archetypes.AnnotationContext.

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

Use archetypes.AnnotationContext to associate each class with a color and a label.

Fields

Required

Optional

Can be shown in

Example

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))