使用Zxing读取之前提高阿兹台克条形码的质量

时间:2019-01-28 21:30:35

标签: image image-processing imagemagick zxing aztec-barcode

我正在尝试使用zxing库从图像中解码阿兹台克代码。

图像或多或少看起来像这样:

https://imgur.com/a/5ExPy6q

到目前为止,我的结果是相当随机的。

我已经尝试使用imagemagick进行一些图像处理操作,例如:

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

虽然有所改进,但大多数代码仍无法解码。

我应该对此类条形码执行哪些特定的图像预处理操作?

1 个答案:

答案 0 :(得分:0)

您可以在Imagemagick中尝试-lat(局部区域阈值)。例如:

输入:

enter image description here

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


enter image description here

您可以通过添加-morphology close来对其进行一些改进:

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


enter image description here