matlab循环显示多张图片_如何在MATLAB中的for循环中读取多个图像?

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:31   1985   0

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

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.

Please suggest where I have gone wrong.

解决方案

I guess your problem is that:

file_name(1).name = . % Stands for current directory

file_name(2).name = .. % Stands for parent directory

file_name(3).name = your_file_name.jpg

Now, do:

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

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP