2017-05-09 219 views
0

我想将自适应阈值应用到我的位图图像,但是一旦我使用下面的代码,它会显示空白(全白)图像,请帮我解决它。自适应阈值变为空白(全白)图像

下面的代码:初始化后,

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); 
+0

你是如何将'resultMat'赋给'imgBitmap'的?对我来说,它看起来就像实例化了位图的大小和类型。 –

+0

谢谢Rick M,我只是这样创建了imgBitmap,我怎么能通过上面的位图ImageView,请帮助 – Appstute

+0

@RickM Utils.matToBitmap(resultMat,imgBitmap);我用这个,但结果相同。 – Appstute

回答

0

添加以下行。位图

Utils.matToBitmap(resultMat, imgBitmap); 

并加载imgBitmap到您的ImageView,我希望这会解决您的问题。