BinaryEye icon indicating copy to clipboard operation
BinaryEye copied to clipboard

Image with a QR and high frequency components does not decode

Open gnusuari0 opened this issue 5 years ago • 4 comments

Example: https://pbs.twimg.com/media/EZIyEWrXQAMfNQs?format=jpg&name=4096x4096

If blurring is applied to the original image, Binary Eye is capable of decoding the QR code. A filter needs to be applied to smooth images. Smaller codes will need the phone to be closer or reduce the amount of blurring applied in order to not lose detail. A threshold should be computed to know the amount of blurring needed, if possible.

gnusuari0 avatar Jun 08 '20 23:06 gnusuari0

SuperSandro2000 avatar Jun 09 '20 08:06 SuperSandro2000

I made a manual filtering with the GIMP. I first applied an average blur. Diamond neighbourhood and a radius of 12. Then I binarized the image using the threshold filter on the RGB channel, with the lower input threshold set at 28.

qr-filtered

In this case, if you first binarize and then you do the average blur to remove the white spots, the radius of the average blur can be lower.

Another option I tested was to reduce the image size to 1/10th of the width and height, and resize it to the original size again (supersampling). Then binarize with threshold at 56. It also works.

gnusuari0 avatar Jun 09 '20 15:06 gnusuari0

Well, Binary Eye already downsamples the camera frame to 75% (see here) which is kind of equivalent to applying a slight blur (the downsampling also results in less data to process what's good for performance on bad devices).

Looking at your samples (you should really have a quiet zone around your QR Codes by the way), I believe the best solution would be to apply an Adaptive Threshold algorithm (something like this).

There are a couple of Adaptive Threshold implementations for RenderScript available so it would be quite easy to try this. And Binary Eye has device tests, so it's easy to tell when a change breaks something.

markusfisch avatar Jun 09 '20 18:06 markusfisch

I was talking about blurring because I supposed Binary Eye uses a local threshold algorithm for binarization (https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/common/HybridBinarizer.java) which is supposed to overcome the problems this sample has: being a high frequency image. Anyways, I hope these samples are useful for improving the app.

gnusuari0 avatar Jun 09 '20 20:06 gnusuari0