
- Python Pillow - Home
- Python Pillow - Overview
- Python Pillow - Environment Setup
- Basic Image Operations
- Python Pillow - Working with Images
- Python Pillow - Resizing an Image
- Python Pillow - Flip and Rotate Images
- Python Pillow - Cropping an Image
- Python Pillow - Adding Borders to Images
- Python Pillow - Identifying Image Files
- Python Pillow - Merging Images
- Python Pillow - Cutting and Pasting Images
- Python Pillow - Rolling an Image
- Python Pillow - Writing text on image
- Python Pillow - ImageDraw Module
- Python Pillow - Concatenating two Images
- Python Pillow - Creating Thumbnails
- Python Pillow - Creating a Watermark
- Python Pillow - Image Sequences
- Python Pillow Color Conversions
- Python Pillow - Colors on an Image
- Python Pillow - Creating Images With Colors
- Python Pillow - Converting Color String to RGB Color Values
- Python Pillow - Converting Color String to Grayscale Values
- Python Pillow - Change the Color by Changing the Pixel Values
- Image Manipulation
- Python Pillow - Reducing Noise
- Python Pillow - Changing Image Modes
- Python Pillow - Compositing Images
- Python Pillow - Working with Alpha Channels
- Python Pillow - Applying Perspective Transforms
- Image Filtering
- Python Pillow - Adding Filters to an Image
- Python Pillow - Convolution Filters
- Python Pillow - Blur an Image
- Python Pillow - Edge Detection
- Python Pillow - Embossing Images
- Python Pillow - Enhancing Edges
- Python Pillow - Unsharp Mask Filter
- Image Enhancement and Correction
- Python Pillow - Enhancing Contrast
- Python Pillow - Enhancing Sharpness
- Python Pillow - Enhancing Color
- Python Pillow - Correcting Color Balance
- Python Pillow - Removing Noise
- Image Analysis
- Python Pillow - Extracting Image Metadata
- Python Pillow - Identifying Colors
- Advanced Topics
- Python Pillow - Creating Animated GIFs
- Python Pillow - Batch Processing Images
- Python Pillow - Converting Image File Formats
- Python Pillow - Adding Padding to an Image
- Python Pillow - Color Inversion
- Python Pillow - M L with Numpy
- Python Pillow with Tkinter BitmapImage and PhotoImage objects
- Image Module
- Python Pillow - Image Blending
- Python Pillow Useful Resources
- Python Pillow - Quick Guide
- Python Pillow - Function Reference
- Python Pillow - Useful Resources
- Python Pillow - Discussion
Python Pillow - Reducing Noise
Reducing noise in Pillow refers to the process of applying various techniques and filters to an image to remove or decrease unwanted artifacts or irregularities that can degrade the image quality. Image noise is random variations in brightness or color in images typically caused by factors such as low light conditions, electronic interference or imperfections in the image sensor. Reducing noise is an important step in image processing to improve the overall quality of images.
Pillow (PIL) provides several built-in filters and methods for reducing noise in images. Some common techniques and filters for noise reduction in Pillow include −
- Gaussian Blur: Applying a Gaussian blur filter to the image can help smooth out reduce noise by averaging the pixel values in the vicinity of each pixel. This creates a smoother appearance and can reduce the impact of noise. The degree of blurring can be adjusted to control the level of noise reduction.
- Median Filter: Median filtering replaces each pixel's value with the median value of the neighboring pixels. The median filter is effective for removing salt-and-pepper noise where isolated pixels have extreme values. It replaces each pixel's value with the median value of neighboring pixels.
- Bilateral Filter: The bilateral filter smooths the image while preserving edges. It can be effective at reducing noise while maintaining image details.
- Denoising Algorithms: Pillow supports various denoising algorithms such as the bilateral filter, Total Variation (TV) denoising algorithm or the Non-Local Means (NLMeans) filter which can be used to reduce noise while preserving image details.
- Thresholding: We can apply a threshold to an image to remove noise by converting pixel values below a certain threshold to black and values above the threshold to white effectively binarizing the image.
Python Pillow - Image.filter() Method
Image.filter() is a method in the Python Imaging Library (PIL) or its fork. Pillow used to apply various image filters and enhancements to an image. Filters are image processing operations that can be used to modify an image in different ways such as blurring, sharpening or enhancing certain features. This method allows us to apply various predefined filters to an image.
Pillow provides a variety of predefined filters that we can use with Image.filter(), including −
ImageFilter.BLUR − Applies a simple blur to the image.
ImageFilter.CONTOUR − Enhances the contours of objects in the image.
ImageFilter.DETAIL − Enhances the image's details.
ImageFilter.EDGE_ENHANCE − Emphasizes the edges in the image.
ImageFilter.EMBOSS − Adds a 3D embossing effect to the image.
ImageFilter.SHARPEN − Sharpens the image.
Syntax
The syntax and parameters for using Image.filter() is as follows −
output_image = input_image.filter(filter_name, filter_parameters)
Where,
input_image − This is the source image to which we want to apply the filter.
filter_name − This is a string specifying the name of the filter we want to apply. Pillow provides a variety of built-in filters and we can use one of these filter names as a string. For example "GaussianBlur," "MedianFilter," "Sharpen", etc. We can also define our custom filters by providing a kernel (a list of values) as a filter.
filter_parameters (optional) − Some filters may accept additional parameters that control the behavior of the filter. These parameters are specific to the particular filter being used. If the filter we are applying requires parameters we would pass them as arguments in the filter_parameters part.
Example
In this example we are trying to blur the image by passing the ImageFilter.BLUR as the input parameter to the Image.filter() method.
from PIL import Image, ImageFilter #Open an image input_image = Image.open("Images/flowers.jpg") #Apply Gaussian blur to the image output_image = input_image.filter(ImageFilter.BLUR()) #Save the resulting image output_image.save("output Image/blur.jpg") output_image.show()
Image to be used

Output

Example
Here in this example we are blurring a specified part of the image by using the ImageFilter.BoxBlur() method.
from PIL import Image, ImageFilter #Open an image input_image = Image.open("Images/rose.jpg") #Apply Gaussian blur to the image output_image = input_image.filter(ImageFilter.BoxBlur(20)) #Save the resulting image output_image.save("output Image/blur.jpg") output_image.show()
Image to be used

Output
