imageproc::map

Function map_pixels_mut

Source
pub fn map_pixels_mut<I, P, F>(image: &mut I, f: F)
where I: GenericImage<Pixel = P>, P: Pixel, F: Fn(u32, u32, P) -> P,
Expand description

Applies f to each pixel in the input image in place.

ยงExamples

use image::Luma;
use imageproc::map::map_pixels_mut;

let mut image = gray_image!(
    1, 2;
    3, 4);

let want = gray_image!(
    1, 3;
    4, 6);

map_pixels_mut(&mut image, |x, y, p| {
    Luma([p[0] + x as u8 + y as u8])
});

assert_pixels_eq!(
    image,
    want);