如何使用变形的网格(可逆)使文档图像变形

时间:2019-01-17 11:04:25

标签: python opencv image-manipulation

我要在变形的网格上扭曲文档图像,如下所示:

enter image description here

此处描述了一种半正确的方法:link

但是,我对可逆映射特别感兴趣,理想情况下,是一种单向操作(无需填充图像,就像使用cv2.remap时那样)。 / p>

示例过程:

步骤1:获取变形的网格(对于给定的图像src)

 xx_deformed = xx + vx
 yy_deformed = yy + vy

其中vx和vy描述变形(请参见上面的链接)。

步骤2:在网格上映射图像:

 warped_img = one_way_operation(src, xx_deformed, yy_deformed)

第3步: 撤消变形:

 xx_inv = xx - vx
 yy_inv = yy - vy

 unwarped_img = one_way_operation(warped_img, xx_inv, yy_inv)

预期结果:

  assert(img == unwarped_img)

有没有达到此目标的优雅方法?我很感谢任何提示。

0 个答案:

没有答案