-1

Im preprocessing a qrcode to read it. I threshold the image, but sometimes I get a fuzzy black output, sometimes i get the proper binary image. Why is this happening? IM using C# and Emgucv.

Here is my code:

                    Image<Gray, byte> grayimg = inoutImg.Convert<Gray, byte>();  
                    grayimg = grayimg.ThresholdBinary(new Gray(this.tbbcrthreshold.Value), new Gray(255));
                    bcrthreshimgbox.Image = grayimg.Bitmap;

This is the Image im trying to threshold: enter image description here

And this is the Image I get sometimes after i crop the image using roi :

enter image description here

Because of this, im unable to read the code.

1 Answers1

0

I tried with the qr code image you shared and works with every threshold value <200 (as it's the background value).

Here's an example with 100 as threashold.

 Image<Gray,byte> qr = new Image<Gray, byte>("qr.png");
 CvInvoke.Threshold(qr, qr, 100, 255, ThresholdType.Binary);
 CvInvoke.Imshow("qr",qr);

Output:

Qr code binary

erik7854
  • 150
  • 1
  • 16