title: How to print pixels of an image as a matrix?
body: <p>I would like to print the pixels of an image as a matrix.</p>
  
  <p>Here is the code I am using:</p>
  
  <pre><code>from PIL import Image
  
  im = Image.open("8Black.png")
  pixels = list(im.getdata())
  
  print(pixels)
  </code></pre>
  
  <p>I created the image "8Black.png" using photoshop and painted it all black. The python version that I use is 3.5.0. However, when I run the above code I get:</p>
  
  <pre><code>[0,0,0,0,0,0,0,0,0,0,0,0,...,0]
  </code></pre>
  
  <p>I want to get this instead:</p>
  
  <pre><code>[[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[...],[...]]
  </code></pre>
  
  <p>I tried changing this:</p>
  
  <pre><code>pixels = list(im.getdata())
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>pixels = np.matrix(im.getdata())
  </code></pre>
  
  <p>but still did not get the result I wanted. </p>
  
  <p>How can I get the pixel data as a matrix? Did I miss something?</p>