i am sending 4 images out of 108 images..please have a look how the images are stored with file names...
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to load CASIA Iris Version V1 database images..
10 views (last 30 days)
Show older comments
Hello, CASIA Iris Image Database Version 1.0 (CASIA-IrisV1) includes 756 iris images from 108 eyes. For each eye, 7 images are captured in two folders...totally there are 108 folders(eyes) and each folder contains 2 sub-folders by name 1 (right eye) and 2 (left eye)..1st sub-folder contains 3 images and 2nd sub-folder contains 4 images... How can i load all the images from all the folders and sub-folders?
4 Comments
KSSV
on 16 May 2017
Jyothi Alugolu
on 16 May 2017
that is not the question which i asked... i used recures.m file,but i am not getting all the subfolder images..
KSSV
on 16 May 2017
How your question of accessing images in sub folders/ folders is different from what given in the link?
Accepted Answer
Walter Roberson
on 16 May 2017
https://www.mathworks.com/help/vision/ref/imageset-class.html
imgSetVector = imageSet(imgFolder,'recursive')
Or you could create an imageDatastore, and use it; see for example https://www.mathworks.com/help/matlab/import_export/read-and-analyze-image-files.html
18 Comments
Jyothi Alugolu
on 16 May 2017
Edited: Walter Roberson
on 16 May 2017
The images of CASIA-IrisV1 are stored as:
$root path$/XXX_S_Y.bmp
XXX: the unique identifier of eye, range from 000 to 108.
S: the index of session, denotes the first session and the second session.
Y: the index of image in the same session. Range from 1 to 3 in the first session, 1 to 4 in the second session.
Therefore XXX_S_Y:bmp means the iris image with index Y in session S from eye XXX.
Jyothi Alugolu
on 16 May 2017
Edited: Walter Roberson
on 16 May 2017
i tried something like this:
close all;
clc;
count=0;
% the folder in which ur images exists
adata(1).f='00';
adata(2).f='0';
for i=1:108
for k=1:4
for j=1:2
if(i<10)
input=strcat('C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)\',[adata(1).f,num2str(i)],'\',num2str(j),'\',[adata(1).f,num2str(i)],'_',num2str(j),'_',num2str(k),'*.bmp');
kk=strcat('C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)\',[adata(1).f,num2str(i)],'\',num2str(j),'\',[adata(1).f,num2str(i)],'_',num2str(j),'_',num2str(k));
elseif(i>=10 && i<=99)
input=strcat('C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)\',[adata(2).f,num2str(i)],'\',num2str(j),'\',[adata(2).f,num2str(i)],'_',num2str(j),'_',num2str(k),'*.bmp');
kk=strcat('C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)\',[adata(2).f,num2str(i)],'\',num2str(j),'\',[adata(2).f,num2str(i)],'_',num2str(j),'_',num2str(k));
else
input=strcat('C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)\',num2str(i),'\',num2str(j),'\',num2str(i),'_',num2str(j),'_',num2str(k),'*.bmp');
kk=strcat('C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)\',num2str(i),'\',num2str(j),'\',num2str(i),'_',num2str(j),'_',num2str(k));
end
end
end
end
srcFiles = dir(input);
p=length(srcFiles);
Walter Roberson
on 16 May 2017
projectdir = '$root path$';
dinfo = dir( fullfile(projectdir, '*.bmp') );
srcFiles = fullfile( projectdir, {dinfo.name} );
Unless, that is, there are other bmp files in the same directory. If there are other .bmp files in the same directory then,
projectdir = '$root path$';
dinfo = dir( fullfile(projectdir, '*.bmp') );
filenames = {dinfo.name};
matchpos = regexp(filenames, '^[01]\d\d_[12]_[1-4]\.bmp$');
wrong_file = cellfun( @isempty, matchpos );
filenames(wrong_file) = [];
srcFiles = fullfile(projectdir, filenames);
Jyothi Alugolu
on 16 May 2017
Edited: Walter Roberson
on 16 May 2017
i tried using recurse.m ...
code:
clc; % Clear the command window.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
start_path = fullfile(matlabroot, 'bin');
%Ask user to confirm or change.
topLevelFolder = uigetdir(start_path);
if topLevelFolder == 0
return;
end
%Get list of all subfolders.
allSubFolders = genpath(topLevelFolder);
%Parse into a cell array.
remain = allSubFolders;
listOfFolderNames = {};
while true
[singleSubFolder, remain] = strtok(remain, ';');
if isempty(singleSubFolder)
break;
end
listOfFolderNames = [listOfFolderNames singleSubFolder];
end
numberOfFolders = length(listOfFolderNames);
%Process all image files in those folders.
for k = 1 : numberOfFolders
%Get this folder and print it out.
thisFolder = listOfFolderNames{k};
fprintf('Processing folder %s\n', thisFolder);
filePattern = sprintf('%s/*.bmp', thisFolder);
baseFileNames = dir(filePattern);
aa=natsortfiles({baseFileNames.name});
numberOfImageFiles = length(aa);
%Now we have a list of all files in this folder.
if numberOfImageFiles >= 1
% Go through all those image files.
for f = 1 : numel(aa) %%here aa is being 4 because 108th user 2nd folder contains 4 images
M1{f} = [imread(fullFileName)]; %%only 4 images are being stored..
fullFileName = fullfile(thisFolder,aa{f});
end
fprintf('\nProcessing image file %s\n', fullFileName);
end
fprintf('Folder %s has no image files in it.\n', thisFolder);
end
In the above code, variable aa is storing last user 2nd folder images and those images are being return by variable M..
But what i want is...108 folders with 7 images...so,finally M must have 756 images..(because 108 * 7 = 756);...
Walter Roberson
on 16 May 2017
In the file structure you described, you only have one folder, not 108 folders.
If your files are all in the same folder, then after using the code I gave, after the line
srcFiles = fullfile(projectdir, filenames);
you can use
srcFiles = reshape(srcFiles, 7, []);
and then you would have a 7 x 108 cell array of strings that were file names.
Walter Roberson
on 16 May 2017
projectdir = '$root path$';
dinfo = dir( fullfile(projectdir, '*.bmp') );
srcFiles = fullfile( projectdir, {dinfo.name} );
srcFiles = reshape(srcFiles, 7, []);
Walter Roberson
on 16 May 2017
You would need to replace '$root path$' with the actual directory name. I copied that from your statement
$root path$/XXX_S_Y.bmp
This code will not be sufficient if your files are in folders. For example are your files really of the form
$root path$/XXX/S/Y.bmp
?
Jyothi Alugolu
on 17 May 2017
The images of CASIA-IrisV1 are stored as: $root path$/XXX_S_Y.bmp XXX: the unique identifier of eye, range from 000 to 108. S: the index of session, denotes the first session and the second session. Y: the index of image in the same session. Range from 1 to 3 in the first session, 1 to 4 in the second session. Therefore XXX_S_Y:bmp means the iris image with index Y in session S from eye XXX. XXX=000:108 (t0tally 108 folders) And if S=1,THEN Y=1:3 (1st sub-folder i.e if S=1, then it contains 3 images If S=2, Then Y=1:4 (2nd Sub-folder i.e if S=2, then it contains 4 images).. so for a folder there will be 7 images(3 images in 1st subfolder and 4 images in 2nd subfolder)... Totally 108 folders..so there will be 108 * 7= 756 images from the database..i want load all those images and store in a cell array... I am sending you zip code with some images
Walter Roberson
on 17 May 2017
Assuming that you have R2016b or later:
projectdir = '$root path$';
dinfo = dir( fullfile(projectdir, '*', '*', '*', '*.bmp') );
srcFiles = fullfile( {dinfo.folder}, {dinfo.name} );
srcFiles = reshape(srcFiles, 7, []);
Walter Roberson
on 18 May 2017
Edited: Walter Roberson
on 18 May 2017
projectdir = '$root path$';
dinfo = subdir( fullfile(projectdir, '*', '*', '*', '*.bmp') );
srcFiles = reshape({dinfo.name}, 7, []);
Jyothi Alugolu
on 18 May 2017
Edited: Walter Roberson
on 18 May 2017
while running your code:
projectdir = 'C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)'; %%folder path
dinfo = subdir( fullfile(projectdir, '*', '*', '*', '*.bmp') );
srcFiles = reshape({dinfo.name}, 7, []);
i am having error:
Error using subdir (line 79)
Folder (C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)\*\*\*) not
found
Error in GOT1 (line 2)
dinfo = subdir( fullfile(projectdir, '*', '*','*', '*.bmp') );
Walter Roberson
on 18 May 2017
projectdir = 'C:\Users\admin\Desktop\Databases\Iris\CASIA-IrisV1\CASIA Iris Image Database (version 1.0)'; %%folder path
paths_to_process = {projectdir};
srcFiles = {};
while ~isempty(paths_to_process)
this_path = paths_to_process{1};
paths_to_process(1) = [];
img_info = dir( fullfile(this_path, '*.bmp') );
these_images = fullfile( this_path, {img_info.name} );
srcFiles = [srcFiles; these_images(:)];
dir_info = dir( this_path );
dir_info( ~[dir_info.isdir] ) = [];
dir_info( ismember( {dir_info.name}, {'.', '..'} ) ) = [];
if ~isempty(dir_info)
these_folders = fullfile( this_path, {dir_info.name} );
paths_to_process = [paths_to_process; these_folders(:)];
end
end
num_files = length(srcFiles);
basenames = cell(num_files,1);
for K = 1 : num_files
[~, basenames{K}, ~] = fileparts(srcFiles{K});
end
[~, sortidx] = sort(basenames);
srcFiles = srcFiles(sortidx);
srcFiles = reshape(srcFiles, 7, []);
Walter Roberson
on 6 Feb 2018
Parul
on 29 Oct 2022
@Jyothi Alugolu can you please share the code for iris preprocessing on casia iris version 1 database
More Answers (1)
Nimra Ibrar
on 9 Jun 2019
please i need code of iris recognization if any one help?
1 Comment
Walter Roberson
on 9 Jun 2019
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)