The Canny edge detection operator was developed by John F. Canny in 1986 and uses a multi-stage algorithm to detect a wide range of edges in images.
While researching motion tracking questions I’ve faced Canny Detector and thought it would be great to run it in Flash. My first approach was to code it in pure AS3, ofcourse I failed. It uses lots of computations in 2D loops so Flash version was running at 12 FPS from 33 required. That time Mario Klingemann released his files from old presentation about image processing and BitmapData thresholding in general. I’ve noticed it was using PixelBender to threshold BitmapData objects. That was an idea!
I’ve never used pixelbender before so it was a little pain to learn whats going on there, also no traces available is terrible. It’s a long story to tell ya
finally we have 6 pixelbender filters and one flash class to handle detection. It runs pretty fast but I guess someone can do it even faster cause it was my first try and I dont know all bender possibilities.
See demo application (you will need web camera and Flash 10 installed)
Sources can be accessed in my Google repo
And here is some demo videos from developing timeline and more screenshots:
First version in pure AS3
First attemp in pixelbender







Great stuff!
I’ve implemented Difference of Gaussians purely in PB previously. It used similar implementation of my PB bilateral blur filter (http://blog.onthewings.net/2009/04/14/bilateral-blur-by-pixel-bender/). May be I’ll post that up later
Very impressive work – but then I’ve come to expect that from you! Great job.
Great work! Obviously I have to go through your code now to see where it can be optimized
.
First thing I spot rightaway is that you are using PB to calculate a Gaussian Blur. I think that is not the best way to use Pixel Bender. Using the native ConvolutionFilter or the BlurFilter is probably faster in this case. The problem with Pixelbender is that bitmaps have to get marshalled around which creates an overhead. The native blur filter (and probably the ConvolutionFilter as well) can use internal optimizations where they do not access the same pixel more often than once (for the whole bitmap), whilst PB runs the same code on every pixel and thus acesses the same pixel up to 8 times when you calculate a convolution kernel.
Very nice !
and BTW, Pinocchio is a very good comic book
@ALL thanx for commenting!
@Mario Klingemann
You right, Gauss Blur is not good solution in Pixel Bender but I needed to separate mixed values of this process for use in next functions. May be there is another approach for this to work. Got to look through it.
Awesome ᴖ ‿ ᴖ
Thx
Great works!!Looking forward to reading more about your understanding on pixel blender.
Great work man!
Really impressive!! Congratulations!
I’m now following you on twitter!
Did you find using pixelbender for thresholds results in better performance? From what Mario is saying, it may seem like pixelbender is more CPU intensive.
Using PixelBender here is a lot faster then doing it in pure AS.
But now I have an idea how to speed up pure version using Integral Image data for gaussian gradient computations.
How can you go from this edge detection to outputting vector lines that represent the edges?
I used the same technique to detect google map road boundaries. If only google could provide a view with no street names on it, with a physics engine, one could roam at the real map…
See @ http://labs.t-c.gr/t-c.gr/demos/canny_map/canny_map.jpg
Alexandros
Wow,Greate!