misc.py 文件源码

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

项目:SMURFS-Superpixels 作者: imaluengo 项目源码 文件源码
def color_gmagnitude(img, sigma=None, norm=True, enhance=False):
    """

    """
    if sigma is not None:
        img = gaussian(img, sigma=sigma, multichannel=True)

    dx = np.dstack([sobel_h(img[..., i]) for i in range(img.shape[-1])])
    dy = np.dstack([sobel_v(img[..., i]) for i in range(img.shape[-1])])

    Jx = np.sum(dx**2, axis=-1)
    Jy = np.sum(dy**2, axis=-1)
    Jxy = np.sum(dx * dy, axis=-1)

    D = np.sqrt(np.abs(Jx**2 - 2 * Jx * Jy + Jy**2 + 4 * Jxy**2))
    e1 = (Jx + Jy + D) / 2. # First eigenvalue
    magnitude = np.sqrt(e1)

    if norm:
        magnitude /= magnitude.max()

    if enhance:
        magnitude = 1 - np.exp(-magnitude**2 / magnitude.mean())

    return magnitude.astype(np.float32)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号