显示好几幅图片在一个窗口内,逗号可以省略。
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190118165940899.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N1bmRhbnBpbmdfMTIz,size_16,color_FFFFFF,t_70)
其实imshow这个函数前两篇博客中已经开始使用了,与matlab中的使用很相似。下面介绍一下
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190118170749999.png)
若要显示灰度图片,参数为 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.gr