1 回答

TA貢獻(xiàn)1887條經(jīng)驗(yàn) 獲得超5個(gè)贊
我假設(shè)該數(shù)組的類(lèi)型為 uint8 并代表紅色、綠色和藍(lán)色 您可以Pillow為此使用,例如
from PyQt5 import QtWidgets, QtGui
from PIL import Image, ImageQt
import numpy as np
# generate data
table = np.zeros((256,256,3), dtype=np.uint8)
for i in range(256):
table[:,i,0] = i
table[i,:,1] = i
table[:,:,2] = (2*255 - table[:,:,0] - table[:,:,1]) // 2
# convert data to QImage using PIL
img = Image.fromarray(table, mode='RGB')
qt_img = ImageQt.ImageQt(img)
app = QtWidgets.QApplication([])
w = QtWidgets.QLabel()
w.setPixmap(QtGui.QPixmap.fromImage(qt_img))
w.show()
app.exec()
添加回答
舉報(bào)