- Hands-On Image Processing with Python
- Sandipan Dey
- 346字
- 2025-02-22 06:42:20
Installing some image processing libraries in Python
In Python, there are many libraries that we can use for image processing. The ones we are going to use are: NumPy, SciPy, scikit-image, PIL (Pillow), OpenCV, scikit-learn, SimpleITK, and Matplotlib.
The matplotlib library will primarily be used for display purposes, whereas numpy will be used for storing an image. The scikit-learn library will be used for building machine-learning models for image processing, and scipy will be used mainly for image enhancements. The scikit-image, mahotas, and opencv libraries will be used for different image processing algorithms.
The following code block shows how the libraries that we are going to use can be downloaded and installed with pip from a Python prompt (interactive mode):
>>> pip install numpy
>>> pip install scipy
>>> pip install scikit-image
>>> pip install scikit-learn
>>> pip install pillow
>>> pip install SimpleITK
>>> pip install opencv-python
>>> pip install matplotlib
There may be some additional installation instructions, depending on the OS platform you are going to use. We suggest the reader goes through the documentation sites for each of the libraries to get detailed platform-specific installation instructions for each library. For example, for the scikit-image library, detailed installation instructions for different OS platforms can be found here: http://scikit-image.org/docs/stable/install.html. Also, the reader should be familiar with websites such as stackoverflow to resolve platform-dependent installation issues for different libraries.
Finally, we can verify whether a library is properly installed or not by importing it from the Python prompt. If the library is imported successfully (no error message is thrown), then we don't have any installation issue. We can print the version of the library installed by printing it to the console.
The following code block shows the versions for the scikit-image and PIL Python libraries:
>>> import skimage, PIL, numpy
>>> print(skimage.__version__)
# 0.14.0
>>> PIL.__version__
# 5.1.0
>>> numpy.__version__
# 1.14.5
Let us ensure that we have the latest versions of all of the libraries.