pub trait ImageArray<P: Pixel, ImageContainer> {
// Required methods
fn as_ndarray(&self) -> ArrayView3<'_, ImageContainer>;
fn as_ndarray_mut(&mut self) -> ArrayViewMut3<'_, 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.
Views and standard-layout ownership conversions reuse the original allocation. Non-standard layouts are copied into image row order.
Required Methods§
Sourcefn as_ndarray(&self) -> ArrayView3<'_, ImageContainer>
fn as_ndarray(&self) -> ArrayView3<'_, ImageContainer>
Cast the ImageBuffer as an ArrayView3.
Yindex is the rowXindex is the columnsZindex 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.
Sourcefn as_ndarray_mut(&mut self) -> ArrayViewMut3<'_, ImageContainer>
fn as_ndarray_mut(&mut self) -> ArrayViewMut3<'_, ImageContainer>
Cast the ImageBuffer as an ArrayViewMut3.
Yindex is the rowXindex is the columnsZindex 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.
Sourcefn to_ndarray(self) -> Array3<ImageContainer>
fn to_ndarray(self) -> Array3<ImageContainer>
Interpret the ImageBuffer as an Array3.
Yindex is the rowXindex is the columnsZindex is the channel
So when referencing:
array[[y, x, z]]
This does not copy the data, but it does consume the buffer.
Sourcefn from_ndarray<D: Dimension>(
array: Array<ImageContainer, D>,
) -> Result<ImageBuffer<P, Vec<ImageContainer>>, Error>
fn from_ndarray<D: Dimension>( array: Array<ImageContainer, D>, ) -> Result<ImageBuffer<P, Vec<ImageContainer>>, Error>
Convert the provided array into the ImageBuffer
Yindex is the rowXindex is the columnsZindex is the channel
So when referencing:
array[[y, x, z]]
This consumes the array. Standard layouts reuse its allocation; other layouts are copied into row-major pixel order.
§Errors
Returns Error::Dimensions if the array is not 2D or 3D, or its size does not fit
into the image dimensions, Error::ChannelMismatch if the channel count differs from
the pixel type, and Error::ImageConstructFailed if the buffer cannot back an image.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<P, C> ImageArray<P, C> for ImageBuffer<P, Vec<C>>
Available on crate feature image only.
impl<P, C> ImageArray<P, C> for ImageBuffer<P, Vec<C>>
image only.