[英]How do I create an array of image in matlab
我从目录中逐张读取图像,并希望创建一个图像数组,并将其传递给处理这些图像的mexFunction。 到目前为止,我的尝试无法正常工作。 假设我有100张图片256x256
directory = uigetdir; fileList = dir(directory); imageVolume= [];
for idx = 3:numel(fileList)
tempImage = imread(fullfile(directory, fileList(idx).name));
imageVolume= [imageVolume tempImage];
end
每当我这样做时,我都不会得到256x256xn的数组,而是得到了256x(256 * n)的图像,这不是我想要的。 任何想法?
使用单元阵列。 假设其余代码正确:
for idx = 3:numel(fileList)
tempImage{idx} = imread(fullfile(directory, fileList(idx).name));
end
使用单元格数组作为@bjornsen建议的作品。 如果您不想使用单元格数组,则可以使用3维矩阵:
imageVolume(:,:,idx) = tempImage;
但是,您必须确保所有图像的大小均相同。 否则,最好使用单元格数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.