import cv2 import numpy from matplotlib import pyplot img=cv2.imread("D:dog.jpg",cv2.IMREAD_GRAYSCALE) #cv2.IMREAD_GRAYSCALE转灰度图 #图像的显示 cv2.imshow("image_1",img) cv2.waitKey(0) #按一下任意键就可以终止 cv2.destroyAllWindows() print(img.shape) #保存图像 cv2.imwrite("new_picture.jpg",img)