i am sending 4 images out of 108 images..please have a look how the images are stored with file names...
How to load CASIA Iris Version V1 database images..
13 次查看(过去 30 天)
显示 更早的评论
Jyothi Alugolu
2017-5-16
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 个评论
KSSV
2017-5-16
Jyothi Alugolu
2017-5-16
that is not the question which i asked... i used recures.m file,but i am not getting all the subfolder images..
KSSV
2017-5-16
How your question of accessing images in sub folders/ folders is different from what given in the link?
采纳的回答
Walter Roberson
2017-5-16
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 个评论
Jyothi Alugolu
2017-5-16
编辑:Walter Roberson
2017-5-16
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
2017-5-16
编辑:Walter Roberson
2017-5-16
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
2017-5-16
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
2017-5-16
编辑:Walter Roberson
2017-5-16
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
2017-5-16
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
2017-5-16
projectdir = '$root path$';
dinfo = dir( fullfile(projectdir, '*.bmp') );
srcFiles = fullfile( projectdir, {dinfo.name} );
srcFiles = reshape(srcFiles, 7, []);
Walter Roberson
2017-5-16
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
2017-5-17
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
2017-5-17
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
2017-5-18
编辑:Walter Roberson
2017-5-18
projectdir = '$root path$';
dinfo = subdir( fullfile(projectdir, '*', '*', '*', '*.bmp') );
srcFiles = reshape({dinfo.name}, 7, []);
Jyothi Alugolu
2017-5-18
编辑:Walter Roberson
2017-5-18
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
2017-5-18
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
2018-2-6
Parul
2022-10-29
@Jyothi Alugolu can you please share the code for iris preprocessing on casia iris version 1 database
更多回答(1 个)
Nimra Ibrar
2019-6-9
please i need code of iris recognization if any one help?
1 个评论
Walter Roberson
2019-6-9
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)