Gaussian Filter Terminology - sigma, kernal

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

Réponses (1)

Thorsten
Thorsten le 14 Fév 2013
Modifié(e) : Thorsten le 14 Fév 2013
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

4 commentaires

Sam
Sam le 14 Fév 2013
Ok thanks for clarifying that. Using the calculations i found above, how would i change the size of the Gaussain?
Thorsten
Thorsten le 14 Fév 2013
By changing sigma.
Sam
Sam le 14 Fév 2013
I thought sigma was the value for the standard deviation of the gaussian and the calculation needed another value to determine the actual size?
Thorsten
Thorsten le 14 Fév 2013
The size is given by inp which depends on sigma.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Question posée :

Sam
le 14 Fév 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by