%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
img = np.array(Image.open('einstein_small.jpg').convert('RGB'))[:,:,0]
plt.imshow(img, cmap=plt.get_cmap('gray'))
filters = np.load('filters.npy')
for f in filters:
plt.figure(); plt.imshow(f)
from scipy.signal import convolve2d
for f in filters:
out = convolve2d(img, f, mode='same')
plt.figure(); plt.imshow(out, cmap=plt.get_cmap('gray'))
dog = filters[1]-filters[2]
plt.figure(); plt.imshow(dog)
plt.figure(); plt.plot(dog[27,:])
out = convolve2d(img, dog, mode='same')
plt.figure(); plt.imshow(out, cmap = plt.get_cmap('gray'))
dog = filters[0]-filters[1]
out = convolve2d(img, dog, mode='same')
plt.figure(); plt.imshow(out, cmap = plt.get_cmap('gray'))