Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to obtain 2d Gaussian kernel in matlab [duplicate]

How do I obtain 2D circularly symmetric Gaussian weighting function sampled out to 3 standard deviations (3 x 3) and re scaled to unit volume?

like image 261
Gaurang Rokad Avatar asked Dec 06 '25 11:12

Gaurang Rokad


1 Answers

Try fspecial (Image Processing Toolbox) with the 'gaussian' option. For example,

z = fspecial('gaussian', [30 30], 4);

generates values on a 30×30 grid with sampling step 1 and standard deviation 4.

surf(z)

produces the graph

enter image description here

The function is normalized to unit volume. To check this, note that the sampling step is 1, so that the Riemann sum approximating the integral is just the sum of all function values:

>> sum(z(:))
ans =
    1.0000
like image 142
Luis Mendo Avatar answered Dec 08 '25 01:12

Luis Mendo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!