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

2 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Matthew Eicholtz
Matthew Eicholtz le 2 Août 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 commentaires
awezmm
awezmm le 21 Nov 2017
what part do you need help with
Linda Hornakova
Linda Hornakova le 30 Nov 2017
Modifié(e) : Linda Hornakova le 30 Nov 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!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by