Qraft

QR Codes and Optical Illusions - Why Human Eyes and Cameras See Different Things

Why Human Eyes Cannot "Read" QR Codes

Even when humans look at a QR code, they cannot read the data stored in it. Although we can understand that the black and white pattern represents some kind of information, the process of converting that pattern into numbers, applying error correction, and restoring the original text or URL is impossible for the human brain.

This may seem obvious at first glance, but from the perspective of vision science it is an interesting fact. The human visual system can instantly recognize characters (the alphabet, kanji, and Arabic numerals). This is the accumulation of thousands of years of cultural learning. On the other hand, the QR code pattern was invented only in 1994, and not enough time has yet passed for the human visual system to be trained to "read" this pattern.

In theory, if you fully memorized the QR code specification, converted the black and white pattern into binary numbers by eye, and performed Reed-Solomon decoding in your head, even a human could "read" a QR code. However, even the smallest QR code, Version 1 (21 by 21 modules), has 441 modules, and reading this accurately by eye would be close to impossible in practice.

How Cameras "See" QR Codes

The process by which a smartphone camera recognizes a QR code is fundamentally different from human vision. The camera captures the image as an array of pixels and processes the brightness value of each pixel as a number.

QR code recognition is carried out in four main steps. (1) Finder pattern detection: The camera searches the image for three nested square patterns and identifies the presence and position of the QR code. (2) Geometric correction: It corrects the distortion caused by the shooting angle (keystone distortion) and converts the image to how it would look from the front. (3) Module sampling: It divides the corrected image into a grid and determines black or white from the brightness value of each cell. (4) Data decoding: It converts the black and white pattern into a bit string and applies error correction to restore the data.

What is interesting in this process is the geometric correction in step (2). When a human looks at a QR code from an angle, it appears distorted into a trapezoid, but the brain corrects this and recognizes it as "this should be a square." The camera performs a similar correction, but its method is a mathematical projective transformation, completely different from the correction mechanism of the human brain. The same "correction of distortion" is achieved by biological neural circuits and by digital algorithms, each in its own way.

Design QR Codes That Use Optical Illusions

By turning the characteristics of the human visual system to advantage, it is possible to create designs that "look like art to the human eye but are recognized as QR codes by the camera." This is an application of optical illusions that cleverly uses the difference between human vision and camera recognition.

Applying the Hermann grid illusion: The "Hermann grid illusion," in which gray dots appear at the intersections of white grid lines, also occurs in the module arrangement of QR codes. To the human eye, the intersections of white modules may appear gray, but because the camera measures brightness values accurately, it is not affected by this illusion. Designers can use this property to design QR codes that have a distinctive visual effect to the human eye but can be read accurately by the camera.

Using color constancy: The human visual system has "color constancy," which lets it perceive the color of an object as constant even when lighting conditions change. However, camera sensors do not have this function, and the same object is recorded in different colors depending on the color temperature of the lighting. Using this difference, it is also theoretically possible to design a QR code that can be scanned only under specific lighting conditions.

Color Vision Diversity and QR Code Accessibility

About 5% of Japanese men (about 3 million people) have "color vision diversity," in which their color vision characteristics differ from those of the majority. For people with P-type / D-type color vision, who have difficulty distinguishing red from green, a QR code made of green modules on a red background appears to have extremely low contrast, and they may "not even notice that there is a QR code."

To ensure QR code accessibility, a contrast design that does not depend on color is important. Specifically, you ensure a sufficient brightness difference (lightness contrast) between dark modules and light modules, and design so that you do not rely only on differences in hue. In practice, the guideline is to ensure a contrast ratio of 4:1 or higher between dark modules and light modules. The 4.5:1 of WCAG (Web Content Accessibility Guidelines), used for text readability on the web, is a separate standard for people reading text, so it cannot be used as is to judge whether a QR code passes or fails. Once you have decided on a color scheme, include scanning it on an actual device to confirm it as part of your design procedure.

The most accessible QR code is the traditional combination of black and white. The contrast ratio of black and white is 21:1, making it the easiest combination to distinguish for people with any color vision characteristics. You should avoid sacrificing accessibility in the pursuit of design.

The Wonder of "Seeing" That QR Codes Teach Us

QR codes are a familiar teaching material that lets us experience the difference between human vision and computer vision in everyday life. Even though both are looking at the same black and white pattern, humans can only recognize it as a "pattern," while cameras read it as "data." This difference teaches us that the act of "seeing" is not simply receiving light but advanced information processing.

The human visual system instantly handles tasks that are still difficult for cameras, such as recognizing faces, reading emotions, and grasping three-dimensional space. On the other hand, cameras accurately carry out tasks that are impossible for humans, such as decoding QR codes, detecting fine patterns, and measuring brightness consistently. The two achieve the same act of "seeing" through completely different approaches.