SciTech-Mathmatics-ImageProcessing-Remove the Background from an image using Python?

abaelhe發表於2024-08-05

https://www.geeksforgeeks.org/how-to-remove-the-background-from-an-image-using-python/

pip install Pillow
pip install rembg
# Importing Required Modules 
from rembg import remove 
from PIL import Image 
  
# Store path of the image in the variable input_path 
input_path =  './RemoveBackGroundOriginal.png' 
  
# Store path of the output image in the variable output_path 
output_path = './Remove BackGroundOutput.png' 
  
# Processing the image 
input = Image.open(input_path) 
  
# Removing the background from the given Image 
output = remove(input) 
  
#Saving the image in the given path 
output.save(output_path)

相關文章