title: numpy.AxisError: axis 2 is out of bounds for array of dimension 0
body: <p>I'm creating a program the requires a black and white image and two arrays containing the X and Y coordinates of both black and white pixels respectively. I have a program that utilizes OpenCV and binary thresholding to create a black and white image (<a href="https://techtutorialsx.com/2019/04/13/python-opencv-converting-image-to-black-and-white/" rel="nofollow noreferrer">code source</a>). Hear is the code I have in full so far.</p>
  <pre><code>#Load image
  im = cv2.imread('image.png')
  
  #create grey image
  grayImage = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
  
  #create full black and white image
  (thresh, blackAndWhiteImage) = cv2.threshold(grayImage, 127, 255, cv2.THRESH_BINARY)
  
  #Define black and white
  black = [0,0,0]
  white = [255,255,255]
  
  #Get X and Y coordinates of both black and white
  Xb,Yb = np.where(np.all(blackAndWhiteImage==black,axis=2))
  Xw,Yw = np.where(np.all(blackAndWhiteImage==white,axis=2))
  
  #combine x and y
  Bzipped = np.column_stack((Xb,Yb))
  Wzipped = np.column_stack((Xw,Yw))
  
  #show
  print(Bzipped,Wzipped)
  </code></pre>
  <p>The problem I have comes up at these lines</p>
  <pre><code>Xb,Yb = np.where(np.all(blackAndWhiteImage==black,axis=2))
  Xw,Yw = np.where(np.all(blackAndWhiteImage==white,axis=2))
  </code></pre>
  <p>when the program is run the error <em><strong>numpy.AxisError: axis 2 is out of bounds for array of dimension 0</strong></em> is shown.</p>
  <p>What does this error mean and how can I fix the program?</p>