Apply different type of filters to the Image by un-commenting respective lines
from PIL import Image, ImageFilter
path = "E:\\testing\\images\\cat-filter.jpeg"# Source
path2 = "E:\\testing\\images\\cat-blur.jpeg" # new image
img = Image.open(path, mode="r")
#img.show()
#img = img.filter(ImageFilter.BLUR)
#img = img.filter(ImageFilter.BoxBlur(radius=10))
#img = img.filter(ImageFilter.GaussianBlur(radius=10))
#img = img.filter(ImageFilter.UnsharpMask(radius=10))
#img = img.filter(ImageFilter.Kernel(size=(3,3),kernel=[2,4])) # not workign
#img = img.filter(ImageFilter.CONTOUR)
#img = img.filter(ImageFilter.DETAIL)
#img = img.filter(ImageFilter.EDGE_ENHANCE)
#img = img.filter(ImageFilter.EDGE_ENHANCE_MORE)
#img = img.filter(ImageFilter.EMBOSS)
#img = img.filter(ImageFilter.FIND_EDGES)
#img = img.filter(ImageFilter.SMOOTH)
#img = img.filter(ImageFilter.SMOOTH_MORE)
img = img.filter(ImageFilter.SHARPEN)
img.show()
img.save(path2)
Here are some sample images after using filters.
img = img.filter(ImageFilter.BLUR)
BoxBlur
img = img.filter(ImageFilter.BoxBlur(radius=10))
GussianBlur
img = img.filter(ImageFilter.GussianBlur(radius=10))
UnsharpMask
img = img.filter(ImageFilter.UnsharpMask(radius=10))
CONTOUR
img = img.filter(ImageFilter.CONTOUR)
DETAIL
img = img.filter(ImageFilter.DETAIL)
EDGE_ENHANCE
img = img.filter(ImageFilter.EDGE_ENHANCE)
EDGE_ENHANCE_MORE
img = img.filter(ImageFilter.EDGE_ENHANCE_MORE)
EMBOSS
img = img.filter(ImageFilter.EMBOSS)
FIND_EDGES
img = img.filter(ImageFilter.FIND_EDGES)
SMOOTH
img = img.filter(ImageFilter.SMOOTH)
SMOOTH_MORE
img = img.filter(ImageFilter.SMOOTH_MORE)
SHARPEN
img = img.filter(ImageFilter.SHARPEN)
← Python Imaging Library PIL ImageDraw to add Line, rectangle, circle to an Image. → ImageDraw to add Text to an Image. → Thumbnails using Pillow and Tkinter GUI →
Watermark on Image using text and Image→
← Subscribe to our YouTube Channel here