OPENCV — COLOR IMAGE TO GRAYSCALE IMAGE, PRINT IMAGE PROPERTY

Powerful learning
1 min readJul 5, 2022

--

I am a Youtuber. My channel name is Powerful Learning. I post free certifications, free internships and free webinars.

Opencv is a python library mainly used in artificial intelligence domain. It is used to deal with images and video. I have explained a very easy yet important basic concepts of opencv function in my video. To watch the process — CLICK HERE

I have already posted the video on how to read, write and show an image in just 5 lines of code. To see the code click here.

To convert color image to grayscale image and to print image property : video explanation — click here

I am using google colab to run this program.

  1. COLOR TO GRAYSCALE

import cv2

#importing opencv library

from google.colab.patches import cv2_imshow

#since google colab doesnt support cv2.imshow() function you have to import its own cv2_imshow() package

image=cv2.imread(“powerful learning (5).png”)

#upload an sample image in colab. I have uploaded an image name “powerful learning (5).png”.

grayimage=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)

#here first parameter is a source file to be changed

cv2_imshow(image)

#viewing original image

cv2_imshow(grayimage)

#viewing grayscale image

2. TO PRINT IMAGE PROPERTY

import cv2

image=cv2.imread(“powerful learning (5).png”)

print(“image shape : “,image.shape)

print(“image size : “,image.size)

print(“image dtype : “,image.dtype.)

Thanks for reading my blog

--

--

Powerful learning

Mini blog on Free certifications, internships and webinars