Image
A monochrome or color image.
See also archetypes.DepthImage
and archetypes.SegmentationImage
.
The raw image data is stored as a single buffer of bytes in a components.Blob
.
The meaning of these bytes is determined by the components.ImageFormat
which specifies the resolution
and the pixel format (e.g. RGB, RGBA, …).
The order of dimensions in the underlying components.Blob
follows the typical
row-major, interleaved-pixel image format.
Rerun also supports compressed images (JPEG, PNG, …), using archetypes.EncodedImage
.
Compressing images can save a lot of bandwidth and memory.
Components components
Required: ImageBuffer
, ImageFormat
Shown in shown-in
- Spatial2DView
- Spatial3DView (if logged under a projection)
- DataframeView
API reference links api-reference-links
Examples examples
image_simple imagesimple
"""Create and log an image."""
import numpy as np
import rerun as rr
# Create an image with numpy
image = np.zeros((200, 300, 3), dtype=np.uint8)
image[:, :, 0] = 255
image[50:150, 50:150] = (0, 255, 0)
rr.init("rerun_example_image", spawn=True)
rr.log("image", rr.Image(image))
Advanced usage of send_columns
to send multiple images at once advanced-usage-of-sendcolumns-to-send-multiple-images-at-once
"""Send multiple images at once using `send_columns`."""
import numpy as np
import rerun as rr
rr.init("rerun_example_image_send_columns", spawn=True)
# Timeline on which the images are distributed.
times = np.arange(0, 20)
# Create a batch of images with a moving rectangle.
width, height = 300, 200
images = np.zeros((len(times), height, width, 3), dtype=np.uint8)
images[:, :, :, 2] = 255
for t in times:
images[t, 50:150, (t * 10) : (t * 10 + 100), 1] = 255
# Log the ImageFormat and indicator once, as static.
format_static = rr.components.ImageFormat(width=width, height=height, color_model="RGB", channel_datatype="U8")
rr.log("images", [format_static, rr.Image.indicator()], static=True)
# Send all images at once.
rr.send_columns(
"images",
times=[rr.TimeSequenceColumn("step", times)],
# Reshape the images so `ImageBufferBatch` can tell that this is several blobs.
#
# Note that the `ImageBufferBatch` consumes arrays of bytes,
# so if you have a different channel datatype than `U8`, you need to make sure
# that the data is converted to arrays of bytes before passing it to `ImageBufferBatch`.
components=[rr.components.ImageBufferBatch(images.reshape(len(times), -1))],
)