我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用pyqtgraph.ImageView()。
def setup(self): self.ui = self.dockarea = pyqtgraph.dockarea.DockArea() self.imview = pg.ImageView() self.imview.getView().invertY(True) # uper left origin self.dockarea.addDock(name='Full Image', widget=self.imview) self.imview_roi = pg.ImageView() self.imview_roi.getView().invertY(True) # upper left origin self.dockarea.addDock(name='ROI Image', widget=self.imview_roi) self.imview_gauss = pg.ImageView() self.imview_gauss.getView().invertY(True) # upper left origin self.dockarea.addDock(name='Gauss Fit Image', widget=self.imview_gauss) self.rect_roi = pg.RectROI([20, 20], [100, 100], pen=(0,9)) self.imview.getView().addItem(self.rect_roi) self.rect_roi.sigRegionChanged[object].connect(self.on_change_rect_roi) self.info_label = QtWidgets.QLabel() self.dockarea.addDock(name='info', widget=self.info_label)
def setup(self): HyperSpectralBaseView.setup(self) TRPLNPZView.scan_specific_setup(self) self.settings.New('plane', dtype=str, initial='xy', choices=('xy', 'yz', 'xz')) self.settings.New('index', dtype=int) self.settings.New('auto_level', dtype=bool, initial=True) for name in ['plane', 'index', 'auto_level']: self.settings.get_lq(name).add_listener(self.update_display) #self.ui = QtWidgets.QWidget() #self.ui.setLayout(QtWidgets.QVBoxLayout()) self.dockarea.addDock(name='Image', widget=self.settings.New_UI()) self.info_label = QtWidgets.QLabel() self.dockarea.addDock(name='info', widget=self.info_label) #self.imview = pg.ImageView() #self.ui.layout().addWidget(self.imview, stretch=1) #self.graph_layout = pg.GraphicsLayoutWidget() #self.graph_layout.addPlot()
def setup(self): self.settings.New('frame', dtype=int, initial=0) self.settings.New('sub_frame', dtype=int, initial=0) chan_choices = ['adc0', 'adc1', 'ctr0', 'ctr1'] + ['auger{}'.format(i) for i in range(10)] + ['sum_auger'] self.settings.New('channel', dtype=str, initial='sum_auger', choices=tuple(chan_choices)) self.settings.New('auto_level', dtype=bool, initial=True) self.ui = QtWidgets.QWidget() self.ui.setLayout(QtWidgets.QVBoxLayout()) self.ui.layout().addWidget(self.settings.New_UI(), stretch=0) self.info_label = QtWidgets.QLabel() self.ui.layout().addWidget(self.info_label, stretch=0) self.imview = pg.ImageView() self.ui.layout().addWidget(self.imview, stretch=1) self.settings.frame.add_listener(self.update_display) self.settings.sub_frame.add_listener(self.update_display) self.settings.channel.add_listener(self.update_display) self.settings.auto_level.add_listener(self.update_display)
def setup(self): self.settings.New('frame', dtype=int) #self.settings.New('sub_frame', dtype=int) self.settings.New('source', dtype=str, choices=('SEM', 'Auger')) self.settings.New('SEM_chan', dtype=int, vmin=0, vmax=1) self.settings.New('Auger_chan', dtype=int, vmin=0, vmax=7) self.settings.New('auto_level', dtype=bool, initial=True) for name in ['frame', 'source','SEM_chan', 'Auger_chan', 'auto_level']: self.settings.get_lq(name).add_listener(self.update_display) self.ui = QtWidgets.QWidget() self.ui.setLayout(QtWidgets.QVBoxLayout()) self.ui.layout().addWidget(self.settings.New_UI(), stretch=0) self.info_label = QtWidgets.QLabel() self.ui.layout().addWidget(self.info_label, stretch=0) self.imview = pg.ImageView() self.ui.layout().addWidget(self.imview, stretch=1) #self.graph_layout = pg.GraphicsLayoutWidget() #self.graph_layout.addPlot()
def setup(self): self.settings.New('frame', dtype=int) self.settings.New('sub_frame', dtype=int) self.settings.New('channel', dtype=str, choices=('ai0', 'ai1', 'ctr0', 'ctr1')) self.settings.New('auto_level', dtype=bool, initial=True) for name in ['frame', 'sub_frame','channel', 'auto_level']: self.settings.get_lq(name).add_listener(self.update_display) self.ui = QtWidgets.QWidget() self.ui.setLayout(QtWidgets.QVBoxLayout()) self.ui.layout().addWidget(self.settings.New_UI(), stretch=0) self.info_label = QtWidgets.QLabel() self.ui.layout().addWidget(self.info_label, stretch=0) self.imview = pg.ImageView() self.ui.layout().addWidget(self.imview, stretch=1) #self.graph_layout = pg.GraphicsLayoutWidget() #self.graph_layout.addPlot()
def setup(self): self.settings.New('plane', dtype=str, initial='xy', choices=('xy', 'yz', 'xz')) self.settings.New('index', dtype=int) self.settings.New('sub_frame', dtype=int) self.settings.New('auto_level', dtype=bool, initial=True) for name in ['plane', 'index', 'sub_frame', 'auto_level']: self.settings.get_lq(name).add_listener(self.update_display) self.ui = QtWidgets.QWidget() self.ui.setLayout(QtWidgets.QVBoxLayout()) self.ui.layout().addWidget(self.settings.New_UI(), stretch=0) self.info_label = QtWidgets.QLabel() self.ui.layout().addWidget(self.info_label, stretch=0) self.imview = pg.ImageView() self.ui.layout().addWidget(self.imview, stretch=1)
def test_ImageView(): def mkobjs(): iv = pg.ImageView() data = np.zeros((10,10,5)) iv.setImage(data) return mkrefs(iv, iv.imageItem, iv.view, iv.ui.histogram, data) for i in range(5): assert_alldead(mkobjs())
def setup(self): self.ui = self.imview = pg.ImageView() #self.graph_layout = pg.GraphicsLayoutWidget() #self.graph_layout.addPlot()
def setup(self): self.ui = self.imview = pg.ImageView() self.imview.getView().invertY(False) # lower left origin #self.graph_layout = pg.GraphicsLayoutWidget() #self.graph_layout.addPlot()
def setup(self): self.ui = self.imview = pg.ImageView()
def __init__(self, data, title=None): PgDataPlot.__init__(self, data) self.dim = self._data[0].output_data.shape self.win = pg.QtGui.QMainWindow() self.win.resize(800, 800) self.win.setWindowTitle("PgSlicePlot: {}".format(title)) self.cw = pg.QtGui.QWidget() self.win.setCentralWidget(self.cw) self.l = pg.QtGui.QGridLayout() self.cw.setLayout(self.l) self.image_view = pg.ImageView(name="img_view") self.l.addWidget(self.image_view, 0, 0) self.slice_view = pg.PlotWidget(name="slice") self.l.addWidget(self.slice_view) self.win.show() # self.imv2 = pg.ImageView() # self.l.addWidget(self.imv2, 1, 0) self.roi = pg.LineSegmentROI([[0, self.dim[1] - 1], [self.dim[0] - 1, self.dim[1] - 1]], pen='r') self.image_view.addItem(self.roi) self.image_view.setImage(self._data[0].output_data) # # self.plot_window.showGrid(x=True, y=True, alpha=.5) # self.plot_window.addLegend() # # input_idx = 0 if self.data_slice.shape[0] > self.data_slice.shape[1] else 0 # for data_set in data: # self.plot_window.plot(data_set.input_data[input_idx], data_set.output_data[self.data_slice], # name=data.name) # TODO: alpha
def setup(self): #self.ui = self.splitter = QtWidgets.QSplitter() #self.ui.setLayout(QtWidgets.QVBoxLayout()) self.ui = self.dockarea = dockarea.DockArea() self.imview = pg.ImageView() self.imview.getView().invertY(False) # lower left origin #self.splitter.addWidget(self.imview) self.dockarea.addDock(name='Image', widget=self.imview) self.graph_layout = pg.GraphicsLayoutWidget() #self.splitter.addWidget(self.graph_layout) self.dockarea.addDock(name='Spec Plot', widget=self.graph_layout) self.spec_plot = self.graph_layout.addPlot() self.rect_plotdata = self.spec_plot.plot() self.point_plotdata = self.spec_plot.plot(pen=(0,9)) # Rectangle ROI self.rect_roi = pg.RectROI([20, 20], [20, 20], pen=(0,9)) self.rect_roi.addTranslateHandle((0.5,0.5)) self.imview.getView().addItem(self.rect_roi) self.rect_roi.sigRegionChanged[object].connect(self.on_change_rect_roi) # Point ROI self.circ_roi = pg.CircleROI( (0,0), (2,2) , movable=True, pen=(0,9)) #self.circ_roi.removeHandle(self.circ_roi.getHandles()[0]) h = self.circ_roi.addTranslateHandle((0.5,.5)) h.pen = pg.mkPen('r') h.update() self.imview.getView().addItem(self.circ_roi) self.circ_roi.removeHandle(0) self.circ_roi_plotline = pg.PlotCurveItem([0], pen=(0,9)) self.imview.getView().addItem(self.circ_roi_plotline) self.circ_roi.sigRegionChanged[object].connect(self.on_update_circ_roi) self.hyperspec_data = None self.display_image = None self.spec_x_array = None self.scan_specific_setup()
def __init__(self,args,parent=None): QtGui.QMainWindow.__init__(self,parent) self.srclist=[] # list of source directories self.imageIndex=0 # index of selected image self.seriesMap=OrderedDict() # maps series table row tuples to DicomSeries object it was generated from self.seriesColumns=list(seriesListColumns) # keywords for columns self.selectedRow=-1 # selected series row self.lastDir='.' # last loaded directory root self.filterRegex='' # regular expression to filter tags by # create the directory queue and loading thread objects self.dirQueue=Queue() # queue of directories to load self.loadDirThread=threading.Thread(target=self._loadDirsThread) self.loadDirThread.daemon=True # clean shutdown possible with daemon threads self.loadDirThread.start() # start the thread now, it will wait until something is put on self.dirQueue # setup ui self.setupUi(self) # create UI elements based on the loaded .ui file self.setWindowTitle('DicomBrowser v%s (FOR RESEARCH ONLY)'%(__version__)) self.setStatus('') # connect signals self.importButton.clicked.connect(self._openDirDialog) self.statusSignal.connect(self.setStatus) self.updateSignal.connect(self._updateSeriesTable) self.filterLine.textChanged.connect(self._setFilterString) self.imageSlider.valueChanged.connect(self.setSeriesImage) self.seriesView.clicked.connect(self._seriesTableClicked) # setup the list and table models self.srcmodel=QStringListModel() self.seriesmodel=SeriesTableModel(self.seriesColumns) self.seriesmodel.layoutChanged.connect(self._seriesTableResize) self.tagmodel=QtGui.QStandardItemModel() # assign models to views self.sourceListView.setModel(self.srcmodel) self.seriesView.setModel(self.seriesmodel) self.tagView.setModel(self.tagmodel) # create the pyqtgraph object for viewing images self.imageview=pg.ImageView() layout=QtGui.QGridLayout(self.view2DGroup) layout.addWidget(self.imageview) # load the empty image placeholder into a ndarray qimg=QtGui.QImage(':/icons/noimage.png') bytedata=qimg.constBits().asstring(qimg.width()*qimg.height()) self.noimg=np.ndarray((qimg.width(),qimg.height()),dtype=np.ubyte,buffer=bytedata) # add the directories passed as arguments to the directory queue to start loading for i in args: if os.path.isdir(i): self.addSourceDir(i)