Mask QR Errors
Mask QR Errors — know exactly which QR modules your art broke
- source_qr
- modified_qr
- QR_ERROR_MASK
- PERCENT_ERROR
- CORRELATION
- RMSE
So you generated a gorgeous QR code that no scanner will touch. Everyone's been there. "Mask QR Errors" is the ComfyQR pack's answer: feed it your original clean QR and the modified art version, and it tells you, module by module, where the pattern went wrong - plus a few numbers to quantify how bad it is.
The mechanism: it locates the QR on the source image, crops both images to those bounds, and averages each module-sized block of pixels into a single value. The modified QR is converted to grayscale (luminance with an sRGB gamma of 2.2 by default; there's a gamma input if you want to fiddle), the source is rounded to strict 0/1, and the two are compared. Every module that doesn't match within tolerance becomes a white pixel on QR_ERROR_MASK.
The inputs that matter:
source_qr/modified_qr- the original and the generated art, same placement and dimensions.module_size- the pixel width of one module in those images. Get this wrong and everything downstream is wrong.evaluate-module_pattern(default) scores the data area,finder_patternscores just the three corners,full_qrscores everything. Start with the default.error_difficulty- 0 to 1. This is the "your reader might be a cheap phone on a bus" knob. Higher values demand modules be closer to perfect black or white to pass: at 0 it only flags perfect grays, at 1 only exact black or white survives. Crank it to simulate a worse monitor or scanner.inverted_pattern- set it if your QR is inverted (white modules on black). Easy to forget, silently wrong when you do.grayscale_method-meanis a blunt average;luminancematches perceived brightness better.
Outputs: QR_ERROR_MASK (white where modules failed, ready to feed into img2img or a ControlNet strength curve), PERCENT_ERROR (fraction of modules that failed), CORRELATION (Pearson coefficient between source and modified), and RMSE (0 = identical to source, 1 = perfect inversion).
Now the assumptions, because these bite. The README is blunt: the source QR must be pure black and white (#FFFFFF/#000000), the module grid must be fixed and not resampled or distorted, and the source must have no stray same-color pixels outside the QR - the node finds the code by scanning for module-colored pixels, so stray ones throw the bounds off. It errors out if the QR bounds aren't a perfect square or don't divide evenly by module_size. The most common way people burn here: feeding it a resampled QR from the "Conformed to Image Size" node, or forgetting to keep the source strictly black and white.
Where it sits in the workflow: generate with the QR Code node, diff against your art, then push QR_ERROR_MASK into an img2img pass that only reworks the failing modules. The README also points at a companion pack (ComfyQR-scanning-nodes) for actual QR reading - Mask QR Errors estimates scannability from pixels, and the author is upfront that the statistics are basic. Use it to find and fix problem areas, not to certify that something scans.
Install is the pack-wide one: ComfyUI Manager → search "ComfyQR", or
cd ComfyUI/custom_nodes
git clone https://github.com/coreyryanhanson/ComfyQR
then restart. Deps are qrcode and pillow, no models. One last thing: the float outputs are lists (one value per image in the batch), so if you're wiring PERCENT_ERROR into a node expecting a scalar, take the batch into account.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| source_qr | IMAGE | — | |
| modified_qr | IMAGE | — | |
| module_size | INT | 161–64 | — |
| grayscale_method | COMBO | luminance | 2 options: mean, luminance |
| aggregate_method | COMBO | mean | 1 options: mean |
| evaluate | COMBO | module_pattern | 3 options: full_qr, module_pattern, finder_pattern |
| error_difficulty | FLOAT | 0.000–1 | — |
| inverted_pattern | BOOLEAN | false | — |
| gamma | FLOAT | 2.20.1–2.8 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| QR_ERROR_MASK | MASK | — |
| PERCENT_ERROR | FLOAT | — |
| CORRELATION | FLOAT | — |
| RMSE | FLOAT | — |