How to display clickable RGB image similar to pyqtgraph ImageView?

∥☆過路亽.° 提交于 2019-12-01 22:50:10

pyqtgraph.ImageView does support rgb / rgba images. For example:

import numpy as np
import pyqtgraph as pg
data = np.random.randint(255, size=(100, 100, 3))
pg.image(data)

..and if you want to display the exact image data without automatic level adjustment:

pg.image(data, levels=(0, 255))

As pointed out by Luke, ImageView() does display RGB, provided the correct array shape is passed. In my sample program, I should have used photo.transpose([1,0,2]) to keep the RGB in the last dimension rather than just photo.transpose(). When ImageView is confronted with an array of dimension (3, W, H), it treats the array as a video consisting of 3 monochrome images, with a slider at the bottom to select the frame.

(Corrected to incorporate followup comment by Luke, below)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!