How to display clickable RGB image similar to pyqtgraph ImageView?

后端 未结 2 1790
你的背包
你的背包 2021-01-15 01:41

Despite not being a proficient GUI programmer, I figured out how to use the pyqtgraph module\'s ImageView function to display an image that I can pan/zoom and click on to ge

相关标签:
2条回答
  • 2021-01-15 02:19

    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)

    0 讨论(0)
  • 2021-01-15 02:30

    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))
    
    0 讨论(0)
提交回复
热议问题