1. opencv方法
- import cv2
- img_path =r"C:/Users/gf879/Pictures/Saved Pictures/cat1.jpg"
- img = cv2.imread(img_path)
- cv2.namedWindow('myPicture',0)
- cv2.resizeWindow('myPicture', 500, 500)
- cv2.imshow('myPicture',img)
- cv2.waitKey()
- cv2.destroyWindow('myPicture')
结果:
2. matplotlib方法
- import matplotlib.pyplot as plt
- img_path =r"C:/Users/gf879/Pictures/Saved Pictures/cat1.jpg"
- img = plt.imread(img_path)
- fig = plt.figure('show picture')
- # ax = fig.add_subplot(111)
- plt.imshow(img)
- plt.show()
结果:
3. PIL
- from PIL import Image
- img=Image.open('C:/Users/gf879/Pictures/Saved Pictures/cat1.jpg')
- img.show()
结果: