Marching Squares: Boundary detection

A little code for a change.

Sakri was working on this, and I ported a class from Java which I believe he adapted into his final implementation. It’s a basic tool for morphing, 3D surface reconstruction, and vectorization.

I’ve cleaned up my version of it and I offer it here. The important function signature looks like this:

public static function perimeter(data:BitmapData, x:int, y:int):Vector.<Point>

It returns a list of pixels representing the boundary between opaque and transparent pixels, starting from a single boundary point that you provide.

You can get a boundary point using Sakri’s and Mario’s EdgeFinder class.

Download the source.

How it works: Marching Squares on Wikipedia

2 comments to Marching Squares: Boundary detection

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>