l1 = v.addGrayscaleLayer(raw, name="raw", direct=True) l1.visible = direct colortable = [ QColor(0, 0, 0, 0).rgba(), QColor(255, 0, 0).rgba(), QColor(0, 255, 0).rgba(), QColor(0, 0, 255).rgba() ] s = ((raw // 64)).astype(numpy.uint8) def onClick(layer, pos5D, pos): print("here i am: ", pos5D, s[pos5D]) l2 = v.addColorTableLayer(s, clickFunctor=onClick, name="thresh", colortable=colortable, direct=direct) l2.colortableIsRandom = True l2.zeroIsTransparent = True l2.visible = False v.addClickableSegmentationLayer(s, "click it", direct=True) v.show() app.exec_()
do() cron.connect(cron, SIGNAL('timeout()'), do) ds = LazyflowSource( op.Output ) layer = ColortableLayer(ds,jet()) mainwin=Viewer() mainwin.layerstack.append(layer) mainwin.dataShape=(1,h,w,1,1) print mainwin.centralWidget() BoxContr=BoxController(mainwin.editor,op.Output,boxListModel) BoxInt=BoxInterpreter(mainwin.editor.navInterpret,mainwin.editor.posModel,BoxContr,mainwin.centralWidget()) mainwin.editor.setNavigationInterpreter(BoxInt) # boxListModel.boxRemoved.connect(BoxContr.deleteItem) LV.show() mainwin.show() app.exec_()
a = np.zeros(500 * 500).reshape(500, 500).astype(np.uint8) ii = np.random.randint(0, 500, 1) jj = np.random.randint(0, 500, 1) a[ii, jj] = 1 a = vigra.filters.discDilation(a, radius=20) array[:] = a.reshape(shape).view(np.ndarray) * 255 op.Input.setDirty() do() cron.timeout.connect(do) ds = createDataSource(op.Output) layer = ColortableLayer(ds, jet()) mainwin = Viewer() mainwin.layerstack.append(layer) mainwin.dataShape = (1, h, w, 1, 1) print(mainwin.centralWidget()) BoxContr = BoxController(mainwin.editor, op.Output, boxListModel) BoxInt = BoxInterpreter(mainwin.editor.navInterpret, mainwin.editor.posModel, BoxContr, mainwin.centralWidget()) mainwin.editor.setNavigationInterpreter(BoxInt) # boxListModel.boxRemoved.connect(BoxContr.deleteItem) LV.show() mainwin.show() app.exec_()
raw.shape = (1,)+raw.shape+(1,) def addLayers(v, direct): l1 = v.addGrayscaleLayer(raw, name="raw direct=%r" % direct, direct=direct) l1.visible = direct colortable = [QColor(0,0,0,0).rgba(), QColor(255,0,0).rgba()] l2 = v.addColorTableLayer((raw>128).astype(numpy.uint8), name="thresh direct=%r" % direct, colortable=colortable, direct=direct) l2.visible = direct return (l1, l2) directLayers = addLayers(v, True) indirectLayers = addLayers(v, False) b = QPushButton("direct mode (Ctrl+d)") b.setCheckable(True) b.setChecked(True) def onDirectModeToggled(direct): for l in directLayers: l.visible = direct for l in indirectLayers: l.visible = not direct b.toggled.connect(onDirectModeToggled) QShortcut(QKeySequence("Ctrl+d"), b, member=b.click, ambiguousMember=b.click) v.rightPaneLayout.addWidget(b) v.show() app.exec_()