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

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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 4월 17일

댓글:

2021년 4월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by