![Python Pillow Tutorial](/python_pillow/images/python-pillow-mini-logo.jpg)
- Python Pillow Tutorial
- 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 - Enhancing Edges
Enhancing edges is a commonly used technique in image processing and computer vision to improve the interpretation and analysis of images. It refers to the process of emphasizing or highlighting the boundaries between different objects or regions in an image. And it aims to improve the visibility of edges, making them more distinct and prominent.
Python Pillow library provides the ImageFilter module with a predefined set of filters that can be applied to images using the Image.filter() method. The current version of the library offers two predefined image enhancement filters namely EDGE_ENHANCE and EDGE_ENHANCE_MORE to enhance edges in an image.
Enhancing Edges using the ImageFilter.EDGE_ENHANCE Kernel
This ImageFilter.EDGE_ENHANCE kernel filter is designed to Enhance the edges in the image.
Following are the steps for enhancing the edges in the image −
Load the input image using the Image.open() function.
Apply the filter() function to the loaded Image object and Provide ImageFilter.EDGE_ENHANCE as an argument to the Image.filter() function, then it returns a PIL.Image.Image object with enhanced edges.
Example
Here's an example that demonstrates how to use the ImageFilter.EDGE_ENHANCE filter kernel to enhance edges in an image.
from PIL import Image, ImageFilter # Open the input image image = Image.open('Images/Flower1.jpg') # Apply edge enhancement filter enhanced_image = image.filter(ImageFilter.EDGE_ENHANCE) # Display the original and enhanced images image.show() enhanced_image.show()
Input Image
![pink_flower.jpg](/python_pillow/images/zinnia_flower.jpg)
Output Image
Output image with enhanced edges −
![imagefilter edge enhance](/python_pillow/images/imagefilter_edge_enhance.jpg)
Enhancing Edges using the EDGE_ENHANCE_MORE Kernel
This approach works similar to the EDGE_ENHANCE filter, but it applies a stronger enhancement to edges.
Example
Here's an example that demonstrates how to use the EDGE_ENHANCE_MORE filter kernel to enhance edges in an image more aggressively.
from PIL import Image, ImageFilter # Open the input image image = Image.open('Images/Flower1.jpg') # Apply the EDGE_ENHANCE_MORE filter to the image enhanced_image = image.filter(ImageFilter.EDGE_ENHANCE_MORE) # Display the original and enhanced images image.show() enhanced_image.show()
Input Image
![pink_flower.jpg](/python_pillow/images/zinnia_flower.jpg)
Output Image
Output image after applying the EDGE_ENHANCE_MORE filter to the input image −
![edge enhance more](/python_pillow/images/edge_enhance_more.jpg)