Loading examples/imageview_example.py +72 Changes for examples/imageview_example.py: 72 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 16 22:28:58 2019 @author: martindrech """ # -*- coding: utf-8 -*- """ Demonstrates very basic use of ImageItem to display image data inside a ViewBox. """ ## Add path to library (just for examples; you do not need this) from pyqtgraph.Qt import QtCore, QtGui import numpy as np import pyqtgraph as pg import pyqtgraph.ptime as ptime def _twoD_gaussian(lim=10, sigma=1, x0=0, y0=0): N = 600 x, y = np.meshgrid(np.linspace(-lim, lim, N), np.linspace(-lim, lim, N)) d = np.sqrt((x - x0) ** 2 + (y - y0) ** 2) g = np.exp(-((d) ** 2 / (2.0 * sigma ** 2))) noise = np.random.normal(size=(N, N))/10 return g + noise app = QtGui.QApplication([]) ## Create window with ImageView widget win = QtGui.QMainWindow() win.resize(800,800) imv = pg.ImageView() win.setCentralWidget(imv) win.show() win.setWindowTitle('pyqtgraph example: ImageView') ## Create random image data = np.asarray([_twoD_gaussian() for i in range(50)]) i = 0 updateTime = ptime.time() fps = 0 def updateData(): global img, data, i, updateTime, fps ## Display the data imv.setImage(data[i], autoHistogramRange=False, autoLevels=False, autoRange=False ) i = (i+1) % data.shape[0] QtCore.QTimer.singleShot(1, updateData) now = ptime.time() fps2 = 1.0 / (now-updateTime) updateTime = now fps = fps * 0.9 + fps2 * 0.1 #print "%0.1f fps" % fps updateData() ## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': import sys if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): QtGui.QApplication.instance().exec_() Loading
examples/imageview_example.py +72 Changes for examples/imageview_example.py: 72 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 16 22:28:58 2019 @author: martindrech """ # -*- coding: utf-8 -*- """ Demonstrates very basic use of ImageItem to display image data inside a ViewBox. """ ## Add path to library (just for examples; you do not need this) from pyqtgraph.Qt import QtCore, QtGui import numpy as np import pyqtgraph as pg import pyqtgraph.ptime as ptime def _twoD_gaussian(lim=10, sigma=1, x0=0, y0=0): N = 600 x, y = np.meshgrid(np.linspace(-lim, lim, N), np.linspace(-lim, lim, N)) d = np.sqrt((x - x0) ** 2 + (y - y0) ** 2) g = np.exp(-((d) ** 2 / (2.0 * sigma ** 2))) noise = np.random.normal(size=(N, N))/10 return g + noise app = QtGui.QApplication([]) ## Create window with ImageView widget win = QtGui.QMainWindow() win.resize(800,800) imv = pg.ImageView() win.setCentralWidget(imv) win.show() win.setWindowTitle('pyqtgraph example: ImageView') ## Create random image data = np.asarray([_twoD_gaussian() for i in range(50)]) i = 0 updateTime = ptime.time() fps = 0 def updateData(): global img, data, i, updateTime, fps ## Display the data imv.setImage(data[i], autoHistogramRange=False, autoLevels=False, autoRange=False ) i = (i+1) % data.shape[0] QtCore.QTimer.singleShot(1, updateData) now = ptime.time() fps2 = 1.0 / (now-updateTime) updateTime = now fps = fps * 0.9 + fps2 * 0.1 #print "%0.1f fps" % fps updateData() ## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': import sys if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): QtGui.QApplication.instance().exec_()