如何在matlab gui中使用impg与msgbox?

时间:2016-01-30 15:21:00

标签: matlab user-interface image-processing matlab-figure matlab-guide

要求: 我正在创建一个matlab gui项目。我的代码中有一个pushbutton,点击后会创建一个figure显示父GUI的图像,并以msgbox作为弹出窗口。点击ok上的msgbox后,我想使用impoly命令选择感兴趣的区域。

问题: 现在问题是单击ok上的msgbox按钮后impoly命令不起作用。鼠标指针不会更改为选择器。我搜索了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

1 个答案:

答案 0 :(得分:1)

您必须在uiwait函数中调用msgbox

这允许阻止执行callbak,直到用户按下OK按钮。

% msgbox('Select ROI for overlapped area','overlapped region'));   %message box
uiwait(msgbox('Select ROI for overlapped area','overlapped region'));   %message box

希望这会有所帮助。 Qapla'