I am trying to add two images together.
When I do so in GIMP, using the 'Addition' layer-mode I get the following desired output.
Now, I am trying to execute this in Python, however I can not manage to get it working properly. According to the gimp documentation, as far as I understand the formula for addition is simply the addition of each pixel, set to a max of 255.
Equation for Addition mode: E = min((M+I), 255)
I try to apply this in Python but the output looks different. How can I get the same output in Python as the gimp addition layer blending mode?
My attempt:
# Load in the images
diffuse = cv2.imread('diffuse.png')
reflection = cv2.imread('reflection.png',)
# Convert BGR to RGB
diffuse = cv2.cvtColor(diffuse, cv2.COLOR_BGR2RGB)
reflection = cv2.cvtColor(reflection, cv2.COLOR_BGR2RGB)
# Covnert to uint64 so values can overflow 255
diffuse = diffuse.astype('uint64')
reflection = reflection.astype('uint64')
added = diffuse + reflection # actually add
# clamp values above 255 to be 255
added[added > 255] = 255
# display
im = Image.fromarray(added.astype('uint8'))
im.save('blended_python.png')
Now, this looks pretty similar but it is actually too bright compared to the GIMP addition. Just open both in a new tab and alt+tab between them and the difference becomes obvious.
How can I get the exact same result as in GIMP? I tried to use Python-fu or gimp batch rendering (as I have thousands of images that I want to blend like this) but I could not get that working, either.