利用cv与matplotlib.pyplot读图片与显示图片

import matplotlib.pyplot as plt
import cv2 as cv
a=cv.imread('learn.jpg')
cv.imshow('learn',a)
fig=plt.figure(1) #新建绘图窗口
b=fig.add_subplot(221) #选择画布第一个
b.imshow(a,cmap=plt.cm.gray) #读图
cv.imshow('learn',a)
fig=plt.figure(1) #新建绘图窗口
b=fig.add_subplot(222) #选择画布第一个
b.imshow(a,cmap='gray') #读图
plt.title('fig')
fig1=plt.figure(2) #新建绘图窗口
b1=fig1.add_subplot(223) #选择画布第一个
b1.imshow(a,cmap=plt.cm.gray) #读图
plt.title('fig1')
plt.figure(3) #新建绘图窗口
plt.subplot(111) #选择画布第一个
plt.imshow(a,cmap='gray') #读图
plt.title('fig2')

原文地址:https://www.cnblogs.com/tangjunjun/p/11229908.html