GAUSSIAN_SHAPED_LABELS Gaussian-shaped labels for all shifts of a sample. LABELS = GAUSSIAN_SHAPED_LABELS(SIGMA, SZ) Creates an array of labels (regression targets) for all shifts of a sample of dimensions SZ. The output will have size SZ, representing one label for each possible shift. The labels will be Gaussian-shaped, with the peak at 0-shift (top-left element of the array), decaying as the distance increases, and wrapping around at the borders. The Gaussian function has spatial bandwidth SIGMA. See also INITDSKCFPARAM, SINGLEFRAMEDSKCF This function has been inserted in the DS-KCF matlab library from the KCF library released by Joao F. Henriques, 2014 http://www.isr.uc.pt/~henriques/ %as a simple example, the limit sigma = 0 would be a Dirac delta, %instead of a Gaussian: labels = zeros(sz(1:2)); %labels for all shifted samples labels(1,1) = magnitude; %label for 0-shift (original sample)
0001 function labels = gaussian_shaped_labels(sigma, sz) 0002 %GAUSSIAN_SHAPED_LABELS 0003 % Gaussian-shaped labels for all shifts of a sample. 0004 % 0005 % LABELS = GAUSSIAN_SHAPED_LABELS(SIGMA, SZ) 0006 % Creates an array of labels (regression targets) for all shifts of a 0007 % sample of dimensions SZ. The output will have size SZ, representing 0008 % one label for each possible shift. The labels will be Gaussian-shaped, 0009 % with the peak at 0-shift (top-left element of the array), decaying 0010 % as the distance increases, and wrapping around at the borders. 0011 % The Gaussian function has spatial bandwidth SIGMA. 0012 % 0013 % See also INITDSKCFPARAM, SINGLEFRAMEDSKCF 0014 % 0015 % This function has been inserted in the DS-KCF matlab library from the 0016 % KCF library released by 0017 % 0018 % Joao F. Henriques, 2014 0019 % http://www.isr.uc.pt/~henriques/ 0020 % 0021 % %as a simple example, the limit sigma = 0 would be a Dirac delta, 0022 % %instead of a Gaussian: 0023 % labels = zeros(sz(1:2)); %labels for all shifted samples 0024 % labels(1,1) = magnitude; %label for 0-shift (original sample) 0025 0026 0027 %evaluate a Gaussian with the peak at the center element 0028 [rs, cs] = ndgrid((1:sz(1)) - floor(sz(1)/2), (1:sz(2)) - floor(sz(2)/2)); 0029 labels = exp(-0.5 / sigma^2 * (rs.^2 + cs.^2)); 0030 0031 %move the peak to the top-left, with wrap-around 0032 labels = circshift(labels, -floor(sz(1:2) / 2) + 1); 0033 0034 %sanity check: make sure it's really at top-left 0035 assert(labels(1,1) == 1) 0036 0037 end 0038