Pillow
In [1]:
import imageio.v2 as imageio
import numpy as np
import matplotlib.pyplot as plt
def plot_image_from_array(image_array, title='Image'):
plt.imshow(image_array, cmap='gray')
plt.axis('off') # Hide axes
plt.title(title)
plt.show()
Pillow (PIL Fork)¶
BLUR
CONTOUR
DETAIL
EDGE_ENHANCE
EDGE_ENHANCE_MORE
EMBOSS
FIND_EDGES
SHARPEN
SMOOTH
SMOOTH_MORE
In [2]:
from PIL import Image, ImageFilter
# Open an image file
im = Image.open("lena.jpg")
# Apply a filter to the image
im_blur = im.filter(ImageFilter.BLUR)
plot_image_from_array(im_blur, title='BLUR')
In [3]:
from PIL import Image, ImageFilter
im = Image.open("lena.jpg")
im_contour = im.filter(ImageFilter.CONTOUR)
plot_image_from_array(im_contour, title='CONTOUR')
In [4]:
from PIL import Image, ImageFilter
im = Image.open("lena.jpg")
im_detail = im.filter(ImageFilter.DETAIL)
plot_image_from_array(im_detail, title='DETAIL')
In [5]:
from PIL import Image, ImageFilter
im = Image.open("lena.jpg")
im_edge_enhance = im.filter(ImageFilter.EDGE_ENHANCE)
plot_image_from_array(im_edge_enhance, title='EDGE_ENHANCE')
In [6]:
from PIL import Image, ImageFilter
im = Image.open("lena.jpg")
im_emboss = im.filter(ImageFilter.EMBOSS)
plot_image_from_array(im_emboss, title='EMBOSS')
In [7]:
from PIL import Image, ImageFilter
im = Image.open("lena.jpg")
im_find_edges = im.filter(ImageFilter.FIND_EDGES)
plot_image_from_array(im_find_edges, title='FIND_EDGES')
In [8]:
from PIL import Image, ImageFilter
im = Image.open("lena.jpg")
im_sharpen = im.filter(ImageFilter.SHARPEN)
plot_image_from_array(im_sharpen, title='SHARPEN')
