pillow读取图片 from PIL import Image import numpy as np img_path = './Training/meningioma/M546.jpg' # 读取图片 image = Image.open(img_path) width, height = image.size print("图片的宽度为={},高度为={}".format(width,height)) print("图片的mode为{}".format(image.mode)) print("图片的format为{}".format(image.format)) pixel = image.load() img_arr = np.array(image) print("图片数组大小为{}".format(img_arr.shape)) print("图片像素值最大为{}".format(np.max(img_arr))) print("图片像素值最大为{}".format(np.min(img_arr))) #显示图片 image.show() # matplotlib读取图片 import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np img_path = './Training/meningioma/M546.jpg' # 打开PNG图片文件 png_image = mpimg.imread(img_path) plt.imshow(png_image) CV2读取图片 import cv2 import numpy as np img_path = './Training/meningioma/M546.jpg' # 读取图片 img = cv2.imread(img_path) print(img.shape) # mac显示图片有问题,会卡死,图片无法关闭,