code: def create_perspective_transform_matrix(src, dst):
      """Creates a perspective transformation matrix which transforms points
      in quadrilateral ``src`` to the corresponding points on quadrilateral
      ``dst``.
  
      Will raise a ``np.linalg.LinAlgError`` on invalid input.
      """
      # See:
      # * http://xenia.media.mit.edu/~cwren/interpolator/
      # * http://stackoverflow.com/a/14178717/71522
      in_matrix = []
      for (x, y), (X, Y) in zip(src, dst):
          in_matrix.extend(
              [
                  [x, y, 1, 0, 0, 0, -X * x, -X * y],
                  [0, 0, 0, x, y, 1, -Y * x, -Y * y],
              ]
          )
  
      A = np.matrix(in_matrix, dtype=np.float)
      B = np.array(dst).reshape(8)
      af = np.dot(np.linalg.inv(A.T * A) * A.T, B)
      return np.append(np.array(af).reshape(8), 1).reshape((3, 3))
  
imports: import numpy
  import scipy.ndimage
  import PIL.Image
label_desc: Use image node_id 1 for calling a global function with example usage: create_perspective_transform_matrix(src, dst) and returns: np