← All posts
9 min read

DiffQR and the scanability problem: making artistic codes that actually scan

Pretty QR codes are easy. Pretty QR codes that scan on a Pixel under fluorescent light are not. Here is how DiffQR-style approaches close the gap.

ResearchEngineering

Anyone who has shipped artistic QR codes has felt the same gut-punch: the result looks gorgeous on the laptop, scans fine on the iPhone next to you, then refuses to read for a customer holding a three-year-old Android in a dim bar. Scanability is not a single number. It is a distribution across cameras, lighting, distance, angle, and decoder version. DiffQR-style methods exist to drag that distribution to the right.

Why baseline diffusion-QR pipelines miss

A standard ControlNet-for-QR setup conditions every denoising step on the QR pattern and hopes the final image stays readable. It usually does — for ideal scanners. The trouble is that "scanability" inside the model is a soft signal: the image just needs to look QR-shaped enough that the loss is happy. Real decoders are stricter. They threshold to binary, they apply error correction, they reject low-contrast modules outright.

DiffQR (Diffusion-based QR Coder) and the broader DiffQRCoder line of work close that gap by introducing a second loss that mirrors what a real scanner does. Concretely: at each step, decode the current latent, compare the decoded modules against the ground-truth QR, and use the per-module error as additional guidance. The model is no longer just trying to look right — it is trying to be right under a binarizing decoder.

The Scanning-Robust Perceptual Guidance idea

The core technique often called Scanning-Robust Perceptual Guidance (SRPG) does roughly this in plain English: simulate the scanner during generation, find the modules that would currently fail, and steer the next denoising step to fix exactly those modules — without disturbing the parts of the image that are already both pretty and readable. The result is a model that "knows" which pixels it can play with and which it cannot.

Practical levers that move scan rate

You do not need to be implementing SRPG from scratch to apply its lessons. Most of the leverage in a real pipeline comes from a few choices that any team can tune.

  • Error-correction level — bump to H for art-heavy codes. You spend density, you buy redundancy. Worth it.
  • Module size — print bigger. Scan rate is dominated by camera-pixels-per-module. Doubling the physical size often does more than any model tweak.
  • Contrast floor — clip the generated image so the dark modules stay below a threshold and the light modules above one. Cheap, brutal, effective.
  • Finder protection — composite the original finder patterns back over the generated image. Almost free, fixes a huge class of failures.
  • Decoder loop — after generation, decode with a real library (zxing, zbar, the iOS native API). Reject anything that does not survive the round trip and regenerate.
  • Test fleet — keep a small set of representative phones (one old Android, one mid-tier iPhone, one Pixel) and test under bad lighting. Synthetic metrics lie.

The honest trade-off

Even with DiffQR-class methods, an artistic QR code will never beat a plain black-and-white code on raw scan rate. The right framing is different: an artistic code that scans 95% of the time but gets 3× the engagement is a better business outcome than a plain code that scans 100% of the time and gets ignored. Scanability is a constraint you optimize against, not a goal you maximize. The job is to push that 95 as high as you can without losing the art.

Where the field is going

Two threads are worth watching. First, scanner-aware losses are getting cheaper to compute, which means they will start showing up in real-time generators rather than offline pipelines. Second, the codes themselves are evolving — rectangular Micro QR variants, color-channel encodings, and JAB-style 2D codes are all candidates for the next wave of "QR-but-prettier." Whatever wins, the underlying lesson stays the same: the model that respects the decoder ships codes that actually get scanned.