Created
January 16, 2019 09:58
-
-
Save FienSoP/49b61a7afdcb992fef0c8ef1b2b3364c to your computer and use it in GitHub Desktop.
Function that generate a Gaussian kernel of specific size and specific sigma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def gaussian_kernel(size, sigma=1): | |
size = int(size) // 2 | |
x, y = np.mgrid[-size:size+1, -size:size+1] | |
normal = 1 / (2.0 * np.pi * sigma**2) | |
g = np.exp(-((x**2 + y**2) / (2.0*sigma**2))) * normal | |
return g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment