Changing Background of Portrait Image

Dear OpenCV Development Team ,
Currently, I’m working on a segmentation task using U-Net, and I got a binary mask as a model’s output which contains 0 (background) and 1 (foreground) values. I want to utilize OpenCV in replacing the background of portrait image by the new one with a given mask. Are there any approaches that meet my needs? The below attachment is my given mask of 4 people as an example, but of course I just need to apply on 1 people only.

Sincerely thanks :heart:

maybe a simple copyTo with your mask ?