patchmatch算法笔记

PatchMatch: A Randomized Correspondence Algorithm for Structural Image Editing
Patch match算法主要分为三步:初始化,传播,和随机搜索

The key insights driving the algorithm are that some good patch matches can be found via random sampling, and that natural coherence in the imagery allows us to propagate such matches quickly to surrounding areas.
算法主要原理是一个好的块匹配可以通过随机采样搜索和图像的自然连续性,借助块邻域特征传播

patchmatch算法笔记_第1张图片

Initially, the nearest-neighbor field is filled with either random offsets or some prior information. Next, an iterative update process is applied to the NNF, in which good patch offsets are propagated to adjacent pixels, followed by random search in the neighborhood of the best offset found so far

首先初始化:初始化可以是随机值也可以根据先验信息,随机设置offsets,参考图patch和随机的目标图中的匹配patch,计算两个patch距离(比如L2距离),将随机offsets和初始距离存入一个矩阵
传播:根据迭代次数奇偶决定扫描顺序,比如为奇数,就比较左上两点和现在的初始距离,比如左边点的距离最小,那就认为左边是匹配好,现在点的offsets跟新为左边那个点的offsets,根据跟新的offsets更新该点距离
patchmatch算法笔记_第2张图片
随机搜索:搜索半径w可以设为该点到边界的距离,每次搜索都在一个半径里随机选一个值,然后在缩小半径,直到搜索半径小于1pixel停止随机搜索,在这一系列随机搜索中跟现在的距离比较,找到最小距离的offsets,更新offsets和匹配距离。
patchmatch算法笔记_第3张图片
代码

你可能感兴趣的:(算法)