It’s a heck of a lot faster than my code, the canny/sobel operators especially. Also it works. See photos for more.
The first is the original with 5×5 blur to reduce the noise, the second is adaptive threshold and the third is a canny edge detection. Takes about a 1/100th of the time to run on my netbook compared to image magick and my own stuff. Awesome.