I am having difficulty implementing a Laplacian of Gaussian kernel. I have the following code and I am trying to implement a 9x9 kernel with sigma = 1.4. The kernel is shown on this link
http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm
However, my values are nothing like those in that kernel, I think my function is off. Help would be greatly appreciated. Thank you.
import math
pi= math.pi
log = [[0 for x in range(9)] for x in range(9)]
def genlog(log,size,o):
for i in range(-size/2,size/2):
for j in range(-size/2,size/2):
log[i][j] = -(pi*o**4)**(-1)*(1-(i**2+j**2)/(2*o**2))*math.exp(-(i**2+j**2)/(2*o**2))
def printlog(log,size):
for i in range(-size/2,size/2):
print ' '.join(str(log[i][j]) for j in range(-size/2,size/2))
genlog(log,9,1.4)
printlog(log,9)