Function imageproc::map::map_subpixels

source ·
pub fn map_subpixels<I, P, F, S>(image: &I, f: F) -> Image<ChannelMap<P, S>>
where I: GenericImage<Pixel = P>, P: WithChannel<S>, S: Primitive, F: Fn(P::Subpixel) -> S,
Expand description

Applies f to each subpixel of the input image.

§Examples

use imageproc::map::map_subpixels;

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

let scaled = gray_image!(type: i16,
    -2, -4;
    -6, -8);

assert_pixels_eq!(
    map_subpixels(&image, |x| -2 * (x as i16)),
    scaled);