Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def rootate(x, y):
- ...: img = cv2.cvtColor(y*255, cv2.COLOR_GRAY2BGR)
- ...: edges = cv2.Canny(y,0, 1)
- ...:
- ...: lines = cv2.HoughLines(edges,1,np.pi/180, 1)
- ...: for rho,theta in lines[0]:
- ...: a = np.cos(theta)
- ...: b = np.sin(theta)
- ...: x0 = a*rho
- ...: y0 = b*rho
- ...: print(theta)
- ...: M = cv2.getRotationMatrix2D((x.shape[1] / 2, x.shape[0] / 2), - 90 + (theta * 180 / np.pi), 1)
- ...: res = cv2.warpAffine(x, M, (x.shape[1], x.shape[0]))
- ...: plt.imshow(x)
- ...: plt.show()
- ...: plt.imshow(res)
- ...: plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement