Video: Computer paints images with millions of colours

What is the most eye-catching way to use 16.8 million colours in one image? For Hungarian programmer József Fejes, it was a question he felt compelled to answer.

Last month, an online challenge prompted coders to write a simple piece of software to produce original images where every pixel is a different colour.

They could use as many as 16,777,216 colours – the highest number possible with 24-bit RGB technology. This is because the colour of any RGB pixel is determined by how much red, green and blue light it contains. In 24-bit colour, each of these three components has an intensity value from 0 to 255 (256 x 256 x 256 = 16,777,216).


(Image: József Fejes)

The competition entries varied wildly, but Fejes was declared the winner after participants marvelled at the designs his program produced. Some appear floral, like watercolours, and he calls them “rainbow smoke”.

The program works by automatically plotting coloured pixels according to how similar they are in hue and brightness. In some images, a colour is picked at random and then placed in the most suitable location, before another random colour is selected and placed. In others – the “rainbow smoke” examples – the program goes through each colour group in sequence, so all the reds are placed, then the oranges and so on.

(Image: József Fejes)

It is also possible to determine how the image “grows” by deciding whether the program places a given colour next to the most similar single colour, or in the position surrounded by the most similar colours on average.

“At first I didn’t really know if it was going to end up looking beautiful or not, it was just an interesting programming challenge for me,” he says. “I was very surprised at how beautiful it turned out to be.”

Although the image above looks impressive, it is not actually the real deal. Only the full-size, uncompressed, 4096 x 4096 pixel images Fejes created – this one, for example – actually contain 16.8 million colours. The version in this story is only 1200 pixels wide. The screen you use to view the image will also affect how many colours will actually be displayed.

(Image: József Fejes)

Your screen may not even show RGB colours accurately, says Sally Day of University College London, who is the UK and Ireland director of the Society for Information Display. “While the program generates attractive images, the display you are using is unlikely to show all the colours that are there,” says Day.”Some displays are being developed which use lasers to form the red, green and blue colours, and these can show a greater range. They have applications in digital cinema and aren’t yet available for your TV or mobile phone.”

Although 16.8 million may sound like a lot, the human eye can perceive a wide range of additional colours outside RGB’s limited palette. The RGB colours make up a smaller triangle inside what is known as a CIE diagram, which shows all the colours that a human eye should be able to see.