遮挡是按位操作执行的
from imutils import *
image = imread('test.jpg')
show(image)
image.shape
(400, 300, 3)
# 创建遮挡
mask = np.zeros(image.shape,dtype='uint8')
white = (255,255,255)
cv2.rectangle(mask, (50,50), (250,350), white, -1)
show(mask)
# 对图像遮挡
masked = cv2.bitwise_and(image, mask) #只有中间白色区域显示
show(masked)
# 创建遮挡
mask = np.zeros(image.shape,dtype='uint8')
white = (255,255,255)
cv2.circle(mask, (150,100), 80, white, -1)
show(mask)
# 对图像遮挡
masked = cv2.bitwise_and(image, mask)
show(masked)