views:

61

answers:

1

I'm trying to figure out an algorithm which can look at raw rgba pixels and return points that make up the polygon of the object inside example:

http://img706.imageshack.us/i/polii.png//

It doesn't have to return bezier curves or anything smooth or fancy, nor a connected outline as I showed, but basically the points to build such an outline. I'm doing this so I can store these and avoid pixel perfect collision detection in my game.

Thanks

I want verticies not the outline image

+2  A: 

If you just want an image of the line (and not the vectors), then the field of algorithms your looking for is "edge detection", see http://en.wikipedia.org/wiki/Edge_detection.

If you are always looking for circles like that you could try the generalized Hough transform (http://en.wikipedia.org/wiki/Hough_transform) which would give you likely locations of circles rather than simply outline images.

If you're trying to do fast collision detection (and don't want to use an available game framework that does it for you ) then maybe look into building your collision detector with bounding boxes to do most of the work for efficiency. But you'll have to still use the real bitmap in case one is fully inside the other or something -- the outlines wouldn't intersect but they definitely collided.

Scott Stafford
Actually I want the verticies...
Milo
I'm going to feed these to Box2D
Milo