The Ultimate Handbook for OpenCV & Pillow
Introduction
OpenCV and Pillow are the commonly used libraries in Python for image processing.
In this article, I will list out all the codes that are useful regarding OpenCV and Pillow side by side, so that you can compare them easily.
New Version
Please note that all the new content and full versions of this tutorial will be moved to CodoRaven.com > OpenCV vs Pillow.
Updates
- 15-Jun-22: Added [13. RGBA to RGB].
- 16-Jul-22: Added “specify background color” to [6. Rotate].
- 28-Jan-23: Updated
Image.ANTIALIAS
toImage.Resampling.LANCZOS
[5. Resize]. - 29-Jan-23: Updated
np.float
tonp.float32
;Image.PERSPECTIVE
toImage.Transform.PERSPECTIVE
;Image.BICUBIC
toImage.Resampling.BICUBIC
[10. Warp / Transform].
0. Install & Import
To install Pillow and OpenCV, please type the following in your terminal (replace pip with pip3 if your python3 is using pip3):
pip install numpy
pip install opencv-python
pip install Pillow
Before using them, you have to import them into your python file with the following codes: