Using findObj to locate ROI.Lines and extract position data
Show older comments
Hi, Im trying to add an option to the Contex Menu of the MATLAB Distance_using_lines_ROIs example code that allowed users to display the magnitudes of all of the line ROIs magnitudes. I figured I could just use findObj to locate the ROIs and use a command like getPosition or evt.Source.Position but I dont think I'm going about it the right way. Would I need the handles of each ROI too in order to get access to their position? Is there a location that Event data is stored that can be refrenced? Would I have to import my Axes data? Clearly ROIs are still a little abstract to me...
This is my function, when I call it in my code I pick up all the ROIs I am just searching for a way to gather their magnitudes into a table.
function plotAll(src)
pFig = ancestor(src,'figure');
pROIs = findobj(pFig,'Type','images.roi.Line');
table(pROIS)
end
This is the MATLAB code i'm building off of
Thanks!
3 Comments
Walter Roberson
on 17 Apr 2021
In the brief test I just did,
cat(3,findobj(gcf,'Type','images.roi.Line').Position)
worked. The third dimension is for the case where there are multiple ROIs.
William Schultz
on 17 Apr 2021
Walter Roberson
on 17 Apr 2021
You will need to reshape it. Maybe
reshape(ROIs, 4,[]).'
My guess is that would give x1 x2 y1 y2 for each row
Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!