Chapter 04 of 22 Part I: Foundations of Digital Information

The Incredible QR Code

Difficulty: Intermediate Editorial estimate: ~50 min Prerequisites: Chapter 01, Chapter 03

Chapter Field Guide

LOCATE
  • Find the square
  • DECODE
  • Recover codewords
  • CHECK
  • Repair within capacity
DATA BIT
  • 1
  • XOR MASK
  • 1
  • MASKED BIT
  • 0; XOR again to restore 1

Measurable Learning Outcomes

  • Identify finder patterns, timing patterns, and format modules in a QR matrix.
  • Explain why QR codes apply XOR mask patterns to avoid confusing optical scanners.
  • Describe how Reed-Solomon parity codewords allow recovery even when a region is damaged.

Core Scientific Intuition

Unlike a 1D barcode, a QR code stores bits in a 2D grid. Three square finder patterns let a camera determine position, scale, and rotation in one frame. Data bytes are paired with Reed-Solomon error-correction codewords computed in GF(256), allowing up to 7% (L), 15% (M), 25% (Q), or 30% (H) of codewords to be recovered.

2t ≤ n − k (max correctable symbol errors t from n − k parity bytes)
In plain words: Each corrupted byte requires two Reed-Solomon parity bytes to both locate and repair.
Units & assumptions: n = total codewords, k = data codewords, t = unknown-location byte errors in GF(256).

Worked Example

A Version 1-M QR code (21×21 modules) holds 26 total codewords: 16 data bytes and 10 Reed-Solomon parity bytes, enabling correction of up to 5 corrupted bytes anywhere in the symbol.

Hands-On Exploration

Interactive Laboratory

Test the concepts directly with 5 interactive panels, live controls, and visual feedback.

Open Interactive Lab →

Three Guided Projects

Structured experiments with hypotheses, boundary tests, hints, and reflection prompts.

View 3 Projects →

Source Code (5 Snippets)

Inspect byte-identical printed JavaScript blocks, download `.js` files, or test runnable blocks in the isolated sandbox.

Browse Code →

Self-Check Quiz (5 Questions)

Immediate explanations for every choice, unlimited retries, and local-only score tracking.

Take Self-Check Quiz →

Book Chapter Outline (Reference Guide)

Section headings from Volume 1 for cross-referencing with the printed book.

Show all 27 book section headings
  1. A guide to QR codes and error correction.
  2. A parcel that refused to forget
  3. Try this before reading on
  4. The engineer behind the square
  5. Masahiro Hara (born 1957)
  6. From factory floors to everyday life
  7. The anatomy of a square
  8. From text to a matrix
  9. Two mathematicians, one remarkable idea
  10. Irving Stoy Reed (1923 to 2012)
  11. Gustave Solomon (1930 to 1996)
  12. Give the message extra clues
  13. Four levels, four compromises
  14. Why does a QR code look random?
  15. Build your own QR generator
  16. Damage the code, then repair it
  17. Can a copied QR label fool a verification system?
  18. Can a square prove a product is genuine?
  19. The case of the scratched cargo label
  20. Mission questions
  21. Invent a better experiment
  22. What even a clever code cannot do
  23. Now invent
  24. Answers to the detective mission
  25. Scientific vocabulary and sources
  26. Further reading and references
  27. Next chapter

Primary Sources & Further Reading

External links are provided for independent verification and deeper study. Link availability can change over time; see the Resources page for verification notes.

Source Type Link
Real photograph: Masahiro Hara, Qargo (2024), CC0, Wikimedia Commons reference https://commons.wikimedia.org/wiki/File:Masahiro_Hara_honored_by_French_artist_qargo.jpg
Biography and historical portrait source: National Academy of Engineering memorial reference https://www.nationalacademies.org/read/18959/chapter/46
Biography and photograph reference: IT History Society (Reed) reference https://ithistory.org/honoree/irving-stoy-reed
Historical photograph reference: University of Victoria course notes (Reed and Solomon) reference https://www.ece.uvic.ca/~agullive/reedsolomon-2014.pdf
DENSO WAVE: error correction reference https://www.qrcode.com/en/about/error_correction.html
TrustQR product verification workflow reference https://trustqr.org/how-it-works/
DENSO WAVE: QR Code history reference https://www.qrcode.com/en/history/
DENSO WAVE: QR Code versions and capacity reference https://www.qrcode.com/en/about/version.html
European Patent Office: QR code inventor team reference https://www.epo.org/en/news-events/european-inventor-award/meet-the-finalists/masahiro-hara-motoaki-watabe-tadao-nojiri
Reed and Solomon (1960): original paper reference https://doi.org/10.1137/0108018
Thonky: QR encoding, masking and placement tutorial reference https://www.thonky.com/qr-code-tutorial/
MDN: Canvas API and JavaScript official-docs https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API