added code from SO on dominant color extraction.