a[ii,jj]=1 a=vigra.filters.discDilation(a,radius=20) array[:]=a.reshape(shape).view(np.ndarray)*255 op.Input.setDirty() 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_()
mainwin.editor.brushingModel.erasingNumber = 0 def _handleSelection(int): if int == 0: mainwin.editor.brushingModel.setErasing() else: # mainwin.editor.brushingModel.disableErasing() mainwin.editor.brushingModel.setDrawnNumber(int) if int == 1: mainwin.editor.brushingModel.setBrushColor(QColor(255, 0, 0)) mainwin.editor.brushingModel.setBrushSize(1) else: mainwin.editor.brushingModel.setBrushSize(20) mainwin.editor.brushingModel.setBrushColor(QColor(0, 255, 0)) labelListModel.elementSelected.connect(_handleSelection) mainwin.layerstack.append(layer) mainwin.dataShape = (1, 500, 500, 1, 1) logger.debug(str(mainwin.centralWidget())) BoxContr = DotController(mainwin.editor.imageScenes[2], mainwin.editor.brushingController) BoxInt = DotInterpreter(mainwin.editor.navCtrl, mainwin.editor.brushingController, BoxContr) mainwin.editor.setNavigationInterpreter(BoxInt) labelListModel.select(1) LV.show() mainwin.show() app.exec_()
def _handleSelection(int): if int == 0: mainwin.editor.brushingModel.setErasing() else: #mainwin.editor.brushingModel.disableErasing() mainwin.editor.brushingModel.setDrawnNumber(int) if int == 1: mainwin.editor.brushingModel.setBrushColor(QColor(255, 0, 0)) mainwin.editor.brushingModel.setBrushSize(1) else: mainwin.editor.brushingModel.setBrushSize(20) mainwin.editor.brushingModel.setBrushColor(QColor(0, 255, 0)) labelListModel.elementSelected.connect(_handleSelection) mainwin.layerstack.append(layer) mainwin.dataShape = (1, 500, 500, 1, 1) logger.debug(str(mainwin.centralWidget())) BoxContr = DotController(mainwin.editor.imageScenes[2], mainwin.editor.brushingController) BoxInt = DotInterpreter(mainwin.editor.navCtrl, mainwin.editor.brushingController, BoxContr) mainwin.editor.setNavigationInterpreter(BoxInt) labelListModel.select(1) LV.show() mainwin.show() app.exec_()
def showStuff(raw_name, pred_viewer1, pred_viewer2, cutout_name, one_extra = None): # display the raw and annotations for cremi challenge data raw = vigra.impex.readHDF5(indir+datasets[raw_name], "data", order = 'C') # raw_old = vigra.readHDF5(indir+datasets["raw_bad"], "data", order = 'C') defect_prediction_128 = vigra.impex.readHDF5(indir+datasets[pred_viewer2], "data", order = 'C') defect_prediction_150 = vigra.impex.readHDF5(indir+datasets[pred_viewer1], "data", order = 'C') cutout_from_150_pred = vigra.impex.readHDF5(indir+datasets[cutout_name], "data", order = 'C') #################################################################################################################### # only used for fast testing stuff #change_one = vigra.readHDF5(indir+datasets["segmentation_on_equalized_image"], "data", order = 'C') #pdb.set_trace() #defect_prediction_150[1,:,:] = change_one[0,:,:,0] #################################################################################################################### # defect_prediction_150 = gt[..., 0] cutout = numpy.asarray(cutout_from_150_pred) rawdata = numpy.asarray(raw) # rawdata_old = numpy.asarray(raw_old) # op5ify # shape5d = rawdata.shape shape5d = (1,)+rawdata.shape+(1,) print shape5d, rawdata.shape, rawdata.dtype app = QApplication([]) v = Viewer() direct = False # layer for raw data rawdata = numpy.reshape(rawdata, shape5d) rawsource = ArraySource(rawdata) v.dataShape = shape5d lraw = GrayscaleLayer(rawsource, direct=direct) lraw.visible = True lraw.name = "raw" v.layerstack.append(lraw) # layer for cutout regions from raw data cutout = numpy.reshape(cutout, shape5d) cutoutsource = ArraySource(cutout) lcutout = GrayscaleLayer(cutoutsource, direct = direct) lcutout.visible = False lcutout.name = "cut_out" v.layerstack.append(lcutout) # layer for first prediction result defect_prediction_128 = numpy.reshape(defect_prediction_128, shape5d) synsource = ArraySource(defect_prediction_128) ct = create_random_16bit() ct[0] = 0 lsyn = ColortableLayer(synsource, ct) lsyn.name = pred_viewer2 lsyn.visible = False v.layerstack.append(lsyn) # layer for second prediction result segm = numpy.reshape(defect_prediction_150, shape5d) segsource = ArraySource(segm) ct = create_random_16bit() ct[0] = 0 lseg = ColortableLayer(segsource, ct) lseg.name = pred_viewer1 lseg.visible = False v.layerstack.append(lseg) if one_extra is None: v.showMaximized() app.exec_() if one_extra is not None: # layer for third prediction result extra_prediction = vigra.readHDF5(indir+datasets[one_extra], "data", order = 'C') extra_pred_reshaped = numpy.reshape(extra_prediction, shape5d) segsource = ArraySource(extra_pred_reshaped) ct = create_random_16bit() ct[0] = 0 # ct = create_default_16bit() lseg = ColortableLayer(segsource, ct) lseg.name = one_extra lseg.visible = False v.layerstack.append(lseg) v.showMaximized() app.exec_()
label_arr = numpy.zeros(SHAPE, dtype=numpy.uint8) ##----- app = QApplication(sys.argv) v = Viewer() data_src = ArraySource(data_arr) data_layer = GrayscaleLayer(data_src) data_layer.name = "Raw" data_layer.numberOfChannels = 1 label_src = ArraySinkSource(label_arr) label_layer = ColortableLayer(label_src, colorTable=default16_new, direct=False) label_layer.name = "Labels" label_layer.ref_object = None assert SHAPE == label_arr.shape == data_arr.shape v.dataShape = SHAPE v.layerstack.append(data_layer) v.layerstack.append(label_layer) v.editor.setLabelSink(label_src) v.editor.setInteractionMode("brushing") v.setWindowTitle("labeling") v.showMaximized() app.exec_()
def showStuff(raw_name, pred_viewer1, pred_viewer2, cutout_name, one_extra=None): # display the raw and annotations for cremi challenge data raw = vigra.impex.readHDF5(indir + datasets[raw_name], "data", order='C') # raw_old = vigra.readHDF5(indir+datasets["raw_bad"], "data", order = 'C') defect_prediction_128 = vigra.impex.readHDF5(indir + datasets[pred_viewer2], "data", order='C') defect_prediction_150 = vigra.impex.readHDF5(indir + datasets[pred_viewer1], "data", order='C') cutout_from_150_pred = vigra.impex.readHDF5(indir + datasets[cutout_name], "data", order='C') #################################################################################################################### # only used for fast testing stuff #change_one = vigra.readHDF5(indir+datasets["segmentation_on_equalized_image"], "data", order = 'C') #pdb.set_trace() #defect_prediction_150[1,:,:] = change_one[0,:,:,0] #################################################################################################################### # defect_prediction_150 = gt[..., 0] cutout = numpy.asarray(cutout_from_150_pred) rawdata = numpy.asarray(raw) # rawdata_old = numpy.asarray(raw_old) # op5ify # shape5d = rawdata.shape shape5d = (1, ) + rawdata.shape + (1, ) print shape5d, rawdata.shape, rawdata.dtype app = QApplication([]) v = Viewer() direct = False # layer for raw data rawdata = numpy.reshape(rawdata, shape5d) rawsource = ArraySource(rawdata) v.dataShape = shape5d lraw = GrayscaleLayer(rawsource, direct=direct) lraw.visible = True lraw.name = "raw" v.layerstack.append(lraw) # layer for cutout regions from raw data cutout = numpy.reshape(cutout, shape5d) cutoutsource = ArraySource(cutout) lcutout = GrayscaleLayer(cutoutsource, direct=direct) lcutout.visible = False lcutout.name = "cut_out" v.layerstack.append(lcutout) # layer for first prediction result defect_prediction_128 = numpy.reshape(defect_prediction_128, shape5d) synsource = ArraySource(defect_prediction_128) ct = create_random_16bit() ct[0] = 0 lsyn = ColortableLayer(synsource, ct) lsyn.name = pred_viewer2 lsyn.visible = False v.layerstack.append(lsyn) # layer for second prediction result segm = numpy.reshape(defect_prediction_150, shape5d) segsource = ArraySource(segm) ct = create_random_16bit() ct[0] = 0 lseg = ColortableLayer(segsource, ct) lseg.name = pred_viewer1 lseg.visible = False v.layerstack.append(lseg) if one_extra is None: v.showMaximized() app.exec_() if one_extra is not None: # layer for third prediction result extra_prediction = vigra.readHDF5(indir + datasets[one_extra], "data", order='C') extra_pred_reshaped = numpy.reshape(extra_prediction, shape5d) segsource = ArraySource(extra_pred_reshaped) ct = create_random_16bit() ct[0] = 0 # ct = create_default_16bit() lseg = ColortableLayer(segsource, ct) lseg.name = one_extra lseg.visible = False v.layerstack.append(lseg) v.showMaximized() app.exec_()