Anthony S.
Anthony S.

Reputation: 128

Extracting a shape/polygon from a binary image?

I'm trying to construct navigation meshes from mapping data. One of the steps involves converting a binary image (where 0 represents occupied space and 1 represents free space) into a planar straight line graph.

I'm trying to figure out a way to do this that is somewhat reliable. My current thoughts are to use a Canny edge detector, and then run that through OpenCV's Hough line transform. However, that has no guarantee that the lines detected are connected in a way representative of the original shape.

It is safe to assume that the map is relatively smooth, and that none of the regions touch one another.

EDIT - Here is an example image:

sample map

White regions represent free space

Black regions represent occupied space

Upvotes: 0

Views: 3096

Answers (1)

user1196549
user1196549

Reputation:

Edge detection is unnecessary/harmful on this binary image, just use contour following.

Then you turn the Freeman chains into polylines by the Douglas-Peucker line simplification method.

Upvotes: 4

Related Questions