0
$\begingroup$

I am trying to understand MATLAB code and it uses a line like:

%create regression labels, gaussian shaped, with a bandwidth proportional to target size
output_sigma = sqrt(prod(target_sz)) * output_sigma_factor / cell_size;
yf = fft2(gaussian_shaped_labels(output_sigma, floor(window_sz / cell_size)));

I am trying to understand what it means by 'gaussian shaped labels'? I understand what is a gaussian filter and the signal with peak at the centre, but I don't get what it means by label here. When I look for the definition, it says:

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.

I especially don't understand the part:

Creates an array of labels (regression targets) for all shifts of a sample

Edit 1: I am adding the code for 'gaussian shaped labels' below:

> function labels = gaussian_shaped_labels(sigma, sz)
> %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. % %   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)
>   
> 
> %evaluate a Gaussian with the peak at the center element  [rs, cs] =
> ndgrid((1:sz(1)) - floor(sz(1)/2), (1:sz(2)) - floor(sz(2)/2));
> labels = exp(-0.5 / sigma^2 * (rs.^2 + cs.^2));    %
> plot(labels(1,1)); 
> 
> %move the peak to the top-left, with wrap-around  labels =
> circshift(labels, -floor(sz(1:2) / 2) + 1); %     plot(fft(labels));
> 
> %sanity check: make sure it's really at top-left  assert(labels(1,1)
> == 1)
> 
> end
$\endgroup$
  • $\begingroup$ Um, that function doesn't seem to be part of Matlab itself, we'd need to guess as much as you do, but unlike you, we don't have access to the code of gaussian_shaped_labels. "Regression Target" usually means a "function to be approximated", but sometimes also means "the approximation function", depending on context! Now, that doesn't make too much sense with the rest of the paragraph, so this nomenclature might refer to the coefficients of some approximating function made out of shifted Gaussians. But as you can see, this is a wild guess. I'd not be comfortable posting this as answer. $\endgroup$ – Marcus Müller Mar 11 at 8:21
  • $\begingroup$ It implies the use of a Gaussian that indicates the probability that a particular location has a particular characterisation. For example, a Gaussian function could be centred around location $5$ on an axis. The closer your quantity is to $5$, the higher the probability that it is actually the $5$. If you are dealing with a spatial domain, then this is a way to assign "soft" labels around a vicinity. For example, the probability that you are in a city is higher at its centre rather than its borders. $\endgroup$ – A_A Mar 11 at 8:54
  • $\begingroup$ @MarcusMüller I added the code for gaussian-shaped labels for more reference, $\endgroup$ – Sulphur Mar 14 at 4:35
  • $\begingroup$ @A_A : Thank you for the response. How should I think thios in terms of an image? It is about locating a target in the image given a window size. Does it mean, if a gaussian is focussed around , say pixel 25, it means, the pixels around pixel 25 are have higher probabilty of being the target than pixels farther away? $\endgroup$ – Sulphur Mar 14 at 4:38
  • $\begingroup$ @Sulphur Yes, that's right. It is also in the description of the function (?) $\endgroup$ – A_A Mar 14 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.