import numpy as np
import matplotlib.pyplot as pt
from PIL import Image
def load_image(name):
with Image.open(name).resize((500,500)) as img:
return np.sum(np.array(img), axis=-1).astype(np.float32)/(3*255)
andreas = load_image("andreas.jpeg")
# keep
pt.imshow(andreas, cmap="gray")
Let's get a little creative... (vmin
and vmax
as keyword arguments on imshow
might be handy)
pt.imshow(3*andreas, cmap="gray", vmin=0, vmax=1)
dicaprio = load_image("dicaprio.jpeg")
Now let's try something truly scary...
pt.imshow(andreas + dicaprio, cmap="gray")