One of the more common reasons why a QR code won't scan is because there isn’t enough contrast between the foreground and background colour used. For a QR code to be scanned reliably the contrast difference between the foreground colour and the background colour used in the QR code image must be large enough for the camera in the scanning device to be able to identify the QR code pattern against its background. If the contrast between the foreground and background colours isn’t large enough then the scanning device won’t able to “see” the QR code image against the background and hence won’t be able to scan it and decode it. So, how much contrast is required? The answer is in two parts. 1. Tonal Contrast vs Hue Contrast Many QR code scanning apps scan in black and white (grey-scale) and not in colour so the “contrast” value actually relates to the difference in the grey-scale tone (or brightness) of the two colours used and not the differences in their hues (colour). To show the difference between Hue Contrast and Tonal Contrast here’s two QR code shown in colour and as their grey-scale equivalent – basically what we see versus what the scanning app "sees". While there’s an obvious difference in foreground and background colour used in each QR code, the grey-scale tonal contrast in both cases is pretty much zero. Because it scans in black and white the scanning app won’t "see" the colours, just the greys, and hence not being able to discern the QR code image, the scan attempt will fail. 2. How Much Tonal Contrast Is Enough? The amount of tonal contrast to ensure a reliable scan is going to depend on several factors:
- Ambient light – not even a black and white QR code will scan in the dark.
- Surface reflection – a shiny QR code image will reflect white. Not good if it’s on a white background.
- Scan distance – the further away the QR code is, the smaller it looks to the camera and hence the more pronounced the distinction between foreground and background areas needs to be. This distinction is enhanced by a higher foreground to background colour contrast.
- Camera quality – some cameras have a better tonal range response than others.