Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A Python script to filter out pixels with a red value higher than 30.
from PIL import Image
im ='C:\\Users\\Desktop\\HexTest.png')
pix = im.load()
width = im.size[0]
height = im.size[1]
new_im ='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]'C:\\Users\\Desktop\\HexTest_New.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.