Generate a Gaussian kernel given mean and standard deviation

社会主义新天地 提交于 2019-12-11 06:36:19

问题


This question here addresses how to generate a Gaussian kernel using 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.

How would I generate a 2d Gaussian kernel described by, say mean = (8, 10) and sigma = 3? The ideal output would be a 2-dimensional array representing the Gaussian distribution.


回答1:


You could use astropy, especially the Gaussian2D model from the astropy.modeling.models module:

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



来源:https://stackoverflow.com/questions/42078840/generate-a-gaussian-kernel-given-mean-and-standard-deviation

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