def computeWeightsLocallyNormalized(I, centered_gradient=True, norm_radius=45):
h,w = I.shape[:2]
if centered_gradient:
gy,gx = np.gradient(I)[:2]
gysq = (gy**2).mean(axis=2) if gy.ndim > 2 else gy**2
gxsq = (gx**2).mean(axis=2) if gx.ndim > 2 else gx**2
gxsq_local_mean = cv2.blur(gxsq, ksize=(norm_radius, norm_radius))
gysq_local_mean = cv2.blur(gysq, ksize=(norm_radius, norm_radius))
w_horizontal = np.exp( - gxsq * 1.0/(2*np.maximum(1e-6, gxsq_local_mean)))
w_vertical = np.exp( - gysq * 1.0/(2*np.maximum(1e-6, gysq_local_mean)))
else:
raise Exception("NotImplementedYet")
return w_horizontal, w_vertical
评论列表
文章目录