Created
August 1, 2019 12:39
-
-
Save suvojit-0x55aa/fdbaeade2618ac302ec85dfa5f01f9e9 to your computer and use it in GitHub Desktop.
Python Numpy Gaussian Function
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
def gauss_map(size_x, size_y=None, sigma_x=5, sigma_y=None): | |
if size_y == None: | |
size_y = size_x | |
if sigma_y == None: | |
sigma_y = sigma_x | |
assert isinstance(size_x, int) | |
assert isinstance(size_y, int) | |
x0 = size_x // 2 | |
y0 = size_y // 2 | |
x = np.arange(0, size_x, dtype=float) | |
y = np.arange(0, size_y, dtype=float)[:,np.newaxis] | |
x -= x0 | |
y -= y0 | |
exp_part = x**2/(2*sigma_x**2)+ y**2/(2*sigma_y**2) | |
return 1/(2*np.pi*sigma_x*sigma_y) * np.exp(-exp_part) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment