cv2.imread()+plt.imread()+Image.open()的读取与相应的显示图片

cv2.imread()+plt.imread()+Image.open()的读取与相应的显示图片

import cv2
import matplotlib.pyplot as plt
from PIL import Image

'''
OpenCV: 
	img = cv2.imread()读取,cv2.imshow(img)显示;

matplotlib.pyplot:
	img = plt.imread()读取,plt.imshow(img)显示;

PIL.Image:
	img = Image.open()读取,img.show()显示;
'''
img1 = cv2.imread('C:/Users/Administrator/Desktop/meihua.jpg')
cv2.imshow('meihua',img1)
cv2.waitKey(0)  # 保持图形界面,直到你在终端输入任意字符
cv2.destroyAllWindows()
print(img1.shape)  # h,w,c
print(img1.size)  # h*w*c

img2 = plt.imread('C:/Users/Administrator/Desktop/meihua.jpg')
plt.imshow(img2)
print(img2.shape)  # h,w,c
print(img2.size)  # h*w*c

img3 = Image.open('C:/Users/Administrator/Desktop/meihua.jpg')
img3  # 或者img.show()
print(img3.size)  # h,w
# print(img3.size) 会报错,因为Image没有size属性

在notebook中运行代码如下:

你可能感兴趣的:(python)