2

I want to make the mask which I append to an image transparent in some way. I have the following:

img_background[mask]=[0,5,255]

I want to have the mask region ([0,5,255]) transparent.

beaker
  • 16,331
  • 3
  • 32
  • 49
David Radianu
  • 129
  • 1
  • 9

1 Answers1

1

You can add the two images using cv2.addWeighted like this:

import cv2

background = cv2.imread('field.jpg')
overlay = cv2.imread('dice.png')

added_image = cv2.addWeighted(background,0.4,overlay,0.1,0)

cv2.imwrite('combined.png', added_image)

Credits: Using openCV to overlay transparent image onto another image

Julio Milani
  • 191
  • 1
  • 6