edge_weights.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mrflow 作者: jswulff 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号