利用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')

 

 

 

 

 

posted @ 2019-07-23 09:49  tangjunjun  阅读(1849)  评论(0编辑  收藏  举报
https://rpc.cnblogs.com/metaweblog/tangjunjun