Yeay! Fixed a rather niggly bug.
Displayed colour counts were inaccurate, although the displayed colours were correctly identified as being the most prevalent in the image. This was a frustrating bug, as it meant that calculation of ‘percentage of image of particular colour’ could not be reliably calculated. I mean, I am looking at 36000 odd pixels, and the top colour is reported to have occured 12 times. hmmm.
The bug was mainly caused by an incorrect comparison, which assumed that all colours in the incoming array were repeated sequentially rather than randomly. All I had to do was check for existence of the key, rather than comparing the current value to the previous value. Voila.
Tags: bug, colour, colourphon, fixed