I would look up something like "finding the average colors of a photo"
http://blog.soulwire.co.uk/code/…