I recently started visiting the programming puzzles SE site. To a geek like me, it’s a little paradise: many interesting challenges, many interesting solutions, many like-minded people. Two days ago, there was one particular challenge: make a program to create an image that contains all RGB colors exactly once (and of course the best looking one wins). A very long time ago I made a small screen saver in assembly which grew a colorful coral (I may post that one day, too). I thought something similar would work here and maybe I’ll even get some votes. You can see the very first image right here. The results completely blew my mind, they were absolutely stunning, and of course it was a big success. Then I thought, let’s make a huge image, maybe even a YouTube video from this. But it wasn’t easy because it’s a brutally exponential problem. Two days of non-stop coding and minimum sleeping later, here it is!
Of the four most widespread image formats, the images have to be in PNG format, because it supports lossless compression and all RGB colors. GIF doesn’t work because it only supports at most 256 colors. JPEG doesn’t work because it uses a lossy compression, so some colors are slightly altered. We need to have 100% accuracy to represent all these different colors. BMP’s would be fine but they don’t do any (decent) compression. So all the images you see below are PNG’s, the original, raw files, which were produced by my program. Feel free to count the colors in them .
The first images: 15 bits
Let’s start with some of the first images I made. These contain 15-bit RGB colors, with a resolution of 256×128 (about 32 thousand pixels). (Note: when the number of pixels in an image is a power of 2, then the dimensions of the image must also be powers of 2, but my size choices are not the only ones possible.) Little tweaks in the algorithm lead to somewhat or very different images, there are endless possibilities which I’m sure some other people will find themselves if they try it. These are just a very few samples.
I even made some small animgifs because watching them grow is also beautiful.
A bit bigger: 18 bits
All 18 bit RGB colors fit on a 512×512 image (about 260 thousand pixels). It took tens of minutes to render them with the very first version of my program, now it only takes a few seconds. The bottom three images are used in the YouTube video.
Let’s go to YouTube: 21 bits
Next up: 21 bits, that’s 2048×1024 (about 2 million pixels). I seriously had to work on those. Even with all the optimizations I could think of (yet!), some of these took up to 8 hours to render. Let me show you four different ones, each in an intermediate state and in the final state.
This is actually my favorite. It differs from the previous one because the colors are not entirely random, they are sorted by hue. The phrases that come to my mind are rainbow smoke and spilled ink. This is the best one to see in motion.
When you look at the end result, this one looks very much like the first one, only a little bit blurred. What’s very different is how it grows. It uses a different algorithm that makes it look like a coral. The best is when it is 90-95% finished, as shown here.
And finally, a blend between the second and third: ordered by hue, growing like a coral. When you look at the intermediate one, be sure that it’s shown 1:1 and not resized because that looks bad. The end result is just weird.
My best idea about this topic was to create a YouTube video of how each of the above four pictures are created inside the program. I never created many interesting videos before, but I knew that this is going to be a hit. Sadly the images had to be cropped (2048->1920) and I added little black bars on the top and bottom (1024->1080), and of course the video compression alters the colors slightly (and in the case of YouTube, it also introduced some really ugly artifacts). So this is not technically all-RGB imagery anymore, but it’s not the point. The point is that this video looks spectacular! I also wrote a lot of source code to render the video frames, then I used FFMpeg to put it all together. Finally I chose a music from YouTube’s free audio library. Enough talking, watch the video now, and be sure to watch it in HD!
The holy grail: 24 bits
Nowadays, most consumer grade equipment’s and software’s limit is to display 24 bit colors. So naturally this was my final goal as well. It fits on an image with 4096×4096 resolution (about 16 million pixels). (I remember the days when my Windows 98 could only display 16 bits with my graphics card, and better cameras today are capable of 3*10 or 3*12 bit depths, so 24 is neither the beginning, nor the end, it’s just the most widespread currently.)
The optimizations in my software were not finished, but I was too tired and wanted to produce results with what I had, so I ran the renders on a server at my company with CPU time to spare (thank you ArgonSoft). It all took about 50 hours. It would have taken 500 or 5000 hours with a previous version, and maybe it would have taken only 5 hours or 0.5 hours if I had more time, but it doesn’t matter now. The images are ready, so let me present you the results. (Note: sadly the images are temporarily presented here in a scaled down version, because they are huge (50 MB!), and the big interest caused it to bring my site down several times. I promise to reupload them soon.)
Wanna try it out?
You can’t wait to grab the program and try it out, can you? Okay, lucky for you, I’m releasing the source code of the program under the terms of the GPL. The source code can be found here.
I will write a more technical blog post about this topic in a few days.
UPDATE 2014.03.05.: The interest in my video has become huge. Thank you everyone for the nice comments, sharing, etc., I am so happy that my images made you happy . My program was featured on a New Scientist article and Gizmodo and this is the biggest achievement of my career ever. If there is more interest, and you can support and promote this thing, I am planning to continue this project, create screensavers, and writing new algorithms to produce even better images and videos. It won’t be easy next to my day job, but my biggest goal is to bring amazement to you all . Thanks again and enjoy the computer generated art .
UPDATE 2014.04.02.: I’ve been extremely busy lately, I dedicated all my freetime to this project. The Society6 thing didn’t work out the way I hoped, so I removed it from the article, but something better is on the way. The promised follow-up article can be found here.