text: import cv2
  import numpy as np
  
  
  def bin_spatial(img, size=(32, 32)):
      color1 = cv2.resize(img[:, :, 0], size).ravel()
      color2 = cv2.resize(img[:, :, 1], size).ravel()
      color3 = cv2.resize(img[:, :, 2], size).ravel()
      return np.hstack((color1, color2, color3))
  
  
  def color_hist(img, nbins=32):  # bins_range=(0, 256)
      # Compute the histogram of the color channels separately
      channel1_hist = np.histogram(img[:, :, 0], bins=nbins)
      channel2_hist = np.histogram(img[:, :, 1], bins=nbins)
      channel3_hist = np.histogram(img[:, :, 2], bins=nbins)
  
      # Concatenate the histograms into a single feature vector & return
      hist_features = np.concatenate((channel1_hist[0], channel2_hist[0], channel3_hist[0]))
      return hist_features
  