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

1 回表示 (過去 30 日間)
玥 曾
玥 曾 2022 年 9 月 11 日
コメント済み: 玥 曾 2022 年 9 月 12 日
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.

採用された回答

Image Analyst
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 ExchangeImage Segmentation and Analysis についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by