且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将背景的一部分颜色(黑色)更改为白色?

更新时间:2023-01-26 20:18:44

opencv 有一个按位不能正确反转图像的功能

opencv has a bitwise not function wich correctly reverses the image

您可以在图像的其余部分(已经正确的部分)放置蒙版/冻结并使用以下内容:

you can put a mask / freeze on the rest of the image (the part that is correct already) and use something like this:

imageWithMask = cv2.bitwise_not(imageWithMask)

imageWithMask = cv2.bitwise_not(imageWithMask)

或者,您也可以对图像的副本执行操作,只复制您需要的部分/像素/区域....

alternatively you can also perform the operation on a copy of the image and only copy over parts / pixels / regions you need....