I am trying to replace all black pixels in an image with pixels of another image...
this is the code I have so far-
imgFront = cv2.imread('withoutbackground.jpg')
imgBack = cv2.imread('background.jpg')
height, width = img.shape[:2]
resizeBack = cv2.resize(imgBack, (width, height), interpolation = cv2.INTER_CUBIC)
for i in range(width):
for j in range(height):
pixel = imgFront[j, i]
if pixel == [255, 255, 255]:
imgFront[j, i] = resizeBack[j, i]
however I am getting an error message that says incorrect syntax on this part --
pixel = imgFront[j, i]
which is weird because I am looking right at the opencv documentation and thats how it says to do it..