开发者

Algorithm to generate outline of an alpha picture?

开发者 https://www.devze.com 2023-01-06 15:13 出处:网络
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:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消