In this Python OpenCV article i want to show you How to Show Python OpenCV Images in Matplotlib, also if you are interested in Python GUI Development, check the below links.
What is Python OpenCV ?
Python OpenCV (Open Source Computer Vision) is an open source computer vision and machine learning library that is designed to help developers create real time computer vision applications. it is Python interface to the OpenCV library, which is written in C++ and optimized for performance.
Python OpenCV provides different tools and algorithms for image and video processing, including image filtering, edge detection, object detection and recognition and facial recognition. it can also be used for feature extraction, motion detection and camera calibration.
OpenCV is highly modular and scalable, and it can be used for different types of computer vision applications, from simple image processing tasks to complex robotics and automation projects. it supports many different programming languages, including Python, C++, Java, and MATLAB and this makes it powerful library for computer vision development.
Python OpenCV is free to use and is compatible with many different operating systems and platforms, including Windows, Linux, macOS and Android. it is widely used in industries such as healthcare, automotive and security, and it is powerful tool for developing computer vision applications in various fields.
So first of all you need to install Python OpenCV
1 |
pip install opencv-python |
What is Python Matplotlib ?
Python Matplotlib is popular data visualization library that is used to create high quality 2D and 3D visualizations in Python. It provides different tools for creating different types of plots, including line plots, scatter plots, bar plots, histograms and many more.
Matplotlib is powerful and flexible library that can be used for different types of data visualization tasks, from simple exploratory data analysis to complex data science projects. it allows users to customize almost every aspect of their plots, including the size, color, labels and fonts.
in addition to basic plotting functionality, Matplotlib also provides tools for creating more advanced visualizations, such as animations, 3D plots and interactive plots. it can also be used in combination with other Python libraries such as NumPy, Pandas, and SciPy to create even more complex visualizations.
Matplotlib is open source and free to use, and it is widely used in scientific research, data science, and engineering. It is compatible with many different operating systems and development environments, and it is actively maintained and updated by a large community of developers.
First of all you need to install Matplotlib, because we are using matplotlib for this article.
You can simply install Matplotlib by pip
1 |
pip install matplotlib |
So now this is the complete source code for How to Show Python OpenCV Images in Matplotlib.
1 2 3 4 5 6 7 8 9 |
import cv2 import matplotlib.pyplot as plt image = cv2.imread("lena_color_512.tif") plt.imshow(image, cmap = 'gray', interpolation='bicubic') plt.xticks([]), plt.yticks([]) # for hading ticks in the x and y positions plt.show() |
In the above code first we have imported cv2 and matplotlib , after that we have read the image. and now instead of showing image in opencv window we show the image in matplotlib. also we set the ticks for our graph by plt.xticks and plt.yticks.
Run the complete code this will be the result
Also you can check Python GUI Development Tutorials in the below link.
- PyQt5 GUI Development Tutorials
- TKinter GUI Development Tutorials
- Pyside2 GUI Development Tutorials
- Kivy GUI Development Tutorials
Also you can watch the complete video for this article
Subscribe and Get Free Video Courses & Articles in your Email