fork download
  1. import numpy as np
  2.  
  3. def LoG(sigma):
  4. #window size
  5. n = np.ceil(sigma*6)
  6. n = 2
  7. y,x = np.ogrid[-n//2:n//2+1,-n//2:n//2+1]
  8. y_filter = np.exp(-(y*y/(2.*sigma*sigma)))
  9. x_filter = np.exp(-(x*x/(2.*sigma*sigma)))
  10. print(x + y)
  11. final_filter = (-(2*sigma**2) + (x*x + y*y) ) * (x_filter*y_filter) * (1/(2*np.pi*sigma**4))
  12. return final_filter
  13.  
  14. LoG(1)
Success #stdin #stdout 0.05s 24164KB
stdin
Standard input is empty
stdout
[[-2 -1  0]
 [-1  0  1]
 [ 0  1  2]]