使用PIL\matplotlib\numpy读取和展示图像文件
1.安装PIL,matplotlib,numpy install mudule - numpy matplotlib numpy
python -m pip install --upgrade pip #更新pip安装工具
#安装numpy,matplotlib,PIL
pip install numpy
pip install matplotlib
pip install pillow
2.读取图片 Read image
3.图片路径 Image path
"D:\\college\\1474.jpg"
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
im = Image.open("D:\\college\\1474.jpg") # read image as Image
im.show() # show the image
img = np.array(im) # set the image as a numpy array which value could change
4.查看矩阵 Check the img numpy array
>>> img
array([[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],