Using RegionProps for User-Defined ROI
Show older comments
I would like to use the "regionprops" function on a user-defined ROI from an image (The image is the output from my code which detects circular objects from the entire image using "regionprops" and "viscircles" documentation ) in order to plot a histogram that plots the frequencies of the diameters of the circular objects ONLY within the user-defined ROI. I was experimenting with some cropping documentation but was having a bit of trouble. Would someone be able to provide me with any recommendations for documentation to experiment with to allow the "regionprops" function to use the user-defined ROI? I have attached a sample output image that I would like the user to define their own ROI from and generate the histogram.
Answers (1)
Walter Roberson
on 23 Dec 2020
0 votes
The first parameter to regionprops() needs to be a BW (binary) or CC (connected component) or L (label matrix), but the second parameter can be the image data.
You would apply the user ROI to the BW or CC or L first.
If you binarized the image, then convert the user ROI to a mask (such as with roi2mask) and "and" it with the binary image.
5 Comments
Michael DiStefano
on 23 Dec 2020
Walter Roberson
on 23 Dec 2020
Is the user marking the center of each of those circles, or are you locating them in your code and you are just plotting them here to point out which of the circles you want to be affected?
Michael DiStefano
on 23 Dec 2020
Edited: Michael DiStefano
on 23 Dec 2020
Walter Roberson
on 23 Dec 2020
viscircles does not detect anything: it only draws circles.
Where is centroids and diameters coming from? Whatever is creating those is what is detecting the circles.
Michael DiStefano
on 23 Dec 2020
Categories
Find more on Region and Image Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!