ImageArray

Trait ImageArray 

Source
pub trait ImageArray<P: Pixel, ImageContainer> {
    // Required methods
    fn as_ndarray<'a>(&'a self) -> ArrayView3<'a, ImageContainer>;
    fn as_ndarray_mut<'a>(&'a mut self) -> ArrayViewMut3<'a, ImageContainer>;
    fn to_ndarray(self) -> Array3<ImageContainer>;
    fn from_ndarray<D: Dimension>(
        array: Array<ImageContainer, D>,
    ) -> Result<ImageBuffer<P, Vec<ImageContainer>>, Error>;
}
Expand description

Conversion methods for working with ndarrays.

All methods work without copying any data.

Required Methods§

Source

fn as_ndarray<'a>(&'a self) -> ArrayView3<'a, ImageContainer>

Cast the ImageBuffer as an ArrayView3.

  • Y index is the row
  • X index is the columns
  • Z index is the channel

So when referencing: array[[y, x, z]]

This does not copy the data, as it is a reference to the actual data in the buffer.

Source

fn as_ndarray_mut<'a>(&'a mut self) -> ArrayViewMut3<'a, ImageContainer>

Cast the ImageBuffer as an ArrayViewMut3.

  • Y index is the row
  • X index is the columns
  • Z index is the channel

So when referencing: array[[y, x, z]]

This does not copy the data, as it is a reference to the actual data in the buffer.

Source

fn to_ndarray(self) -> Array3<ImageContainer>

Interpret the ImageBuffer as an Array3.

  • Y index is the row
  • X index is the columns
  • Z index is the channel

So when referencing: array[[y, x, z]]

This does not copy the data, but it does consume the buffer.

Source

fn from_ndarray<D: Dimension>( array: Array<ImageContainer, D>, ) -> Result<ImageBuffer<P, Vec<ImageContainer>>, Error>

Convert the provided array into the ImageBuffer

  • Y index is the row
  • X index is the columns
  • Z index is the channel

So when referencing: array[[y, x, z]]

This does not copy the data, but it does consume the buffer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<P, C> ImageArray<P, C> for ImageBuffer<P, Vec<C>>
where P: Pixel<Subpixel = C>, C: Clone + Copy,

Available on crate feature image only.
Source§

fn as_ndarray<'a>(&'a self) -> ArrayView3<'a, C>

Source§

fn to_ndarray(self) -> Array3<C>

Source§

fn from_ndarray<D: Dimension>( array: Array<C, D>, ) -> Result<ImageBuffer<P, Vec<C>>, Error>

Source§

fn as_ndarray_mut<'a>(&'a mut self) -> ArrayViewMut3<'a, C>

Implementors§