
One basic technique for counting the colours in an image would be to create an array or collection to hold the colours and then start counting from the start of the image. However, consider what happens then if you load a 1280 x 1024 pixel image. Firstly, you have 1.3 million pixels to check, and secondly for every single one you need to check whether that colour has been counted before. With an array, that would potentially mean you could have to perform somewhere around 400 billion checks, and with a collection you'll probably find it dies if there are more than 10,000 unique colours.Clearly you need a quicker method. One method is to use ..
|