def local_normalize_1ch(img, const=127.0):
mu = convolve(img, kern, mode='nearest')
mu_sq = mu * mu
im_sq = img * img
tmp = convolve(im_sq, kern, mode='nearest') - mu_sq
sigma = np.sqrt(np.abs(tmp))
structdis = (img - mu) / (sigma + const)
# Rescale within 0 and 1
# structdis = (structdis + 3) / 6
structdis = 2. * structdis / 3.
return structdis
评论列表
文章目录