pub fn map_subpixels<P, F, S>(image: &Image<P>, f: F) -> Image<ChannelMap<P, S>>
where
    P: WithChannel<S>,
    S: Primitive,
    F: Fn(P::Subpixel) -> S,
{
    Image::from_vec(
        image.width(),
        image.height(),
        image.iter().map(|subpixel| f(*subpixel)).collect(),
    )
    .expect("of course the length is good, it's just a map")
}
Applies `f` to each subpixel of the input image.

# Examples
```
# extern crate image;
# #[macro_use]
# extern crate imageproc;
# fn main() {
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);
# }
```
src/map.rs