import cv2
import numpy as np
img2 = cv2.imread('data/result/R000183B3_C00034AD8_open.png')
img1 = cv2.imread('data/mask/R000183B3_C00034AD8_mask.png')
cv2.imshow('img1', img1)
cv2.imshow('img2', img2)
img1gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
img2gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
ret1, img1_Mask = cv2.threshold(img1gray, 10, 255, cv2.THRESH_BINARY)
ret2, img2_Mask = cv2.threshold(img2gray, 10, 255, cv2.THRESH_BINARY)
# Mask_inv = cv2.bitwise_not(Mask)
# cv2.imshow('Mask_inv', Mask_inv)
# cv2.waitKey(0)
#  AND， OR， NOT， XOR
img1_mask = cv2.bitwise_not(img1, img1, mask=img2_Mask)
cv2.imshow('img1_mask', img1_mask)
cv2.waitKey(0)
img2_mask = cv2.bitwise_not(img2, img2, mask=img1_Mask)
cv2.imshow('img2_mask', img2_mask)
cv2.waitKey(0)
# dst = cv2.add(img1_bg, img1_fg)
# cv2.imshow('das', img2)
# cv2.waitKey(0)
cv2.destroyAllWindows()