An image kernel is a small matrix used to apply effects like the ones you might find in Photoshop or Gimp, such as blurring, sharpening, outlining or embossing. They're also used in machine learning for 'feature extraction', a technique for determining the most important portions of an image.
pip install imgkernel
import imgkernel
import matplotlib.pyplot as plt
%matplotlib inline
def show2imgs(img1, img2, title=None):
fig = plt.figure(figsize=(10, 5))
if title is not None:
fig.suptitle(title)
plt.subplot(121)
plt.axis('off')
plt.imshow(img1)
plt.subplot(122)
plt.axis('off')
plt.imshow(img2)
plt.show()
imgpath = 'image.jpeg'
show2imgs(*imgkernel.identity(imgpath, gray=False, iden=1.6), 'imgkernel.identity()')
show2imgs(*imgkernel.blur(imgpath, gray=False), 'imgkernel.blur()')
show2imgs(*imgkernel.sharpen(imgpath, gray=False, inner=1.7, edge=-0.08), 'imgkernel.sharpen()')
show2imgs(*imgkernel.emboss(imgpath, gray=False), 'imgkernel.emboss()')
show2imgs(*imgkernel.outline(imgpath, gray=False, inner=8.9, outer=-1.29), 'imgkernel.outline()')
show2imgs(*imgkernel.sobel(imgpath, gray=False, direction='top', base=0.03), 'imgkernel.sobel(top)')
show2imgs(*imgkernel.sobel(imgpath, gray=False, direction='bottom', base=0.03), 'imgkernel.sobel(bottom)')
show2imgs(*imgkernel.sobel(imgpath, gray=False, direction='left', base=0.03), 'imgkernel.sobel(left)')
show2imgs(*imgkernel.sobel(imgpath, gray=False, direction='right', base=0.03), 'imgkernel.sobel(right)')