Il'ya Zhenin
Il'ya Zhenin

Reputation: 1332

How to merge two images using second as a transparent binary mask in Python?

For example I have a image of a cat, and second image with a mask of cat. And I want to add transparent red mask for pixels of a cat in first image. Both images are numpy arrays...So how to do it?

Upvotes: 0

Views: 1419

Answers (1)

Divakar
Divakar

Reputation: 221504

IIUC you could do something like this -

img[:,:,2] = np.where(mask,255,img[:,:,2])

Results -

enter image description here

enter image description here

enter image description here

Upvotes: 2

Related Questions