sakyan
sakyan

Reputation: 35

How to use impoly with msgbox in matlab gui?

Requirement : I am creating a matlab gui project. I have a pushbutton in my code, when clicked creates a figure displaying an image from the parent GUI with a msgbox as a popup. After clicking ok on the msgbox I want to select the region of interest using impoly command.

Problem: Now the problem is after clicking the ok button on the msgbox the impoly command doesn't work. The mouse pointer doesn't change into a selector. I have searched the matlab documentation and the alternate is warndlg but the same happens.

Here is my code :

% --- 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

Upvotes: 0

Views: 270

Answers (1)

il_raffa
il_raffa

Reputation: 5190

You have to call the msgbox within the uiwait function.

This allows blocking the execution of the callbak until the user press the OK button.

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

Hope this helps. Qapla'

Upvotes: 1

Related Questions