title: How to halftone a black and white picture?
body: <p>I want to divide a picture in equally big squares and measure the average gray scale level and replace it with a blob, aka halftoning. This code gives me a picture but it doesn't look right. Any ideas what could be wrong? </p>
  
  <pre><code>im = scipy.misc.imread("uggla.tif")
  
  def halftoning(im):
      im = im.astype('float64')
      width,height = im.shape
      halftone_pic = np.zeros((width, height))
      for x in range(width):
          for y in range(height):
              floating_matrix = im[x:x + 1, y:y + 1]
              sum = np.sum(floating_matrix)
              mean = np.mean(sum)
              round = (mean &gt; 128) * 255
              halftone_pic[x,y] = round
      fig, ax = plt.subplots(1,2)
      ax[0].imshow(im, cmap="gray")
      ax[1].imshow(halftone_pic, cmap="gray")
      plt.show()
  </code></pre>