Reputation: 947
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.
Upvotes: 1
Views: 1576
Reputation: 152647
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
Upvotes: 2