我不完全确定你想做什么(特别是你试图显示什么类型的图像),但这里有一些示例代码可以做你想要的:
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
Run Code Online (Sandbox Code Playgroud)
我使用了通用函数IMSHOW,但这有时会改变图形/轴的其他属性,这可能不符合您的喜好(因为您提到将其添加到现有GUI).您可能希望使用IMAGE功能.此外,代替for循环,您可以使用while循环,在满足条件时停止切换图像(例如按下按钮).
您的图像如何存储在 Matlab 中?作为 matlab 电影或 3 或 4 维矩阵,具体取决于图像是彩色还是灰度。另外,如果您有图像处理工具箱,implay并且immovie. 另一种选择假设您的图像采用mxnx3xk(RGB 颜色)或mxnxk(灰度)矩阵。那么以下应该可以工作。假设以下情况
Img- 存储图像数据的矩阵,具有尺寸mxnx3xk
或mxnxk
handles.imageAxes- 要显示图像的轴的句柄(在GUIDE中将轴的标签设置为imageAxes)
现在你可以循环浏览 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
Run Code Online (Sandbox Code Playgroud)
就是这样。