pub fn row_running_sum(image: &GrayImage, row: u32, buffer: &mut [u32], padding: u32) {
    // TODO: faster, more formats
    let (width, height) = image.dimensions();
    let (width, padding) = (width as usize, padding as usize);
    assert!(
        buffer.len() >= width + 2 * padding,
        "Buffer length {} is less than {} + 2 * {}",
        buffer.len(),
        width,
        padding
    );
    assert!(row < height, "row out of bounds: {} >= {}", row, height);
    assert!(width > 0, "image is empty");

    let row_data = &(**image)[width * row as usize..][..width];
    let first = row_data[0] as u32;
    let last = row_data[width - 1] as u32;

    let mut sum = 0;

    for b in &mut buffer[..padding] {
        sum += first;
        *b = sum;
    }
    for (b, p) in buffer[padding..].iter_mut().zip(row_data) {
        sum += *p as u32;
        *b = sum;
    }
    for b in &mut buffer[padding + width..] {
        sum += last;
        *b = sum;
    }
}
Computes the running sum of one row of image, padded
at the beginning and end. The padding is by continuity.
Takes a reference to buffer so that this can be reused
for all rows in an image.

# Panics
- If `buffer.len() < 2 * padding + image.width()`.
- If `row >= image.height()`.
- If `image.width() == 0`.

# Examples
```
# extern crate image;
# #[macro_use]
# extern crate imageproc;
# fn main() {
use imageproc::integral_image::row_running_sum;

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

// Buffer has length two greater than image width, hence padding of 1
let mut buffer = [0; 5];
row_running_sum(&image, 0, &mut buffer, 1);

// The image is padded by continuity on either side
assert_eq!(buffer, [1, 2, 4, 7, 10]);
# }
```
src/integral_image.rs