Everything below starts from this
These take arguments, so you can tune the strength. For real work, use these.
GaussianBlur(3)A proper Gaussian blur. The one to reach for
BoxBlur(3)Cheaper than Gaussian, slightly blockier
UnsharpMask(2, 150, 3)Sharpening with radius, strength and a threshold
MedianFilter(5)Removes speckle while keeping edges
MinFilter(5)Erode. Dark areas grow
MaxFilter(5)Dilate. Light areas grow
ModeFilter(5)The most common value nearby. Good on flat art
RankFilter(5, 2)The general form of the three above
Kernel((3,3), [0,-1,0,-1,5,-1,0,-1,0])Your own 3 by 3 kernel
No arguments, small built in kernels. Quick effects rather than tools.
BLURA fixed 5 by 5 blur. Mild, and not adjustable
CONTOUROutlines on white, like a pencil tracing
DETAILA gentle local contrast boost
EDGE_ENHANCELifts edges a little
EDGE_ENHANCE_MOREThe same, harder
EMBOSSFlat grey with raised edges
FIND_EDGESEdges only, on black
SHARPENA fixed sharpen kernel
SMOOTHA light averaging
SMOOTH_MOREThe same, stronger
from PIL import Image, ImageFilter
im = Image.open("photo.jpg")
soft = im.filter(ImageFilter.GaussianBlur(3))
crisp = im.filter(ImageFilter.UnsharpMask(radius=2, percent=150, threshold=3))
edges = im.filter(ImageFilter.FIND_EDGES)
The adjustable ones are called with arguments, the fixed ones are passed as they are. Both return a new image.
GaussianBlur. BLUR and SMOOTH are fixed and weak.UnsharpMask with a small radius. Shrinking always softens, and this puts the crispness back.MedianFilter, which kills speckle without smearing the edges the way a blur would.MinFilter and MaxFilter to shrink or grow the white areas.Kernel. The kernel designer lets you try values and copy the code.P image filters the palette indexes rather than the colours, which produces nonsense. Convert to RGB first. See concepts.The ImageFilter module page covers the arguments in detail.