-
Notifications
You must be signed in to change notification settings - Fork 29
/
get_scale_subwindow.m
35 lines (26 loc) · 1.09 KB
/
get_scale_subwindow.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
function out = get_scale_subwindow(im, pos, base_target_sz, scaleFactors, scale_window, scale_model_sz, scale_feature)
nScales = length(scaleFactors);
for s = 1:nScales
patch_sz = floor(base_target_sz * scaleFactors(s));
xs = floor(pos(2)) + (1:patch_sz(2)) - floor(patch_sz(2)/2);
ys = floor(pos(1)) + (1:patch_sz(1)) - floor(patch_sz(1)/2);
%check for out-of-bounds coordinates, and set them to the values at
%the borders
xs(xs < 1) = 1;
ys(ys < 1) = 1;
xs(xs > size(im,2)) = size(im,2);
ys(ys > size(im,1)) = size(im,1);
%extract image
im_patch = im(ys, xs, :);
% resize image to model size
im_patch_resized = imresize(im_patch, scale_model_sz, 'bilinear', 'AntiAliasing',false);
%im_patch_resized = mexResize(im_patch, scale_model_sz, 'auto');
% extract scale features
temp_hog = fhog(single(im_patch_resized), 4);
temp = temp_hog(:,:,1:31);
if s == 1
out = zeros(numel(temp), nScales, 'single');
end
% window
out(:,s) = temp(:) * scale_window(s);
end