QR code cleaning after scan

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sucotronic
Posts: 2
Joined: 2013-12-17T04:11:00-07:00
Authentication code: 6789

QR code cleaning after scan

Post by sucotronic »

I've developed a script to process scanned documents that carry a QR code on them. When the original is scanned, I apply median 2 and noise 2 and the QR decoding library (zxing more used for android), and normally it decodes ok. The problem is when somebody scan a not original document. I've tried to vary values of median an noise, but the qr library is not able to indentify it. Any tips in additional parameter to get better results?

Here are my tests so far:

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: QR code cleaning after scan

Post by fmw42 »

try using -threshold and -morphology

convert test.png -threshold 75% -morphology open square:1 result.png

see
http://www.imagemagick.org/Usage/morphology/


Or try multiple iterations of -despeckle (and possible threshold afterwards)

convert test.png -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle result.png

see
http://www.imagemagick.org/script/comma ... #despeckle


If on linux/mac osx or windows with Cygwin, for automatic thresholding try my scripts, otsuthresh or kmeansthresh or isodatathresh. See my link below.
sucotronic
Posts: 2
Joined: 2013-12-17T04:11:00-07:00
Authentication code: 6789

Re: QR code cleaning after scan

Post by sucotronic »

fmw42 wrote:try using -threshold and -morphology

convert test.png -threshold 75% -morphology open square:1 result.png

see
http://www.imagemagick.org/Usage/morphology/


Or try multiple iterations of -despeckle (and possible threshold afterwards)

convert test.png -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle result.png

see
http://www.imagemagick.org/script/comma ... #despeckle


If on linux/mac osx or windows with Cygwin, for automatic thresholding try my scripts, otsuthresh or kmeansthresh or isodatathresh. See my link below.
Thanks! I also have to add -scale 30% because it seems that the QR decoding engine works better with small images instead of full 300dpi A4 scans :P

Image
Post Reply