How to calculate the corner of a straight line in a binary image?
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Image Analyst
on 11 Sep 2022
Edited: Image Analyst
on 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.
More Answers (0)
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!