SegmentationImage
An image made up of integer components.ClassId
s.
The shape of the components.TensorData
must be mappable to an HxW
tensor.
Each pixel corresponds to a components.ClassId
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.
See also archetypes.AnnotationContext
to associate each class with a color and a label.
Components components
Required: TensorData
Shown in shown-in
- Spatial2DView
- Spatial3DView (if logged under a projection)
API reference links api-reference-links
- 🌊 C++ API docs for
SegmentationImage
- 🐍 Python API docs for
SegmentationImage
- 🦀 Rust API docs for
SegmentationImage
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))