Skip to content

Instantly share code, notes, and snippets.

@Nithilaa
Created October 28, 2021 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nithilaa/92fc51efb752a8b6c8c182d550c58286 to your computer and use it in GitHub Desktop.
Save Nithilaa/92fc51efb752a8b6c8c182d550c58286 to your computer and use it in GitHub Desktop.
import numpy as np
rows, cols, ch = img.shape
src_points = np.float32([[0,0], [cols-1,0], [0,rows-1]])
dst_points = np.float32([[0,0], [int(0.6*(cols-1)),0], [int(0.4*(cols-1)),rows-1]])
matrix = cv2.getAffineTransform(src_points, dst_points)
img_afftran = cv2.warpAffine(img, matrix, (cols,rows))
cv2.imshow("Affine Transformation", img_afftran)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment