How to calculate the corner of a straight line in a binary image?

1 Ansicht (letzte 30 Tage)
Excuse me, as shown in the image (picture format), what method should be used to obtain the corners of each polygon area (obtain coordinates)?(fig.1)
I tried to use image thinning, but the thinning results distorted these corners.(fig.2)
I also try to use the Hough algorithm, but it can't get good results in the process of straight line fitting. Among them, most of the straight lines were not fitted.(fig.3)
I will feel very honored for your help. Thank you.

Akzeptierte Antwort

Image Analyst
Image Analyst am 11 Sep. 2022
Bearbeitet: Image Analyst am 11 Sep. 2022
You can thin the image with bwskel and then use bwmorph to find branchpoints. I think those should be accurate enough. If they aren't, then tell us why.
You could erase the branchpoints to segment the image into separate segments and then use bwlabel and ismember and find OR regionprops to get each individual line's coordinates. Then use polyfit to get the equation of each line. Then have a double nested for loop where find the exact points where each pair of lines cross.
Or you could threshold for white and find the centroid of each white polygon. Then get the boundary with bwboundaries and compute the distance of each boundary coordinate from the centroid. Then use findpeaks to find the coordinates of the vertices. See attached demos.

Weitere Antworten (0)

Produkte


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by