In this project, you will learn the Basics of Image processing using Matplotlib and OpenCV
In this project, we will see Image Basics with OpenCV and Python Using Jupyter Notebook.
Firstly, we import important Libraries like NumPy, matplotlib then to open an image we use PIL(Python Imaging Library) which is free and open-source an additional library for the Python language. After that, we see how to rotate the image, how to check the type of the image, how to turn the image into an array, and how to check height, width, and Channels.
Then, Let’s get familiar with RGB channels. An RGB image has three channels: red, green, and blue. The RGB channels roughly follow the color receptors in the human eye and are used in computer displays and also in image scanners.
The red channel is in position No 0, The green channel is in position No 1,
The blue channel is in position No 2, The Colour Values are from 0==no color from the channel to 255==full color from the channel. Now, we knew the RGB channels. Let’s check every color one by one on Image and also scale channels to Gray.
Next, we will learn about OpenCV. We see how to read the image using matplotlib, now we will see using OpenCV. Firstly, to import OpenCV we use a command
import cv2 (If OpenCV is not installed on your machine then install it using Command prompt by typing
pip install OpenCV-python)
After importing OpenCV, Read image by
cv2.imread(). then we check the type of the image and shape of the image.
Until now we were working with Matplotlib and RGB. OpenCV is reading the channel as BGR. We will convert OpenCV to the channels of the photo. After fixing the image, check the shape and scale it to gray. Then we will learn about Resize and Flip(Vertical or Horizontal) of an image.
Next, we will Learn about Draw Shapes on an Image. Firstly, we create a black image to work then we learn to draw a Circle, Filled Circle, Rectangle, Triangle, Filled Rectangle, Filled Triangle, Line, Text on it using OpenCV.