uiwait Interfering with Object Wait Function in GUIDE GUI

2 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Image Analyst
Image Analyst el 5 de Abr. de 2013
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 comentarios
Image Analyst
Image Analyst el 8 de Abr. de 2013
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);
Susan
Susan el 9 de Abr. de 2013
You're right. There must have been something else wrong. Thanks, it works great!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by