Advertisement
dan-masek

Untitled

Sep 22nd, 2018
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4. img = cv2.imread('captcha1.jpg')
  5. phase = -0.8 * np.pi
  6. omega = 2.0 * np.pi / img.shape[1]
  7. amp = 15.0
  8.  
  9. # NB: Mat_<Vec2f> -> 2 channels
  10. proj = np.zeros((img.shape[0], img.shape[1], 2), np.float32)
  11.  
  12. for y in range(img.shape[0]):
  13.     for x in range(img.shape[1]):
  14.         u = 0.0
  15.         v = np.sin(phase + float(x) * omega) * amp
  16.         proj[y, x] = (float(x) + u, float(y) + v)
  17.  
  18. corr = cv2.remap(img, proj, None, cv2.INTER_LINEAR)
  19. cv2.imshow('in', img)
  20. cv2.imshow('out', corr)
  21. cv2.waitKey()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement