码迷,mamicode.com
首页 > 其他好文 > 详细

opencv imshow plt imshow

时间:2019-07-19 23:45:22      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:http   imshow   pytho   cin   html   color   exe   bsp   from   

 

opencv官方文档上写的,https://docs.opencv.org/master/dc/d2e/tutorial_py_image_display.html

Color image loaded by OpenCV is in BGR mode. But Matplotlib displays in RGB mode. So color images will not be displayed correctly in Matplotlib if image is read with OpenCV. Please see the exercises for more details.

https://stackoverflow.com/questions/15072736/extracting-a-region-from-an-image-using-slicing-in-python-opencv/15074748#15074748

import cv2
import numpy as np
import matplotlib.pyplot as plt

img = cv2.imread(‘messi4.jpg‘)
b,g,r = cv2.split(img)
img2 = cv2.merge([r,g,b])
#img2 = img[:,:,::-1]
plt.subplot(121);plt.imshow(img) # expects distorted color
plt.subplot(122);plt.imshow(img2) # expect true color
plt.show()

cv2.imshow(‘bgr image‘,img) # expects true color
cv2.imshow(‘rgb image‘,img2) # expects distorted color
cv2.waitKey(0)
cv2.destroyAllWindows()

  

opencv imshow plt imshow

标签:http   imshow   pytho   cin   html   color   exe   bsp   from   

原文地址:https://www.cnblogs.com/jianyingzhou/p/11216163.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!