-
Meaning, you want the average colour for each square? According to this link, taking the root mean square of all RGB values (per channel) should give you a good 'average colour'. If you then want to only know the actual colour hue, you could convert the RGB values into the HSV colour space (hue/saturation/value) and look at hue numbers only. If you set up a list of 'main colours' that correspond to a range of hues each, you can end up with something like your proposed result.
I want to pixilate an image, reducing the number of colours too. This is easy enough to do, but then I want to know what the underlying colours for each square are. So the result would look something like this:
1 Attachment