I need to take 2 numpy.ndarrays as an arguments and iterate through each of them pixel by pixel, adding the 2 values and dividing by 2.
Essentially creating a blended image of the two and returning it as a numpy.ndarray
This is what i've come up with, but could really use some advice.
def blendImages(image1, image2):
it1 = np.nditer(image1)
it2 = np.nditer(image2)
for (x) in it1:
for (y) in it2:
newImage = (x + y) / 2
return newImage
You can use OpenCV function addWeighted like:
cv2.addWeighted(img1,0.5,img2,0.5,0)`
As long as the arrays are the same size:
newImage = 0.5 * image1 + 0.5 * image2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With