text: import cv2
  import numpy as np
  from matplotlib import pyplot as plt
  img = cv2.imread('sudoku.png')
  rows,cols,ch = img.shape
  
  pts1 = np.float32([[50,50],[200,50],[50,200]])
  pts2 = np.float32([[10,100],[200,50],[100,250]])
  
  M = cv2.getAffineTransform(pts1,pts2)
  
  dst = cv2.warpAffine(img,M,(cols,rows))
  
  plt.subplot(121),plt.imshow(img),plt.title('Input')
  plt.subplot(122),plt.imshow(dst),plt.title('Output')
  plt.show()
  
  
  # PRESPECTIVE TRANSFORMATION
  
  img = cv2.imread('sudoku.png')
  rows,cols,ch = img.shape
  
  pts1 = np.float32([[56,65],[368,52],[28,387],[389,390]])
  pts2 = np.float32([[0,0],[300,0],[0,300],[300,300]])
  
  M = cv2.getPerspectiveTransform(pts1,pts2)
  
  dst = cv2.warpPerspective(img,M,(300,300))
  
  plt.subplot(121),plt.imshow(img),plt.title('Input')
  plt.subplot(122),plt.imshow(dst),plt.title('Output')
  plt.show()