Pappu19

Image Translation

Sep 16th, 2021 (edited)
712
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import cv2
  2. import numpy as np
  3.  
  4. image = cv2.imread('Image.png')
  5.  
  6. height, width = image.shape[:2]
  7.  
  8. quarter_height, quarter_width = height / 4, width / 4
  9.  
  10. T = np.float32([[1, 0, quarter_width], [0, 1, quarter_height]])
  11.  
  12. translation = cv2.warpAffine(image, T, (width, height))
  13.  
  14. cv2.imshow("Original Image", image)
  15. cv2.imshow('Translation', translation)
  16. cv2.waitKey()
  17.  
  18. cv2.destroyAllWindows()
RAW Paste Data