Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4. image = cv2.imread('images/input.jpg')
  5.  
  6. # Store height and width of the image
  7. height, width = image.shape[:2]
  8.  
  9. quarter_height, quarter_width = height/4, width/4
  10.  
  11. # | 1 0 Tx |
  12. # T = | 0 1 Ty |
  13.  
  14. # T is our translation matrix
  15. T = np.float32([[1, 0, quarter_width], [0, 1,quarter_height]])
  16.  
  17. # We use warpAffine to transform the image using the matrix, T
  18. img_translation = cv2.warpAffine(image, T, (width, height))
  19. cv2.imshow('Translation', img_translation)
  20. cv2.waitKey()
  21. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement