打开简历创建垂直正弦波以修复垂直失真

时间:2018-11-24 18:40:10

标签: python-3.x opencv image-processing opencv3.0

我正在尝试处理下面的图像。该图像在水平和垂直方向上都失真。我可以使用开放式cv重新映射来修复水平失真,但不确定如何对垂直y轴应用相同的逻辑。代码,但不能提供预期的结果。

我如何将弯头l变成笔直的l。

代码

img = cv2.imread('test.png',0)
phase = 1.2 * np.pi
omega = 2.0 * np.pi / img.shape[1]
amp = 18.0

proj = np.zeros((img.shape[0], img.shape[1], 2), np.float32)

for y in range(img.shape[0]):
    for x in range(img.shape[1]):
        u = 0.0
        v = np.sin(phase + float(x) * omega) * amp
        proj[y, x] = (float(x) + u, float(y) + v)

corr = cv2.remap(img, proj, None, cv2.INTER_LINEAR)
cv2.imshow('in', img)
cv2.imshow('out', corr)
cv2.waitKey()

原始图片

enter image description here

处理后的图像:

enter image description here

0 个答案:

没有答案
相关问题