drawcircle function in while loop does NOT store data

Hello everyone,
I need to select multiple ROIs from a figure so I am using the function drawcircle. Since I need multiple rois, I added a while loop and halt it with a STOP button. However, the drawcircle function works outside the loop, but it does not store the info when within it.
That's the code I am using:
figure;
imagesc(your_figure_here)
H = uicontrol('Style', 'PushButton', ...
'String', 'Break', ...
'Callback', 'delete(gcbf)');
n=0;
while (ishandle(H))
n=n+1;
roi()= drawcircle()
end

回答 (1 件)

Ernesto Salcedo
Ernesto Salcedo 2020 年 9 月 4 日

0 投票

How about something like this
figure;
imshow(img)
crater_mask = false(size(img));
H = uicontrol('Style', 'PushButton', ...
'String', 'STOP', ...
'Callback', 'delete(gcbf)');
while ishandle(H)
roi = drawcircle;
if ishandle(roi)
wait(roi); % wait for double click
crater_mask = roi.createMask | crater_mask;
end
end
imshowpair(img,crater_mask)

1 件のコメント

Xingwang Yong
Xingwang Yong 2020 年 10 月 16 日
Thank you, this works.
By the way, I found another solution recomended by MATLAB, Use Wait Function After Drawing ROI

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

質問済み:

MP
2020 年 5 月 25 日

コメント済み:

2020 年 10 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by