python rembg - change background color

636 views Asked by At

I remove background but instead of having a transparent background I would like to have green for example but I don't understand how to do it.

I want to change the background of my image for that I do:

from rembg import remove
import cv2
image = cv2.imread(imgPath)
removeim = remove(im)

But no idea for complete background with a color...

Thanks

1

There are 1 answers

0
Akshay Gondaliya On

use this

"removeim = remove(im,bgcolor=[255,0,0,255])"

this will give you an output with complete red background.

change bgcolor=[255,0,0,255] to bgcolor=[0,255,0,255] to get complete green background.