a guest Jul 23rd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. from scipy import signal
  4. def gaussian_kernel(n, std, normalised=False):
  5.     '''
  6.     Generates a n x n matrix with a centered gaussian
  7.     of standard deviation std centered on it. If normalised,
  8.     its volume equals 1.'''
  9.     gaussian1D = signal.gaussian(n, std)
  10.     gaussian2D = np.outer(gaussian1D, gaussian1D)
  11.     if normalised:
  12.         gaussian2D /= (2*np.pi*(std**2))
  13.     return gaussian2D
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand