如何在MATLAB中读取for循环中的多幅图像?
我在文件夹中分割了结果。这些需要在for循环中读取,并在循环中进一步处理。我试着阅读如下:如何在MATLAB中读取for循环中的多幅图像?,matlab,image-processing,matlab-cvst,Matlab,Image Processing,Matlab Cvst,我在文件夹中分割了结果。这些需要在for循环中读取,并在循环中进一步处理。我试着阅读如下: for i=1:10 file_name=dir(strcat('C:\Users\adminp\Desktop\dinosaurs\')); im=imread(strcat('C:\Users\adminp\Desktop\dinosaurs\',file_name(i).name)); %processing of read image end 引发了一个错误:???在370处使用==
for i=1:10
file_name=dir(strcat('C:\Users\adminp\Desktop\dinosaurs\'));
im=imread(strcat('C:\Users\adminp\Desktop\dinosaurs\',file_name(i).name));
%processing of read image
end
引发了一个错误:???在370处使用==>imread时出错
无法打开文件“C:\Users\adminp\Desktop\Digoros\”进行读取;
您可能没有阅读权限
请告诉我哪里出了问题。我想你的问题是:
file_name(1).name = . % Stands for current directory
file_name(2).name = .. % Stands for parent directory
file_name(3).name = your_file_name.jpg
现在,请执行以下操作:
images = dir('*JPG')
for i=1:numel(images)
file_name=dir(strcat('C:\Users\adminp\Desktop\dinosaurs\'));
im=imread(strcat('C:\Users\adminp\Desktop\dinosaurs\',images(i).name));
%processing of read image
end
如果您有带有计算机视觉系统工具箱的MATLAB R2014b版本,则可以使用对象在一行中完成此操作 将创建一个对象,其中包含
恐龙
目录中所有图像的路径。它将自动排除任何非图像文件
然后,您可以按如下方式处理图像
for i = 1:images.Count
im = read(images, i);
% process the image
end
现在你有了答案,但我可以批评一下,你真的应该自己想出这个解决方案;只需查看数据,这是调试的重要部分?也许下次;-)注意:这一定是非常新的功能,因为我在2013b CVST中没有它,但无论如何+1,因为哦,闪亮的新东西。@nkjt,是的,全新的。它是在2014b中与对特征包对象类别识别的支持一起添加的。
for i = 1:images.Count
im = read(images, i);
% process the image
end