# Generating every image possible.

## Or, limiting the infinte.

Jun 25, 2013 · 5 min read

Imagine owning every photo that has ever been taken and that ever will be taken. To accustom your mind to the immensity of this concept, these photos will include a photo of you at every moment in your life at every possible angle. Now expand that to every living and dead person ever been on this planet. Add all plants, insects, animals, forests, mountains, rivers, deserts, cities. Now add every planet, star and moon that exists in this universe. Now include photos of these photos at every possible angle at every possible position in the universe. Even every CAPTCHA you’ve ever encountered.

Phew. Sounds like an infinite amount of photos, right? It’s not. It may be an extremely, extremely, extremely huge number but it’s not infinite and is technically achievable.

Take the image to the left for an example. It’s a 300x300 image consisting of 90,000 pixels in total. Each one of these pixels has 16,581,375 possible colors to choose from. The picture’s size is 130KB. The pixels in the image on the left is just one possible combination that a 300x300 image can make up. Let’s take a look at all the possible combinations, or at least the numbers behind them.

## The numbers

To calculate the amount of images, we’ll be using Permutations. Specifically the formula n^r where n in our case is the amount of colors (255^3) and r is the amount of pixels (width*height).

For a 300x300 images with a full RGB color range, n reaches 16,581,375 and r is 90,000. Wolfram Alpha gives us this.

That’s a lot of images. At 130 KB per image, that’s 8.4×10^649755 petabytes of storage required. After doing some ridiculous calculations, we end up unfeasible amount of data that we would never be able to physically store.

## The Generation

The actual image generation is even more painful. It’s like trying to unlock that old combination lock stuck on your suitcase but instead of 9 possible numbers on 3 discs, you have 16,581,375 possible numbers on 90,000 discs. Once you start the generation process, it would take an incredibly long time before you see any results that aren’t partially blank or just noise.

At today’s standards with the latest SSD and GPU, you could probably generate and write ~500mb per second which is, with a filesize of 130KB, ~4000 300x300 images per second. This would take a cosy 7.46 × 10^649754 years to complete. I know what you’re thinking, all of these numbers are so completely fargone and that it’s just a futile exercise even contemplating attempting such a feat. Well, one, it’s food for thought and two, what if we tweaked the numbers to be something more manageable?

## Tweaking the variables

We have two variables involved in this system. One is the length of the side of the image and the other is the amount of colors. (colors)^(side). Increasing the length of the side exponentially increases the amount of images to be generated which is unfortunate because although it may mean more content within the images, it also pushes it further and further away from the reality of what’s achievable. Here’s pretty poor 3D graph partially demonstrating what I’m talking about.

x^y is the graph plotted. On the x we have the increase of colors from 0 to 16 and on the y we have the increase in the side length from 0 to 100 pixels. That’s 1.5 × 10^12041 of 100x100 images with just 16 colors. As you can see, any change in the variables results in a massive increase in the amount of images to be produced. However, we’ll march on with 100x100 images with a 16 color grayscale palette because it would be the absolute minimum for anything discernable to be produced with these variables.

## What can you fit in a black and white 100x100 pixel image?

Quite a lot infact but it’s all about perspective. Definitely enough room to distinguish a face or animal and enough to permit some fun and experimentation of all kinds.

So let’s get down to the hard facts. With 16 colors and 100x100 pixels, we have (16)^(100^2) which is 1.58426 × 10^12041 images of an average size of 15KB. With an average write speed of 500mb/s, we can generate 512000/15 which is ~34000 images per second. It would take one machine running 24/7 for 1.59 × 10^12018 years to generate those images. To generate it in our lifetime, it would take a cool 2.65 × 10^12016 machines 60 years to complete.

The whole notion is pretty ridiculous. What do you do once you have those absurdly large volumes of images? How do you make sense of them would be the real question. However, I like to think of it as putting a cap on what previously seemed to be an infinite number, limiting infinity if you will. Who knows, maybe some program like this already exists that harvests images of everything, at every possible moment. Actually sounds familiar, doesn't it?