wtrite python code to implement color2gray
时间: 2023-04-10 20:05:11 浏览: 144
All algorithms implemented in Python - for education Implementat
Sure, here's a Python code to implement color2gray:
```
import cv2
# Load the color image
img = cv2.imread('color_image.jpg')
# Convert the image to grayscale
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Save the grayscale image
cv2.imwrite('gray_image.jpg', gray_img)
```
This code uses the OpenCV library to load a color image, convert it to grayscale, and save the grayscale image. Note that you'll need to replace 'color_image.jpg' with the filename of your own color image.
阅读全文