1

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.

Community
  • 1
  • 1
John Crow
  • 927
  • 3
  • 13
  • 26

1 Answers1

2

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

enter image description here

MSeifert
  • 145,886
  • 38
  • 333
  • 352