SoFunction
Updated on 2024-12-16

Example of reading a grayscale plot in python using matplotlib

Code for:

import  as plt # For displaying pictures
import  as mpimg # mpimg for reading images
 
picdir = 'C:\\Users\\wyt\\Desktop\\test\\ship\\'
img = (picdir)
(img)                
('Original train image')  
()

The results are displayed as follows, in the form of a heat map.

To display a grayscale map, use the code

(img,cmap='Greys_r') 

Just replace (img)

The above example of using matplotlib to read grayscale map in python is all that I have shared with you.