How to convert an image from RGB to Grayscale in Python

Converting an image from RGB to Grayscale removes color from the image.

Solution for How to convert an image from RGB to Grayscale in Python : You can use numpy.dot() to convert an image from RGB to grayscale Call matplotlib.image.imread(fname) to get a NumPy array representing an image named fname. Call numpy.dot(a, b) with a as array[…,:3] and b as [0.2989, 0.5870, 0.1140] to convert the previous result array to grayscale. Call matplotlib.pyplot.imshow(image, cmap=color_map) with color_map as matplotlib.pyplot.get_cmap(“gray”) to display the previous result image in grayscale.


how-to-convert-an-image-from-rgb-to-grayscale-in-python