python matplotlib 多图像排列显示

用OpenCV和matplotlib实现多图排列,代码如下:

import cv2
import matplotlib.pyplot as plt

img = cv2.imread('C:\\Users\\admin\\Desktop\\original_img3\\testimg\\lena_300_500.jpg')

plt.subplot(221)
plt.title('img1')
plt.xticks([])   # remove ticks
plt.yticks([])
# The color channel order in matplotlib is [R, G, B]
# The color channel order in opencv is [B, G, R]
plt.imshow(img[:, :, ::-1])

plt.subplot(222)
plt.title('img2')
plt.xticks([])
plt.yticks([])
plt.imshow(img[:, :, ::-1])

plt.subplot(223)
plt.title('img3')
plt.xticks([])
plt.yticks([])
plt.imshow(img[:, :, ::-1])

plt.subplot(224)
plt.title('img4')
plt.xticks([])
plt.yticks([])
plt.imshow(img[:, :, ::-1])

效果如下:

 

 

posted @ 2019-11-08 10:56  Picassooo  阅读(4527)  评论(0编辑  收藏  举报