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()