[英]Generate a Gaussian kernel given mean and standard deviation
This question here addresses how to generate a Gaussian kernel using numpy. 这里的问题解决了如何使用numpy生成高斯内核。 However I do not understand what the inputs used kernlen
and nsig
are and how they relate to the mean/standard deviation usually used to describe a Gaussian distribtion. 但是,我不了解kernlen
和nsig
所使用的输入是什么,以及它们与通常用于描述高斯分布的均值/标准差之间的关系。
How would I generate a 2d Gaussian kernel described by, say mean = (8, 10)
and sigma = 3
? 我将如何生成以mean = (8, 10)
和sigma = 3
描述的2d高斯核? The ideal output would be a 2-dimensional array representing the Gaussian distribution. 理想的输出将是代表高斯分布的二维数组。
You could use astropy
, especially the Gaussian2D
model from the astropy.modeling.models
module: 您可以使用astropy
,尤其是来自astropy.modeling.models
模块的Gaussian2D
模型:
from astropy.modeling.models import Gaussian2D
g2d = Gaussian2D(x_mean=8, y_mean=10, x_stddev=3, y_stddev=3) # specify properties
g2d(*np.mgrid[0:100, 0:100]) # specify the grid for the array
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.