Tuesday, May 27, 2008

Real Time Edge Detection in Flash









Over the last few weeks I've been working on some image processing in Flash. Heres the first post in what could be a series.

The program above shows 3 types of edge detection:

They vary in complexity, the basic sobel algorithm takes advantage of ActionScript 3's built in convolution filter and bitmapdata thresholding function (its not a true sobel edge but close).

The next option combines the two Sobel edges more precisely to create a Gradient Magnitude image. Each pixel is iterated over to combined using their absolute values.

For a tutorial of how to create the gradient magnitude image see this more recent post.

For non-maixima suppression I had to use the ByteArray Object to manipulate the image data. I've made a new implementation which is about 5x faster without need for ByteArrays. The frame rate slows by about 20% when compared with Sobel.

Non-maxima suppression creates 1 pixel thick edges very useful for other types of image processing (such as the Hough transform to find circles).

The code for the last two is based on an excellent tutorial on image processing here.

Thanks for reading.

Labels: ,

10 Comments:

Anonymous LAJ said...

Awesome work!

4:30 PM  
Anonymous craighellen said...

looking good, i never felt so zombified,

6:49 PM  
Anonymous sandro said...

good job!
can you post the source code and the .fla?

5:18 PM  
Blogger SeyelentEco said...

Hey Luke,
You posted in the kirupa forum that my code inspired you... well your code has now inspired me to try to get the NMS implementation to work.

However, I haven't been able to get it to work as performant as yours or as clean (the edges on mine aren't as singular).

Mind sending me your source for the NMS stuff?

Thanks,
Alex
alex.petrescu@gmail.com

4:50 PM  
Blogger theo said...

Hey there,
awesome work. I'm very interested in what kind of optimizations you made in order to make this run so smoothly. Im experimenting with some image processing in flash right now and everything is very choppy. Source code or just any important lessons would be much appreciated!
theo @t kingcow d0t com

7:57 AM  
Blogger theo said...

This post has been removed by the author.

7:57 AM  
Blogger wal5hy said...

Hi Theo, thanks! I keep meaning to write a post with the complete source. I finished the project a few months ago and it includes a very crude eye tracker. Hopefully will post it up soon, if anyone's interested

11:09 PM  
Blogger theo said...

Since I last posted, I have built a real-time face tracker completely in AS3. Check it out HERE. I will be releasing an open-source object-detection toolkit based on the project soon.

11:11 PM  
Blogger wal5hy said...

Just checked out your face tracker. WOW! impressive, can't wait to see the source

11:30 PM  
Anonymous Anonymous said...

Woowww... Simply awesome..
We did a hardware edge detection project. Great to see stuff like this

7:49 PM  

Post a Comment

<< Home