从一个文件夹显示一组图片
1视图(30天)
显示旧的评论
接受的答案
沃尔特·罗伯森
2021年9月19日
编辑:沃尔特·罗伯森
2021年9月19日
=管理扫描“路径/ /图像/目录”;
ext =“使用”;%根据调整的图像
dinfo = dir (fullfile(管理扫描,“*”+ ext));
fullname = fullfile ({dinfo。文件夹},{dinfo.name});
nfile =长度(fullname);
ax = app.axes1;%的地方你想要的图像显示
h =图像(ax, []);%与空的内容创建图像对象
为K = 1: nfile
thisfile = fullname {K};
[thisimg,用途]= imread (thisfile);%伪彩色处理和rgb
h。CData = thisimg;%更新现有的图像对象的新形象
如果~ isempty(用途);colormap (ax,用途);结束%如果需要,更新colormap
暂停(0.2);
结束
然而,上面的代码并不占真实灰度图像。你会发现这些用途是空的,ndims (thisimg) 2。
2的评论
沃尔特·罗伯森
2021年9月19日
ext中使用
dinfo = dir (fullfile(管理扫描,“*”+ ext));
比如从“* . png将构建字符串。png”,成为dir()的模式搜索,文件扩展名。