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