matlab gui image changing

조회 수: 12 (최근 30일)
Fco. Javier Rodríguez Mira
Fco. Javier Rodríguez Mira 2020년 5월 25일
Hi, i'm trying to make a gui that changes an image with the value of a vector, I mean, i've got a vector that has 0, 1 and 2 values and i need to show an image for each value. Can be possible?

답변 (1개)

Ajay Pattassery
Ajay Pattassery 2020년 5월 28일
Hello,
You can make use of uiimage to display images in the GUI.
I am not sure, whether you are looking for this. I just read three images and display them for a duration of 1second and show the other image based on the value in the vectorInput.I have a one to one mapping between vectorInput values 0,1,2 with img0,img1 and img2.
img0 = imread('membrane.png');
img1 = imread('peppers.png');
img2 = imread('football.jpg');
vectorInput = [0 0 1 2 2 0];
f= uifigure();
img =uiimage(f);
for i=1:length(vectorInput)
if(vectorInput(i) == 0)
img.ImageSource = img0;
elseif(vectorInput(i) == 1)
img.ImageSource = img1;
else
img.ImageSource = img2;
end
pause(1);%Holding image for 1 second
end
  댓글 수: 1
Fco. Javier Rodríguez Mira
Fco. Javier Rodríguez Mira 2020년 5월 28일
Hi I've tested your code and It works but the vector I have has 34470 elements so I need the loop to be a little bit faster. It only has 0,1, 2 and 3 values and what I need is: when I have a 0 I need to display an arm image(brazo22) in repose, when is 1 I need to display an arm image in flexion(brazo11) ,when is 2 I need to display an arm image in extension (brazo33) and when it has a 3 I need to display the same image as when It's in repose(brazo22). I´ll attach a zip that contains the gui(poyecto.fig) the function of the gui with your code (proyecto.m), the images of the arm, another function that is the function where I extracted the code for the gui(SolucionP2_eje2.m) and a data archive(EMG 2 channel Wrist Flex_Ext_Raw.mat). In both of the .m archives is a vector called "salida" that is the vector with the 4 values. A brief summary of what I need is: I have a data archive that I have processed and then make a vector "salida" for the values in the previous data. Now I need to make a gui for that 3 values to display an image deppend on the value. The problem is that I need the loop to last 23.16 seconds but the vector "salida" has 34470 elements. Do you have any idea to make this possible? Thank you for your answer.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by