反转颜色 OpenCV Java Api [英] Invert colors OpenCV Java Api

查看:33
本文介绍了反转颜色 OpenCV Java Api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 OpenCV 的 Java API 中反转存储在 Mat image 中的图像的颜色?使用 image.inv() 给我一个错误.

How do I invert the colors of an image stored in Mat image in the Java API of OpenCV? Using image.inv() gets me an error.

推荐答案

inv() 方法将尝试对矩阵求逆,这就是它失败的原因(很可能你的图像矩阵不可逆).

inv() method will try to take inverse of the matrix that's why it is failing (most probably your image matrix is not invertible).

您可以将两个图像相减,因此您可以创建一个所有值为 255 的图像,然后从中提取原始图像(如果这就是反转颜色的意思).

You can subtract two images from each other, so you can create an image with all values are 255 and then extract original one from it, if that is what you mean by invert the colors.

这篇关于反转颜色 OpenCV Java Api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆