How to read image in python?
There are many libraries in python which helps us to read an image. Python has a wide variety of libraries which helps us in many way.
- Opencv – Opencv is a library of programming functions mainly aimed at real-time computer vision. In simple language it is a library used for Image Processing. It is mainly used to do all the operation related to images.
From openCV you can do can whatever you want to do from images. OpenCV helps in manipulation of images. Like read an image, write an image, convert colored to gray, binary, HSV etc.
Installation of CV2:-
- Open the command prompt.
- Run the following command.
- pip install opencv-python
- Successfully install opencv on your system
You can use CV2 by just importing it in your python script.
- Pillow – PIL(Python imaging library) popularly known as pillow is an image manipulation library.
It helps in processing images in different format in python. We can easily import this library and use to process image.
We can easily install PIL in our system.
- Open command prompt.
- Write the following syntax
- pip install pillow
- Successfully install PIL or pillow
syntax:-pip install pillow
We can easily use by importing it in python
import pillow or import PIL
- Matplotlib is a Python library used for plotting the beautiful and attractive Graphs.
In data science, visualization is the important step. By using visualization we can easily understand than how data is split.
Matplotlib library is used to make different types of graphs like bar graph, histogram, scatter graph etc. It helps to study the complex data and gives the data a visual view.
Now it’s time to see how to install matplotlib library in python.
- Open command prompt
- Write the following syntax:-
pip install matplotlib
In this way we can install matplotlib library and use it easily. We can easily import it in python and do whatever we want with that library.
This is how we can import matplotlib library.
By importing these libraries we can read the image in python.
This is all about reading an image.