Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. def rootate(x, y):
  2. ...: img = cv2.cvtColor(y*255, cv2.COLOR_GRAY2BGR)
  3. ...: edges = cv2.Canny(y,0, 1)
  4. ...:
  5. ...: lines = cv2.HoughLines(edges,1,np.pi/180, 1)
  6. ...: for rho,theta in lines[0]:
  7. ...: a = np.cos(theta)
  8. ...: b = np.sin(theta)
  9. ...: x0 = a*rho
  10. ...: y0 = b*rho
  11. ...: print(theta)
  12. ...: M = cv2.getRotationMatrix2D((x.shape[1] / 2, x.shape[0] / 2), - 90 + (theta * 180 / np.pi), 1)
  13. ...: res = cv2.warpAffine(x, M, (x.shape[1], x.shape[0]))
  14. ...: plt.imshow(x)
  15. ...: plt.show()
  16. ...: plt.imshow(res)
  17. ...: plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement