How to calculate the corner of a straight line in a binary image?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2022-9-11
编辑:Image Analyst
2022-9-11
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!