Hello,
I'm a software engineer working on a application designed to scan QR Codes from documents (PDF) to store them in the right place. I'm using ImageMagick with the command line tool to extract the pages of the documents as .PNG files and then Zbar to discover QR Codes. It works fine as long as the original document is well printed/scanned but as soon as the symbol is "damaged", Zbar can't discover anything anymore.
I'm processing the whole page but even with a focus on the QR Code, if it's not good enough, there's nothing to recover. I was wondering if there was any "magick" tool to improve the recognition.
For example, this one is damaged
But the same one with its markings improved is recognized
My knowledge with image processing is limited so I don't know if it's possible at all, but I was wondering if you could contrast and/or remove the with within the black lines to automatically get something close to the improved image.
Many thanks for any advice !
Jean-François
Improve QR Code Recognition with ImageMagick
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Improve QR Code Recognition with ImageMagick
The fact that you have JPG images is losing some quality. Don't save intermediate images as JPG. Nevertheless, try
If on Unix, then try either my script otsuthresh or kmeansthresh to do the threshold automatically.
Code: Select all
convert qr_code_error.jpg -morphology open square:1 -threshold 76% result.png
If on Unix, then try either my script otsuthresh or kmeansthresh to do the threshold automatically.
Code: Select all
convert qr_code_error.jpg -morphology open square:1 miff:- | otsuthresh - result.png
Re: Improve QR Code Recognition with ImageMagick
It worked with a threshold of 85% and 90% !
Now I have to figure out what threshold works with most of my unrecognized documents.
(I'm using PNG files to process Zbar, JPG were just used to share my issue)
Many thanks !
Jean-François
Now I have to figure out what threshold works with most of my unrecognized documents.
(I'm using PNG files to process Zbar, JPG were just used to share my issue)
Many thanks !
Jean-François