def gabor_kernel(W, angle, freq): cos = math.cos(angle) sin = math.sin(angle) yangle = lambda x, y: x * cos + y * sin xangle = lambda x, y: -x * sin + y * cos xsigma = ysigma = 4 return utils.kernel_from_function( W, lambda x, y: math.exp(-( (xangle(x, y)**2) / (xsigma**2) + (yangle(x, y)**2) / (ysigma**2)) / 2) * math.cos(2 * math.pi * freq * xangle(x, y)))
def gabor_kernel(W, angle, freq): cos = math.cos(angle) sin = math.sin(angle) yangle = lambda x, y: x * cos + y * sin xangle = lambda x, y: -x * sin + y * cos xsigma = ysigma = 4 return utils.kernel_from_function(W, lambda x, y: math.exp(-( (xangle(x, y) ** 2) / (xsigma ** 2) + (yangle(x, y) ** 2) / (ysigma ** 2)) / 2) * math.cos(2 * math.pi * freq * xangle(x, y)))