imageimage-processingimagemagickzxingaztec-barcode

Improving quality of aztec barcode before reading using zxing


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

Images looks more or less like this:

https://i.sstatic.net/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 ?


Solution

  • 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