我尝试从本地文件夹加载和绘制几个图像(jpg),并发现绘图图像改变了颜色。cv2和matplotlib之间的颜色通道校正已经完成。
这是怎么发生的?如何校正颜色?谢谢。
import cv2
from matplotlib import pyplot as plt
import numpy as np
import os
folder = 'New_Web_Image'
img_list = np.empty([0,32,32,3])
for file in os.listdir(folder):
img = cv2.imread(os.path.join(folder, file))
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, (32,32), interpolation = cv2.INTER_AREA)
#plt.imshow(img)
#plt.show()#If I plot the image here, the image show right color
img_list = np.append(img_list, [img[:, :, :]], axis=0)
print(img_list.shape) #lists shape check right
plt.imshow(img_list[0])
plt.show() #If I plor the image from the lists, the color changed