efficient way to remove a background from an image in python

40 views Asked by At

I've recently started working on my project of creating an efficient bot to play bejeweled 2, right now i'm stuck on a part in which i want my program to do image recognition, right now the idea is to take a picture of a current board, remove background from it and then tell what gem it is by shape, however when i try running the code using rembg, results were very bad, what should i do to have better results in removing background, heres a code very similiar to the one i tried using in main project (this one was used in testing )

pre background remove 1] post gg removal

entire screen before bg remove entire screen after bg remove

from rembg import remove
from PIL import Image
input_path = 'pic1.png'
output_path = 'pic2.png' //not actual names
input = Image.open(input_path)

output = remove(input)

output.save(output_path)

print('done')

0

There are 0 answers