imageproc 0.1.1

Image processing operations
//! Various ad-hoc messing around related to performance.

// Write a C-like implementation of integral image and compare
// to my current one. A linear running sum should be
// 1. really fast, and 2. the best possible case for the optimiser
// to remove any abstraction overhead, so if we can't make this case
// efficient it's bad news for the rest of the library.

#![feature(test)]
extern crate test;
extern crate num;

use num::{
    Num
};
//
// struct ArrayImage<T: Copy + Clone + Add<Rhs=> {
//     width: usize,
//     height: usize,
//     data: Vec<T>
// }
//
// // let x = 5;
// // let mp = &x as *mut i32;
// // let cp = &x as *const i32;
//
// impl<T> ArrayImage<T> {
//
//     fn new(width: usize, height: usize) -> ArrayImage<T> {
//         ArrayImage { data: vec![0u8; width * height], width: width, height: height}
//     }
//
//     fn clone(&self) -> ArrayImage<T> {
//         ArrayImage { data: self.data.clone(), width: self.width, height: self.height }
//     }
//
//     fn length(&self) -> usize {
//         self.width * self.height
//     }
// }
//
//
// // Backed by an array, read and write by bumping input/output pointers
// fn concrete_integral_image(image: &ArrayImage) -> ArrayImage {
//     let in_data = &image.data[0] as *const u8;
//     let out = image.clone();
//     let out_data = &out.data[0] as *mut i32;
//
//     // Check that this optimises to a memcpy, or find a memcpy implementation
//     let length = image.length() as isize;
//     for i in 0..length {
//         unsafe {
//             *out_data.offset(i) = *in_data.offset(i);
//         }
//     }
//
//     // for x in 1..out_width {
//     //     (*out.get_pixel_mut(x, 0))[0] += out.get_pixel(x - 1, 0)[0];
//     // }
//     //
//     // for y in 1..out_height {
//     //     (*out.get_pixel_mut(0, y))[0] += out.get_pixel(0, y - 1)[0];
//     //
//     //     for x in 1..out_width {
//     //         (*out.get_pixel_mut(x, y))[0] += out.get_pixel(x, y - 1)[0];
//     //         (*out.get_pixel_mut(x, y))[0] += out.get_pixel(x - 1, y)[0];
//     //         (*out.get_pixel_mut(x, y))[0] -= out.get_pixel(x - 1, y - 1)[0];
//     //     }
//     // }
//
//     out
// }
//
// #[bench]
// fn bench_something(b: &mut test::Bencher) {
//     let x = 1000;
//     b.iter(|| {
//         let mut y = 7;
//         for z in 0..x {
//             y = y % x;
//         }
//         test::black_box(y);
//         });
// }