필터 지우기
필터 지우기

Finding handles to ROI objects such as drawline

조회 수: 3 (최근 30일)
Richard McWilliam
Richard McWilliam 2020년 7월 29일
댓글: Xingwang Yong 2022년 9월 30일
Until the advent of drawline, it was easy to find the handle to a line objects created using imline:
fighl = figure;
axhl = axes(fighl);
imagesc(axhl, rand(100));
colormap gray
imline(axhl, [10 50; 80 50])
findobj(axhl, 'type', 'line')
ans =
4×1 Line array:
Line (end point 2)
Line (end point 1)
Line (top line)
Line (bottom line)
Repeating the same functionality using drawline:
fighl = figure;
axhl = axes(fighl);
imagesc(axhl, rand(100));
colormap gray
drawline(axhl, 'position', [10 50; 80 50])
findobj(axhl, 'type', 'line')
ans =
0×0 empty GraphicsPlaceholder array.
I know that this object exists:
>> findobj(axhl)
ans =
3×1 graphics array:
Axes
Line
Image
However, any attempt to access the object handle returns an empty placeholder.
I need to be able to find line objects without having to explicitly store their handles.
Is there a way to achieve this?
  댓글 수: 1
Xingwang Yong
Xingwang Yong 2022년 9월 30일
If I get the 4x1 Line array, can I get the original handle? So that I can call createMask()
h = imline();
mask = h.createMask();
% how to get h using the 4x1 Line array?

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

채택된 답변

Adam Danz
Adam Danz 2020년 7월 29일
편집: Adam Danz 2020년 7월 29일
h = findobj(axhl, 'type', 'images.roi.line');
The object created by drawline is different from regular line objects.
But the best solution is to just store the output handle.
h = drawline(___)
  댓글 수: 1
Richard McWilliam
Richard McWilliam 2020년 7월 30일
Great, thanks for this.
Looks like I need to get up to speed on ROI classes...

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

추가 답변 (0개)

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by