如何将算术颜色转换为其RGB?

时间:2018-07-18 21:25:55

标签: python python-3.x matplotlib cv2

在openCV中使用RGB颜色(255.0,0.0,0.0)(红色)时,输出改为蓝色。

import cv2
import matplotlib.pyplot as plt

plt.plot([1,2,3,4] ,  color=[1.0, 0.0, 0.0])
plt.savefig('tester.png')
img = cv2.imread('tester.png')
m_img = (cv2.line(img,(0,0),(100,100),(255.0,0.0,0.0),5))
cv2.imwrite('./update.png', m_img)

tester.png:

enter image description here

update.png:

enter image description here

如何修改线m_img = (cv2.line(img,(0,0),(100,100),(255.0,0.0,0.0),5))以便从plt.plot([1,2,3,4] , color=[1.0, 0.0, 0.0])绘制相同的RGB线颜色?

1 个答案:

答案 0 :(得分:2)

OpenCV使用BGR,而不使用RGB。交换0和2频道。

removeListener()