Overview
In Image-Processing, smoothing an image reduces noises present in the image and produces less pixelated image.
The smooth filters provided by Pillow are Box Filters, where each output pixel is the weighted mean of its kernel neighbours.
Pillow provides a couple of smooth filters denoted by,
ImageFilter.SMOOTH
ImageFilter.SMOOTH_MORE
- The convolution matrix for the filter ImageFilter.SMOOTH is provided by
(
1, 1, 1,
1, 5, 1,
1, 1, 1
)
- The convolution matrices for the filter ImageFilter.SMOOTH_MORE is provided by
(
1, 1, 1, 1, 1,
1, 5, 5, 5, 1,
1, 5, 44, 5, 1,
1, 5, 5, 5, 1,
1, 1, 1, 1, 1
)
Example
# import the pillow modules
from PIL import Image
from PIL import ImageFilter
# Create an Image Object
image = Image.open("./lamp.jpg")
# Apply SMOOTH filters
smoothenedImage = image.filter(ImageFilter.SMOOTH)
moreSmoothenedImage = image.filter(ImageFilter.SMOOTH_MORE)
# Display the original image and the smoothened Images
image.show()
smoothenedImage.show()
moreSmoothenedImage.show()Output
Before applying smooth filter

After applying smooth filter

After applying increased smooth filter
