Gaussian Filter Terminology - sigma, kernal
Mostrar comentarios más antiguos
I am looking at code people have written to make their own filters in Matlab. These calculations below seem to keep popping up. I understand sigma is the total sum of all values in the kernal grid. Correct? But where in this calculation do you specify the grid/kernal size? eg 3x3, 5x5, etc.
I wish to understand this code and can you advise me on how you can change the size of the kernal/grid. Thank you in advance.
sigma = 1;
inp = (-1 .*2.5 .*sigma):1:(2.5 .* sigma);
gauss1d = (1/(sigma .* sqrt(2*pi))).*exp(-(inp.^2/(2.*sigma.*sigma)));
gaussprime = diff(gauss1d);
inp =
-2.5000 -1.5000 -0.5000 0.5000 1.5000 2.5000
gauss1d =
0.0175 0.1295 0.3521 0.3521 0.1295 0.0175
gaussprime =
0.1120 0.2225 0 -0.2225 -0.1120
Respuestas (1)
You got it wrong. Sigma determines the width of the Gaussian. The larger sigma, the more values you need to sample the Gaussian properly.
function z = gauss(sigma)
%GAUSS 1-D Gaussian.
precision = 3; %
bound_x = ceil(precision * sigma);
x = (-bound_x : bound_x);
z = 1/(sqrt(2*pi) * sigma) * exp(-0.5 * (x.^2 / sigma^2));
z = z/sum(z(:)); % normalize such that the Gaussian integrates to unity
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!