pub fn map_pixels<P, Q, F>(image: &Image<P>, f: F) -> Image<Q>
where
    P: Pixel,
    Q: Pixel,
    F: Fn(P) -> Q,
{
    Image::from_vec(
        image.width(),
        image.height(),
        image
            .pixels()
            //optimisation: remove allocation if Pixel ever gets compile-time size information
            .flat_map(|pixel| f(*pixel).channels().to_vec())
            .collect(),
    )
    .expect("of course the length is good, it's just a map")
}
Applies `f` to each pixel of the input image.

# Examples
```
# extern crate image;
# #[macro_use]
# extern crate imageproc;
# fn main() {
use image::Rgb;
use imageproc::map::map_pixels;

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_pixels(&image, |p| { Rgb([p[0], (2 * p[0]), (3 * p[0])]) }),
rgb);
# }
```
src/map.rs