pub fn min_max<P, T>(image: &Image<P>) -> Vec<MinMax<T>>
where
    P: Pixel<Subpixel = T>,
    T: Ord + Copy,
{
    assert!(
        !image.is_empty(),
        "cannot find the min_max() of an empty image"
    );

    let mut ranges = vec![(None, None); P::CHANNEL_COUNT as usize];

    for pix in image.pixels() {
        for (i, c) in pix.channels().iter().enumerate() {
            let (current_min, current_max) = &mut ranges[i];

            if current_min.map_or(true, |x| c < x) {
                *current_min = Some(c);
            }
            if current_max.map_or(true, |x| c > x) {
                *current_max = Some(c);
            }
        }
    }

    ranges
        .into_iter()
        .map(|(min, max)| MinMax {
            min: *min.unwrap(),
            max: *max.unwrap(),
        })
        .collect()
}
Returns the minimum and maximum values per channel in an image.

# Panics

1. If `image.is_empty()`

# Examples

```
# extern crate image;
# #[macro_use]
# extern crate imageproc;
# fn main() {
use imageproc::stats::min_max;

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

// A greyscale image has only one channel.
let min_max = min_max(&image)[0];

assert_eq!(min_max.min, 1);
assert_eq!(min_max.max, 6);
# }
````
src/stats.rs