title: main color detection in Python
body: <p>I have about 3000 images and 13 different colors (the background of the majority of these images is white). If the main color of an image is one of those 13 different colors, I'd like them to be associated.</p>
  
  <p>I've seen similar questions like <a href="https://stackoverflow.com/questions/2270874/image-color-detection-using-python">Image color detection using python</a> that ask for an average color algorithm. I've pretty much copied that code, using the Python Image Library and histograms, and gotten it to work - but I find that it's not too reliable for determining main colors.</p>
  
  <p>Any ideas? Or libraries that could address this?</p>
  
  <p>Thanks in advance!</p>
  
  <p>:EDIT:
  Thanks guys - you all pretty much said the same thing, to create "buckets" and increase the bucket count with each nearest pixel of the image. I seem to be getting a lot of images returning "White" or "Beige," which is also the background on most of these images. Is there a way to work around or ignore the background?</p>
  
  <p>Thanks again.</p>