如何在MATLAB中的for循环中读取多个图像? [英] How to read mutliple images in a for loop in MATLAB?
本文介绍了如何在MATLAB中的for循环中读取多个图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在文件夹中分段了结果。那些需要在for循环中读取并在循环中进一步处理。我尝试阅读如下:
I have segmented results in a folder. Those need to be read in a for loop and processed further in the loop. I tried reading as below:
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
抛出错误:?? ?使用==> imread at 370
时出错无法打开文件C:\Users\adminp\Desktop\ dicosaurs \。阅读;
你可能没有读取权限。
An error was thrown :??? Error using ==> imread at 370 Can't open file "C:\Users\adminp\Desktop\dinosaurs\." for reading; you may not have read permission.
请告知我出错的地方。
推荐答案
我想你的问题是:
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中的for循环中读取多个图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文