opencv 学习第一课 图像读取、显示、写入 代码注释版 保证你每一行都能读懂

版权声明:文章版权归作者所有,请不要随意转载抄袭,情节严重,追究法律责任!! https://blog.csdn.net/Ibelievesunshine/article/details/89056282
import numpy as np
import cv2 as cv

img = cv.imread('cat.jpg',0)   #读入图片
cv.imshow('image1',img)        #显示图片
k=cv.waitKey(0) & OxFF         #等待键盘输入
if k == 27:                    #如果是ESC键,退出,销毁所有窗口
	cv.destoryAllWindows()
elif k== ord('s'):             #s键保存图片在工作空间,销毁所有窗口
	cv.imwrite('cat1.png',img)
	cv.destoryAllWindows()

import numpy as np 
import cv2 as cv
from matplotlib import pyplot as plt 

img = cv.imread('cat.jpg',0)               #读入灰度图像
plt.imshow(img,cmap='gray',interpolation='bicubic')  #使用双三次插值方式
plt.xticks([]),plt.yticks([])              #不显示x轴 y轴
plt.show()

参考内容:https://docs.opencv.org/4.0.1/dc/d2e/tutorial_py_image_display.html

猜你喜欢

转载自blog.csdn.net/Ibelievesunshine/article/details/89056282