Using findObj to locate ROI.Lines and extract position data

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

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.
Hi, thanks for the quick reply. Should I be able to save this concentrated array to a variable that I can tabulate or export to excel?
Should it look something like this? Thanks I appreciate your help.
function plotAll(src)
gcf = ancestor(src,'figure');
ROIs = cat(3,findobj(gcf,'Type','images.roi.Line').Position);
t = array2table(ROIs)
end
You will need to reshape it. Maybe
reshape(ROIs, 4,[]).'
My guess is that would give x1 x2 y1 y2 for each row

Sign in to comment.

Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2021a

Asked:

on 17 Apr 2021

Commented:

on 17 Apr 2021

Community Treasure Hunt

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

Start Hunting!