import cv2
import numpy as np
import matplotlib.pyplot as plt

image = cv2.imread('../images/scan.jpg')

cv2.imshow('Original', image)
cv2.waitKey(0)

points_A = np.float32([[320,15], [700,215], [85,610], [530,780]])

points_B = np.float32([[0,0], [420,0], [0,594], [420,594]])
   
M = cv2.getPerspectiveTransform(points_A, points_B)
 
warped = cv2.warpPerspective(image, M, (420,594))
 
cv2.imshow('warpPerspective', warped)
cv2.waitKey(0)
cv2.destroyAllWindows()

image = cv2.imread('../images/ex2.jpg')
rows,cols,ch = image.shape

cv2.imshow('Original', image)
cv2.waitKey(0)

points_A = np.float32([[320,15], [700,215], [85,610]])

points_B = np.float32([[0,0], [420,0], [0,594]])
  
M = cv2.getAffineTransform(points_A, points_B)

warped = cv2.warpAffine(image, M, (cols, rows))
 
cv2.imshow('warpPerspective', warped)
cv2.waitKey(0)
cv2.destroyAllWindows()
import cv2
import numpy as np
import matplotlib.pyplot as plt

image = cv2.imread('../images/scan.jpg')

cv2.imshow('Original', image)
cv2.waitKey(0)

points_A = np.float32([[320,15], [700,215], [85,610], [530,780]])

points_B = np.float32([[0,0], [420,0], [0,594], [420,594]])
   
M = cv2.getPerspectiveTransform(points_A, points_B)
 
warped = cv2.warpPerspective(image, M, (420,594))
 
cv2.imshow('warpPerspective', warped)
cv2.waitKey(0)
cv2.destroyAllWindows()

image = cv2.imread('../images/ex2.jpg')
rows,cols,ch = image.shape

cv2.imshow('Original', image)
cv2.waitKey(0)

points_A = np.float32([[320,15], [700,215], [85,610]])

points_B = np.float32([[0,0], [420,0], [0,594]])
  
M = cv2.getAffineTransform(points_A, points_B)

warped = cv2.warpAffine(image, M, (cols, rows))
 
cv2.imshow('warpPerspective', warped)
cv2.waitKey(0)
cv2.destroyAllWindows()