0

i am developing an android application it has a requirement of decoding gray scale images which contains qr codes. i have been trying to integrate zxing with android . for rgb color scale images it's working fine.

for rgb image byte array i have used this code to build the binarybitmap.

RGBLuminanceSource source = new RGBLuminanceSource(width, height, data);
BinaryBitmap Binary_bitmap = new BinaryBitmap(new HybridBinarizer(source));

but for gray scale image i don't know how to build the binarybitmap.

Dinesh Kannan
  • 1,255
  • 13
  • 32

1 Answers1

0

I'm simply using LuminanceSource without the RGB. Works fine for grayscale images, though I'm using a buffered image. So that would be LuminanceSource source = new BufferedImageLuminanceSource(grayscaleImg);

Should you need to convert your mat to a buffered image, do this:

BufferedImage gray = new BufferedImage(mat.width(), mat.height(), BufferedImage.TYPE_BYTE_GRAY);
byte[] data = ((DataBufferByte) gray.getRaster().getDataBuffer()).getData();
mat.get(0, 0, data);
Jonas
  • 381
  • 3
  • 15