Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get pixel values of a binarized image in android studio?

I want to get the pixel value of a binarized image and store it in an integer array. I used openCV to grayscale the image and used adaptivethreshold for the binary: grayBitmap = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);

    Utils.bitmapToMat(imageBitmap,Rgba);//bitmap to Mat
    Imgproc.cvtColor(Rgba,grayMat,Imgproc.COLOR_RGB2GRAY);//grayscale
    //binary
  Imgproc.adaptiveThreshold(grayMat,imageBW,255,Imgproc.ADAPTIVE_THRESH_MEAN_C,Imgproc.THRESH_BINARY,5,4);
    //mat to bitmap
    Utils.matToBitmap(imageBW,grayBitmap);

and I want to get pixel value of imageBW to see the value of each pixels and possibly convert them into 1 and 0 depending o for black and 1 for white if necessary.