移除opencv android java中Mat的alpha通道

移除opencv android java中Mat的alpha通道,java,android,opencv,Java,Android,Opencv,我正在使用Utils.bitmapToMat()从位图加载Mat。这将生成一个具有4个通道的矩阵。我如何得到一个有3个通道的矩阵,而阿尔法通道只是被移除 换句话说,我想要android上opencv java中mat[:,:,0:3]的python等价物。假设alpha通道是最后一个颜色通道(BGRA或RGBA颜色格式),您可以使用Imgproc.cvtColor和Imgproc.color\u BGRA2BGR参数: // Creating the empty destination matr

我正在使用Utils.bitmapToMat()从位图加载Mat。这将生成一个具有4个通道的矩阵。我如何得到一个有3个通道的矩阵,而阿尔法通道只是被移除


换句话说,我想要android上opencv java中mat[:,:,0:3]的python等价物。

假设alpha通道是最后一个颜色通道(BGRA或RGBA颜色格式),您可以使用
Imgproc.cvtColor
Imgproc.color\u BGRA2BGR
参数:

// Creating the empty destination matrix
Mat dst_mat = new Mat();

// Converting the image from BGRA to BGR and saving it in the dst_mat matrix
Imgproc.cvtColor(mat, dst_mat, Imgproc.COLOR_BGRA2BGR);

注:

  • 我没有测试代码,但是根据,代码应该可以工作