Pablo Castilla
Pablo Castilla

Reputation: 2741

Calculating a graph from a skeletonized image

I would like to find the joints and the segments from a image that looks like a graph after skeletonize it. I need the number of both joint and the length of the segments.

Do you know what are the best approach for it?

Thanks

Here is the image explanation:

enter image description here

Original image:

enter image description here

Binary: enter image description here

Skeleton: enter image description here

Upvotes: 5

Views: 1487

Answers (1)

user1196549
user1196549

Reputation:

If your skeletonization algorithm works well, the joints are pixels surrounded by three or four neighbors, while the edges pixels have only two. Free endpoints have only one.

A possible approach is to scan the image in search of all junctions and endpoints and create graph vertices for each. Label these pixels with the vertex indexes.

Then for every joint/endpoint, follow all the incident edges until you reach another joint/endpoint. Add the corresponding graph edge.

Upvotes: 3

Related Questions