Rui*_*rey 2 c++ java api opencv computer-vision
如何反转Mat imageOpenCV的Java API中存储的图像的颜色?使用image.inv()给我一个错误.
以防万一:
Mat invertcolormatrix= new Mat(image.rows(),image.cols(), image.type(), new Scalar(255,255,255));
Core.subtract(invertcolormatrix, image, image);
Run Code Online (Sandbox Code Playgroud)
inv()用于计算逆矩阵 ; 使用bitwise_not代替:
Core.bitwise_not( image, image );
Run Code Online (Sandbox Code Playgroud)
inv()方法将尝试取矩阵的逆,这就是它失败的原因(很可能你的图像矩阵是不可逆的)。
您可以将两个图像相减,这样您就可以创建一个所有值为 255 的图像,然后从中提取原始图像(如果这就是反转颜色的意思)。