Reputation: 903
The mask edge is soft, like this:
and Result with this mask in photoshop is:
After cv2.bitwise_and ,So bad the result is!
How can I handel this like photoshop,or any other method in python-opencv can do this?
Thanks!
Upvotes: 0
Views: 458
Reputation: 4826
If you want the transparent effect like in photoshop, you need to use an alpha channel. See this question.
If you want to composite the image with another background, you can use the alpha matting formula I = aF+(1-a)B
, where a
the alpha, F
the foreground and B
the background. Like this:
ex_alpha = np.repeat(alpha[:, :, np.newaxis], 3, axis=2)
output = (foreground*ex_alpha) + (1-ex_alpha)*background
The repeat exists because foreground/background are 3-channels while alpha is 1-channel.
Upvotes: 1