def showImageProcess(self): '''loads window for image process ''' self.tab_widget.removeTab(0) self.tab_widget.insertTab(0, self.createImageProcessWidget(), unicode("Image Process")) self.testtest = pg.ImageView()
def Imshow3DArray(data, ROI=None, window_size=[800, 800], window_name='Imshow3D', overlap=False): ''' Imshow 3D Array, the dimension is row x col x slice. If the ROI was combined in the data, the dimension is: slice x row x col x color :param data: 3D Array [row x col x slice] or 4D array [slice x row x col x RGB] ''' if isinstance(ROI, list) or isinstance(ROI, type(data)): data = Merge3DImageWithROI(data, ROI, overlap=overlap) if np.ndim(data) == 3: data = np.swapaxes(data, 0, 1) data = np.transpose(data) pg.setConfigOptions(imageAxisOrder='row-major') app = QtGui.QApplication([]) win = QtGui.QMainWindow() win.resize(window_size[0], window_size[1]) imv = pg.ImageView() min_value = np.min(data) max_value = np.max(data) win.setCentralWidget(imv) win.show() win.setWindowTitle(window_name) imv.setImage(data, levels=(min_value, max_value), autoRange=False) app.exec() imv.clear()
def __init__(self, parent=None): qt_import.QWidget.__init__(self, parent) self.curves_dict = {} self.visible_curve = None self.view_box = CustomViewBox() self.one_dim_plot = pg.PlotWidget(viewBox=self.view_box) self.two_dim_plot = pg.ImageView() self.one_dim_plot.showGrid(x=True, y=True) self.two_dim_plot.ui.histogram.hide() self.two_dim_plot.ui.roiBtn.hide() self.two_dim_plot.ui.menuBtn.hide() self.two_dim_plot.setFixedWidth(400) hlayout = qt_import.QHBoxLayout(self) hlayout.addWidget(self.one_dim_plot) hlayout.addWidget(self.two_dim_plot) colors = [(0, 0, 0), (255, 0, 0), (255, 255, 0), (255, 255, 255)] cmap = pg.ColorMap(pos=np.linspace(0.0, 1.0, 4), color=colors) self.two_dim_plot.setColorMap(cmap) self.one_dim_plot.scene().sigMouseMoved.connect(self.one_dim_plot_mouse_moved) self.two_dim_plot.scene.sigMouseMoved.connect(self.two_dim_plot_mouse_moved)
def __init__(self, parent = None): self.parent = parent self.stackStart = 0 self.stackSizeMax = 120 self.stackSize = 20 ## Dock 7: Image Stack self.d7 = Dock("Image Scroll", size=(1, 1)) self.w7L = pg.LayoutWidget() self.w7 = pg.ImageView(view=pg.PlotItem()) self.w7.getView().invertY(False) self.scroll = np.random.random((5, 10, 10)) self.w7.setImage(self.scroll, xvals=np.linspace(0., self.scroll.shape[0] - 1, self.scroll.shape[0])) self.spinBox = QtGui.QSpinBox() self.spinBox.setValue(0) self.label = QtGui.QLabel("Event Number:") self.stackSizeBox = QtGui.QSpinBox() self.stackSizeBox.setMaximum(self.stackSizeMax) self.stackSizeBox.setValue(self.stackSize) self.startBtn = QtGui.QPushButton("&Load image stack") # Connect listeners to functions self.w7L.addWidget(self.w7, row=0, colspan=4) self.w7L.addWidget(self.label, 1, 0) self.w7L.addWidget(self.spinBox, 1, 1) self.w7L.addWidget(self.stackSizeBox, 1, 2) self.w7L.addWidget(self.startBtn, 1, 3) self.d7.addWidget(self.w7L) self.threadpool = LaunchStackProducer.StackProducer(self.parent) # send parent parameters self.parent.connect(self.threadpool, QtCore.SIGNAL("finished()"), self.displayImageStack) self.parent.connect(self.startBtn, QtCore.SIGNAL("clicked()"), self.loadStack)
def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent) """"" Loading the UI File """ self.ui = uic.loadUi( os.path.join(os.path.dirname(__file__), "Try2.ui"), self) """ Setting Multimedia player to play video""" self.player = QtMultimedia.QMediaPlayer( None, QtMultimedia.QMediaPlayer.VideoSurface) """ Setting up the Video Widget, Slider and Layout""" self.player.setVideoOutput(self.ui.widget) self.widget = QtGui.QWidget() self.widget.setLayout(QtGui.QHBoxLayout()) self.slider.show() self.slider.setRange(0, 0) self.slider.sliderMoved.connect(self.setPosition) """ Slider position and duratio synchronization""" self.player.positionChanged.connect(self.positionChanged) self.player.durationChanged.connect(self.durationChanged) imv = pg.ImageView() self.widget.layout().addWidget(imv) self.actionOpen.setStatusTip('Open movie') """ Triggering File Open when File button is clicked""" self.actionOpen.triggered.connect(self.openFile) self.show()
class imagePlot2(pg.ImageView): dp_input, image_header = load('DP_preprocessed.nii.gz') data = np.asarray(dp_input) # Interpret image data as row-major instead of col-major pg.setConfigOptions(imageAxisOrder='col-major') app = QtGui.QApplication([]) # Create window with ImageView widget win = QtGui.QMainWindow() imv = pg.ImageView() win.setCentralWidget(imv) win.show() win.setWindowTitle('pyqtgraph example: ImageView') ## Display the data and assign each frame a time value from 1.0 to 3.0 imv.setImage(data, xvals=np.linspace(1, 144, data.shape[0], dtype = 'int32')) ## Set a custom color map colors = [ (0, 0, 0), (45, 5, 61), (84, 42, 55), (150, 87, 60), (208, 171, 141), (255, 255, 255) ] cmap = pg.ColorMap(pos=np.linspace(0.0, 1.0, 6), color=colors) imv.setColorMap(cmap) imv.setCurrentIndex(72) imv.ui.roiBtn.hide() imv.ui.menuBtn.hide()
def __init__(self, graphicsView_video, video_active=lambda: False, video_reset=lambda: False): self.live_image = np.zeros((480, 640), dtype=np.uint8) self.time_of_last_image = 0 self.live_image_swapped = None self.time_of_last_image_swapped = 0 self.video_fps = 0 self.image_mask = np.zeros((480, 640), dtype=np.uint8) self.video_item = pyqtgraph.ImageView(graphicsView_video) self.video_auto_range = False self.video_auto_level = False self.video_auto_histogram_range = False self.video_item.setFixedWidth(631) self.video_item.setFixedHeight(431) self.video_item.setImage(np.swapaxes(self.live_image, 0, 1), levels=(0, 255), autoHistogramRange=False) self.video_active = video_active self.video_reset = video_reset self.video_apply_mask = lambda: False
def setup_figure(self): """ Runs once during App initialization, after setup() This is the place to make all graphical interface initializations, build plots, etc. """ # connect ui widgets to measurement/hardware settings or functions self.ui.start_pushButton.clicked.connect(self.start) self.ui.interrupt_pushButton.clicked.connect(self.interrupt) self.settings.save_h5.connect_to_widget(self.ui.save_h5_checkBox) self.image_gen.settings.amplitude.connect_to_widget(self.ui.amp_doubleSpinBox) # Set up pyqtgraph graph_layout in the UI self.imv = pg.ImageView() self.ui.image_groupBox.layout().addWidget(self.imv) colors = [(0, 0, 0), (45, 5, 61), (84, 42, 55), (150, 87, 60), (208, 171, 141), (255, 255, 255) ] cmap = pg.ColorMap(pos=np.linspace(0.0, 1.0, 6), color=colors) self.imv.setColorMap(cmap)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.image_viewer = pg.ImageView(parent=self) self.time_series_widget = TimeSeriesWidget(parent=self) self.peak_dynamics_region = pg.ROI(pos=[0, 0], size=[200, 200], pen=pg.mkPen("r")) self.peak_dynamics_region.addScaleHandle([1, 1], [0, 0]) self.peak_dynamics_region.addScaleHandle([0, 0], [1, 1]) self.peak_dynamics_region.sigRegionChanged.connect( self.update_peak_dynamics) self.roi_topleft_text = pg.TextItem("", anchor=(1, 1)) self.roi_bottomright_text = pg.TextItem("", anchor=(0, 0)) self.image_viewer.addItem(self.roi_topleft_text) self.image_viewer.addItem(self.roi_bottomright_text) self.image_viewer.getView().addItem(self.peak_dynamics_region) self.peak_dynamics_region.hide() self.time_series_widget.hide() self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.image_viewer) self.layout.addWidget(self.time_series_widget) self.setLayout(self.layout)
def pyqtgraph(self): # image self.parent.ui.image_view = pg.ImageView(view=pg.PlotItem()) self.parent.ui.image_view.ui.menuBtn.hide() self.parent.ui.image_view.ui.roiBtn.hide() vertical_layout = QtGui.QVBoxLayout() vertical_layout.addWidget(self.parent.ui.image_view) self.parent.ui.pyqtgraph_widget.setLayout(vertical_layout) # profile self.parent.ui.profile_view = pg.PlotWidget() self.parent.ui.profile_view.plot() self.parent.legend = self.parent.ui.profile_view.addLegend() vertical_layout2 = QtGui.QVBoxLayout() vertical_layout2.addWidget(self.parent.ui.profile_view) self.parent.ui.profile_widget.setLayout(vertical_layout2) # all plots self.parent.ui.all_plots_view = pg.PlotWidget() self.parent.ui.all_plots_view.plot() self.parent.all_plots_legend = self.parent.ui.all_plots_view.addLegend( ) vertical_layout2 = QtGui.QVBoxLayout() vertical_layout2.addWidget(self.parent.ui.all_plots_view) self.parent.ui.all_plots_widget.setLayout(vertical_layout2)
def setup_figure(self): self.ui = load_qt_ui_file(sibling_path(__file__,'flircam_live_measure.ui')) self.hw = self.app.hardware['flircam'] self.settings.activation.connect_to_widget(self.ui.live_checkBox) self.settings.auto_level.connect_to_widget(self.ui.auto_level_checkBox) self.settings.crosshairs.connect_to_widget(self.ui.crosshairs_checkBox) self.hw.settings.connected.connect_to_widget(self.ui.cam_connect_checkBox) self.hw.settings.cam_index.connect_to_widget(self.ui.cam_index_doubleSpinBox) self.hw.settings.frame_rate.connect_to_widget(self.ui.framerate_doubleSpinBox) self.hw.settings.exposure.connect_to_widget(self.ui.exp_doubleSpinBox) self.imview = pg.ImageView() def switch_camera_view(): self.ui.plot_groupBox.layout().addWidget(self.imview) self.imview.showMaximized() self.ui.show_pushButton.clicked.connect(switch_camera_view) self.ui.plot_groupBox.layout().addWidget(self.imview) self.ui.auto_exposure_comboBox.addItem("placeholder") self.ui.auto_exposure_comboBox.setCurrentIndex(0) def apply_auto_exposure_index(): self.hw.cam.set_auto_exposure(self.ui.auto_exposure_comboBox.currentIndex()) self.ui.auto_exposure_comboBox.currentIndexChanged.connect(apply_auto_exposure_index) self.ui.save_pushButton.clicked.connect(self.save_image)
def __init__(self, parent=None): super(ContourPlot, self).__init__(parent) self.contour_figure = Figure() self.contour_canvas = FigureCanvas(self.contour_figure) self.contour_toolbar = NavigationToolbar(self.contour_canvas, self) self.contour_figure.set_facecolor('ghostwhite') self.heat_figure = Figure() self.heat_canvas = FigureCanvas(self.heat_figure) self.heat_toolbar = NavigationToolbar(self.heat_canvas, self) self.heat_figure.set_facecolor('ghostwhite') self.variogram_figure = Figure() self.variogram_canvas = FigureCanvas(self.variogram_figure) self.variogram_toolbar = NavigationToolbar(self.variogram_canvas, self) self.variogram_figure.set_facecolor('ghostwhite') self.contour_ax = None self.heatMap_ax = None self.colormap = 'YlGnBu_r' self.X = None self.Y = None self.Z = None pg.setConfigOption('background', '#f8f8ff') pg.setConfigOption('foreground', 'k') self.colorMap = None self.jet_color_map() self.heat_img = pg.ImageView()
def __init__(self): self.__iter = 1000000 self.__size = 5000 self.__xstart = self.__size // 2 self.__ystart = self.__size // 2 self.__x = self.__xstart self.__y = self.__ystart self.__mat = np.zeros([self.__size, self.__size]) self.__dist = np.zeros(self.__iter) self.move() app = pg.mkQApp() pg.setConfigOptions(antialias=True) win = QtWidgets.QMainWindow() win.resize(1200, 700) self.imv = pg.ImageView() win.setCentralWidget(self.imv) win.setWindowTitle("Particle path") win2 = pg.GraphicsWindow(title="Particle distance") win2.addPlot(y=self.__dist) win.show() self.imv.setImage(self.__mat) app.exec()
def configure_plot_type(self, plot_type): self.mainWin.plot_type = plot_type if plot_type in plot_curve_type: if self.mainWin.guiplot_count == 0: self.mainWin.guiplot = pg.PlotWidget() self.mainWin.grid.addWidget(self.mainWin.guiplot, 5, 1, 4, 8) try: self.mainWin.imageCrossHair.clear() except: pass self.mainWin.image_plot_count = 0 elif plot_type in plot_image_type: self.get_colormap(self.mainWin) if self.mainWin.image_plot_count == 0: self.mainWin.plt = pg.PlotItem() self.mainWin.guiplot = pg.ImageView(view=self.mainWin.plt) self.mainWin.grid.addWidget(self.mainWin.guiplot, 5, 1, 4, 8) self.mainWin.guiplot_count = 0 try: self.mainWin.CurCrossHair.clear() except: pass elif plot_type in plot_surface_type: self.get_colormap(self.mainWin) self.mainWin.guiplot = gl.GLViewWidget() self.mainWin.grid.addWidget(self.mainWin.guiplot, 5, 1, 4, 8) self.mainWin.image_plot_count = 0 self.mainWin.guiplot_count = 0
def setup_figure(self): #self.clear_qt_attr('graph_layout') #self.graph_layout=pg.GraphicsLayoutWidget(border=(100,100,100)) #self.ui.plot_groupBox.layout().addWidget(self.graph_layout) self.imview = pg.ImageView() self.ui.plot_groupBox.layout().addWidget(self.imview)
def showImgOverlay(baseImg, overlayImg): imv = pg.ImageView() imv.setImage(baseImg.T) imv.show() regImg = pg.ImageItem() imv.addItem(regImg) regImg.setZValue(10) colormap = cm.get_cmap("CMRmap") # cm.get_cmap("CMRmap") colormap._init() lut = (colormap._lut * 255).view( np.ndarray) # Convert matplotlib colormap from 0-1 to 0 -255 for Qt regImg.setLookupTable(lut) regImg.setAutoDownsample(True) #lut = np.array([[0,0,0], [255,0,0]]) #threshImg.setLookupTable(lut) regImg.setCompositionMode(pg.QtGui.QPainter.CompositionMode_Plus) def updateThresholdImg(): regImg.setImage(overlayImg[..., imv.currentIndex].T) regImg.setLevels([0, np.amax(overlayImg) + 1]) imv.sigTimeChanged.connect(updateThresholdImg)
def pre_run(self): ''' Initialization of the ImageManager class and of figures and creation of the image panels ''' self.display_update_period = self.settings.refresh_period.val eff_subarrayh = self.eff_subarrayh = int(self.camera.subarrayh.val / self.camera.binning.val) eff_subarrayv = self.eff_subarrayv = int(self.camera.subarrayv.val / self.camera.binning.val) numChannels = self.settings.channels_num.val self.channels = list(range(numChannels)) # channels = [0,1,2,...] self.im = ImageManager(eff_subarrayh, eff_subarrayv, self.settings.roi_half_side.val, self.settings.min_cell_size.val, numChannels) imvs = [] for ch in self.channels: plot = pg.PlotItem(title=f'channel{ch}') imv = pg.ImageView(view=plot) imv.ui.histogram.hide() imv.ui.roiBtn.hide() imv.ui.menuBtn.hide() imv.show() imvs.append(imv) self.imvs = imvs self.settings['captured_cells'] = 0
def setupUi(self, name, img_size=(1024,1024), min_size=(512,512)): """ Setup the image view. Args: name (str): widget name img_size (tuple): default image size (used only until actual image is supplied) min_size (tuple): minimal widget size """ self.name=name self.setObjectName(self.name) self.single=False self.layout=QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(0,0,0,0) self.layout.setObjectName("layout") self.img=np.zeros(img_size) self.imageWindow=pyqtgraph.ImageView(self) if min_size: self.imageWindow.setMinimumSize(QtCore.QSize(*min_size)) self.imageWindow.setObjectName("imageWindow") self.layout.addWidget(self.imageWindow) self.set_colormap("hot_sat") self.imageWindow.ui.roiBtn.hide() self.imageWindow.ui.menuBtn.hide() self.imgVLine=pyqtgraph.InfiniteLine(angle=90,movable=True,bounds=[0,None]) self.imgHLine=pyqtgraph.InfiniteLine(angle=0,movable=True,bounds=[0,None]) self.imageWindow.getView().addItem(self.imgVLine) self.imageWindow.getView().addItem(self.imgHLine) self._signals_connected=False self._connect_signals() self.imgVLine.sigPositionChanged.connect(self.update_image_controls) self.imgHLine.sigPositionChanged.connect(self.update_image_controls) self.imageWindow.getHistogramWidget().sigLevelsChanged.connect(self.update_image_controls) self.rectangles={}
def initheatmap(self): #casts z as array for creating heatmap z = np.asarray(self.z) #recasting data in z as integers z.astype(int) #creating heatmap, labeling self.heatmapplot = pg.PlotItem() self.heatmapplot.setLabel('bottom', 'Row') self.heatmapplot.setLabel('left', 'Channel') #self.heatmapplot.setXRange(0, 8, padding=0) #self.heatmapplot.setYRange(0, 32, padding=0) self.heatmap = pg.ImageView(view= self.heatmapplot) self.heatmap.setPredefinedGradient('thermal') self.heatmap.setImage(z) #changes levels for heatmap to create gradient at depending on the data rate print(z) self.avggrad = int(np.average(z)) self.stddevgrad = int(np.std(z)) print('heatmap average: %s' % (self.avggrad)) print('std dev grad %s' % (self.stddevgrad)) self.heatmap.setLevels(self.avggrad - (3 * self.stddevgrad), self.avggrad + (3 * self.stddevgrad)) # if self.frameperfile == 11: # self.heatmap.setLevels(60, 260) # else: # self.heatmap.setLevels(100, 190) self.grid.addWidget(self.heatmap, 3, 2, 2, 3)
def _init_ui(self): self.setWindowTitle('AGIPD Calibration GUI') self.setGeometry(100, 100, 1000, 800) #self.setFixedSize(1000, 800) overall = QtWidgets.QWidget() self.setCentralWidget(overall) layout = QtWidgets.QVBoxLayout(overall) layout.setContentsMargins(0, 0, 0, 0) self._init_menubar() options_widget = self._init_optionsarea() plot_splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) self.plot = pg.PlotWidget(self) plot_splitter.addWidget(self.plot) self.imview = pg.ImageView(self) plot_splitter.addWidget(self.imview) plot_splitter.setSizes([400, 400]) self.genct = gen_constants.GenConstants(plotter=self.plot, imview=self.imview) main_splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical) layout.addWidget(main_splitter) main_splitter.addWidget(plot_splitter) main_splitter.addWidget(options_widget) self.show()
def __init__(self, parent, **kwargs): super(AppWindow, self).__init__(parent) #, QtCore.Qt.WindowStaysOnTopHint) self.addshortcut = QtWidgets.QShortcut(QtGui.QKeySequence("3"), self) self.addshortcut.activated.connect(self.make3D) self.regions = kwargs.get('regions', None) self.short2d = QtWidgets.QShortcut(QtGui.QKeySequence("2"), self) self.short2d.activated.connect(self.make2D) self.saveShortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+S"), self) self.saveShortcut.activated.connect(self.saveAll) self.setupUi(self) self.plot = pg.PlotWidget() self.curve = pg.PlotCurveItem( ) #name = name);C.setPen(color=col, width=3) self.plot.addItem(self.curve) self.exporter = PQG_ImageExporter(self.plot.plotItem) #3D Plot try: self.plot3D = plot3DTools.AppWindow() except: pass #2D plot (surface) self.win = QtGui.QMainWindow() self.win.resize(800, 800) imv = pg.ImageView() self.win.setCentralWidget(imv) ## Create random 3D data set with noisy signals img = pg.gaussianFilter(np.random.normal(size=(200, 200)), (5, 5)) * 20 + 100 img = img[np.newaxis, :, :] decay = np.exp(-np.linspace(0, 0.3, 100))[:, np.newaxis, np.newaxis] data = np.random.normal(size=(100, 200, 200)) data += img * decay data += 2 ## Add time-varying signal sig = np.zeros(data.shape[0]) sig[30:] += np.exp(-np.linspace(1, 10, 70)) sig[40:] += np.exp(-np.linspace(1, 10, 60)) sig[70:] += np.exp(-np.linspace(1, 10, 30)) sig = sig[:, np.newaxis, np.newaxis] * 3 data[:, 50:60, 30:40] += sig ## Display the data and assign each frame a time value from 1.0 to 3.0 imv.setImage(data, xvals=np.linspace(1., 3., data.shape[0])) ## Set a custom color map colors = [(0, 0, 0), (45, 5, 61), (84, 42, 55), (150, 87, 60), (208, 171, 141), (255, 255, 255)] cmap = pg.ColorMap(pos=np.linspace(0.0, 1.0, 6), color=colors) imv.setColorMap(cmap) self.makeMenu()
def __init__(self, parent=None, exp_dict=None): display( HTML( '<span style="font-size: 20px; color:blue">Check UI that poped up \ (maybe hidden behind this browser!)</span>')) self.exp_dict = exp_dict QMainWindow.__init__(self, parent=parent) self.ui = UiMainWindow() self.ui.setupUi(self) self.init_statusbar() self.setWindowTitle("Display Images for Selected Metadata Range") self.ui.image_view = pg.ImageView() self.ui.image_view.ui.roiBtn.hide() self.ui.image_view.ui.menuBtn.hide() top_layout = QtGui.QVBoxLayout() top_layout.addWidget(self.ui.image_view) self.ui.widget.setLayout(top_layout) self.init_widgets() # self.integrate_images() # self.display_image() self.init_table() self.init_display()
def setup_figure(self): """ Runs once during App initialization, after setup() This is the place to make all graphical interface initializations, build plots, etc. """ # connect ui widgets to measurement/hardware settings or functions self.ui.start_pushButton.clicked.connect(self.start) self.ui.interrupt_pushButton.clicked.connect(self.interrupt) self.settings.save_h5.connect_to_widget(self.ui.save_h5_checkBox) # connect ui widgets of live settings self.settings.auto_levels.connect_to_widget( self.ui.autoLevels_checkBox) self.settings.auto_range.connect_to_widget(self.ui.autoRange_checkBox) self.settings.level_min.connect_to_widget( self.ui.min_doubleSpinBox ) #spinBox doesn't work nut it would be better self.settings.level_max.connect_to_widget( self.ui.max_doubleSpinBox ) #spinBox doesn't work nut it would be better # Set up pyqtgraph graph_layout in the UI self.imv = pg.ImageView() self.ui.plot_groupBox.layout().addWidget(self.imv)
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) widget = QtGui.QWidget(self) self.setCentralWidget(widget) self.frame1 = pg.ImageView(self) self.frame1.ui.roiBtn.hide() self.frame1.ui.menuBtn.hide() chop_btn = QtGui.QPushButton("Chop Stack", self) chop_btn.clicked.connect(self.chop) chop_btn.setToolTip( 'Chop the stack in 3 parts: before, during and after mitosis') chop_btn.setFixedSize(110, 17) layout = QtGui.QVBoxLayout(widget) layout.addWidget(self.frame1) layout.addWidget(chop_btn) self.setGeometry(100, 100, 600, 400) self.setWindowTitle('SegmentTrack4MemoryGUI') # self.setWindowIcon(QtGui.QIcon('DrosophilaIcon.png')) self.show()
def __init__(self, parent=None, o_norm=None): display( HTML( '<span style="font-size: 20px; color:blue">Check UI that poped up \ (maybe hidden behind this browser!)</span>')) if o_norm: self.o_norm = o_norm #self.list_files = self.o_norm.data['sample']['file_name'] #self.list_data = self.o_norm.data['sample']['data'] QMainWindow.__init__(self, parent=parent) self.ui = UiMainWindow() self.ui.setupUi(self) self.init_statusbar() self.setWindowTitle("Background ROI Selection Tool") self.ui.image_view = pg.ImageView() self.ui.image_view.ui.roiBtn.hide() self.ui.image_view.ui.menuBtn.hide() top_layout = QtGui.QVBoxLayout() top_layout.addWidget(self.ui.image_view) self.ui.widget.setLayout(top_layout) self.init_widgets() self.integrate_images() self.display_image()
def __init__(self, data): if data.any(): self.data = data # Interpret image data as row-major instead of col-major pg.setConfigOptions(imageAxisOrder='col-major') self.imv = pg.ImageView() # self.imv.view.setBackgroundColor('#f0f0f0') self.imv.timeLine.setPen('y', width=10) self.imv.ui.splitter.setChildrenCollapsible(False) self.imv.ui.splitter.setStretchFactor(8,1) self.imv.timeLine.setHoverPen('r', width=12) self.imv.view.setMenuEnabled(False) roi = self.imv.getRoiPlot() slider = roi.plotItem.getViewWidget() slider.setMaximumHeight(60) roi.plotItem.setMenuEnabled(False) ## Display the data and assign each frame a time value from 1.0 to 3.0 self.imv.setImage(self.data, xvals=np.linspace(1,self.data.shape[0] , self.data.shape[0], dtype = 'int32')) ## Set a custom color map colors = [ (0, 0, 0), (45, 5, 61), (84, 42, 55), (150, 87, 60), (208, 171, 141), (255, 255, 255) ] self.cmap = pg.ColorMap(pos=np.linspace(0.0, 1.0, 6), color=colors) self.imv.setColorMap(self.cmap) self.imv.setCurrentIndex(72) self.imv.ui.roiBtn.hide() self.imv.ui.menuBtn.hide()
def diffshow(image): """ Display an image (from an array or from a file) in an interactive window. This function requires `PyQtGraph` to be importable. These are optional dependencies. Parameters ---------- image : path-like or array-like Image file name or array-like. Raises ------ ImportError : if `PyQtGraph` is not available. Notes ----- All file formats supported by ``skued.diffread`` are also supported by this function. """ if not WITH_PYQTGRAPH: raise ImportError('PyQtGraph is not installed.') if isinstance(image, (str, Path)): image = diffread(image) app = pg.QtGui.QApplication([]) viewer = pg.ImageView() viewer.setImage(image) viewer.setWindowTitle('Scikit-UED Diffraction Viewer') viewer.show() app.exec_()
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)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(800, 600) self.setLayout(QtWidgets.QGridLayout()) # self.layout().setFocusPolicy(0) self.widges = [] for i in range(self.data.num_c): self.widges.append([]) for y in range(2): w1 = pg.ImageView(self) # w1.mousePressEvent = self.printCursor self.widges[i].append(w1) self.layout().addWidget(w1, i, y) # self.layout().addWidget(la) # gradients for temp = ‘thermal’, ‘flame’, ‘yellowy’, ‘bipolar’, ‘spectrum’, ‘cyclic’, ‘greyclip’, ‘grey’ #Set temperature graph style for y in range(2): self.widges[0][y].setPredefinedGradient('thermal') self.showFigures() self.t = 0 self.paused = False self.ended = False self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.draw) self.timer.start(16)
def __init__(self, parent=None, model_file="", data_range = [0, 0]): QtGui.QWidget.__init__( self, parent=parent) self.setContentsMargins(0, 0, 0, 0) self.data_range = data_range self.setAcceptDrops(True) self.layout = QtGui.QVBoxLayout() self.setLayout(self.layout) #self.graphicsView = pg.GraphicsLayoutWidget() #self.view = self.graphicsView.addViewBox() #self.imageItem = pg.ImageItem(border='w') #self.view.addItem(self.imageItem) self.imageItem = pg.ImageView() self.imageItem.getView().setAspectLocked(False) self.layout.addWidget(self.imageItem) self.layout.setMargin(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.targets_area=QtGui.QWidget() self.targets_layout=QtGui.QHBoxLayout() self.targets_area.setLayout(self.targets_layout) self.targets_area.setHidden(True) self.targets=[] self.layout.addWidget(self.targets_area) self.layout.setStretch(0, 20) data = np.random.normal(size=(600, 600), loc=1024, scale=64).astype(np.uint16) self.imageItem.setImage(data) self.source = None