如何在matlab中获得二维高斯核 [英] how to obtain 2d Gaussian kernel in matlab
本文介绍了如何在matlab中获得二维高斯核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获得二维圆对称高斯加权函数采样到 3标准偏差 (3 x 3) 并重新缩放到单位体积?
解决方案
尝试
函数被归一化为单位体积.要检查这一点,请注意采样步骤是 1
,因此近似积分的黎曼和就是所有函数值的总和:
<代码>>>总和(z(:))答案 =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
这篇关于如何在matlab中获得二维高斯核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文