pub struct ImageU8 { /* private fields */ }Expand description
HWC u8 image wrapper: (width, height, channels, Vec<u8>).
Simple u8 image wrapper (HWC layout, row-major).
Implementations§
Source§impl ImageU8
impl ImageU8
Sourcepub fn new(
data: Vec<u8>,
height: usize,
width: usize,
channels: usize,
) -> Option<Self>
pub fn new( data: Vec<u8>, height: usize, width: usize, channels: usize, ) -> Option<Self>
Creates a new image from raw bytes. Returns None if length doesn’t match.
Sourcepub fn zeros(height: usize, width: usize, channels: usize) -> Self
pub fn zeros(height: usize, width: usize, channels: usize) -> Self
Creates a zero-filled image.
pub fn data(&self) -> &[u8] ⓘ
pub fn data_mut(&mut self) -> &mut [u8] ⓘ
pub fn height(&self) -> usize
pub fn width(&self) -> usize
pub fn channels(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn from_tensor(tensor: &Tensor) -> Option<Self>
pub fn from_tensor(tensor: &Tensor) -> Option<Self>
Convert from f32 Tensor [H,W,C] to u8 image (clamp to [0,255]).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImageU8
impl RefUnwindSafe for ImageU8
impl Send for ImageU8
impl Sync for ImageU8
impl Unpin for ImageU8
impl UnsafeUnpin for ImageU8
impl UnwindSafe for ImageU8
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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