语言:Python
库:OpenCV
计算图像灰度图计算方法:
1.利用函数cvtColor计算
2.直接在imread函数后面加“0”
import cv2
image_path = "aaa.jpg"
image = cv2.imread(image_path)
#image = cv2.imread(image_path,0)
gray_image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
cv2.imshow('Gray Image', gray_image)
cv2.waitKey(0)