Improving quality of aztec barcode before reading using zxing

1.9k views Asked by At

I'm trying to decode aztec codes from images using zxing library.

Images looks more or less like this:

https://i.stack.imgur.com/8ybYb.jpg

So far my results are quite random.

I've tried a few image processing actions using imagemagick such as:

convert -brightness-contrast 50x20 in.png out.png
convert -colorspace Gray in.png out.png

And there was improvement but still most of codes fails to decode.

What specific image preprocessing actions should I do for such barcodes ?

1

There are 1 answers

2
fmw42 On BEST ANSWER

You can try -lat (local area threshold) in Imagemagick. For example:

Input:

enter image description here

convert barcode.png -colorspace gray -negate -lat 20x20+10% -negate result.png


enter image description here

You can improve that a little by adding -morphology close:

convert barcode.png -colorspace gray -negate -lat 20x20+10% -negate -morphology open diamond:1 result2.png


enter image description here