Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4. image = cv2.imread('images/input.jpg')
  5. height, width = image.shape[:2]
  6.  
  7. # Divide by two to rototate the image around its centre
  8. rotation_matrix = cv2.getRotationMatrix2D((width/2, height/2), 90, .5)
  9.  
  10. rotated_image = cv2.warpAffine(image, rotation_matrix, (width, height))
  11.  
  12. cv2.imshow('Rotated Image', rotated_image)
  13. cv2.waitKey()
  14. cv2.destroyAllWindows()
  15.  
  16.  
  17. # Other Option to Rotate
  18. img = cv2.imread('images/input.jpg')
  19.  
  20. rotated_image = cv2.transpose(img)
  21.  
  22. cv2.imshow('Rotated Image - Method 2', rotated_image)
  23. cv2.waitKey()
  24. cv2.destroyAllWindows()
  25.  
  26. # Let's now to a horizontal flip.
  27. flipped = cv2.flip(image, 1)
  28. cv2.imshow('Horizontal Flip', flipped)
  29. cv2.waitKey()
  30. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement