HomeBlogAbout UsWorkContentContact Us
 
 Advertisment 

Wounded QR codes

QR codes (short for Quick Response Codes) were invented in 1994, by the DENSO Corporation. I'm sure you've seen lots of them. They are the natural progression of bar codes.

Bar codes are one dimensional, encoding data in a series of alternating high contrast lines.

QR codes store data in two dimensions in the form of an array of contrasting regions. The information density of a QR code is much higher than a vanilla barcode; depending on the format used and the resolution of reader, over a thousand bytes can be encoded in a region the size of a postage stamp.

QR codes use a Reed–Solomon error correction based technology to help recover from errors in reading (for instance, caused by a smudge, badly printed code or other deformity).

There are four selectable levels of redundancy that can be used in generating QR codes (more on this later). I was curious as to what this damage tolerance translated to in real life.

That's right, I'm going to maim, damage and disfigure some QR codes (all in the interests of research) …

How do QR codes work?

Before we break things it’s probably best to have a quick look at how QR codes work. It don’t want to duplicate the excellent resources already out there, so here is just a brief explanation. (For full details, check out the specifications of the standard ISO/IEC18004).

On three corners of a QR code are square blocks that the reader uses to coarsely identify and then align the code. A correctly rendered code also has a “Quiet Region” (Ideally, at least four 'pixel' elements wide) all around the edge of the code to help the reader disambiguate between the code and any other background image.

A spacing gap appears around the edge of the orientation elements, and around this are Format and Versioning information.

In addition to different storage formats and redundancy definitions, a variety of masks can be applied to the encoding, and the specification of the mask used is stored in the format information.

The masks alter the appearance of the code (toggling elements to make canonical versions that represent the same data, but are rendered in different ways).

Ideally a mask is chosen that minimizes the appearance of large blocks of the same color that may cause issues in reproduction or reading in a ‘noisy’ environment).

The mask is applied via an XOR function and can be removed be applying the same Boolean operation a second time. There are multiple masks available in the standard that can be applied.

An additional alignment block appears in the fourth corner on small codes (in larger codes, multiple alignment blocks appear in the grid). These alignment blocks help deal with the skew. Finally, there are two timing strips in perpendicular directions composed of alternating elements.

A larger format QR code is shown below showing multiple alignment blocks. All other elements remain the same.

The payload for the code (data and checksum data) is then zig-zagged through the grid around the control elements.

Error Correction

Data is stored in a QR in words that are 8 bits long and use the Reed–Solomon error correction algorithm with four configurable error correction levels. The higher the error correction level, the less storage capacity. The following table lists the approximate error correction capability at each of the four levels:

L(Low)7% of codewords can be restored.
M(Medium)15% of codewords can be restored.
Q(Quartile)25% of codewords can be restored.
H(High)30% of codewords can be restored.

Here are renderings of a QR code for https://DataGenetics.com. Note, when we have low damage tolerance, the payload is short and so a smaller size QR code is generated. As more redundancy is encoded into the payload the length increases, and the resulting code is larger.

LowMediumQuartileHigh

Let the destruction begin …

Using the H version of the above QR code, I'm going to attempt a few distortions and deformations to see how much damage it is possible to do to the code and still be able to read it.

I'm not being incredibly rigorous or controlled in these tests; all I'm doing is distorting the QR code in some way, then pointing my smart phone (which has a free QR reader app installed) at the screen to see if it could be read. (far away from a standard lab environment!).

There could be variability depending on the brightness of the screen, background lighting … etc. but at least it will give some idea of what is possible. If you try scanning these codes, you might get different results.

To make it a little more fun and interactive, I've turned it into a little game. Below, on the left, you'll see a series of QR codes displayed in some modified ways. In the middle will be a short description of what changed and a button marked  Show Result 

Your goal is to look at the source image and guess if you think my smartphone reader was able to scan the code. Click on the button to reveal the answer. It's just for fun, no points will be recorded!

Let the destruction begin …

Quiz

 1

Control test. This is the basic QR code. Does it scan?

 
 2

How about if we shrink it down. Does it scan?

 
 3

How about if we rotate and shrink it. Does it scan?

 
 4

Reduced contrast. Does it scan?

 
 5

Even more reduced contrast. Does it scan?

 
 6

What happens if we lose the corner and edge? Does it scan?

 
 7

What happens if you code catches yellow spot fever? Does it scan?

 
 8

How about yellow and red spot fever? Does it scan?

 
 9

What happens if we lose part of the positioning block? Does it scan?

 
 10

How about a blob of orange paint in the middle, rather than lots of little blobs? Does it scan?

 
 11

Here the code has been ripped and not put together correctly, leaving a gap. Does it scan?

 
 12

If, instead of pulling apart, the code is glued back together with an excess of (orange) glue will that make things better? Does it scan?

 
 13

Missing a chunk in the middle. Does it scan?

 
 14

What if we fill the void with "noise"? Does it scan?

 
 15

How about a skew? Does it scan?

 
 16

Skewing in two planes and some added noise. Does it scan?

 
 17

More extreme skewing/tomb-stoning. Does it scan?

 
 18

Need eyeglasses? How about a Gaussian Blur? Does it scan?

 
 19

A little bit more blurring. Does it scan?

 
 20

Random colored noise. Does it scan?

 
 21

Clipping a few corners. Does it scan?

 
 22

Feeling a little dizzy? Does it scan?

 
 23

Feeling more dizzy. Does it scan?

 
 24

Star-Wars. Starting jump to hyperspace. Does it scan?

 
 25

Faster hyperspace. Does it scan?

 
 26

Blurry edges. Does it scan?

 
 27

Ants are eating my code. Does it scan?

 
 28

Bigger ants. Does it scan?

 
 29

Someone spilled water on my code. Does it scan?

 
 30

Spray painted code. Does it scan?

 
 31

Sent through a very poor quality fax machine. Does it scan?

 
 32

No "Quiet Zone" and lost in the middle of other QR code noise. Does it scan?

Test

Does your smart phone have a QR code scanner? See if you can read the following code:

If you are interested in error correction codes, you might also like this article about how Credit Card Numbers Work.

Update

Since writing this article, various people have contacted me to say that they were able to successfully scan all the wounded codes I created. This is great! As I mentioned earlier in the article, there are many variables, and my testing was far removed from laboratory conditions. There are differences in monitor dot pitch, brightness and contrast between yours and mine. There are differences in lighting conditions, scan conditions and scan distance. There are differences in camera quality, resolution and tolerance. And, (probably most importantly), there are differences in the scanning app. Some software is more sophisticated/tolerant, and able to deal with a wider range of discrepancies than the app I used. This is good news for all the wounded QR codes out there!

You can find a complete list of all the articles here.      Click here to receive email alerts on new articles.

© 2009-2013 DataGenetics    Privacy Policy