Skip to content

Instantly share code, notes, and snippets.

@ogroleg
Created July 5, 2015 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogroleg/ecbd2e6bb23bbb11c4ee to your computer and use it in GitHub Desktop.
Save ogroleg/ecbd2e6bb23bbb11c4ee to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from PIL import Image
im = Image.open(u'07052015.png').convert('RGB')
pix = im.load()
colors_to_save = [(104, 104, 104), (114, 114, 114)]
w, b = (0xffffff, 0xffffff, 0xffffff), (0, 0, 0)
for x in range(im.size[0]):
for y in range(im.size[1]):
pix[x,y] = b if pix[x,y] in colors_to_save else w
im.save(u'result.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment