Vidhi Patel
Published

Converting a Color Image to Grayscale in Python Using OpenCV

This article will help you to convert a color image to grayscale.

BeginnerProtip7,287
Converting a Color Image to Grayscale in Python Using OpenCV

Things used in this project

Hardware components

Odinub
Odinub
×1

Software apps and online services

OpenCV
OpenCV – Open Source Computer Vision Library OpenCV

Story

Read more

Code

gray_img.py

Python
import cv2
  
image = cv2.imread('C:/Users/N/Desktop/Test.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  
cv2.imshow('Original image',image)
cv2.imshow('Gray image', gray)
  
cv2.waitKey(0)
cv2.destroyAllWindows()

Credits

Vidhi Patel
4 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.