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

ε祈祈猫儿з 提交于 2020-01-15 07:06:10

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/29406373/how-to-obtain-2d-gaussian-kernel-in-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!