title: Use Numpy to convert rgb pixel array into grayscale
body: <p>What's the best way to use Numpy to convert a size (x, y, 3) array of rgb pixel values to a size (x, y, 1) array of grayscale pixel values?</p>
  
  <p>I have a function, rgbToGrey(rgbArray) that can take the [r,g,b] array and return the greyscale value. I'd like to use it along with Numpy to shrink the 3rd dimension of my array from size 3 to size 1.</p>
  
  <p>How can I do this?</p>
  
  <p>Note: This would be pretty easy if I had the original image and could grayscale it first using Pillow, but I don't have it.</p>
  
  <p>UPDATE:</p>
  
  <p>The function I was looking for was <code>np.dot()</code>.</p>
  
  <p><strong>From the answer to this quesiton</strong>:</p>
  
  <p>Assuming we convert rgb into greyscale through the formula:</p>
  
  <p>.3r * .6g * .1b = grey,</p>
  
  <p>we can do <code>np.dot(rgb[...,:3], [.3, .6, .1])</code> to get what I'm looking for, a 2d array of grey-only values.</p>