显示好几幅图片在一个窗口内,逗号可以省略。
其实imshow这个函数前两篇博客中已经开始使用了,与matlab中的使用很相似。下面介绍一下
若要显示灰度图片,参数为 cam=plt.cm.gray
若要显示彩色图片,opencv 读入的图片默认BGR,必须调整为RGB才能显示
imshow灰度图片 编程对比一下 显示效果。
import cv2
import matplotlib.pyplot as plt
o=cv2.imread('image\\girl.bmp')
g=cv2.cvtColor(o,cv2.COLOR_BGR2GRAY)
plt.subplot(221)
plt.imshow(o),plt.axis('off') #显示彩色图片 参数默认 去掉坐标系
plt.subplot(222)
plt.imshow(o,cmap=plt.cm.gray) #显示彩色图片 参数设为灰度图片
plt.subplot(223)
plt.imshow(g) #显示灰度图片 参数默认
plt.subplot(224)
plt.imshow(g,cmap=plt.cm.gray) #显示灰度图片 参数设为灰度图片
plt.show()