# Introduction to Image Processing Using OpenCV in Google Colab

For more details and information, you can watch the YouTube video on Image Processing in Google Colab.

Video URL : https://youtu.be/Z3-Z3PmxFQc

Overview

In this tutorial, we will implement on how to do Image processing in google colaboratory using OpenCV. For that you should have some knowledge on python basics. The below given steps will help you to learn on Image processing using OpenCV in Google Colab which is helpful in Machine Learning Artificial Intelligence.

::: But there are some ways missing in the article below, so please refer the YouTube video given above in URL.

# Image Processing is divided into 6 steps:

Step 1: Load the Dependencies

We will loading some required libraries such as:

Numpy, pandas, cv2, skimage, PIL and Matplotlib.

Let us Load the Dependencies on Google colab.

It might take few seconds to import dependencies.

Step 2: Read Image from URLs

In this step, we will read images from URLs, and display them using OpenCV in google colab. We will use following code for displaying image.

Let’s try it on Google colab. These are the URLs of an images.

After running the code given above, the images shown above will be displayed as result.

Please note the difference when reading image in RGB and BGR format. The default input color channels are in BGR format for OpenCV.

Step 3: Image Contours and Histograms

We will be using the following codes.

Then check the image matrix data type, height of image, width of image, number of channels of the image.

Now let us Display the histogram of all the pixels in the color image.

Display the histogram of R, G, B channel. We could observe that the green channel has many pixels in 255, which represents the white patch in the image.

Now let’s try to make a gray image. Here, we successfully got a gray image of a dog. Plot the histogram of the gray image.

We could observe that the frequency of the image hist has decreased 1/3 of the histogram of color image.

Step 4: Grayscale Transform and Histogram Equalization

Grayscale Transformation provides some examples of conducting mathematical transformations of the grayscale image.

This is an inverse operation of the grayscale image. you could see that the bright pixels become dark, and the dark pixels become bright.

Another transform of the image, after adding a constant.
All the pixels become brighter and a hazing-like effect of the image is generated. The lightness level of the gray image decreases after this step.

Step 5: Fourier Transform of Gray Images

A Fourier transform is used to find the frequency domain of an image.
let’s move on with a code. it Blurs the grayscale image by a Gaussian filter with kernel size of 10 and Transform the image to frequency domain.

Step 6: Finding Edges by Highpass Filtering in FFT

This final step demonstrates the conducting of a high pass filter to remove the low frequency component, resulting in a sharpened image which contains the edges.