Hi all,
I'm using regionprops to extract some properties from a watershed segmentation of polygonal objects in an image. It returns values for the centroid, area, and perimeter of each segmented polygon.
Does anyone know if there's a way to extract specific lengths of the sides of the polygons, rather than just their entire perimeters?
Looking forward to your suggestions!
Thanks!
Best,
Veena

 Akzeptierte Antwort

Adam Danz
Adam Danz am 9 Mär. 2020

0 Stimmen

You could also return the "ConvexHull" values which will return a p-by-2 matrix for each polygon where each row of the matrix contains the x- and y-coordinates of one vertex of the polygon. Then you could use pdist() to compute the length of each segment.

5 Kommentare

Veena Chatti
Veena Chatti am 10 Mär. 2020
Hi Adam,
Thanks for your answer, I think returning that property is the way I want to go with this.
But I should have been a little clearer in my question- they are polygons, but somewhat squishy ones. The lines connecting the vertices are not straight, and I am also interested in the tiny fluctuations and bends they might contain. I wonder if pdist() can capture those? Can you think of any other way?
Thanks again,
Best,
Veena
Adam Danz
Adam Danz am 10 Mär. 2020
Providing a screenshot might provide inspiration. pdist() isn't involved in capturing the edges of objects. That's what regionprops would do. pdist() merely computes the distance between all verticies of an object, ie, the length of each side of the polygon.
Adam Danz
Adam Danz am 10 Mär. 2020
What do the regionprops + convexhull results look like?
Veena Chatti
Veena Chatti am 26 Apr. 2020
Thank you, I am sorry for my late response, but the regionprops convexhull seems to capture a lot of the shapes quite accurately. I needed to get back onto a computer to be able to try it out and let you know, but now that I have I see that this is indeed a good solution that captures these shapes well. Thanks again!
Image Analyst
Image Analyst am 27 Apr. 2020
Note: using the convex hull will only work for polygons or shapes that are convex. If you have any shapes that have any incursions into them, like a blob shaped like the letter F or H or Z etc., the convex hull will not work.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 10 Mär. 2020

1 Stimme

You need to compute the boundary of each polygon with bwboundaries(). Then use findpeaks() to decide how many vertices there are. Then you can extract each "straight" segment from the boundary and do some kind of analysis on the shape of that "line". See my attached shape recognition demo to get you started.

Produkte

Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by