A button in GUI to move on to next image from a for loop in a different push button.

2 visualizaciones (últimos 30 días)
When the user presses, the first push button the program allows it to select some directories and then starts displaying the images from the directories in a for loop. So, the first image will be shown and the user will do some imfreehand drawing in it.
I want a separate push button that will allow them to go to the next iteration/picture in the for loop running from the first push button. Is there any way to do this? I don't want to resort to message boxes at this time.

Respuesta aceptada

Matthew Eicholtz
Matthew Eicholtz el 2 de Ag. de 2017
I would advise against "displaying the images from the directories in a for loop." What about the following setup?
  • Pushbutton #1 (load images): When the user presses this button, they are queried to select a directory of images from file. Those images are all loaded into the GUI and stored in a variable (e.g., I).
  • Axes: I assume there is an axes in your GUI to display the images. Use a variable (e.g., current_image) that keeps track of the index of which image to show. When that variable changes (from the Pushbutton #2), use a listener function to update the image that is shown in the axes.
  • Pushbutton #2 (change images): When the user presses this button, the variable current_image updates (triggering the update of the image shown in the axes). In fact, if it were me, I would use a slider that ranges from 1 to the number of images so that the user can move forward and backward through the directory of images; in this case, you can simply use the value of the slider instead of current_image.
  • Pushbutton #3 (starts imfreehand tool): you don't explicitly say this, but I'd suggest incorporating the imfreehand as a button that the user selects. In this way, the user can decide when they want to draw on the image, instead of being forced in a for loop.
Does this make sense? Let me know if anything is unclear.
  3 comentarios
Linda Hornakova
Linda Hornakova el 30 de Nov. de 2017
Editada: Linda Hornakova el 30 de Nov. de 2017
Hello, I am able to load picture with:
>>[filename, pathname] = uigetfile('.jpg','C:\Data\LOOP-1');
>>img=imread([pathname, filename]);
>>imshow(img,'Parent',handles.axes1);
But I have many pictures in the file, is it possible after uploading one to skip to the next picture with push button called "Next"?
Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings 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