Analysing Colours in an Image
Note: This article was originally published at Planet PHP
on 25 November 2010.
Analysing Colours in an Image
London, UK Thursday, November 25th 2010, 18:24 GMTFor a project that I am working on, I had to figure out which colours are primarily used in an image so that it can be indexed for sorting. Obviously, there is only a small finite set of colours that we are interested in. This article shows on how I went about analysing an image to see which of those colours were primarily used in the image.
First of all, I had to define a palette that I wanted to index on. Then I needed to check the image to see which colours existed, and map those to my finite set of colours. Then we could count them, and select the ones that were used most.


