Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Image Analyst
Image Analyst il 11 Set 2022
Modificato: Image Analyst il 11 Set 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.

Più risposte (0)

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by