
Image processing is the phenomenon of manipulating an image to extract features from it.
In today’s world of Computer Vision and deep learning, different algorithms for image processing are heavily used to carry out edge detection, recognition, classification from a dataset of images.
Sometimes these algorithms are also applied to videos frame by frame to extract features from them.
In today’s article, we will take a look at the 5 best Python libraries that might help you to carry out manipulation of images like cropping, grayscaling etc.
1. OpenCV
OpenCV is one of the most popular and widely used libraries for image processing and computer vision. This oral library can be used with many programming languages like C, C++, Python, Java but the library of Python bindings is the most popular one.
Not only image manipulation but complex deep learning algorithms related to computer vision can also be implemented using this library easily. The best thing about open CV is that it is cross-platform and it can work with mobile devices also.
Installation
pip install opencv-python
To do a Gaussian blur on an image. We will be using Colab as there we don’t need to set thing environment – everything is pre-setup here.
First of all, let’s import the necessary packages. Colab doesn’t support cv2.imshow() – but, we have an alternative for that.
import cv2
import numpy as np
import urllib
import urllib.request as ur
from google.colab.patches import cv2_imshow
Now, let’s load an image from the internet and apply some filters.

2. SimpleCV
SimpleCV is a python framework that uses computer vision libraries like OpenCV. This library is quite simple and easy to use and can be really helpful for quick prototyping.
This library can particularly be useful for those who don’t have a knowledge of different image manipulation concepts like eigenvalues, colour spaces, and bit depth.
Installation
pip install SimpleCV
This library can be a better choice to play with object detection tasks. You can find some amazing tasks like – detecting if a car is parked or not, using this library.
You can learn more about this library here.
3. Pillow
Pillow is an image processing library for Python derived from the PIL or the Python Imaging Library. Although it is not as powerful and fast as openCV it can be used for simple image manipulation works like cropping, resizing, rotating and greyscaling the image. Another benefit is that it can be used without NumPy and Matplotlib.
Installation
pip install pillow
To read an image in PIL we can use:
from PIL import Image
im = Image.open(r"C:UsersSystem-PcDesktopimage1.jpg")
im.show()
You can learn more about this library here.
4. Mahotas
Mahotas is a Python library for image processing and computer vision that was originally designed for bioimage Informatics. But other computer vision tasks can be performed using it as well. It is originally written in C++ which makes it pretty fast and it has no dependencies other than NumPy.
Installation
pip install mahotas
Grayscaling an image using mahotas:
Finally, after running the code – we can get the following result.

5. pgmagick
Pgmagick is a Python wrapper for GraphicsMagick which is the collection of tools and libraries for the manipulation of images. It supports more than 88 formats of image. Other than image processing work it can also be used in web applications for creating new images.
Installation
pip install pgmagick
For extracting the edge from a picture:
from pgmagick.api import Image
img = Image('lena.jpg') #Your image path will come here
img.edge(2)
img.write('lena_edge.jpg')
Conclusion
Although OpenCV is the major image processing library that we are going to use in the future, having a little bit of knowledge about the other image processing libraries will definitely be a good idea.
All these libraries can make your workflow easier with their simpler implementation for specific functions.
To know more about these libraries you can always follow the official documentation and also consult with the open-source community that these libraries have.
Before you go…
If you liked this article and want to stay tuned with more exciting articles on Python & Data Science – do consider becoming a medium member by clicking here https://pranjalai.medium.com/membership.
Please do consider signing up using my referral link. In this way, the portion of the membership fee goes to me, which motivates me to write more exciting stuff on Python and Data Science.
Also, feel free to subscribe to my free newsletter: Pranjal’s Newsletter.