-
Notifications
You must be signed in to change notification settings - Fork 9
/
preprocesspascal.m
executable file
·56 lines (55 loc) · 1.69 KB
/
preprocesspascal.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
44
45
46
47
48
49
50
51
52
53
54
55
56
% Author: Carl Doersch (cdoersch at cs dot cmu dot edu)
%
% Generate an imgs structure and save it to gbz.datasetname.
% It reads all directories contained in gbz.imagedir and
% collects all of the images.
function preprocessindoor67(imagedir,datasetfile)
try
%for(imset=1:2)
imdirs=struct('name',['JPEGImages']);
[~,inds]=sort({imdirs.name})
imdirs=imdirs(inds);
imgs=[];
pascalimgs=textread([imagedir '/ImageSets/Main/trainval.txt'],'%s');
%imdata=[];
%smdata=[];
%if(imset==1)
% pascalimgs=textread('TrainImages.txt','%s','delimiter','\n');
%else
% pascalimgs=textread('TestImages.txt','%s','delimiter','\n');
%end
for(fn=1:numel(imdirs))
if(strcmp(imdirs(fn).name,'.')||strcmp(imdirs(fn).name,'..'))
continue;
end
imdirs(fn).name
imgs1=cleandir([imagedir '/' imdirs(fn).name]);
[~,inds]=sort({imgs1.name});
imgs1=imgs1(inds);
rand('seed',fn);
s=randperm(numel(imgs1));
imgs2={};
for(m=1:numel(imgs1))
if(~ismember(lower([imgs1(m).name(1:end-4)]),lower(pascalimgs)))
continue;
end
[~,pos]=ismember(lower([imgs1(m).name(1:end-4)]),lower(pascalimgs));
pascalimgs(pos)=[];
imgs2{end+1}.fullname=[imdirs(fn).name filesep imgs1(m).name];
imtmp=imread([imagedir '/' imgs2{end}.fullname]);
sz=size(imtmp);
imgs2{end}.imsize=sz(1:2);
if(mod(m,100)==0)
disp([num2str(m) '/' num2str(numel(imgs1))]);
end
end
imgs=[imgs;cell2mat(imgs2')];
%imdata=[imdata; imdata1];
%smdata=[smdata;smdata1];
end
imgs=str2effstr(imgs);
%labelnames=sort(unique(imgs.label));
%[~,imgs.label]=ismember(imgs.label,labelnames);
save(datasetfile,'imgs');
%end
catch ex,dsprinterr;end