如何在 matlab gui 中将 impoly 与 msgbox 一起使用?
How to use impoly with msgbox in matlab gui?
要求:
我正在创建一个 matlab gui 项目。我的代码中有一个 pushbutton
,单击时会创建一个 figure
,显示来自父 GUI 的图像,并带有一个 msgbox
作为弹出窗口。单击 msgbox
上的 ok
后,我想使用 impoly
命令 select 感兴趣区域。
问题:
现在的问题是单击 msgbox
上的 ok
按钮后 impoly
命令不起作用。鼠标指针不会变为 selector。我搜索了 matlab 文档,替代方法是 warndlg
但同样的情况发生了。
这是我的代码:
% --- Executes on button press in roi.
function roi_Callback(hObject, eventdata, handles)
% hObject handle to roi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
image=getimage(handles.axes2); % acquire image from parent gui
figure; % figure;
msgbox('Select ROI for overlapped area','overlapped region'); %message box
im=imshow(image); % to show the image in figure;
data12=impoly; % creates a roi polygon selector
mask12=createMask(data12,im); % creates a binary mask
您必须在 uiwait 函数中调用 msgbox
。
这允许在用户按下 OK 按钮之前阻止 callbak 的执行。
% msgbox('Select ROI for overlapped area','overlapped region')); %message box
uiwait(msgbox('Select ROI for overlapped area','overlapped region')); %message box
希望这对您有所帮助。
卡普拉'
要求:
我正在创建一个 matlab gui 项目。我的代码中有一个 pushbutton
,单击时会创建一个 figure
,显示来自父 GUI 的图像,并带有一个 msgbox
作为弹出窗口。单击 msgbox
上的 ok
后,我想使用 impoly
命令 select 感兴趣区域。
问题:
现在的问题是单击 msgbox
上的 ok
按钮后 impoly
命令不起作用。鼠标指针不会变为 selector。我搜索了 matlab 文档,替代方法是 warndlg
但同样的情况发生了。
这是我的代码:
% --- Executes on button press in roi.
function roi_Callback(hObject, eventdata, handles)
% hObject handle to roi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
image=getimage(handles.axes2); % acquire image from parent gui
figure; % figure;
msgbox('Select ROI for overlapped area','overlapped region'); %message box
im=imshow(image); % to show the image in figure;
data12=impoly; % creates a roi polygon selector
mask12=createMask(data12,im); % creates a binary mask
您必须在 uiwait 函数中调用 msgbox
。
这允许在用户按下 OK 按钮之前阻止 callbak 的执行。
% msgbox('Select ROI for overlapped area','overlapped region')); %message box
uiwait(msgbox('Select ROI for overlapped area','overlapped region')); %message box
希望这对您有所帮助。 卡普拉'