pub fn crop<P>(image: &Image<P>, rect: Rect) -> Image<P>
where
    P: Pixel,
{
    assert!(rect.x + rect.width <= image.width());
    assert!(rect.y + rect.height <= image.height());

    Image::from_fn(rect.width, rect.height, |x, y| {
        *image.get_pixel(rect.x + x, rect.y + y)
    })
}
Crops an image to a given rectangle.

# Panics

- If `rect.x + rect.width > image.width()`
- If `rect.y + rect.height > image.height()`

# Examples
```
use imageproc::compose::crop;
use image::math::Rect;
use imageproc::gray_image;

let image = gray_image!(
0, 0, 0, 0, 0, 0;
0, 0, 0, 1, 1, 0;
0, 0, 0, 1, 1, 0;
0, 0, 0, 1, 1, 0;
0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0);

let cropped = crop(&image, Rect {x: 3, y: 1, width: 2, height: 3});

assert_eq!(cropped, gray_image!(
1, 1;
1, 1;
1, 1));
```
src/compose.rs