问题描述
我有一张图片,我想用OpenCV删除(或遮盖)它的一部分.这是我的原始图片:
我想通过此图像蒙版删除其中心的圆:
我在我的代码中使用了此命令,从我阅读的教程中应该可以使用此命令,并在原始图像的中心涂上一个圆圈:
I have an image and I want to simply remove(or mask) parts of it with OpenCV. this is my original image :
And I want to remove a circle on its center via this image mask :
I use this command in my code which from the tutorials I read should work and black out a circle in the center of my original image :
img = cv2.bitwise_not(imgOriginal,imgOriginal,mask=imgMask)
但是我得到的结果是下面的图像,实际上,它并没有去除被蒙版的部分,而是反转了黑白:
but the result I get is the image below, in fact instead of removing the masked parts, it just inverts blacks and whites:
如果您能帮助我找到适当遮罩(或移除)所需零件的方法,我将不胜感激.
谢谢
I'll appreciate if you can help me on finding a way to properly mask(or remove) the parts I want.
Thanks
推荐答案
尝试一下:
//given source, mask and destination Mat images with same size
cv::subtract(img, mask, dst);
这篇关于使用OpenCV删除图像的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!