3

I have two images and a mask. The first image (im1) is my source image, the second (im2) is the image whose region need to be inserted in im1 and the third image (mask) contains 1's in the region that needs to be pasted. All images have the same size (H*W*3). It should be noted that im1 is HDR( .exr format). After reading via OpenCV

im1 = .imread(im1, cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)[:,:,0:3]
im2 = ...
mask = ...

how can I transfer the masked region(contained in mask array) of image im2 without any loss of information (no change apart from masked region) in im1?

singa1994
  • 747
  • 1
  • 7
  • 18

1 Answers1

0

Normally you would use OpenCV's copyTo() method which will copy an image or masked image region from one Mat to another. Unfortunately, this functionality is not available in the OpenCV Python bindings.

There is a Python workaround for this function from this answer though which you could use instead.

T A
  • 1,677
  • 4
  • 21
  • 29