sarvesh.
Blogs

Lightfold

How much of a file can an ordinary camera recover from a single photograph? Lightfold is an experiment in turning a file into a pattern of light that a camera can read.

Take a page of text. A QR code might hold the address where the page lives. Lightfold encodes the text itself. If the decoder can read the pattern, it can reconstruct the page even when the original file and the network are out of reach.

The first phone photograph exposed a difference that’s easy to miss on a screen. The decoder could read the brightness pattern, yet too many color values had shifted to reconstruct the whole file. See what the phone captured.

1. How a file becomes a picture

Digital informationDocuments, images, model weights, software, arbitrary bytes01001101 10110010 01101001
Lightfold encoderMathematically transform bits into visual patterns
Multicolored rectangular cells illustrating the encoded bytes. Illustrative visual representation of encoded data
Photograph or scan
Lightfold decoderCorrect distortion, recover information and verify integrity
Exact original digital information

A text file, an image and a computer program all enter the encoder the same way, as a sequence of bytes. The decoder’s job is to recover that sequence exactly.

2. How do the tiles carry information?

A tile that can be black or white can carry one bit. Give it four brightness levels that the camera can reliably tell apart, and the same tile can carry two bits. The four examples below show how the choice of pattern changes what fits in each tile.

Alternating black and white tiles.BinaryBlack and white1 bit per cell
Tiles with four shades from black to white.IntensityMultiple brightness levels2 bits with four levels
Eight tiles with distinct colors.ColorDifferent wavelengths and intensities3 bits with eight colors
Colored tiles split diagonally into different brightness levels.Hybrid encodingColor, brightness and geometryMultiple bits per tile

Lightfold’s v0.5 prototype combines brightness and color. In each two-by-two group, the four small cells can be light or dark independently. The group also carries one of four color signals. That gives four bits from brightness and two from color, before setting any space aside for calibration and error correction.

3. What makes a photograph hard to decode?

Two neighboring cells can be perfectly distinct in the image the encoder draws. Photograph the image slightly out of focus and those cells start to blend together. A reflection can wash out a whole patch. Even the angle of the camera changes where the decoder should look for each cell.

In information theory, this is a noisy communication channel. The challenge is balancing two goals.

  • Fit as much of the file as possible into the image.
  • Leave enough room for reference patterns and extra bits that help the decoder recognize colors and correct errors.

Smaller tiles can fit more data on a page. But if a camera can no longer tell two neighboring tiles apart, adding more tiles can leave it with fewer usable bytes.

4. How much data has Lightfold recovered?

v0.1Local color calibration130.5 KB
v0.2Perspective and error correction114.1 KB
v0.3Density optimization207.4 KB
v0.4Damage recovery and photo fusion207.4 KB
v0.5Hybrid brightness and color encoding1,007.1 KB
Payload capacity of selected prototypes, in decimal kilobytes. The first two bars show format limits. Later trials used different configurations and simulated capture resolutions.

In two trials, the v0.5 decoder recovered 1,007,053 bytes from a single simulated photograph of a target 5,800 pixels wide. Each trial used a different file of random bytes. In both cases, the recovered file’s SHA-256 hash matched the original.

Random bytes make this a useful test. A file full of the same letter can be compressed into a short instruction. Random bytes give the compressor little to work with, so nearly all of that megabyte has to travel through the image itself.

What survived a real phone photograph?

For the first physical test, a screen displayed a pattern carrying 249,991 bytes. Two existing decoders failed to find the pattern’s black border in an iPhone photograph. A decoder tuned on that photograph found the border and all 100 calibration patches. These patches contain known patterns that help the decoder find the cells and interpret their brightness and color.

Magnified calibration pattern in the target image, with sharply bounded light, dark and colored cells.Display target
The same calibration pattern in the phone photograph. Its light and dark bands remain visible, with softer edges and changed colors.Phone photograph
The same calibration patch, enlarged from the target PNG and the original phone photograph. The photographed patch is aligned to the target so the rows can be compared.

The brightness signal yielded the first 163,486 bytes. Every byte matched the original file. The remaining 86,505 bytes were carried by color, where the errors exceeded what the correction code could repair. Feeding the same decoder the original PNG recovered all 249,991 bytes.

File recovered from the photograph65.4%
163,486 bytes verified86,505 bytes unresolved

This was one photograph, used both to develop the decoder and to evaluate it. The next test is to photograph fresh targets at the same size, some using brightness alone and others also using color. Keeping the decoder fixed would show whether the brightness result repeats and how many additional bytes color can reliably carry.

What if the screen runs out of pixels?

The million-byte pattern started as an image 8,640 pixels wide. In a display simulation, fitting it into a square just 1,964 pixels across left each fine brightness cell only 0.68 display pixels wide. Neighboring cells had already begun to blend before the simulated camera took its first picture.

What the screen showedDisplay pixels per fine cellWhole files recovered
One dense image, photographed five times0.680 of 3
Five coarser images, each carrying part of the file1.523 of 3
Three independently generated 1,007,053-byte files. Both strategies had the same 1,964 × 1,964 display area and five simulated exposures per file.

Even averaging the five aligned photographs of the dense image failed to recover a whole file. The sequence gave each cell more room on the screen and spread the bytes over five images. All five parts decoded in every trial. Measuring how fast a real phone and display could do this would require accounting for screen refresh, motion and missed frames.

Multiple photographs can help in a different way, too. In an earlier simulation, a fifth of the pattern was covered in each of two views. Each view failed alone. Because different regions were covered, combining the readable parts recovered all 207,370 bytes. Download the trial results (CSV).

5. Where could this be useful?

Physical information archivesPreserve digital information on printed materials without depending on electronic storage.

Optical communicationTransfer information between devices using displays and cameras without network connectivity.

Machine-to-machine communicationExchange information through visual signals in robotics and industrial environments.

New scientific discoveriesDiscover encoding architectures that approach the information-carrying limits of imaging systems.

These are possible uses. For a printed archive, the practical test would be whether a reader years later could photograph the page and recover every byte.

6. What if the encoder could choose the pattern?

The grid in these experiments follows rules chosen by hand. The encoder can change the brightness of a cell or the color of a group, but it always starts with the same grid. What would it draw if it could choose the pattern, too?

One experiment would train an encoder and a decoder together. The encoder would draw an image from a file. The decoder would see only a distorted capture and try to reconstruct the bytes. Training would reward the pair for recovering larger files exactly within the same image area.

Would a grid emerge again? Or would a texture that looks like noise to a person prove easier for a camera to read? The way to find out is to photograph both patterns on the same display, with the same camera and light, and measure how much data survives.

lightfold

Exploring the limits of information encoded in light.An independent research project at the intersection of information theory, optics, computational imaging and artificial intelligence.