added some optimizations. one optimization is subsampling. actually I think I added that in the previous commit. but I made it clearer here. also, when scanning a line, rather than looking at the whole image, it only looks at the pixels around where the previous line location was. could lead to missing pixels, but will increase speed greatly for a relatively flat scene.