How to add image to MATLAB GUI?

I want to switch between two images, for example, blink: 1 second for the first image and one second for the second image.

+5
source share
2 answers

I'm not quite sure what you want to do (in particular, what types of images you are trying to display), but here is an example of code that can do what you want:

image1 = imread('cameraman.tif');  % Load a test image
image2 = imread('circles.png');    % Load another test image

hAxes = gca;  % Get a handle to the current axes

for iLoop = 1:5,  % Loop five times
  imshow(image1,'Parent',hAxes);
  pause(1);
  imshow(image2,'Parent',hAxes);
  pause(1);
end

IMSHOW, /, ( ). IMAGE. , for while, (, ).

+6

Matlab? 3 4 , . , , implay immovie. , , mxnx3xk (rgb color) mxnxk ( ). .

  • Img - , mxnx3xk mxnxk

  • handles.imageAxes - , ( imageAxes GUIDE)

Img

for i=1:k
    % display the i^th image use `Img(:,:,i)` for a gray scale stack
    image(Img(:,:,:,i),'parent',handles.imageAxes);
    pause(1) % pause one second
end

.

+2

All Articles