title: Counting white pixels in image
body: <p>very new to python. I have used code found in guides etc to try and grab the white pixles in an image but getting stuck. Probably super easy but my if statement to select white is not playing ball. Can anyone help?</p>
  
  <pre><code>#***convert image to no pixels per shade output
  import cv2
  import numpy as np
  from collections import defaultdict 
  img = cv2.imread('..\\Snapshots\\Me.png')
  pixels = img.reshape(-1,3)
  counts = defaultdict(int)
  for pixel in pixels:
  if pixel[0] == pixel[1] == pixel[2]:
      counts[pixel[0]] += 1
  for pv in sorted(counts.keys()):
  print("(%d,%d,%d): %d pixels" % (pv, pv, pv, counts[pv]))
  
  
  
  #***count white pixels
  from PIL import Image  
  im = Image.open('..\\snapshots\\Me.png')
  white = 0
  other = 0
  for pixel in im.getdata():
  if pixel == (255, 255, 255, 255): # if your image is RGB (if RGBA, (0, 0,     0, 255) or so
      white += 1
  else:
      other += 1
  print('white=' + str(white)+', Other='+str(other))
  </code></pre>