I have two images stored as numpy arrays. I am looking for a function that can replace the parts of array2 that have black pixels ([0, 0, 0]) with the same indices of array1. My code so far is non-numpy:
for y in range(array2.shape[0]):
for x in range(array2.shape[1]):
if np.all(array2[y, x]) == False:
array2[y, x] = array1[y, x]
The code loops over every pixel in array2 to see if all of the channels are 0 (black), and if so copies the colour of array1 at that index onto array2.
This is obviously very slow because it loops over a lot of pixels that aren't black and has no affect on them. I assume numpy has a function that can do this, but I can't understand what they do. Any guidance (with or without numpy) is appreciated.
array2andarray1? at least to have matching.shape