在MATLAB中从文件读取图像 [英] Reading images from file in MATLAB

查看:103
本文介绍了在MATLAB中从文件读取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的计算机上的图像文件夹中有bmp图像.我从1.bmp命名为100.bmp.

I have bmp images in image folder on my computer. I named it from 1.bmp to 100.bmp.

我想像这样阅读这些图像:

And I want to read these images like this:

for i=1:100
    s='C:\images'+i+'.bmp';
    A=imread(s);
end

但是Matlab给出了一个错误.我该如何实施?

But Matlab gave an error. How can I implement this?

推荐答案

>  for i=1:100
>      s=strcat('C:\images',num2str(i),'.bmp');
>      try                                                  
>        A=imread(s);
>      catch
>      end 
>    end

这里我使用num2str,它用于将数字的数据类型转换为字符串,并且我使用try来避免该错误,因为如果文件不存在,那么它将避免该错误.

here i am using num2str which is used for convert the data type of number to string and i am using try for aviod the error because if file is not there then it will aviod that error.

这篇关于在MATLAB中从文件读取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆