我有一段代码图像格式
imgPath = 'F:\SIFT\images\';
dCell = dir([imgPath '*.jpg']);
在这里,我打开一个目录,并获得在DCELL类型JPG,但我真正想要的所有图像的列表不只是JPG,但甚至其他图像格式,如PNG或TIFF等等,都可以考虑...请帮助!谢谢
我有一段代码图像格式
imgPath = 'F:\SIFT\images\';
dCell = dir([imgPath '*.jpg']);
在这里,我打开一个目录,并获得在DCELL类型JPG,但我真正想要的所有图像的列表不只是JPG,但甚至其他图像格式,如PNG或TIFF等等,都可以考虑...请帮助!谢谢
假设你的文件夹,F:\SIFT\images\
只包含必要的图像文件,你可以简单地使用:
imgPath = 'F:\SIFT\images\'; %Specifies the directory path as a string.
dCell = dir(imgPath); %Gets all entries in the directory; similar to `dir` command in Windows or the `ls` command in linux.
%By default, the first two output entries of `dir` are `.` and `..` which refer to the current and parent directories respectively.
dCell = dCell(3:end); %Eliminates the default dir entries `.` and `..` by truncating the first two array elements.
现在日e结果可以访问为:
dCell(1) %Entry corresponding to the first file.
dCell(2) %Entry corresponding to the second file.
等等。
的dCell
每个输出条目是struct
具有以下字段:
name
date
bytes
isdir
datenum
得到各个领域,用途:
dCell.name
等。
为了得到一个特定的输出struct
的各个领域,用途:
dCell(1).name
dCell(3).date
等。
欲了解更多相关信息,您可以尝试help dir
和help struct
。
我认为你必须建立自己的数组:
imgPath = 'F:\SIFT\images\';
dCell = dir([imgPath '*.jpg']);
dCell = {dCell; dir([imgPath '*.gif'])};
dCell = {dCell; dir([imgPath '*.jpg'])};
%etc...
我不是,如果上面的应该是[]
或{}
100%,即可能是dCell = [dCel; dir([imgPath '*.gif'])];
可以请你解释一下我的代码...我对matlab没什么兴趣 – aushima 2013-04-05 07:11:07
@aushima:好的。我会发表评论。 – 2013-04-05 07:15:23
plz编辑答案...谢谢! – aushima 2013-04-05 07:17:25