#[non_exhaustive]pub enum ImageView {
U8(TensorView<u8>),
U16(TensorView<u16>),
F32(TensorView<f32>),
}Expand description
The read-only views Payload::view decodes into (blueprint §9.1’s
let img: ImageView = data.view()?;).
They belong to astrs-data — a view is a checked window over columns
somebody else built, and the layout rules it checks are that crate’s — but
the line that names them is a node’s event loop, so a node reaches them
here rather than through a second crate. ImageView has a
FromPayload implementation (see message::media); TensorView is
the general n-dimensional form the same module builds on.
A (height, width, channels) view over one std/media/v1/Image row.
The sample type is exactly the row’s data column’s element type —
UInt8, UInt16 or Float32, per image_layout.
Match on the variant to work with the concrete TensorView directly,
or use ImageView::get_f64 for a type-erased read.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
U8(TensorView<u8>)
sample is UInt8 (mono8, rgb8, rgba8, bgr8, bgra8, the
Bayer mosaics).
U16(TensorView<u16>)
sample is UInt16 (mono16, rgb16, rgba16, bgr16, bgra16).
F32(TensorView<f32>)
sample is Float32 (mono32f, rgb32f, rgba32f).
Implementations§
Source§impl ImageView
impl ImageView
Sourcepub fn from_struct_row(
array: &StructArray,
row: usize,
) -> Result<ImageView, DataError>
pub fn from_struct_row( array: &StructArray, row: usize, ) -> Result<ImageView, DataError>
Builds a view over row row of a std/media/v1/Image-shaped struct
array (or of a payload’s own top-level column downcast to one).
§Errors
DataError::FieldNotFound—arrayis missing one ofwidth/height/channels/data.DataError::DowncastFailed— a field’s column is not the typeimage_layoutdeclares.DataError::RequiredFieldIsNull—width/height/channelsor the whole row is null.DataError::IndexOutOfBounds—row >= array.len().DataError::TypeMismatch—data’s element type is notUInt8/UInt16/Float32.DataError::TensorShapeMismatch—data’s row does not hold exactlywidth * height * channelssamples.
Sourcepub fn as_u8(&self) -> Option<&TensorView<u8>>
pub fn as_u8(&self) -> Option<&TensorView<u8>>
The UInt8-sample tensor, if this view holds one.
Sourcepub fn as_u16(&self) -> Option<&TensorView<u16>>
pub fn as_u16(&self) -> Option<&TensorView<u16>>
The UInt16-sample tensor, if this view holds one.
Sourcepub fn as_f32(&self) -> Option<&TensorView<f32>>
pub fn as_f32(&self) -> Option<&TensorView<f32>>
The Float32-sample tensor, if this view holds one.
Trait Implementations§
Source§impl FromPayload for ImageView
impl FromPayload for ImageView
Source§fn from_batch(batch: &RecordBatch) -> Result<Self>
fn from_batch(batch: &RecordBatch) -> Result<Self>
Reads an std/media/v1/Image payload as a checked N-D view.
This is the blueprint §9.1 shape: let img: ImageView = data.view()?;
— a view, not a copy, over the payload’s own sample column.