def edge_LoG(I, sigma):
LoG = laplace(gaussian(I, sigma=sigma), ksize=3)
thres = np.absolute(LoG).mean() * 1.0
output = sp.zeros(LoG.shape)
w = output.shape[1]
h = output.shape[0]
for y in range(1, h - 1):
for x in range(1, w - 1):
patch = LoG[y - 1:y + 2, x - 1:x + 2]
p = LoG[y, x]
maxP = patch.max()
minP = patch.min()
if p > 0:
zeroCross = True if minP < 0 else False
else:
zeroCross = True if maxP > 0 else False
if ((maxP - minP) > thres) and zeroCross:
output[y, x] = 1
#FIXME: It is necesary to define if return the closing of the output or just the output
#return binary_closing(output)
return output
评论列表
文章目录