Skip to content

Instantly share code, notes, and snippets.

View liuhao2050's full-sized avatar
🎯
Focusing

Brooks Liu liuhao2050

🎯
Focusing
  • Baidu, Inc.
  • Beijing·China
View GitHub Profile
@liuhao2050
liuhao2050 / images_bg_change.py
Last active November 6, 2021 05:41
A demo to change a picture's background use python
from PIL import Image
if __name__ == "__main__":
im = Image.open("mr.zhang.jpg")
x, y = im.size
for i in range(x):
for j in range(y):
r, g, b = im.getpixel((i,j))
if (20< r < 180) and (80< g < 250) and (180< b< 265):
r, g, b = 255, 255, 255
im.putpixel((i, j), (r, g, b))