Aluode/PerceptionLabPortable
0
1"""2This example demonstrates the use of ImageView with 3-color image stacks.3ImageView is a high-level widget for displaying and analyzing 2D and 3D data.4ImageView provides:5 6 1. A zoomable region (ViewBox) for displaying the image7 2. A combination histogram and gradient editor (HistogramLUTItem) for8 controlling the visual appearance of the image9 3. A timeline for selecting the currently displayed frame (for 3D data only).10 4. Tools for very basic analysis of image data (see ROI and Norm buttons)11 12"""13 14import numpy as np15 16import pyqtgraph as pg17from pyqtgraph.Qt import QtWidgets18 19# Interpret image data as row-major instead of col-major20pg.setConfigOptions(imageAxisOrder='row-major')21 22app = pg.mkQApp("ImageView Example")23 24## Create window with ImageView widget25win = QtWidgets.QMainWindow()26win.resize(800,800)27imv = pg.ImageView(discreteTimeLine=True, levelMode='rgba')28win.setCentralWidget(imv)29win.show()30win.setWindowTitle('pyqtgraph example: ImageView')31imv.setHistogramLabel("Histogram label goes here")32 33## Create random 3D data set with time varying signals34dataRed = np.ones((100, 200, 200)) * np.linspace(90, 150, 100)[:, np.newaxis, np.newaxis]35dataRed += pg.gaussianFilter(np.random.normal(size=(200, 200)), (5, 5)) * 10036dataGrn = np.ones((100, 200, 200)) * np.linspace(90, 180, 100)[:, np.newaxis, np.newaxis]37dataGrn += pg.gaussianFilter(np.random.normal(size=(200, 200)), (5, 5)) * 10038dataBlu = np.ones((100, 200, 200)) * np.linspace(180, 90, 100)[:, np.newaxis, np.newaxis]39dataBlu += pg.gaussianFilter(np.random.normal(size=(200, 200)), (5, 5)) * 10040 41data = np.concatenate(42 (dataRed[:, :, :, np.newaxis], dataGrn[:, :, :, np.newaxis], dataBlu[:, :, :, np.newaxis]), axis=343)44 45 46# Display the data and assign each frame a time value from 1.0 to 3.047imv.setImage(data, xvals=np.linspace(1., 3., data.shape[0]))48imv.play(10)49 50# Start up with an ROI51imv.ui.roiBtn.setChecked(True)52imv.roiClicked()53 54if __name__ == '__main__':55 pg.exec()56 