Created
July 27, 2020 15:24
-
-
Save MartinMatta/e7da99fceb82307a32612e4f4f8d9a83 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 getGaussianKernel(size=3, sigma=1): | |
| center = (int)(size/2) | |
| kernel = np.zeros((size, size)) | |
| for x in range(-center, center+1): | |
| for y in range(-center, center+1): | |
| x1 = 2*np.pi*sigma**2 | |
| x2 = np.exp(-((x**2 + y**2) / (2*sigma**2))) | |
| kernel[x+center, y+center] = (1/x1) * x2 | |
| return kernel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment