Muna
Muna

Reputation: 73

how i can read images from multiple folder in matlab?

My question I have folder of image organized as

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

the structure of folder as

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

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

Upvotes: 1

Views: 1653

Answers (1)

petrichor
petrichor

Reputation: 6579

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

Upvotes: 1

Related Questions