且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Matlab中获得2d高斯核

更新时间:2023-02-27 11:19:07

尝试



该功能已标准化为单位体积。要对此进行检查,请注意采样步骤为 1 ,因此逼近积分的黎曼总和就是所有函数值的总和:

 >> sum(z(:))
ans =
1.0000


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?

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