Python基本图像处理
相关包 matplotlib PIL cv2 numpy 各种操作 读取图片 1 matplotlib.pylab import numpy as np from matplotlib import pyplot as plt img = plt.imread( 'examples.png' ) print(type(img), img.dtype, np.min(img), np.max(img)) [out] (<type 'numpy.ndarray' >, dtype( 'float32' ), 0.0 , 1.0 ) # matplotlib读取进来的图片是float,0-1 2 PIL.image.open from PIL import Image import numpy as np img = Image.open( 'examples.png' ) print(type(img), np.min(img), np.max(img)) img = np.array(img) # 将PIL格式图片转为numpy格式 print(type(img), img.dtype, np.min(img), np.max(img)) [out] (< class ' PIL . PngImagePlugin . PngImageFile '>, 0, 255) # 注意,