给定均值和标准差,生成高斯核 [英] Generate a Gaussian kernel given mean and standard deviation

查看:118
本文介绍了给定均值和标准差,生成高斯核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题在这里解决了使用numpy生成高斯内核.但是,我不了解使用kernlennsig的输入是什么,以及它们与通常用于描述高斯分布的均值/标准差之间的关系.

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.

如何生成用mean = (8, 10)sigma = 3描述的2d高斯核?理想的输出将是代表高斯分布的二维数组.

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.

推荐答案

您可以使用astropy,尤其是

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

这篇关于给定均值和标准差,生成高斯核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆