0

I want to apply adaptiveThreshold using open cv library to my bitmap image, but once i do with following code, it shows blank (full white) image, please help me to resolve it.

following is code:

Mat grayMat = imread(getImageUri(this, photo).getPath(), IMREAD_GRAYSCALE);
        Mat resultMat = new Mat();
        Imgproc.adaptiveThreshold(grayMat, resultMat, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 3, 40);
        Bitmap imgBitmap = Bitmap.createBitmap(resultMat.cols(), resultMat.rows(), Bitmap.Config.ARGB_8888);
Appstute
  • 13
  • 3
  • How did you assign the `resultMat` to the `imgBitmap`? To me it looks like you just instantiate the size and type of the bitmap. – Rick M. May 09 '17 at 14:56
  • Thank you Rick M, I just created imgBitmap like this only, how can i pass above bitmap to ImageView, pls help – Appstute May 10 '17 at 04:19
  • @RickM Utils.matToBitmap(resultMat, imgBitmap); i used this, but same result. – Appstute May 10 '17 at 04:29

1 Answers1

0

Add following line after init. bitmap

Utils.matToBitmap(resultMat, imgBitmap);

and load imgBitmap to your ImageView, I hope this will solve your problem.

Pratik Pitale
  • 1,655
  • 1
  • 16
  • 30