Well, that works great for the rainbow, but fails for all my other "normal" cases, like a room scene or a grassy hill, where it just returns all browns or greens and nothing else. My ultimate goal is to be able to pull the perceived dominant colors like here:
http://lokeshdhakar.com/projects/color-thief/
http://lokeshdhakar.com/projects/color-thief/