Convert RBG Image to Gray Scale Image Using CV2

1736876748.png

Written by Aayush Saini · 1 minute read · Jun 21, 2020 . Computer Vision, 4

Hi Everyone, In this Post, We Will Learn How to Convert a Simple RBG Image to Gray Scale Image It's Very easy to convert any image into grayscale image using Python CV2 Library. So Now Let's Start How We Can do this, Follow the Post Until End.

We Use Two Method for Convert Image into Gray Scale Image.

First Method

 


import cv2
img = cv2.imread('logo.png')
cv2.imshow('output ', img)
cv2.waitKey(0)

grey_scale = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.imshow('Greyscale', grey_scale)
cv2.waitKey(0)
cv2.destroyAllWindows()

Output

grayscale

Second Method

 


import cv2
img = cv2.imread('logo.png', 0)
cv2.imshow('Grey Scale Image ', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

Output

grayscale-output



Download Source Code

Thanks for Reading Share this 

 

Share   Share