Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python: PIL (Pillow) Numpy intersect images
from itertools import izip
from PIL import Image
import numpy as np
i1 ='1.png').convert(mode='L', dither=Image.NONE)
i2 ='C.png').convert(mode='L', dither=Image.NONE)
pixelThreshold = 200
i1 = np.array(i1)
i1 = np.where(i1 > pixelThreshold, 255, 0)
i2 = np.array(i2)
i2 = np.where(i2 > pixelThreshold, 255, 0)
final1 = (i1+i2)
final1 = Image.fromarray(final1.astype(np.uint8))'test.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment