Trait image_hasher::Image

source ·
pub trait Image: GenericImageView + 'static {
    type Buf: Image + DiffImage;

    // Required methods
    fn to_grayscale(&self) -> Cow<'_, GrayImage>;
    fn blur(&self, sigma: f32) -> Self::Buf;
    fn foreach_pixel8<F>(&self, foreach: F)
       where F: FnMut(u32, u32, &[u8]);
}
Expand description

Shorthand trait bound for APIs in this crate.

Currently only implemented for the types provided by image with 8-bit channels.

Required Associated Types§

source

type Buf: Image + DiffImage

The equivalent ImageBuffer type for this container.

Required Methods§

source

fn to_grayscale(&self) -> Cow<'_, GrayImage>

Grayscale the image, reducing to 8 bit depth and dropping the alpha channel.

source

fn blur(&self, sigma: f32) -> Self::Buf

Blur the image with the given Gaussian sigma.

source

fn foreach_pixel8<F>(&self, foreach: F)where F: FnMut(u32, u32, &[u8]),

Iterate over the image, passing each pixel’s coordinates and values in u8 to the closure.

The iteration order is unspecified but each pixel must be visited exactly once.

If the pixel’s channels are wider than 8 bits then the values should be scaled to [0, 255], not truncated.

Note

If the pixel data length is 2 or 4, the last index is assumed to be the alpha channel. A pixel data length outside of [1, 4] will cause a panic.

Implementations on Foreign Types§

source§

impl Image for DynamicImage

§

type Buf = ImageBuffer<Rgba<u8>, Vec<u8, Global>>

source§

fn to_grayscale(&self) -> Cow<'_, GrayImage>

source§

fn blur(&self, sigma: f32) -> Self::Buf

source§

fn foreach_pixel8<F>(&self, foreach: F)where F: FnMut(u32, u32, &[u8]),

source§

impl<P, C> Image for ImageBuffer<P, C>where P: Pixel<Subpixel = u8> + 'static, C: Deref<Target = [u8]> + 'static,

§

type Buf = ImageBuffer<P, Vec<u8, Global>>

source§

fn to_grayscale(&self) -> Cow<'_, GrayImage>

source§

fn blur(&self, sigma: f32) -> Self::Buf

source§

fn foreach_pixel8<F>(&self, foreach: F)where F: FnMut(u32, u32, &[u8]),

Implementors§