image changing gui matlab
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Geoff Hayes
2020-5-26
What are the dimensions of your vector? How are these three numbers (or are there more?) mapped to colours?
回答(1 个)
Geoff Hayes
2020-5-27
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!