Struct re_types::archetypes::Image
source · pub struct Image {
pub data: TensorData,
pub draw_order: Option<DrawOrder>,
}Expand description
Archetype: A monochrome or color image.
The shape of the TensorData must be mappable to:
- A
HxWtensor, treated as a grayscale image. - A
HxWx3tensor, treated as an RGB image. - A
HxWx4tensor, treated as an RGBA image.
Leading and trailing unit-dimensions are ignored, so that
1x640x480x3x1 is treated as a 640x480x3 RGB image.
Example
image_simple:
ⓘ
//! Create and log an image
use ndarray::{s, Array, ShapeBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let (rec, storage) =
rerun::RecordingStreamBuilder::new("rerun_example_image_simple").memory()?;
let mut image = Array::<u8, _>::zeros((8, 12, 3).f());
image.slice_mut(s![.., .., 0]).fill(255);
image.slice_mut(s![0..4, 0..6, 0]).fill(0);
image.slice_mut(s![0..4, 0..6, 1]).fill(255);
rec.log("image", &rerun::Image::try_from(image)?)?;
rerun::native_viewer::show(storage.take())?;
Ok(())
}Fields§
§data: TensorDataThe image data. Should always be a rank-2 or rank-3 tensor.
draw_order: Option<DrawOrder>An optional floating point value that specifies the 2D drawing order.
Objects with higher values are drawn on top of those with lower values.
Implementations§
source§impl Image
impl Image
pub fn new(data: impl Into<TensorData>) -> Self
pub fn with_draw_order(self, draw_order: impl Into<DrawOrder>) -> Self
source§impl Image
impl Image
sourcepub fn try_from<T: TryInto<TensorData>>(
data: T
) -> Result<Self, ImageConstructionError<T>>
pub fn try_from<T: TryInto<TensorData>>( data: T ) -> Result<Self, ImageConstructionError<T>>
Try to construct an Image from anything that can be converted into TensorData
Will return an ImageConstructionError if the shape of the tensor data is invalid
for treating as an image.
This is useful for constructing an Image from an ndarray.
Trait Implementations§
source§impl Archetype for Image
impl Archetype for Image
§type Indicator = GenericIndicatorComponent<Image>
type Indicator = GenericIndicatorComponent<Image>
The associated indicator component, whose presence indicates that the high-level
archetype-based APIs were used to log the data. Read more
source§fn name() -> ArchetypeName
fn name() -> ArchetypeName
The fully-qualified name of this archetype, e.g.
rerun.archetypes.Points2D.source§fn indicator() -> MaybeOwnedComponentBatch<'static>
fn indicator() -> MaybeOwnedComponentBatch<'static>
source§fn required_components() -> Cow<'static, [ComponentName]>
fn required_components() -> Cow<'static, [ComponentName]>
Returns the names of all components that must be provided by the user when constructing
this archetype.
source§fn recommended_components() -> Cow<'static, [ComponentName]>
fn recommended_components() -> Cow<'static, [ComponentName]>
Returns the names of all components that should be provided by the user when constructing
this archetype.
source§fn optional_components() -> Cow<'static, [ComponentName]>
fn optional_components() -> Cow<'static, [ComponentName]>
Returns the names of all components that may be provided by the user when constructing
this archetype.
source§fn all_components() -> Cow<'static, [ComponentName]>
fn all_components() -> Cow<'static, [ComponentName]>
Returns the names of all components that must, should and may be provided by the user when
constructing this archetype. Read more
source§fn from_arrow(
arrow_data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> DeserializationResult<Self>
fn from_arrow( arrow_data: impl IntoIterator<Item = (Field, Box<dyn Array>)> ) -> DeserializationResult<Self>
Given an iterator of Arrow arrays and their respective field metadata, deserializes them
into this archetype. Read more
source§impl AsComponents for Image
impl AsComponents for Image
source§fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
Exposes the object’s contents as a set of
ComponentBatchs. Read moresource§fn num_instances(&self) -> usize
fn num_instances(&self) -> usize
The number of instances in each batch. Read more
source§impl PartialEq for Image
impl PartialEq for Image
impl StructuralPartialEq for Image
Auto Trait Implementations§
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more