【问题标题】:how i can read images from multiple folder in matlab?matlab如何从多个文件夹中读取图像?
【发布时间】:2012-05-17 18:14:27
【问题描述】:

我的问题是,我将图像文件夹组织为

Database -> CASIA Iris Image Database (version 1.0) -> folder001(此文件夹更改为 001 至 108) -> previous 文件夹包含两个文件夹,每个文件夹包含 3 个图像

文件夹结构为

http://imageshack.us/photo/my-images/337/picture1ki.png/

如何在 MATLAB 中阅读 CASIA V1.0 1?

【问题讨论】:

    标签: matlab


    【解决方案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
    

    【讨论】:

    • 感谢您的帮助.........但是我遇到了问题,因为我的文件夹 Database/CASIA-IrisV1/ 包含 108 个文件夹(每个文件夹 108 人,我有 2 个文件夹对于左眼和右眼以及每个左右文件夹我有3个图像)......我修改了你的代码但有错误。
    • 这可能是因为您忘记了路径中的左右子文件夹。相应地修改代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    相关资源
    最近更新 更多