Pixel cryptography

Whenever someone at the AEI defends their PhD thesis, their friends construct an elaborate hat. In the celebrations after their presentation, they have to wear it. Over the years, the hats have evolved from simple constructions with a few themed items or pictures, to hats featuring LEDs, sounds and other electronics.

For one of the students in my group, the theme involved digital interferometry. This is a technique where pseudo-random noise is intentionally imprinted onto the laser in an interferometer, and read out in a special way to infer the position of the optical cavities. For the hat, wanted to construct a puzzle to be solved by the student involving information hidden in pseudo-random noise. We decided to make a ruler, with tick marks that would only appear if the puzzle was solved. This ruler would be needed to measure a length for another puzzle. After a bit of thought, I hit upon the idea of overlaying two sheets of transparent paper, each imprinted with supposedly random noise, but with the ticks arranged such that when overlaid they become visible.

How it works

First, the intended message must be drawn onto a pixel map. In this case, I drew the ruler ticks and letters. I also added some fiducials to help with alignment, but these can be removed to make it more difficult.

I then created a new, empty map with the same dimensions, and generated white noise across the map such that each pixel was either transparent or black. I created one further map that was the inverse of the first random map.

At this point, overlaying these two maps on transparent paper would result in a completely black image, because each coordinate would contain one black pixel and one transparent pixel. In order to hide information within the overlaid transparencies, I had to do one final pass on the layers. Looping through each pixel coordinate, I then made sure that, on parts of the inverted map corresponding to parts of the pixel map containg the message, the pixel was transparent. This meant that effectively the second (inverted) transparency would always show the first layer's pixel, which, due to being random noise, would be either transparent or black. Contrast this to the rest of the image which is guaranteed to be black, and you find that you can see the message when the two layers are overlaid! The pixel regions with the message, of course, still show the random noise from the first layer. Removing the random noise in these regions would make the message visible on the first layer, so this is not an option.


I made a small Python script to build and generate the pixel cryptography images. You need the Python Imaging Library to make it work. It generates the two layers as individual image files in three different sizes (1, 4 and 9 pixels per dot), and builds an A4 page containing all three. Once printed, you can cut them out with scissors.

In practice, I found the 1 and 3 pixels per dot versions solvable with human hands and a flat surface, but requiring effort. The 9 pixels per dot version was too easy. One improvement I made was to mirror the second layer such that it could be arranged ink-side to ink-side with the other layer - this removed the ~100 micrometer gap between the two layers due to the paper thickness, which improved the viewing angle of the perfectly overlapped layers.


You obviously need to print the layers on transparent paper, but you also need to use a high quality printer. The dot size needs to be small enough to print the dot size being used in the code. I used a Canon inkjet printer on high quality photo mode and it worked well.

I made a sheet with three different pixel sizes, and found the middle pixel size version was best, taking the average person about 30 s to align, but the smallest was still doable with about 5 minutes of patient alignment.

Pixel cryptography, with three pixel sizes.

Pairs of strips with three pixel sizes on an A4 sheet.