- Matplotlib 3.0 Cookbook
- Srinivasa Rao Poladi
- 75字
- 2021-08-13 15:15:58
How to do it...
Here is the code block that reads a JPEG file as a pixel-valued list and displays it as an image on the screen:
- Read the image louvre.jpg into a three-dimensional array (color images have three channels, whereas black and white images have one channel only):
image = plt.imread('louvre.jpg')
- Print the dimensions of the image:
print("Dimensions of the image: ", image.shape)
- Plot the image:
plt.imshow(image)
- Display the image on the screen:
plt.show()