2017-09-16 127 views
0

我正在使用以下代码创建具有白色的蒙版。但是当我提取它时,我希望它是透明的。我该怎么做?如何使用opencv创建透明蒙版而不是白色

mask = cv2.ellipse(mask, center=(cX, cY), axes=(axesX, axesY), angle=0, startAngle=0, endAngle=360, 
         color=(255, 255, 255), thickness=-1) 

inside = np.bitwise_and(image, mask) 
outside = np.bitwise_and(image, ~mask) 

http://answers.opencv.org/question/25523/extract-an-ellipse-form-from-an-image-instead-of-drawing-it-inside/

enter image description here

enter image description here

+0

你想提取的图像至透明吗?另外,以图片为例。 – zindarod

+0

使用** dst = cv2.addWeighted(img1,0.7,inside,0.3,0)**其中** img1 = np.zeros_like(inside)**。 –

+0

@Zindarod它与电子商务网站上的任何产品图片大多具有白色背景相似。在某些情况下,它也可能是黑色的。你可以从amazon挑选任何产品图片 – jason

回答

相关问题