Struct imgproc_rs::image::Image[][src]

pub struct Image<T: Number> { /* fields omitted */ }

A struct representing an image

Implementations

impl<T: Number> Image<T>[src]

pub fn from_slice(
    width: u32,
    height: u32,
    channels: u8,
    alpha: bool,
    data: &[T]
) -> Self
[src]

Creates a new Image<T> from a slice

pub fn from_vec(
    width: u32,
    height: u32,
    channels: u8,
    alpha: bool,
    data: Vec<T>
) -> Self
[src]

Creates a new Image<T> from a vector

pub fn from_vec_of_vec(
    width: u32,
    height: u32,
    channels: u8,
    alpha: bool,
    data: Vec<Vec<T>>
) -> Self
[src]

Creates a new Image<T> from a vector of vectors

pub fn from_vec_of_slice(
    width: u32,
    height: u32,
    channels: u8,
    alpha: bool,
    data: Vec<&[T]>
) -> Self
[src]

Creates a new Image<T> from a vector of slices

pub fn blank(info: ImageInfo) -> Self[src]

Creates an Image<T> populated with zeroes

pub fn empty(info: ImageInfo) -> Self[src]

Creates an empty Image<T>

pub fn index(&self, x: u32, y: u32) -> usize[src]

Returns the 1d index corresponding to the 2d (x, y) indices

pub fn data(&self) -> &[T][src]

Returns all data as a slice

pub fn data_mut(&mut self) -> &mut [T][src]

Returns all data as a mutable slice

pub fn get_pixel_unchecked(&self, x: u32, y: u32) -> &[T][src]

Returns a slice representing the pixel located at (x, y) without checking index bounds

pub fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut [T][src]

Returns a mutable slice representing the pixel located at (x, y)

Panics

Panics if x or y is out of bounds

pub fn get_pixel_mut_unchecked(&mut self, x: u32, y: u32) -> &mut [T][src]

Returns a mutable slice representing the pixel located at (x, y) without checking index bounds

pub fn get_subimage(
    &self,
    x: u32,
    y: u32,
    width: u32,
    height: u32
) -> SubImage<'_, T>
[src]

Returns a SubImage<T> representing the part of the image of width width and height height, with upper left hand corner located at (x, y)

Panics

Panics if x or y is out of bounds

pub fn get_neighborhood_1d(
    &self,
    x: u32,
    y: u32,
    size: u32,
    is_vert: bool
) -> SubImage<'_, T>
[src]

Returns a SubImage<T> representing the row or column of pixels of length size centered at (x, y). If is_vert is true, returns the column; otherwise, returns the row. Uses clamp padding for edge pixels (edge pixels are repeated indefinitely)

Panics

Panics if x or y is out of bounds

pub fn get_neighborhood_2d(&self, x: u32, y: u32, size: u32) -> SubImage<'_, T>[src]

Returns a SubImage<T> representing the “square” of pixels of side length size centered at (x, y). Uses clamp padding for edge pixels (edge pixels are repeated indefinitely)

Panics

Panics if x or y is out of bounds

pub fn set_pixel(&mut self, x: u32, y: u32, pixel: &[T])[src]

Replaces the pixel located at (x, y) with pixel

Panics

Panics if the length of pixel is not equal to the number of channels in the image or x or y is out of bounds

pub fn set_pixel_indexed(&mut self, index: usize, pixel: &[T])[src]

Replaces the pixel at index index with pixel

Panics

Panics if the length of pixel is not equal to the number of channels in the image

pub fn map_pixels<S: Number, F>(&self, f: F) -> Image<S> where
    F: Fn(&[T]) -> Vec<S>, 
[src]

Applies function f to each pixel

pub fn map_pixels_if_alpha<S: Number, F, G>(&self, f: F, g: G) -> Image<S> where
    F: Fn(&[T]) -> Vec<S>,
    G: Fn(T) -> S, 
[src]

If alpha, applies function f to the non-alpha portion of each pixel and applies function g to the alpha channel of each pixel; otherwise, applies function f to each pixel

pub fn map_channels<S: Number, F>(&self, f: F) -> Image<S> where
    F: Fn(T) -> S, 
[src]

Applies function f to each channel of each pixel

pub fn map_channels_if_alpha<S: Number, F, G>(&self, f: F, g: G) -> Image<S> where
    F: Fn(T) -> S,
    G: Fn(T) -> S, 
[src]

If alpha, applies function f to each non-alpha channel of each pixel and applies function g to the alpha channel of each pixel; otherwise, applies function f to each channel of each pixel

pub fn apply_pixels<F>(&mut self, f: F) where
    F: Fn(&[T]) -> Vec<T>, 
[src]

Applies function f to each pixel

pub fn apply_pixels_if_alpha<F, G>(&mut self, f: F, g: G) where
    F: Fn(&[T]) -> Vec<T>,
    G: Fn(T) -> T, 
[src]

If alpha, applies function f to the non-alpha portion of each pixel and applies function g to the alpha channel of each pixel; otherwise, applies function f to each pixel

pub fn apply_channels<F>(&mut self, f: F) where
    F: Fn(T) -> T, 
[src]

Applies function f to each channel of each pixel

pub fn apply_channels_if_alpha<F, G>(&mut self, f: F, g: G) where
    F: Fn(T) -> T,
    G: Fn(T) -> T, 
[src]

If alpha, applies function f to each non-alpha channel of each pixel and applies function g to the alpha channel of each pixel; otherwise, applies function f to each channel of each pixel

pub fn edit_channel<F>(&mut self, f: F, index: usize) where
    F: Fn(T) -> T, 
[src]

Applies function f to each channel of index index of each pixel. Modifies self

Trait Implementations

impl<T: Number> BaseImage<T> for Image<T>[src]

impl<T: Clone + Number> Clone for Image<T>[src]

impl<T: Debug + Number> Debug for Image<T>[src]

impl From<Image<f32>> for Image<f64>[src]

impl From<Image<f32>> for Image<u8>[src]

impl From<Image<f64>> for Image<u8>[src]

impl From<Image<u128>> for Image<f64>[src]

impl From<Image<u16>> for Image<f64>[src]

impl From<Image<u32>> for Image<f64>[src]

impl From<Image<u64>> for Image<f64>[src]

impl From<Image<u8>> for Image<f64>[src]

impl From<Image<usize>> for Image<f64>[src]

impl<T: Number> Index<usize> for Image<T>[src]

type Output = [T]

The returned type after indexing.

impl<T: Number> IndexMut<usize> for Image<T>[src]

impl<'a, T: Number> IntoIterator for &'a Image<T>[src]

type Item = (u32, u32, &'a [T])

The type of the elements being iterated over.

type IntoIter = PixelIter<'a, T>

Which kind of iterator are we turning this into?

impl<T: PartialEq + Number> PartialEq<Image<T>> for Image<T>[src]

impl<T: Number> StructuralPartialEq for Image<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Image<T> where
    T: RefUnwindSafe

impl<T> Send for Image<T>

impl<T> Sync for Image<T>

impl<T> Unpin for Image<T> where
    T: Unpin

impl<T> UnwindSafe for Image<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.