Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::SegmentationImage Struct Reference

Archetype: An image made up of integer components::ClassIds. More...

#include <rerun/archetypes/segmentation_image.hpp>

Public Types

using IndicatorComponent = rerun::components::IndicatorComponent< IndicatorComponentName >
 Indicator component, used to identify the archetype when converting to a list of components.
 

Public Member Functions

template<typename TElement >
 SegmentationImage (const TElement *pixels, WidthHeight resolution)
 Constructs image from pointer + resolution, inferring the datatype from the pointer type.
 
template<typename TElement >
 SegmentationImage (Collection< TElement > pixels, WidthHeight resolution)
 Constructs image from pixel data + resolution with datatype inferred from the passed collection.
 
 SegmentationImage (const void *bytes, WidthHeight resolution, datatypes::ChannelDatatype datatype)
 Constructs image from pixel data + resolution with explicit datatype.
 
 SegmentationImage (Collection< uint8_t > bytes, WidthHeight resolution, datatypes::ChannelDatatype datatype)
 Constructs image from pixel data + resolution + datatype.
 
 SegmentationImage (SegmentationImage &&other)=default
 
SegmentationImage with_opacity (rerun::components::Opacity _opacity) &&
 Opacity of the image, useful for layering the segmentation image on top of another image.
 
SegmentationImage with_draw_order (rerun::components::DrawOrder _draw_order) &&
 An optional floating point value that specifies the 2D drawing order.
 

Public Attributes

rerun::components::ImageBuffer buffer
 The raw image data.
 
rerun::components::ImageFormat format
 The format of the image.
 
std::optional< rerun::components::Opacityopacity
 Opacity of the image, useful for layering the segmentation image on top of another image.
 
std::optional< rerun::components::DrawOrderdraw_order
 An optional floating point value that specifies the 2D drawing order.
 

Static Public Attributes

static constexpr const char IndicatorComponentName []
 

Detailed Description

Archetype: An image made up of integer components::ClassIds.

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.

Since the underlying rerun::datatypes::TensorData uses rerun::Collection internally, data can be passed in without a copy from raw pointers or by reference from std::vector/std::array/c-arrays. If needed, this "borrow-behavior" can be extended by defining your own rerun::CollectionAdapter.

Example

Simple segmentation image

image

#include <rerun.hpp>
#include <algorithm> // std::fill_n
#include <vector>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_segmentation_image");
rec.spawn().exit_on_failure();
// Create a segmentation image
const int HEIGHT = 8;
const int WIDTH = 12;
std::vector<uint8_t> data(WIDTH * HEIGHT, 0);
for (auto y = 0; y <4; ++y) { // top half
std::fill_n(data.begin() + y * WIDTH, 6, static_cast<uint8_t>(1)); // left half
}
for (auto y = 4; y <8; ++y) { // bottom half
std::fill_n(data.begin() + y * WIDTH + 6, 6, static_cast<uint8_t>(2)); // right half
}
// create an annotation context to describe the classes
rec.log_static(
"/",
rerun::AnnotationInfo(1, "red", rerun::Rgba32(255, 0, 0)),
rerun::AnnotationInfo(2, "green", rerun::Rgba32(0, 255, 0)),
})
);
rec.log("image", rerun::SegmentationImage(data.data(), {WIDTH, HEIGHT}));
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60
Archetype: The annotation context provides additional information on how to display entities.
Definition annotation_context.hpp:65
Archetype: An image made up of integer components::ClassIds.
Definition segmentation_image.hpp:74
Datatype: Annotation info annotating a class id or key-point id.
Definition annotation_info.hpp:26
Datatype: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition rgba32.hpp:28

Constructor & Destructor Documentation

◆ SegmentationImage() [1/4]

template<typename TElement >
rerun::archetypes::SegmentationImage::SegmentationImage ( const TElement *  pixels,
WidthHeight  resolution 
)
inline

Constructs image from pointer + resolution, inferring the datatype from the pointer type.

Parameters
pixelsThe raw image data. ⚠️ Does not take ownership of the data, the caller must ensure the data outlives the image. The number of elements is assumed to be W * H.
resolutionThe resolution of the image as {width, height}.

◆ SegmentationImage() [2/4]

template<typename TElement >
rerun::archetypes::SegmentationImage::SegmentationImage ( Collection< TElement >  pixels,
WidthHeight  resolution 
)
inline

Constructs image from pixel data + resolution with datatype inferred from the passed collection.

Parameters
pixelsThe raw image data. If the data does not outlive the image, use std::move or create the rerun::Collection explicitly ahead of time with rerun::Collection::take_ownership. The length of the data should be W * H.
resolutionThe resolution of the image as {width, height}.

◆ SegmentationImage() [3/4]

rerun::archetypes::SegmentationImage::SegmentationImage ( const void *  bytes,
WidthHeight  resolution,
datatypes::ChannelDatatype  datatype 
)
inline

Constructs image from pixel data + resolution with explicit datatype.

Borrows data from a pointer (i.e. data must outlive the image!).

Parameters
bytesThe raw image data. ⚠️ Does not take ownership of the data, the caller must ensure the data outlives the image. The byte size of the data is assumed to be W * H * datatype.size
resolutionThe resolution of the image as {width, height}.
datatypeHow the data should be interpreted.

◆ SegmentationImage() [4/4]

rerun::archetypes::SegmentationImage::SegmentationImage ( Collection< uint8_t >  bytes,
WidthHeight  resolution,
datatypes::ChannelDatatype  datatype 
)
inline

Constructs image from pixel data + resolution + datatype.

Parameters
bytesThe raw image data as bytes. If the data does not outlive the image, use std::move or create the rerun::Collection explicitly ahead of time with rerun::Collection::take_ownership. The length of the data should be W * H.
resolutionThe resolution of the image as {width, height}.
datatypeHow the data should be interpreted.

Member Function Documentation

◆ with_opacity()

SegmentationImage rerun::archetypes::SegmentationImage::with_opacity ( rerun::components::Opacity  _opacity) &&
inline

Opacity of the image, useful for layering the segmentation image on top of another image.

Defaults to 0.5 if there's any other images in the scene, otherwise 1.0.

◆ with_draw_order()

SegmentationImage rerun::archetypes::SegmentationImage::with_draw_order ( rerun::components::DrawOrder  _draw_order) &&
inline

An optional floating point value that specifies the 2D drawing order.

Objects with higher values are drawn on top of those with lower values.

Member Data Documentation

◆ opacity

std::optional<rerun::components::Opacity> rerun::archetypes::SegmentationImage::opacity

Opacity of the image, useful for layering the segmentation image on top of another image.

Defaults to 0.5 if there's any other images in the scene, otherwise 1.0.

◆ draw_order

std::optional<rerun::components::DrawOrder> rerun::archetypes::SegmentationImage::draw_order

An optional floating point value that specifies the 2D drawing order.

Objects with higher values are drawn on top of those with lower values.

◆ IndicatorComponentName

constexpr const char rerun::archetypes::SegmentationImage::IndicatorComponentName[]
staticconstexpr
Initial value:
=
"rerun.components.SegmentationImageIndicator"

The documentation for this struct was generated from the following file: