code: def shift_image(im, shift, borderValue=0):
      
      im = np.asarray(im, dtype=np.float32)
      rows, cols = im.shape
      M = np.asarray([[1, 0, shift[1]], [0, 1, shift[0]]], dtype=np.float32)
      return cv2.warpAffine(im, M, (cols, rows),
                            borderMode=cv2.BORDER_CONSTANT,
                            flags=cv2.INTER_CUBIC,
                            borderValue=borderValue)
docs: shift the image
  
      Parameters
      ----------
      im: 2d array
          The image
      shift: 2 numbers
          (y,x) the shift in y and x direction
      borderValue: number, default 0
          The value for the pixels outside the border (default 0)
  
      Returns
      -------
      im: 2d array
          The shifted image
  
      Notes
      -----
      The output image has the same size as the input.
      Therefore the image will be cropped in the process.