code: import numpy as np
  import cv2
  import matplotlib.image as mpimg
  
  
  def perspect_transform(img, src, dst):
  
      # Get transform matrix using cv2.getPerspectivTransform()
      M = cv2.getPerspectiveTransform(src, dst)
      # Warp image using cv2.warpPerspective()
      # keep same size as input image
      warped = cv2.warpPerspective(img, M, (img.shape[1], img.shape[0]))
      # Return the result
      return warped
  
  
  def color_thresh(img, rgb_thresh=(160, 160, 160)):
      # Create an array of zeros same xy size as img, but single channel
      color_select = np.zeros_like(img[:, :, 0])
      # Require that each pixel be above all thre threshold values in RGB
      # above_thresh will now contain a boolean array with "True"
      # where threshold was met
      above_thresh = (img[:, :, 0] > rgb_thresh[0]) \
          & (img[:, :, 1] > rgb_thresh[1]) \
          & (img[:, :, 2] > rgb_thresh[2])
      # Index the array of zeros with the boolean array and set to 1
      color_select[above_thresh] = 1
      # Return the binary image
      return color_select
  
  
  image_name = '../data/IMG/robocam_2017_10_03_15_35_32_475.jpg'
  image = mpimg.imread(image_name)
  # Define calibration box in source (actual) and destination (desired) coordinates
  # These source and destination points are defined to warp the image
  # to a grid where each 10x10 pixel square represents 1 square meter
  dst_size = 5
  # Set a bottom offset to account for the fact that the bottom of the image
  # is not the position of the rover but a bit in front of it
  bottom_offset = 6
  source = np.float32([[35, 135], [120, 97], [202, 97], [300, 135]])
  destination = np.float32([[image.shape[1] / 2 - dst_size, image.shape[0] - bottom_offset],
                            [image.shape[1] / 2 - dst_size, image.shape[0] -
                                bottom_offset - 2 * dst_size],
                            [image.shape[1] / 2 + dst_size, image.shape[0] -
                                bottom_offset - 2 * dst_size],
                            [image.shape[1] / 2 + dst_size, image.shape[0] - bottom_offset]])
  
apis: numpy.zeros_like numpy.float32 matplotlib.image.imread