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

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

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

let rgb = rgb_image!(
[1, 0, 0], [2, 1, 0];
[3, 0, 1], [4, 1, 1]);

assert_pixels_eq!(
map_enumerated_pixels(&image, |x, y, p| {
Rgb([p[0], x as u8, y as u8])
}),
rgb);
# }
```
src/map.rs