Insanely slow updating of pyqtgraph when changing colorbar bounds
-
I am having trouble with a pyqtgraph w/ colorbar updating very slowly. I have created an app in PyQt5 that takes a bunch of images, does some math, and then displays the image in a pyqtgraph ImageView() w/ a colorbar.
When I change the colorbar bounds, it takes about 5-6 seconds to actually move the colorbar widget to where I dragged it to, then another 5-6 seconds to update the image.
Here is the code I use to display the image. I call "display_plot" from a pyqtSlot inside the UI thread, no issues with it freezing/shutting down, the UI thread should be handling the image display.
import pyqtgraph as pg from PyQt5 import QtWidgets class ImageWindow(QtWidgets.QWidget): def __init__(self): self.graph_widget = pg.ImageView() self.cmap = pg.colormap.get('CET-L9') vbox = QtWidgets.QVBoxLayout(self) vbox.addWidget(self.graph_widget) def display_plot(self, image): self.graph_widget.setImage(image) self.graph_widget.setColorMap(self.cmap)
The image is a 3200x3200 grayscale np-image.
Is there someway I can make this ImageView() update faster? Anything I'm doing very wrong?
Also, when you set the colorbar/image, does it create a thread that will handle updating the image? who updates the image in this?
-
@kgenbio You'd have to ask the PyQtGraph project how their processing works internally. I assume that the "colorbar widget" is part of the ImageView.
I have not used the library, but it looks to me that setColorMap() needs on be called once at ImageView setup. If you do that does it make a difference?