How to convert an image to grayscale in Python

Converting an image to grayscale changes the value of each pixel to a shade of gray corresponding to the intensity of the pixel in the original image.

Solution for How to convert an image to grayscale in Python : You can use PIL.Image.Image.convert() to convert an image to grayscale Call PIL.Image.open(pathname) to open the image file at pathname as a PIL.Image.Image. Call PIL.Image.Image.convert(mode, dither) with the opened image file as PIL.Image.Image and “L” as mode to return the converted grayscale image as a PIL.Image.Image.


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