title: fastest way to find the rgb pixel color count of image
body: <p>I have a use case where i have to find the consecutive rgb pixel color count of each frame of live video after searching i found a piece of code which does the same thing but performance wise it take around ~ 3 sec to give me output but in my case i have to do this calculation as fast as possible may be 25 frames in 1 seconds. Can someone help me to figure out how to do this by refactoring the below code</p>
  
  <pre><code>from PIL import Image
  import timeit
  
  starttime = timeit.default_timer()
  with Image.open("netflix.png") as image:
      color_count = {}
      width, height = image.size
      print(width,height)
      rgb_image = image.convert('RGB')
      for x in range(width):
          for y in range(height):
              rgb = rgb_image.getpixel((x, y))
              if rgb in color_count:
                  color_count[rgb] += 1
              else:
                  color_count[rgb] = 1
  
      print('Pixel Count per Unique Color:')
      print('-' * 30)
      print(len(color_count.items()))
  print("The time difference is :", timeit.default_timer() - starttime)
  </code></pre>
  
  <p>output:</p>
  
  <p>Pixel Count per Unique Color:
  130869</p>
  
  <p>The time difference is : 3.9660612</p>