SegmentationImage
An image made up of integer components.ClassId
s.
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.
See also archetypes.AnnotationContext
to associate each class with a color and a label.
Components components
Required: ImageBuffer
, ImageFormat
Shown in shown-in
- Spatial2DView
- Spatial3DView (if logged under a projection)
- DataframeView
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))