title: fast method calc count black pixel, Pillow
body: <p>I need calc count black pixel in each line of the image. My code:</p>
  
  <pre><code> from PIL import Image
  
  
  im1 = Image.open("2.png")
  
  def bw_filter(threshold=127):
      def table_gen(x):
          return 0 if x &lt; threshold else 255
      return table_gen
  
  new = im1.convert("L").point(bw_filter(200)).convert("1")
  
  shir = new.size[0]
  vys = new.size[1]
  
  pix = new.load()
  str_mas = []
  
  for y in range(vys):
      sum_str = 0
      for x in range(shir):
          sum_str += pix[x,y]/255
      str_mas.append(shir - sum_str)
  </code></pre>
  
  <p>This is slow. 5 second on image size A4. Faster method exists?</p>