我如何从Matlab的多个文件夹中读取图像? [英] how i can read images from multiple folder in matlab?

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

问题描述

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

My question I have folder of image organized as

数据库-> CASIA Iris图像数据库(1.0版)->文件夹001(此文件夹更改为001至108)->先前文件夹包含两个文件夹,每个文件夹包含3张图像

Database -> CASIA Iris Image Database (version 1.0) -> folder001(this folder change to 001to 108) -> previouse folder contains two folder each of them contains 3 images

文件夹的结构

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

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

how i can read CASIA V1.0 1 IN MATLAB?

推荐答案

以下是文件夹中任意数量图像的通用代码.如果您确定每个文件夹有3张图片并且知道每个文件名的格式,则可以简化它.

Below is a generic code for any number of images in a folder. You can simplify it if you are sure to have 3 images per folder and you know the filename format for each.

%# 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

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

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