File tree 1 file changed +3
-3
lines changed
image_background_subtractor 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 6
6
mp_drawing = mp .solutions .drawing_utils
7
7
mp_selfie_segmentation = mp .solutions .selfie_segmentation
8
8
9
- IMAGE_FILES = ['location_to_image/image.jpg' ] # You can use multiple Images for removal at a go by just specifying the name of the images in the list.
10
- BG_COLOR = (255 ,255 ,255 ) # White Background
9
+ IMAGE_FILES = ['location_to_image/image.jpg' ] # You can use multiple Images for removal at a go by just specifying the name of the images in the list.
10
+ BG_COLOR = (255 ,255 ,255 ) # White Background
11
11
with mp_selfie_segmentation .SelfieSegmentation (model_selection = 0 ) as selfie_segmentation :
12
12
for idx , file in enumerate (IMAGE_FILES ):
13
13
image = cv2 .imread (file , cv2 .IMREAD_UNCHANGED )
18
18
bg_image [:] = BG_COLOR
19
19
output_image = np .where (condition ,image ,bg_image )
20
20
cv2 .imwrite ('./white_bg' + str (idx ) + '.png' , output_image )
21
- #Converting the White Background to Transparent Background.
21
+ # Converting the White Background to Transparent Background.
22
22
img = Image .open ("./white_bg" + str (idx )+ ".png" )
23
23
img = img .convert ("RGBA" )
24
24
datas = img .getdata ()
You can’t perform that action at this time.
0 commit comments