Skip to main content

ImageView

Enum ImageView 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

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
Source

pub fn shape(&self) -> &[usize]

The (height, width, channels) shape, whatever the sample type.

Source

pub fn height(&self) -> usize

Row count.

Source

pub fn width(&self) -> usize

Column count.

Source

pub fn channels(&self) -> usize

Samples per pixel.

Source

pub fn as_u8(&self) -> Option<&TensorView<u8>>

The UInt8-sample tensor, if this view holds one.

Source

pub fn as_u16(&self) -> Option<&TensorView<u16>>

The UInt16-sample tensor, if this view holds one.

Source

pub fn as_f32(&self) -> Option<&TensorView<f32>>

The Float32-sample tensor, if this view holds one.

Source

pub fn get_f64(&self, index: &[usize]) -> Result<f64, DataError>

The sample at [row, column, channel], widened to f64 — every sample type this view can hold widens losslessly.

§Errors

Whatever the underlying TensorView::get reports.

Trait Implementations§

Source§

impl Clone for ImageView

Source§

fn clone(&self) -> ImageView

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ImageView

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FromPayload for ImageView

Source§

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeDebug for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more