python读取tif文件与png文件

python读取tif文件与png文件

读取tif文件:

import tifffile as tiff
image = tiff.imread(image)

读取png文件:

import numpy as np
from PIL import Image
from matplotlib import pyplot as plt

label = Image.open(labeldir)
label = np.array(label)
print(‘图片的shape:’, label.shape)
plt.imshow(label)
plt.show()

若图片太多显示不出,加上这句:
Image.MAX_IMAGE_PIXELS = None

你可能感兴趣的:(python)