Skip to content Skip to sidebar Skip to footer

Removing An Overlay Image From Another Image

So I have two images, the original one and one which is supposed to be the overlay on top of it. The overlay image is semi-transparant, let's say white with alpha 0,5. I can overla

Solution 1:

well... for linear blending bld = a*org + (1-a)*fil (in your example a = 0.5)

so org = (bld - (1-a)*fil) / a

which is org = 1/a * bld + (1-1/a) * fil if I'm not wrong.

with a = 0.5: org = 2*bld -1*fil

in code:

a = 0.5org = cv2.addWeighted(bld,1/a,fil,1-1/a, 0)

or

org = cv2.addWeighted(bld,2,fil,-1, 0)

you could also use org = 2*bld - fil but openCV truncates the values if they go beyond e.g. 255 for 8U types (called saturate_cast), so this won't work if you dont convert to 16/32 bit types before computation.

In general, if you didnt blend linearly, you would have to change the first formula to bld = a*org + b*fil and compute the rest from that.

Post a Comment for "Removing An Overlay Image From Another Image"