[][src]Function imageproc::map::map_colors

pub fn map_colors<I, P, Q, F>(image: &I, f: F) -> Image<Q> where
    I: GenericImage<Pixel = P>,
    P: Pixel,
    Q: Pixel + 'static,
    F: Fn(P) -> Q, 

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);