High-Speed Tracking with Kernelized Correlation Filters(二)
首先看看get_features函数。
首先判断是hog特征还是gray,分两种情况。
如果是hog特征,调用fhog函数,返回x,并将矩阵x的第三维最后一个组数据删除(好奇fhog函数http://vision.ucsd.edu/~pdollar/toolbox/doc/index.html)。
1 if features.hog,
2 %HOG features, from Piotr's Toolbox
3 x = double(fhog(single(im) / 255, cell_size, features.hog_orientations));
4 x(:,:,end) = []; %remove all-zeros channel ("truncation feature")
5 %将矩阵x的第三维最后一个组数据删除
6 end
如果是gray,则直接对其归一化处理。
if features.gray,
%gray-level (scalar feature)
x = double(im) / 255;
x = x - mean(x(:));
end
函数最后返回x
下面分析下各个核的correlation。
首先是gaussian核,计算跟CSK没什么两样:
1 N = size(xf,1) * size(xf,2);
2 xx = xf(:)' * xf(:) / N; %squared norm of x
3 yy = yf(:)' * yf(:) / N; %squared norm of y
4
5 %cross-correlation term in Fourier domain
6 xyf = xf .* conj(yf);
7 xy = sum(real(ifft2(xyf)), 3); %to spatial domain
8
9 %calculate gaussian response for all positions, then go back to the
10 %Fourier domain
11 kf = fft2(exp(-1 / sigma^2 * max(0, (xx + yy - 2 * xy) / numel(xf))));
对于linear kernel
kf = sum(xf .* conj(yf), 3) / numel(xf);
对于polynomial kernel
1 xyf = xf .* conj(yf); 2 xy = sum(real(ifft2(xyf)), 3); %to spatial domain 3 4 %calculate polynomial response for all positions, then go back to the 5 %Fourier domain 6 kf = fft2((xy / numel(xf) + a) .^ b);