Extract data from regionprops.
2 views (last 30 days)
Show older comments
Hi everyone !
I have a set of images like this:

I use regionprops to find centroids and equivalent diameters.
The problem is: I need to select only the greater region and so, how can i extract the max EquivDiameter and the respective centroids ???
Thanks for your Help :)
0 Comments
Answers (1)
Image Analyst
on 4 Dec 2017
Edited: Image Analyst
on 4 Dec 2017
props = regionprops(binaryImage, 'EquivDiameter', 'Centroid');
allDiameters = [props.EquivDiameter]
centroids = [props.Centroid]; % [x1,y1,x2,y2]
xCentroids = centroids(1:2:end)
yCentroids = centroids(2:2:end)
The first elements describe the blob on the left. The second elements describe the blob on the right.
Sounds like you haven't run my Image Segmentation Tutorial yet, where I go over all that. I suggest you do that: https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
Another thing you might want to do, instead of measuring everything there, if you want only the largest blob in the image, use bwareafilt() to extract it:
largestBlob = bwareafilt(binaryImage, 1);
Then if you call regionprops, there is information from only the largest blob, not both/all of them.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!