patchmatch_code.py 文件源码

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

项目:patchmatch 作者: samyblusseau 项目源码 文件源码
def try_improve_a_from_b(idx_a, idx_b, heap_a, heap_b,
                         patches, M, N, alpha, g):
    k = len(heap_a)
    p0 = patches[idx_a, :, :]# patch around pixel idx_a
    for nn in range(0,k):
        # compute the 2D offset corresponding idx_b's nn-est nearest neighbour
        offs_b = heap_b[nn][1]
        idx_d = int(idx_a + offs_b)
        idx_d = max(idx_d, 0)
        idx_d = min(idx_d, patches.shape[0]-1)
        offs_b = idx_d - idx_a
        p2 = patches[idx_d, :, :]# patch around the new pixel to compare to idx_a
        w_b = patches_dissimilarity(p0, p2, alpha, g)# new weight
        if w_b > heap_a[0][0] and not ((w_b, offs_b) in heap_a):
            heapq.heapreplace(heap_a, (w_b, offs_b))
    return heap_a
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号