So I currently have 2 images below. These were obtained using a neural style transfer network on the foreground and background parts of the image.
The code used was the following:
add = cv2.add(image1, image2)
cv2.imshow('Addition', add)
cv2.waitKey(0)
cv2.destroyAllWindows()
I have merged them to create the following resultant image:
However, I want to use the salience mask on the obtained picture. The salience mask is below. I have tried inputting the mask argument to the add function but had no luck. I've tried looking at this article but wasn't able to work out what to do Add 2 images together based on a mask
EDIT:
Found the issue was that I was not converting the data types. The updated code is:
saliencyMap = cv2.resize(saliencyMap, (384,384))
newmap = saliencyMap.astype(np.uint8)
add = cv2.add(image1, image2, mask=newmap)
cv2.imshow('addition', add)
cv2.waitKey(0)
However, the resultant image is and I'm not sure why:





I think what you might want is to simply resize the two images to the same size and then add them. Then use the mask to do hard light compositing in Python/OpenCV.
img1:
img2:
mask (saliency):
Result: