image changing gui matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Fco. Javier Rodríguez Mira
el 26 de Mayo de 2020
Comentada: Geoff Hayes
el 28 de Mayo de 2020
Hi, I´d like to make a code that displays an image in a gui from a vector. I mean, I´ve got a vector that has the values 0,1,2 and I need to display in a gui an image depend on the value. I´ve got no idea to make this. Thank you.
2 comentarios
Geoff Hayes
el 26 de Mayo de 2020
What are the dimensions of your vector? How are these three numbers (or are there more?) mapped to colours?
Respuestas (1)
Geoff Hayes
el 27 de Mayo de 2020
So once you have created the salida array you need to determine which GUI action will invoke the process to display all the images one after the other. Let's assume that you have a pushbutton to do this. In the callback, you would place all of your code (that is right now in the OpeningFcn) to create the salida array, load the three images, and then cycle through each value in the array. Something like
image0 = imread('brazo22.jpg');
image1 = imread('brazo11.jpg');
image2 = imread('brazo33.jpg');
for k = 1:length(salida)
value = salida(k);
if value == 0 || value == 3
imshow(image0);
elseif value == 1
imshow(image1);
elseif value == 2
imshow(image2);
else
fprintf('error - invalid value: %d!\n', value)
end
pause(1.0); % <---- pause for one second
end
You can use a switch statement instead of the if/elseif if you'd rather. So we get the value of the kth element of the array, show the appropriate image (in the axes of your GUI), pause for one second (you can change this) and then move to the next element.
Ver también
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!