
上QQ阅读APP看书,第一时间看更新
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()