Studying QR Code Degradation

It’s fair to say that QR codes are a technology that has finally come of age. A decade or more ago they were a little over-hyped and sometimes used in inappropriate or pointless ways, but now they are an accepted and useful part of life.

They’re not without their faults though, one of which is that despite four increasingly redundant levels of error correction, there comes a point at which a degraded QR code can no longer be read. [HumanQR] is soliciting these broken QR codes for research purposes and inclusion in an eventual open-source database, and they’ll even have a shot at repairing your submissions for you.

It’s a problem inherent to all digital media, that once the limit of whatever error correction they contain has been reached, they arrive at a cliff-edge at which they go immediately from readability to non readability. The example given in the linked article is a locator tag on a stray cat, it had been rubbed away in part. Improving its contrast, sharply defining its edges, and improving the definition of its fiducials was able to revive it, we hope leading to the cat being returned home.

The idea is that by studying enough damaged codes it should be possible to identify the means by which they become degraded, and perhaps come up with a way to inform some repair software. Meanwhile if you are interested, you might want to learn more about how they work, the hard way.

30 thoughts on “Studying QR Code Degradation

  1. Sadly, many QR codes are broken before they even get printed. Someone had the brilliant idea to start abusing the data redundancy mechanism to put whatever logo in the middle of it, make them colorful, round the squares, etc.

      1. You do realize that QR code has different error correction levels? I’d assume you can increase redundancy when putting a logo in the middle to keep the number of correctable errors on a similar level.

    1. Try reading a QR code off of a piece of tech where the code is printed in dark gray on a black cabinet. Several manufacturers were doing that with barcodes and now have done that with QR’s.

    2. While yes, overlaying an image on the middle of a QR code will reduce the error-correction capabilities of the code, changing the colours or rounding the corners of the cells (afaik) does not.
      QR code readers are looking for contrast between the ‘black’ and ‘white’ cells, as the actual colour reported by the camera can be different depending on lighting conditions etc. So while it will reduce the range of lighting conditions the code will work under, changing the colour won’t affect the data. Similarly, QR readers are usually only actually looking at the centre-most pixel of each cell, so you can round the corners of the cells without damaging the data, or even add other stuff in the intercellular space: https://www.reddit.com/r/touhou/s/DZahuS5XYS

      More to the point though, why is it sad if people add images to the middle of a QR code? Sure, if a code needs to last a long time under harsh conditions (on an inventory management sticker for example), it’s unwise to mess with the error-correction. For other applications though, if it still scans, and it’s intended to be used for a shorter period time than it will take for the data to degrade, what’s the harm?

      Is it really abuse of a feature? Or just using the features in a new, unexpected way?

  2. Wouldn’t this be a failure of the physical media’s not the digital of the qrcode? Everything physical will degrade over time. My own body is proof of that.

  3. I have used QR code breaking to my advantage, when replying to official traffic violation notices.
    They use a QR code to they can efficiently scan the document into their database.
    So I corrupt it with small blobs of ink, and check it with my phone scanner to make sure there’s enough degradation.
    This then forces them to enter the data by hand, which then causes them to miss deadlines for fining, etc.
    You can use the same technique with document barcodes.

    1. You have a very inefficient government.
      We just get a fine, have to pay it first and only after that is done you can contest the fine and maybe get your money back.
      The term for paying and contesting is just a few weeks, whereas the appeal may take months to proceed.

  4. How would brute forcing the illegible part work? Seems to me it could be a viable solution for some.
    Even providing the incomplete data available in a human readable form could allow the incredible amount of processing power in the grey matter to tease out some clues.
    In the missing cat example merely knowing the name of the pet tracking/reporting service would be enough to report the missing animal.
    Although we could also suggest that RFID or tattoo is probably a more robust pet ID method, not to mention a description of the animal and where it was lost is more than sufficient in most cases. 🤷🏼‍♂️

    Maybe if you intend the QR to last it should be cast in metal or milled into the plastic instead of screen printed. I’m also going to call it that the physical medium needs to be considered if the QR is supposed to be depended on in harsh environments.

    1. Also my face hurts, the example is a QR on a Bluetooth tracker. Just why? What is wrong with just putting an email or phone number on the cat’s collar.

      I am not sure the Bluetooth or the QR are the proper application of technology in that case. I still don’t think the QR code was the failure, the failure came in applying the tech as the only tracking.

      1. I don’t really have a strong opinion one way or the other but one possible reason to go with a QR code over a human readable label is that it does have error correction, obviously there are limits to that correction, that’s what this article is about, but consider the alternative. If two digits of a phone number get scratched off you’re out of luck unless you want to cold call 100 people. You might not even realize that an email address is one if the @ symbol gets lost. QR has error correction that would easily recover from losses like that.

        1. RFID in the tag as well as the pet, QR is easier because people can just scan it and get correct contact details instead of having to read and spell an email address, but when it’s worn off it’s obviously not going to work. Though I do wonder if just deeper engraving would be a better way to ensure longevity of the code.

          1. Kinda, but I think the opportunities for phishing presented by the collar tag on a pet are pretty limited so I’d be fairly confident that I could scan it.

    2. My only reference experience is working with very basic error correction in RF transmissions. The standard contains NO error correction, but has CRC error detection. Interestingly, for every single-bit error possible in this standard, you can calculate the precise location of the error in the bitstream from the CRC, and therefore toggle that bit to correct it.

      My experience was that while you can build a seemingly correct “answer” by brute force, for every erroneous bit, the number of possible “answers” that fit the “question” goes up exponentially. So if you’re error correcting, say, “ABCDEFG”, you received “ABCDEzG”. Brute force might have two possible answers, one is the transmitted message, one is “ABCDEGG” but there’s no way to know which is correct without extra information – a human would guess that “ABCDEFG” is the correct version, but the algorithm probably couldn’t.

  5. There is another way QR can go bad: obsolete link. Example, a prank QR code that load Rick n roll video. If the user deletes the video, Youtube shuts down the account, or they change the link format without auto-redirect to new link, then using QR would result in a 404.

    1. Link rot is the term. It is a serious problem. Many websites don’t take it seriously to preserve links. If you want to look up specs of a product older than 5 years it is often removed from the website or it is moved to a different section. Even the internet archive can not recover some pages.
      There should be a list of rules for the internet.

  6. At first I was going to suggest using soft-decision Reed-Solomon decoding, but from the picture of the cat’s tag I see that the problem is that bits aren’t faded, but that they’ve been obliterated. For this you want to use erasure decoding. Reed-Solomon codes are well-suited to this. You need to mark the obliterated bits as “erasures” rather than 1s or 0s and the error-correction decoder can correct a lot more bits when erasures are marked. If there are 8 erasures, for example, you can think of these as having 2**8=256 possible original encodings and you can try those and choose the Reed-Solomon codeword that has the smallest Hamming distance from one of those. (This is built into the erasure decoding algorithm, however, and needn’t be done explicitly.)

    The problem with [HumanQR’s] method is that he’s enhanced the contrast, making the erasures black and thus assigning them a high-confidence value of 0 rather than a no-confidence value of ‘x’ (erasure).

    To use this scheme you’d need to use the erasure decoding algorithm and a means of marking the erasures. In this particular case there are also scratches which did not totally obliterate bits and repairing these by hand might also help a little.

    1. Actually, looking again at the high-contrast “repaired” image, I see that it is a negative image and the obliterated bits have actually been replaced with white. That is probably why it is working, because it seems like more white than black ink has been removed (the remaining ink is all black), so making the assumption that the erasures are all white is a simple first attempt at a repair.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.