- PIL Home
- Python Image Library Intro
- Python Image Library Setup
- Python Image Library Basics
- Python Image Library Hierarchy
- Python Image Library Modules
- Python ImageColor Module
- Python ImageDraw Module
- Python ImageStat Module
- Python ImageTK Module
- Python ImageFile Module
- Python ImageFilter Module
- Python ImageGrab Module
- Python ImageMath Module
- Python - Loading Image
- Python - Rotating Image
- Python - Blurring Image
- Python - Converting Image
- Python - Cropping Image
- Python - Image Thumbnails
- Python - Text on Images
- Python - Multiple Image Copies
- Python - Saving Image As PDF
- Python - Saving Screenshot
- Python - Resizing Image
- Python - Adding Watermark
- Python Image Library Resources
- Python - Quick Guide
- Python - Useful Resources
- Python - Discussion
Python ImageFilter Module
ImageFilter module
In general, a filter is a particular effect that is can be applied to an image or part of an image.Filters can be fairly simple effects like blurring,sharpening,smoothing,enhancing the edges of an image.
The ImageFilter module contains definitions for a pre-defined set of filters, which can be be used with the filter method of the Image class.
Importing ImageFilter module
from PIL import ImageFilter
Once you have imported the module, you can use any of these filters:
ImageFilter.BLUR
ImageFilter.CONTOUR
ImageFilter.DETAIL
ImageFilter.EDGE_ENHANCE
ImageFilter.EDGE_ENHANCE_MORE
ImageFilter.EMBOSS
ImageFilter.FIND_EDGES
ImageFilter.SMOOTH
ImageFilter.SMOOTH_MORE
ImageFilter.SHARPEN
ImageFilter.MinFilter
ImageFilter.MedianFilter
ImageFilter.ModeFilter
ImageFilter.MaxFilter
Example that demonstrates various Image Filters
from PIL import Image
import ImageFilter
im = Image.open('cours.png')
out = im.filter(ImageFilter.BLUR)
out.save('blur.jpg', "JPEG")
out2 = im.filter(ImageFilter.MinFilter)
out2.save('min.jpg', "JPEG")
out3 = im.filter(ImageFilter.MedianFilter)
out3.save('median.jpg', "JPEG")
Advertisements