-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadImageNames.m
44 lines (40 loc) · 1.6 KB
/
ReadImageNames.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function [ FList, cnos ] = ReadImageNames(DataFolder)
% Author: Thokare Nitin D.
%
% This function reads all file names contained in Datafolder and it's subfolders
% with extension given in extList variable in this code...
% Note: Keep each extension in extension list with length 3
% i.e. last 3 characters of the filename with extension
% if extension is 2 character length (e.g. MA for mathematica ascii file), use '.'
% (i.e. '.MA' for given example)
% Example:
% extList={'jpg','peg','bmp','tif','iff','png','gif','ppm','pgm','pbm','pmn','xcf'};
% Gives the list of all image files in DataFolder and it's subfolder
%
DirContents=dir(DataFolder);
FList=[];
cnos=[];
if(strcmpi(computer,'PCWIN') || strcmpi(computer,'PCWIN64'))
NameSeperator='\';
elseif(strcmpi(computer,'GLNX86') || strcmpi(computer,'GLNXA86'))
NameSeperator='/';
end
extList={'jpg','peg','bmp','tif','iff','png','gif','ppm','pgm','pbm','pmn','xcf'};
% Here 'peg' is written for .jpeg and 'iff' is written for .tiff
for i=1:numel(DirContents)
if(~(strcmpi(DirContents(i).name,'.') || strcmpi(DirContents(i).name,'..') ))
if(~DirContents(i).isdir)
extension=DirContents(i).name(end-2:end);
if(numel(find(strcmpi(extension,extList)))~=0)
% tname=;
FList=cat(1,FList,{[DataFolder,NameSeperator,DirContents(i).name]});
cnos=cat(1,cnos,{DataFolder});
end
else
[getlist, ctemp]=ReadImageNames([DataFolder,NameSeperator,DirContents(i).name]);
FList=cat(1,FList,getlist);
cnos=cat(1,cnos,ctemp);
end
end
end
end