如何在matlab中读取多个文件夹中的图像?
我的问题是,我把图像文件夹组织为 数据库->CASIA Iris图像数据库(1.0版)->folder001(此文件夹更改为001至108)->以前的文件夹包含两个文件夹,每个文件夹包含3个图像 文件夹as的结构如何在matlab中读取多个文件夹中的图像?,matlab,Matlab,我的问题是,我把图像文件夹组织为 数据库->CASIA Iris图像数据库(1.0版)->folder001(此文件夹更改为001至108)->以前的文件夹包含两个文件夹,每个文件夹包含3个图像 文件夹as的结构 如何在MATLAB中阅读CASIA V1.0 1?下面是文件夹中任意数量图像的通用代码。如果您确定每个文件夹有3个图像,并且您知道每个图像的文件名格式,则可以简化它 %# Set the relative path for the database basePath = 'Datab
如何在MATLAB中阅读CASIA V1.0 1?下面是文件夹中任意数量图像的通用代码。如果您确定每个文件夹有3个图像,并且您知道每个图像的文件名格式,则可以简化它
%# Set the relative path for the database
basePath = 'Database/CASIA Iris Image Database (version 1.0)/';
for iFolder = 1:108
%# Set current folder
folder = sprintf('%s%03d/', basePath, iFolder);
%# Find the image (e.g. bmp) files in the folder. Modify bmp for your needs.
%# and also modify 'left' string according to the subfolder of left images
filenames = arrayfun(@(x) x.name, dir([folder 'left/*.bmp']),'UniformOutput',false);
for iFile = 1:length(filenames)
img = imread([folder filenames{iFile}]);
%# and process the image
%# ...
end
%# Modify the code for to run it for right folder
%# ...
end
下面是文件夹中任意数量图像的通用代码。如果您确定每个文件夹有3个图像,并且您知道每个图像的文件名格式,则可以简化它
%# Set the relative path for the database
basePath = 'Database/CASIA Iris Image Database (version 1.0)/';
for iFolder = 1:108
%# Set current folder
folder = sprintf('%s%03d/', basePath, iFolder);
%# Find the image (e.g. bmp) files in the folder. Modify bmp for your needs.
%# and also modify 'left' string according to the subfolder of left images
filenames = arrayfun(@(x) x.name, dir([folder 'left/*.bmp']),'UniformOutput',false);
for iFile = 1:length(filenames)
img = imread([folder filenames{iFile}]);
%# and process the image
%# ...
end
%# Modify the code for to run it for right folder
%# ...
end
感谢您的帮助……但我面临这个问题,因为我的文件夹数据库/CASIA-IrisV1/由108个文件夹组成(每个文件夹108人,我有2个左右眼文件夹,每个左右文件夹我有3个图像)。。。。。。。。。。。。我修改了您的代码,但出现了错误。这可能是因为您忘记了路径中的左侧和右侧子文件夹。相应地修改代码。感谢您的帮助………但我面临问题,因为我的文件夹数据库/CASIA-IrisV1/由108个文件夹组成(每个文件夹108人,我有2个左右眼文件夹,每个左右文件夹我有3张图像)。。。。。。。。。。。。我修改了您的代码,但出现了错误。这可能是因为您忘记了路径中的左侧和右侧子文件夹。相应地修改代码。