Monday, February 21st 2005

All 16,777,216 RGB colours

A while back, having nothing better to do, I set about creating an image with all the RGB colours. Yes, that’s right. All 16.8 million.

This little show of lunacy also turned out to be a great demonstration of the powers of the PNG image format: The graphic, being 16.8 million pixels and 24 bit colour, ends up a modest 50 MB uncompressed. The PNG format produces a 58.0 kB file.

Before you take look at this (truly) colourful piece of art, I warn those with slow computers. Don’t let the light download trick you – the graphic packs a nice punch to the CPU if you’re on something like 400 MHz.

All 16,8 million RGB colours

Update: Per popular request, I have now created a version of the image with all pixels randomized… (This time it’s a bit more than 58 kB…)

All 16,777,216 RGB colours, randomized.

And how about a little mathematical challenge: What are the chances that, by randomizing the pixels in the (randomized) image above, I would get the (ordered) version at the top? 🙂

Update 2: I created another version of the ordered image, with the squares laid out along the diagonal of the image instead. This one (78 kB) didn’t compress quite as well as the first one (58 kB).

All 16,777,216 RGB colours, with tiles ordered along the diagonal of the image.

Edit 2011-06-30: Was inspired by one of the comments to try and compress the 58 kB png file. IzArc can create a 7z file which is only 705 bytes large! That is 1/71436th the size of the uncompressed image in Tiff format. That’s pretty impressive stuff!

No Responses to this post:

  1. Anonymous says:

    The approximate value of 1/2^24! is 1.2174221e-113924436.

  2. Anonymous says:

    The approximate value of 1/2^24! is 1.2174221e-113924436.

  3. ACJ says:

    Hey there. Some time ago, I started a little project called allRGB. So far I have posted 11 creations myself (see entries), and I was wondering if you would be willing to contribute. Cheers!

  4. Anonymous says:

    If you open the randomized picture in photoshop and use a gaussian blur at maximum blur you get exacly 50% black.Later.

  5. Anonymous says:

    If you open the randomized picture in photoshop and use a gaussian blur at maximum blur you get exacly 50% black.Later.

  6. Nathan says:

    The number of combinations there are is 16777216_P_16777216 = 16777216! / (16777216-16777216)! = 16777216!, so yes, 1/16777216! is the probability of getting the ordered example (since the randomized image has no repeated colors)stirling's approximation of 16777216! is: sqrt(2 pi 16777216) (16777216/e)^16777216(using the help of logarithms to approximate the second term)which is approximately 10267 * (8 * 10^113924433)which is 82136 * 10^113924433which is 8.2136 * 10^113924437so the probability is (approximately):1/(8.2 * 10^113924437)which, i must say, is incredibly tiny (the smallest amount time possible, planck time, is 1/(5.39 * 10^44) )

  7. Anonymous says:

    If you re-compress it with PNGOUT, you can shave another 6% off the size… and then compress that with WinRAR, it smashes it down to a teeny tiny 1.34kb.That's just 1/36,680th of the uncompressed [bitmap] size!

  8. Anonymous says:

    Wow! Great work! I counted how many pixels there are in one of the boxes (which there are 256*256 colors (since one row of one box consists of 256 colors), or 65536 colors). There are 256 boxes, so the total number of colors there are 65536*256, which equals 16777216 colors. Amazing! How did you make it? I once tried with Paint, but I failed, cause it takes too much time…To the mathematical challenge: There are 16777216! ways to arrange the colors. So, the possibility is 1/16777216! to get the random image.

  9. Anonymous says:

    What software did you used?

  10. David Naylor says:

    I believe I made it using Photoshop. I started off by making one of the small squares and then copying it 256 tims and adding one level of green for each square, somehow.

  11. Anonymous says:

    Wow, how much time did you spend to finish this? Am I right, that after you copy it 256 times, you have to edit all of the square's colors? Because I think it's impossible to finish it…or is there another way? I tried to make one… I think you should make a tutorial of how to make it… 😉

  12. David Naylor says:

    No, for each of the 256 squares I increased the green by using a mask. Can't remember how exactly.