Image

A monochrome or color image.

See also archetypes.DepthImage and archetypes.SegmentationImage.

Rerun also supports compressed images (JPEG, PNG, …), using archetypes.EncodedImage. For images that refer to video frames see archetypes.VideoFrameReference. Compressing images or using video data instead can save a lot of bandwidth and memory.

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.

Components components

Required: ImageBuffer, ImageFormat

Optional: Opacity, DrawOrder

Shown in shown-in

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

Logging images with various formats logging-images-with-various-formats

"""Create and log an image with various formats."""

import numpy as np
import rerun as rr

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

# Simple gradient image, logged in different formats.
image = np.array([[[x, min(255, x + y), y] for x in range(0, 256)] for y in range(0, 256)], dtype=np.uint8)
rr.log("image_rgb", rr.Image(image))
rr.log("image_green_only", rr.Image(image[:, :, 1], color_model="l"))  # Luminance only
rr.log("image_bgr", rr.Image(image[:, :, ::-1], color_model="bgr"))  # BGR

# New image with Separate Y/U/V planes with 4:2:2 chroma downsampling
y = bytes([128 for y in range(0, 256) for x in range(0, 256)])
u = bytes([x * 2 for y in range(0, 256) for x in range(0, 128)])  # Half horizontal resolution for chroma.
v = bytes([y for y in range(0, 256) for x in range(0, 128)])
rr.log("image_yuv422", rr.Image(bytes=y + u + v, width=256, height=256, pixel_format=rr.PixelFormat.Y_U_V16_FullRange))

Image from file, PIL & OpenCV image-from-file-pil--opencv

"""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))],
)