Skip to content

Instantly share code, notes, and snippets.

@HiCraigChen
Created February 16, 2020 23:52
Show Gist options
  • Save HiCraigChen/2ef0cbb005ddbb84a65a3ab25f46daab to your computer and use it in GitHub Desktop.
Save HiCraigChen/2ef0cbb005ddbb84a65a3ab25f46daab to your computer and use it in GitHub Desktop.
def distance(point1,point2):
return sqrt((point1[0]-point2[0])**2 + (point1[1]-point2[1])**2)
def gaussianLP(D0,imgShape):
base = np.zeros(imgShape[:2])
rows, cols = imgShape[:2]
center = (rows/2,cols/2)
for x in range(cols):
for y in range(rows):
base[y,x] = exp(((-distance((y,x),center)**2)/(2*(D0**2))))
return base
def gaussianHP(D0,imgShape):
base = np.zeros(imgShape[:2])
rows, cols = imgShape[:2]
center = (rows/2,cols/2)
for x in range(cols):
for y in range(rows):
base[y,x] = 1 - exp(((-distance((y,x),center)**2)/(2*(D0**2))))
return base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment