uiwait Interfering with Object Wait Function in GUIDE GUI
2 次查看(过去 30 天)
显示 更早的评论
I have created a GUI using GUIDE to allow users to segment objects out of an image interactively using marker-controlled watershed segmentation. One of the push buttons of the GUI allows a user to draw additional regions on the image using impoly. The impoly doc says to use wait(h) to have the rest of the push button callback pause until the user double clicks the polygon, so that they have time to interactively re-size and move the object they drew. The problem I'm having is that after wait(h) is completed and the remaining push button script completes, the entire GUI closes. I think the wait function is interfering with the GUI uiwait(hObject) call in the OpeningFcn. I tried modifying the push button code so that uiwait(hObject) is called again at the end of the script, thereby preventing the GUI from closing. However, it doesn't appear to work well, as the whole GUI freezes and then MATLAB crashes.
Any ideas on how I can get the remaining push button script to wait until the user is done manipulating their object without using the wait(h) command so that it doesn't interfere with the GUI's uiwait(hObject) command? I'd really appreciate any suggestions! Thanks!
0 个评论
采纳的回答
Image Analyst
2013-4-5
Try roipolyold() instead, and don't use the wait. I think that will avoid the problem. Or else try imfreehand():
message = sprintf('Left click and hold to begin drawing.\nSimply lift the mouse button to finish');
uiwait(msgbox(message));
hFH = imfreehand();
% Create a binary image ("mask") from the ROI object (if needed).
binaryImage = hFH.createMask();
xy = hFH.getPosition; % Get (x,y) coordinates also.
3 个评论
Image Analyst
2013-4-8
You are mistaken. roipolyold() does not display any image. Whatever image you have displayed last, or is the "current" image, it will put up a dashed black and white line/outline. It does not do anything to change the color of the underlying image.
You can popup a full screen figure to draw on. I do that often so that I can see the thing I'm drawing better. After drawing, close it down
figure(1)
imshow(yourImage);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
[x y] = roipolyold();
close(1);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!