Last active
August 29, 2015 14:00
-
-
Save fabienhinault/57c8c5f6631323488e7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import PIL.ImageOps | |
import glob | |
for f in glob.glob('./*.bmp'): | |
image = Image.open(f).convert("RGB") | |
inverted_image = PIL.ImageOps.invert(image) | |
inverted_image.save(f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import PIL.ImageOps | |
import glob | |
orange = (255,102,0) | |
blue =(30,86,160) | |
for f in glob.glob('./*.bmp'): | |
img = Image.open(f).convert("RGB") | |
pixdata = img.load() | |
for y in xrange(img.size[1]): | |
for x in xrange(img.size[0]): | |
pix = pixdata[x, y] | |
delta = (pix[0] - orange[0], pix[1] - orange[1], | |
pix[2] - orange[2]) | |
maxdelta = sum(abs(d) for d in delta) | |
if maxdelta < 300: | |
pixdata[x, y] = (blue[0] + delta[0], | |
blue[1] + delta[1], | |
blue[2] + delta[2]) | |
img.save(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment