In this lesson we want to learn about Image Enhancement in Python Pillow.
What is Python Pillow ?
Python Imaging Library (PIL) is now known as Python Pillow library, and it provides extensive support for image manipulation and processing. one of the key features of Pillow is image enhancement, which refers to the process of improving the quality of an image. some common image enhancement techniques include:
- Brightness and Contrast: Increasing or decreasing the brightness and contrast levels of an image can help improve its visual appeal, and you can do that by pillow
- Sharpening: Sharpening an image can enhance detail and clarity of the image.
- Color Correction: Color correction can help balance the colors in an image and it will make it to look more natural and appealing.
- Noise Reduction: Reducing noise in an image can improve its overall clarity and quality.
- Resizing and Scaling: Resizing and scaling can help an image fit a specific dimension, aspect ratio or resolution, improving the image quality.
To perform image enhancement using Pillow, you can use different functions and techniques such as ImageOps, ImageFilter, ImageEnhance and etc.
1 2 3 4 5 6 7 8 9 10 11 12 |
from PIL import Image # Open an image img = Image.open("image.png") # Enhance the contrast of the image img = img.convert("L") img = img.point(lambda x: x * 1.5) img = img.convert("RGB") # Save the enhanced image img.save("output.jpg") |
This example takes an input image, converts it to grayscale image, multiplies its pixel values by 1.5 to enhance the contrast, and then converts it back to RGB format and saves it as an output image.
Learn More on Python
- PyQt6: The Ultimate GUI Toolkit for Python
- Python: The Most Versatile Programming Language of the 21st Century
- Tkinter: A Beginner’s Guide to Building GUI Applications in Python
- PySide6: The Cross-Platform GUI Framework for Python
- The Ultimate Guide to Kivy: Building Cross-Platform Apps with Python
- Discover the Power of Django: The Best Web Framework for Your Next Project
- How to Earn Money with Python
- Why Flask is the Ideal Micro-Web Framework
- Python Pillow: The Ultimate Guide to Image Processing with Python
- Get Started with Pygame: A Beginner’s Guide to Game Development with Python
- Python PyOpenGL: A Guide to High-Performance 3D Graphics in Python
- The Cross-Platform Game Development Library in Python
- Unleash the Power of Computer Vision with Python OpenCV
- Unleash the Power of Automated Testing with Python Selenium