ffcc
ffcc copied to clipboard
How to understand the meaning of the conv operations in the function "RenderHistorgramGaussian"?
hi, @jonbarron, thanks for sharing the codes of the ffcc. I can't understand the meaning of the conv operations in the function "RenderHistorgramGaussian". The code is as follow,
% Threshold the mahalanobis distance at 3 to make a binary mask, which is
% dilated to produce an ellipse with a dot in the center.
mask = mahal_dist <= 3;
prediction = (conv2(double(mask), ones(3,3), 'same') > 0) & ~mask;
prediction = prediction | (conv2(double(mahal_dist == min(mahal_dist(:))), [0, 1, 0; 1, 1, 1; 0, 1, 0], 'same') > 0);
% Optionally create a mask with the ground-truth white point rendered as a dot.
if ~isempty(mu_true)
D = (us - mu_true(1)).^2 + (vs - mu_true(2)).^2;
truth = D == min(D(:));
truth = (conv2(double(truth), [0, 1, 0; 1, 1, 1; 0, 1, 0], 'same') > 0);
truth = (conv2(double(truth), [0, 1, 0; 1, 1, 1; 0, 1, 0], 'same') > 0);
I want to ask the questions,
- What's the meaning of the function conv2(double(mask), ones(3,3), 'same') > 0) ?
- I can understand the formula about mahal_dist == min(mahal_dist(:) to get the ellipse of the minmum distance. However, i can't understand why to run the conv operation of the formula conv2(double(mahal_dist == min(mahal_dist(:))), [0, 1, 0; 1, 1, 1; 0, 1, 0], 'same') and why to chose the matrix [0, 1, 0; 1, 1, 1; 0, 1, 0] .
- Why are the two same conv operations with conv2(double(truth), [0, 1, 0; 1, 1, 1; 0, 1, 0], 'same') ?
Look forward to your favourable reply ! @jonbarron
- This just dilates the mask, https://en.wikipedia.org/wiki/Dilation_(morphology). By dilating the mask and then removing the original mask, you get a boundary around the ellipse.
mahal_dist == min(mahal_dist(:)just makes a single pixel at the argmin, and then it's convolved by a plus shape to make a plus. This is just because I wanted a plus shape at the center.- Convolving by
[0, 1, 0; 1, 1, 1; 0, 1, 0]twice just gives a nice diamond shape. All of this code is just for visualizing the results, and isn't critical to the algorithm.
@jonbarron I am very glad to receive your prompt reply! Thanks!