Algorithms, visualizedExhibit 16

Why do damaged QR codes still scan?

A QR code carries spare data, made with Reed-Solomon coding, that can rebuild parts that are scratched or covered. The usual claim is up to 30 percent damage. That 30 percent counts the code's data units, not its area: in our test the strongest level survived a sticker over about 14 percent of the picture, and covering one corner square stopped it completely.

Try it: damage a QR code

Paint over the code with your finger or mouse. After every stroke, a reader in your browser tries to read it. Pick a strength level, then try the middle, then one of the three corner squares.

Strength level (how much of the code is spare data)
Reader says
reads
Painted over
0%

The code holds the link https://bitsandwhys.com and is always 29 by 29 squares. The reader here is the open-source jsQR library, which is not the same reader as in our video test or in your phone, so the exact breaking point can differ.

The video for this exhibit comes out on YouTube on Friday 25 December. Subscribe so you don’t miss it

Made for car parts

The QR code was released in 1994 by Denso, a Japanese car parts maker. A barcode holds only about 20 characters, so engineer Masahiro Hara and one teammate spent about a year and a half on a code that holds far more, reads fast, and keeps working when part of it is dirty or damaged.

What is in the picture

The three big squares in the corners carry no data. They let a scanner find the code and see which way up it is. The rest is a grid of small squares called modules; eight modules make one codeword. Our test code is 29 by 29 modules and holds 70 codewords.

Spare data

At the strongest level, only 26 of those 70 codewords hold the link. The other 44 are spare, calculated from the first 26 with Reed-Solomon coding, published in 1960. Roughly, every two spare codewords can find and fix one wrong codeword, wherever it is. The same math protects music CDs and carried Voyager 2's pictures home from Uranus and Neptune.

What we measured

We covered the middle of the code with a growing white sticker. The weakest level stopped reading once the sticker passed 4.3% of the picture; the strongest lasted to 14.4%. That largest sticker had spoiled 19 of the 70 codewords, which is 27%: the famous 30 percent counts codewords, not area, and about a third of the picture is fixed patterns with no codewords in them. A sticker over a single corner square, 5.8% of the picture, stopped every level on all three readers we tried. That was one small code and clean computer-made pictures; a phone camera may do better or worse.

Frequently asked questions

How much of a QR code can be damaged?

It depends on the error correction level chosen when the code was made: about 7, 15, 25 or 30 percent of its codewords can be restored. Measured as area of the picture the limit is lower; in our test of one small code it was about 4 to 14 percent.

Why can a QR code have a logo in the middle?

The logo is simply damage that the spare data repairs. It works because the middle holds ordinary data. The three corner squares must stay clear, because the scanner needs them to find the code.

Who invented the QR code?

Masahiro Hara and his team at Denso in Japan, in 1994, to track car parts. The company chose not to enforce its patent, which is one reason the code spread so widely.

Sources

Last updated

Keep exploring