📅  最后修改于: 2022-03-11 14:45:36.178000             🧑  作者: Mango
from matplotlib import pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('test.jpg')
R, G, B = img[:,:,0], img[:,:,1], img[:,:,2]
imgGray = 0.2989 * R + 0.5870 * G + 0.1140 * B
plt.imshow(imgGray, cmap='gray')
plt.show()