Converting an image into grayscale

We can use the convert() function with the 'L' parameter to change an RGB color image into a gray-level image, as shown in the following code:

im_g = im.convert('L')   # convert the RGB color image to a grayscale image

We are going to use this image for the next few gray-level transformations.

Get Hands-On Image Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.