Created
June 10, 2018 18:17
-
-
Save gifguide2code/feafbab1514f57543f120668e35d47f5 to your computer and use it in GitHub Desktop.
A Python script to filter out pixels with a red value higher than 30.
This file contains 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 | |
im = Image.open('C:\\Users\\Desktop\\HexTest.png') | |
pix = im.load() | |
width = im.size[0] | |
height = im.size[1] | |
new_im = Image.new('RGB', (width,height), "white") | |
new_pix = new_im.load() | |
for y in range(height): | |
for x in range(width): | |
if pix[x,y][0] < 30: | |
new_pix[x,y] = pix[x,y] | |
new_im.save('C:\\Users\\Desktop\\HexTest_New.png') | |
print('Done') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment