pub struct Image {
pub data: TensorData,
pub draw_order: Option<DrawOrder>,
}
Expand description
Archetype: A monochrome or color image.
The order of dimensions in the underlying TensorData
follows the typical
row-major, interleaved-pixel image format. Additionally, Rerun orders the
TensorDimension
s within the shape description from outer-most to inner-most.
As such, the shape of the TensorData
must be mappable to:
- A
HxW
tensor, treated as a grayscale image. - A
HxWx3
tensor, treated as an RGB image. - A
HxWx4
tensor, treated as an RGBA image.
Leading and trailing unit-dimensions are ignored, so that
1x480x640x3x1
is treated as a 480x640x3
RGB image.
Rerun also supports compressed image encoded as JPEG, N12, and YUY2.
Using these formats can save a lot of bandwidth and memory.
See crate::components::TensorData
for more.
§Example
§image_simple
:
use ndarray::{s, Array, ShapeBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_image").spawn()?;
let mut image = Array::<u8, _>::zeros((200, 300, 3).f());
image.slice_mut(s![.., .., 0]).fill(255);
image.slice_mut(s![50..150, 50..150, 0]).fill(0);
image.slice_mut(s![50..150, 50..150, 1]).fill(255);
rec.log("image", &rerun::Image::try_from(image)?)?;
Ok(())
}

Fields§
§data: TensorData
The 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
sourcepub const NUM_COMPONENTS: usize = 3usize
pub const NUM_COMPONENTS: usize = 3usize
The total number of components in the archetype: 1 required, 1 recommended, 1 optional
source§impl Image
impl Image
sourcepub fn new(data: impl Into<TensorData>) -> Image
pub fn new(data: impl Into<TensorData>) -> Image
Create a new Image
.
sourcepub fn with_draw_order(self, draw_order: impl Into<DrawOrder>) -> Image
pub fn with_draw_order(self, draw_order: impl Into<DrawOrder>) -> Image
An optional floating point value that specifies the 2D drawing order.
Objects with higher values are drawn on top of those with lower values.
source§impl Image
impl Image
sourcepub fn try_from<T>(data: T) -> Result<Image, ImageConstructionError<T>>
pub fn try_from<T>(data: T) -> Result<Image, 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>
source§fn name() -> ArchetypeName
fn name() -> ArchetypeName
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]>
source§fn recommended_components() -> Cow<'static, [ComponentName]>
fn recommended_components() -> Cow<'static, [ComponentName]>
source§fn optional_components() -> Cow<'static, [ComponentName]>
fn optional_components() -> Cow<'static, [ComponentName]>
source§fn all_components() -> Cow<'static, [ComponentName]>
fn all_components() -> Cow<'static, [ComponentName]>
source§fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)>
) -> Result<Image, DeserializationError>
fn from_arrow_components( arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)> ) -> Result<Image, DeserializationError>
ComponentNames
, deserializes them
into this archetype. Read moresource§fn from_arrow(
data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<Self, DeserializationError>where
Self: Sized,
fn from_arrow(
data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<Self, DeserializationError>where
Self: Sized,
source§impl AsComponents for Image
impl AsComponents for Image
source§fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
ComponentBatch
s. Read moresource§impl PartialEq for Image
impl PartialEq for Image
source§impl SizeBytes for Image
impl SizeBytes for Image
source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
self
on the heap, in bytes.source§fn total_size_bytes(&self) -> u64
fn total_size_bytes(&self) -> u64
self
in bytes, accounting for both stack and heap space.source§fn stack_size_bytes(&self) -> u64
fn stack_size_bytes(&self) -> u64
self
on the stack, in bytes. Read moresource§impl ToArchetype<Image> for LatestAtResults
impl ToArchetype<Image> for LatestAtResults
source§fn to_archetype(
&self,
resolver: &PromiseResolver
) -> PromiseResult<Result<Image, QueryError>>
fn to_archetype( &self, resolver: &PromiseResolver ) -> PromiseResult<Result<Image, QueryError>>
re_types_core::Archetype
. Read moreimpl StructuralPartialEq for Image
Auto Trait Implementations§
impl Freeze for Image
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more