imageproc::map

Function map_colors

Source
pub fn map_colors<I, P, Q, F>(image: &I, f: F) -> Image<Q>
where I: GenericImage<Pixel = P>, P: Pixel, Q: Pixel, F: Fn(P) -> Q,
Expand description

Applies f to the color of each pixel in the input image.

ยงExamples

use image::Rgb;
use imageproc::map::map_colors;

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

let rgb = rgb_image!(
    [1, 2, 3], [2, 4, 6];
    [3, 6, 9], [4, 8, 12]);

assert_pixels_eq!(
    map_colors(&image, |p| { Rgb([p[0], (2 * p[0]), (3 * p[0])]) }),
    rgb);