-
Notifications
You must be signed in to change notification settings - Fork 1
/
extractpatches.m
executable file
·51 lines (49 loc) · 1.3 KB
/
extractpatches.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
% Author: Carl Doersch (cdoersch at cs dot cmu dot edu)
%
% Extract patches corresponding to detections in images.
% detsimple is the set of detections, with a 'pos' field
% specifying positions, and a 'imidx' field, specifying
% an index into the current image set. imgs_all us unused.
function res=extractpatches(detsimple,imgs_all,conf)
global ds;
if(~exist('conf','var'))
conf=struct();
end
try
% dsload('ds.imgs');
% global imgs;
% if(isempty(imgs))
imgs=cell(numel(ds.imgs{ds.conf.currimset}),1);
% end
numel(detsimple)
loaded=[];
ct=1;
[~,ord]=sort([detsimple.imidx]);
for(dsidx=ord(:)')
pos=detsimple(dsidx).pos;
i=detsimple(dsidx).imidx;
if(isempty(imgs{i}))
imgs{i}=getimg(ds,i);%imread([ds.conf.gbz.cutoutdir imgs_all(i).fullname]);
loaded(loaded==i)=[];
loaded=[loaded i];
if(numel(loaded)>1)
imgs{loaded(1)}=[];
loaded(1)=[];
end
end
if(dsbool(conf,'noresize'))
res{dsidx}=imgs{i}(pos.y1:pos.y2,pos.x1:pos.x2,:);
else
maxsz=max(pos.y2-pos.y1,pos.x2-pos.x1);
reszx=80*(pos.x2-pos.x1)/maxsz;
reszy=80*(pos.y2-pos.y1)/maxsz;
res{dsidx}=imresize(imgs{i}(pos.y1:pos.y2,pos.x1:pos.x2,:),[reszy reszx]);
end
if(mod(ct,10)==0)
disp(ct)
end
ct=ct+1;
end
catch ex
dsprinterr
end