本文整理匯總了Python中volumina.view3d.volumeRendering.RenderingManager.setup方法的典型用法代碼示例。如果您正苦於以下問題:Python RenderingManager.setup方法的具體用法?Python RenderingManager.setup怎麽用?Python RenderingManager.setup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類volumina.view3d.volumeRendering.RenderingManager
的用法示例。
在下文中一共展示了RenderingManager.setup方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
#.........這裏部分代碼省略.........
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplets[0].topLevelOperator.innerOperators[0]
elif self.topLevelOperatorView.name=="OpPixelClassification1":
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplets[1].topLevelOperator.innerOperators[0]
elif self.topLevelOperatorView.name=="OpPixelClassification2":
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplets[2].topLevelOperator.innerOperators[0]
elif self.topLevelOperatorView.name=="OpPixelClassification3":
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplets[3].topLevelOperator.innerOperators[0]
else:
raise NotImplementedError
self.featSelDlg = FeatureSelectionDialog(thisOpFeatureSelection, self.topLevelOperatorView)
def show_feature_selection_dialog(self):
self.featSelDlg.exec_()
def update_features_from_dialog(self):
if self.topLevelOperatorView.name=="OpPixelClassification":
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplet.topLevelOperator.innerOperators[0]
elif self.topLevelOperatorView.name=="OpPixelClassification0":
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplets[0].topLevelOperator.innerOperators[0]
elif self.topLevelOperatorView.name=="OpPixelClassification1":
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplets[1].topLevelOperator.innerOperators[0]
elif self.topLevelOperatorView.name=="OpPixelClassification2":
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplets[2].topLevelOperator.innerOperators[0]
elif self.topLevelOperatorView.name=="OpPixelClassification3":
thisOpFeatureSelection = self.topLevelOperatorView.parent.featureSelectionApplets[3].topLevelOperator.innerOperators[0]
else:
raise NotImplementedError
thisOpFeatureSelection.SelectionMatrix.setValue(self.featSelDlg.selected_features_matrix)
thisOpFeatureSelection.SelectionMatrix.setDirty()
thisOpFeatureSelection.setupOutputs()
def initViewerControlUi(self):
localDir = os.path.split(__file__)[0]
self._viewerControlUi = uic.loadUi( os.path.join( localDir, "viewerControls.ui" ) )
# Connect checkboxes
def nextCheckState(checkbox):
checkbox.setChecked( not checkbox.isChecked() )
self._viewerControlUi.checkShowPredictions.nextCheckState = partial(nextCheckState, self._viewerControlUi.checkShowPredictions)
self._viewerControlUi.checkShowSegmentation.nextCheckState = partial(nextCheckState, self._viewerControlUi.checkShowSegmentation)
self._viewerControlUi.checkShowPredictions.clicked.connect( self.handleShowPredictionsClicked )
self._viewerControlUi.checkShowSegmentation.clicked.connect( self.handleShowSegmentationClicked )
# The editor's layerstack is in charge of which layer movement buttons are enabled
model = self.editor.layerStack
self._viewerControlUi.viewerControls.setupConnections(model)
def _initShortcuts(self):
mgr = ShortcutManager()
ActionInfo = ShortcutManager.ActionInfo
shortcutGroupName = "Predictions"
mgr.register( "p", ActionInfo( shortcutGroupName,
"Toggle Prediction",
"Toggle Prediction Layer Visibility",
self._viewerControlUi.checkShowPredictions.click,
self._viewerControlUi.checkShowPredictions,
self._viewerControlUi.checkShowPredictions ) )
mgr.register( "s", ActionInfo( shortcutGroupName,
"Toggle Segmentaton",
示例2: Counting3dGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
#.........這裏部分代碼省略.........
self.changedSigma = False
def _changedSigma(self, text):
self.changedSigma = True
def _updateEpsilon(self):
self.op.opTrain.Epsilon.setValue(self.labelingDrawerUi.EpsilonBox.value())
def _updateSVROptions(self):
index = self.labelingDrawerUi.SVROptions.currentIndex()
option = self.labelingDrawerUi.SVROptions.itemData(index).toPyObject()[0]
self.op.opTrain.SelectedOption.setValue(option)
def _debug(self):
import sitecustomize
sitecustomize.debug_trace()
@traceLogged(traceLogger)
def initViewerControlUi(self):
localDir = os.path.split(__file__)[0]
self._viewerControlUi = uic.loadUi( os.path.join( localDir, "viewerControls.ui" ) )
# Connect checkboxes
def nextCheckState(checkbox):
checkbox.setChecked( not checkbox.isChecked() )
self._viewerControlUi.checkShowPredictions.clicked.connect( self.handleShowPredictionsClicked )
self._viewerControlUi.checkShowSegmentation.clicked.connect( self.handleShowSegmentationClicked )
# The editor's layerstack is in charge of which layer movement buttons are enabled
model = self.editor.layerStack
self._viewerControlUi.viewerControls.setupConnections(model)
def _initShortcuts(self):
mgr = ShortcutManager()
shortcutGroupName = "Predictions"
togglePredictions = QShortcut( QKeySequence("p"), self, member=self._viewerControlUi.checkShowPredictions.click )
mgr.register( shortcutGroupName,
"Toggle Prediction Layer Visibility",
togglePredictions,
self._viewerControlUi.checkShowPredictions )
toggleSegmentation = QShortcut( QKeySequence("s"), self, member=self._viewerControlUi.checkShowSegmentation.click )
mgr.register( shortcutGroupName,
"Toggle Segmentaton Layer Visibility",
toggleSegmentation,
self._viewerControlUi.checkShowSegmentation )
toggleLivePredict = QShortcut( QKeySequence("l"), self, member=self.labelingDrawerUi.liveUpdateButton.toggle )
mgr.register( shortcutGroupName,
"Toggle Live Prediction Mode",
toggleLivePredict,
self.labelingDrawerUi.liveUpdateButton )
def _setup_contexts(self, layer):
def callback(pos, clayer=layer):
name = clayer.name
if name in self._renderedLayers:
label = self._renderedLayers.pop(name)
self._renderMgr.removeObject(label)
self._update_rendering()
else:
label = self._renderMgr.addObject()
示例3: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
#.........這裏部分代碼省略.........
window.finished.connect( onMeshesComplete )
# Kick off the save process and exit to the event loop
window.show()
QTimer.singleShot(0, partial(window.run, object_volume, [0]))
def handleEditorRightClick(self, position5d, globalWindowCoordinate):
names = self.topLevelOperatorView.doneObjectNamesForPosition(position5d[1:4])
op = self.topLevelOperatorView
# (Subclasses may override menu)
menu = self.labelingContextMenu(names,op,position5d)
if menu is not None:
menu.exec_(globalWindowCoordinate)
def _toggleSegmentation3D(self):
self._showSegmentationIn3D = not self._showSegmentationIn3D
if self._showSegmentationIn3D:
self._segmentation_3d_label = self._renderMgr.addObject()
else:
self._renderMgr.removeObject(self._segmentation_3d_label)
self._segmentation_3d_label = None
self._update_rendering()
def _update_rendering(self):
if not self.render:
return
op = self.topLevelOperatorView
if not self._renderMgr.ready:
shape = op.InputData.meta.shape[1:4]
self._renderMgr.setup(op.InputData.meta.shape[1:4])
# remove nonexistent objects
self._shownObjects3D = dict((k, v) for k, v in self._shownObjects3D.iteritems()
if k in op.MST.value.object_lut.keys())
lut = numpy.zeros(op.MST.value.nodeNum+1, dtype=numpy.int32)
for name, label in self._shownObjects3D.iteritems():
objectSupervoxels = op.MST.value.objects[name]
lut[objectSupervoxels] = label
if self._showSegmentationIn3D:
# Add segmentation as label, which is green
lut[:] = numpy.where( op.MST.value.getSuperVoxelSeg() == 2, self._segmentation_3d_label, lut )
import vigra
#with vigra.Timer("remapping"):
self._renderMgr.volume = lut[op.MST.value.supervoxelUint32] # (Advanced indexing)
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
op = self.topLevelOperatorView
ctable = self._doneSegmentationLayer.colorTable
for name, label in self._shownObjects3D.iteritems():
color = QColor(ctable[op.MST.value.object_names[name]])
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
if self._showSegmentationIn3D and self._segmentation_3d_label is not None:
self._renderMgr.setColor(self._segmentation_3d_label, (0.0, 1.0, 0.0)) # Green
def _getNext(self, slot, parentFun, transform=None):
示例4: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
#.........這裏部分代碼省略.........
menu.addAction("position %d %d %d" % (position5d[1], position5d[2], position5d[3]))
for name in names:
menu.addAction("edit %s" % name)
menu.addAction("delete %s" % name)
if self.render:
if name in self._shownObjects3D:
menu.addAction("remove %s from 3D view" % name)
else:
menu.addAction("show 3D %s" % name)
act = menu.exec_(globalWindowCoordinate)
for name in names:
if act is not None and act.text() == "edit %s" %name:
op.loadObject(name)
elif act is not None and act.text() =="delete %s" % name:
op.deleteObject(name)
if self.render and self._renderMgr.ready:
self._update_rendering()
elif act is not None and act.text() == "show 3D %s" % name:
label = self._renderMgr.addObject()
self._shownObjects3D[name] = label
self._update_rendering()
elif act is not None and act.text() == "remove %s from 3D view" % name:
label = self._shownObjects3D.pop(name)
self._renderMgr.removeObject(label)
self._update_rendering()
def _update_rendering(self):
if not self.render:
return
op = self.topLevelOperatorView.opCarving
if not self._renderMgr.ready:
self._renderMgr.setup(op.MST.value.raw.shape)
# remove nonexistent objects
self._shownObjects3D = dict((k, v) for k, v in self._shownObjects3D.iteritems()
if k in op.MST.value.object_lut.keys())
lut = numpy.zeros(len(op.MST.value.objects.lut), dtype=numpy.int32)
for name, label in self._shownObjects3D.iteritems():
objectSupervoxels = op.MST.value.object_lut[name]
lut[objectSupervoxels] = label
self._renderMgr.volume = lut[op.MST.value.regionVol]
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
op = self.topLevelOperatorView.opCarving
ctable = self._doneSegmentationLayer.colorTable
for name, label in self._shownObjects3D.iteritems():
color = QColor(ctable[op.MST.value.object_names[name]])
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
def getNextLabelName(self):
l = len(self._labelControlUi.labelListModel)
if l == 0:
return "Background"
else:
return "Object"
def appletDrawers(self):
示例5: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
#.........這裏部分代碼省略.........
showSeg3DAction.triggered.connect( self._toggleSegmentation3D )
if op.dataIsStorable():
menu.addAction("Save object").triggered.connect( self.onSaveButton )
menu.addAction("Browse objects").triggered.connect( self.onShowObjectNames )
menu.addAction("Segment").triggered.connect( self.onSegmentButton )
menu.addAction("Clear").triggered.connect( self.topLevelOperatorView.clearCurrentLabeling )
return menu
def handleEditorRightClick(self, position5d, globalWindowCoordinate):
names = self.topLevelOperatorView.doneObjectNamesForPosition(position5d[1:4])
op = self.topLevelOperatorView
# (Subclasses may override menu)
menu = self.labelingContextMenu(names,op,position5d)
if menu is not None:
menu.exec_(globalWindowCoordinate)
def _toggleSegmentation3D(self):
self._showSegmentationIn3D = not self._showSegmentationIn3D
if self._showSegmentationIn3D:
self._segmentation_3d_label = self._renderMgr.addObject()
else:
self._renderMgr.removeObject(self._segmentation_3d_label)
self._segmentation_3d_label = None
self._update_rendering()
def _update_rendering(self):
if not self.render:
return
op = self.topLevelOperatorView
if not self._renderMgr.ready:
self._renderMgr.setup(op.InputData.meta.shape[1:4])
# remove nonexistent objects
self._shownObjects3D = dict((k, v) for k, v in self._shownObjects3D.iteritems()
if k in op.MST.value.object_lut.keys())
lut = numpy.zeros(len(op.MST.value.objects.lut), dtype=numpy.int32)
for name, label in self._shownObjects3D.iteritems():
objectSupervoxels = op.MST.value.object_lut[name]
lut[objectSupervoxels] = label
if self._showSegmentationIn3D:
# Add segmentation as label, which is green
lut[:] = numpy.where( op.MST.value.segmentation.lut == 2, self._segmentation_3d_label, lut )
self._renderMgr.volume = lut[op.MST.value.regionVol] # (Advanced indexing)
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
op = self.topLevelOperatorView
ctable = self._doneSegmentationLayer.colorTable
for name, label in self._shownObjects3D.iteritems():
color = QColor(ctable[op.MST.value.object_names[name]])
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
if self._showSegmentationIn3D and self._segmentation_3d_label is not None:
self._renderMgr.setColor(self._segmentation_3d_label, (0.0, 1.0, 0.0)) # Green
def _getNext(self, slot, parentFun, transform=None):
numLabels = self.labelListData.rowCount()
示例6: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
#.........這裏部分代碼省略.........
self._renderMgr = None
self._renderedLayers = {} # (layer name, label number)
# Always off for now (see note above)
if self.render:
try:
self._renderMgr = RenderingManager( self.editor.view3d )
except:
self.render = False
# toggle interactive mode according to freezePredictions.value
self.toggleInteractive(not self.topLevelOperatorView.FreezePredictions.value)
def FreezePredDirty():
self.toggleInteractive(not self.topLevelOperatorView.FreezePredictions.value)
# listen to freezePrediction changes
self.topLevelOperatorView.FreezePredictions.notifyDirty( bind(FreezePredDirty) )
self.__cleanup_fns.append( partial( self.topLevelOperatorView.FreezePredictions.unregisterDirty, bind(FreezePredDirty) ) )
def initViewerControlUi(self):
localDir = os.path.split(__file__)[0]
self._viewerControlUi = uic.loadUi( os.path.join( localDir, "viewerControls.ui" ) )
# Connect checkboxes
def nextCheckState(checkbox):
checkbox.setChecked( not checkbox.isChecked() )
self._viewerControlUi.checkShowPredictions.nextCheckState = partial(nextCheckState, self._viewerControlUi.checkShowPredictions)
self._viewerControlUi.checkShowSegmentation.nextCheckState = partial(nextCheckState, self._viewerControlUi.checkShowSegmentation)
self._viewerControlUi.checkShowPredictions.clicked.connect( self.handleShowPredictionsClicked )
self._viewerControlUi.checkShowSegmentation.clicked.connect( self.handleShowSegmentationClicked )
# The editor's layerstack is in charge of which layer movement buttons are enabled
model = self.editor.layerStack
self._viewerControlUi.viewerControls.setupConnections(model)
def _initShortcuts(self):
mgr = ShortcutManager()
ActionInfo = ShortcutManager.ActionInfo
shortcutGroupName = "Predictions"
mgr.register( "p", ActionInfo( shortcutGroupName,
"Toggle Prediction",
"Toggle Prediction Layer Visibility",
self._viewerControlUi.checkShowPredictions.click,
self._viewerControlUi.checkShowPredictions,
self._viewerControlUi.checkShowPredictions ) )
mgr.register( "s", ActionInfo( shortcutGroupName,
"Toggle Segmentaton",
"Toggle Segmentaton Layer Visibility",
self._viewerControlUi.checkShowSegmentation.click,
self._viewerControlUi.checkShowSegmentation,
self._viewerControlUi.checkShowSegmentation ) )
mgr.register( "l", ActionInfo( shortcutGroupName,
"Live Prediction",
"Toggle Live Prediction Mode",
self.labelingDrawerUi.liveUpdateButton.toggle,
self.labelingDrawerUi.liveUpdateButton,
self.labelingDrawerUi.liveUpdateButton ) )
def _setup_contexts(self, layer):
def callback(pos, clayer=layer):
name = clayer.name
if name in self._renderedLayers:
label = self._renderedLayers.pop(name)
示例7: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
class PixelClassificationGui(LabelingGui):
###########################################
### AppletGuiInterface Concrete Methods ###
###########################################
def centralWidget( self ):
return self
def stopAndCleanUp(self):
# Base class first
super(PixelClassificationGui, self).stopAndCleanUp()
# Ensure that we are NOT in interactive mode
self.labelingDrawerUi.liveUpdateButton.setChecked(False)
self._viewerControlUi.checkShowPredictions.setChecked(False)
self._viewerControlUi.checkShowSegmentation.setChecked(False)
self.toggleInteractive(False)
for fn in self.__cleanup_fns:
fn()
def viewerControlWidget(self):
return self._viewerControlUi
###########################################
###########################################
def __init__(self, topLevelOperatorView, shellRequestSignal, guiControlSignal, predictionSerializer ):
# Tell our base class which slots to monitor
labelSlots = LabelingGui.LabelingSlots()
labelSlots.labelInput = topLevelOperatorView.LabelInputs
labelSlots.labelOutput = topLevelOperatorView.LabelImages
labelSlots.labelEraserValue = topLevelOperatorView.opLabelPipeline.opLabelArray.eraser
labelSlots.labelDelete = topLevelOperatorView.opLabelPipeline.opLabelArray.deleteLabel
labelSlots.maxLabelValue = topLevelOperatorView.MaxLabelValue
labelSlots.labelsAllowed = topLevelOperatorView.LabelsAllowedFlags
labelSlots.LabelNames = topLevelOperatorView.LabelNames
self.__cleanup_fns = []
# We provide our own UI file (which adds an extra control for interactive mode)
labelingDrawerUiPath = os.path.split(__file__)[0] + '/labelingDrawer.ui'
# Base class init
super(PixelClassificationGui, self).__init__( labelSlots, topLevelOperatorView, labelingDrawerUiPath )
self.topLevelOperatorView = topLevelOperatorView
self.shellRequestSignal = shellRequestSignal
self.guiControlSignal = guiControlSignal
self.predictionSerializer = predictionSerializer
self.interactiveModeActive = False
# Immediately update our interactive state
self.toggleInteractive( not self.topLevelOperatorView.FreezePredictions.value )
self._currentlySavingPredictions = False
self.labelingDrawerUi.liveUpdateButton.setEnabled(False)
self.labelingDrawerUi.liveUpdateButton.setIcon( QIcon(ilastikIcons.Play) )
self.labelingDrawerUi.liveUpdateButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.labelingDrawerUi.liveUpdateButton.toggled.connect( self.toggleInteractive )
self.topLevelOperatorView.MaxLabelValue.notifyDirty( bind(self.handleLabelSelectionChange) )
self.__cleanup_fns.append( partial( self.topLevelOperatorView.MaxLabelValue.unregisterDirty, bind(self.handleLabelSelectionChange) ) )
self._initShortcuts()
try:
self.render = True
self._renderedLayers = {} # (layer name, label number)
self._renderMgr = RenderingManager(
renderer=self.editor.view3d.qvtk.renderer,
qvtk=self.editor.view3d.qvtk)
except:
self.render = False
# toggle interactive mode according to freezePredictions.value
self.toggleInteractive(not self.topLevelOperatorView.FreezePredictions.value)
def FreezePredDirty():
self.toggleInteractive(not self.topLevelOperatorView.FreezePredictions.value)
# listen to freezePrediction changes
self.topLevelOperatorView.FreezePredictions.notifyDirty( bind(FreezePredDirty) )
self.__cleanup_fns.append( partial( self.topLevelOperatorView.FreezePredictions.unregisterDirty, bind(FreezePredDirty) ) )
def initViewerControlUi(self):
localDir = os.path.split(__file__)[0]
self._viewerControlUi = uic.loadUi( os.path.join( localDir, "viewerControls.ui" ) )
# Connect checkboxes
def nextCheckState(checkbox):
checkbox.setChecked( not checkbox.isChecked() )
self._viewerControlUi.checkShowPredictions.nextCheckState = partial(nextCheckState, self._viewerControlUi.checkShowPredictions)
self._viewerControlUi.checkShowSegmentation.nextCheckState = partial(nextCheckState, self._viewerControlUi.checkShowSegmentation)
self._viewerControlUi.checkShowPredictions.clicked.connect( self.handleShowPredictionsClicked )
self._viewerControlUi.checkShowSegmentation.clicked.connect( self.handleShowSegmentationClicked )
# The editor's layerstack is in charge of which layer movement buttons are enabled
model = self.editor.layerStack
self._viewerControlUi.viewerControls.setupConnections(model)
#.........這裏部分代碼省略.........
示例8: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
#.........這裏部分代碼省略.........
showSeg3DAction.setChecked( self._showSegmentationIn3D )
showSeg3DAction.triggered.connect( self._toggleSegmentation3D )
if op.dataIsStorable():
menu.addAction("Save objects").triggered.connect( self.onSegmentButton )
menu.addAction("Browse objects").triggered.connect( self.topLevelOperatorView.clearCurrentLabeling )
menu.addAction("Segment").triggered.connect( self.onShowObjectNames )
menu.addAction("Clear").triggered.connect( self.onSaveAsButton )
return menu
def handleEditorRightClick(self, position5d, globalWindowCoordinate):
names = self.topLevelOperatorView.doneObjectNamesForPosition(position5d[1:4])
op = self.topLevelOperatorView
# (Subclasses may override menu)
menu = self.labelingContextMenu(names,op,position5d)
if menu is not None:
menu.exec_(globalWindowCoordinate)
def _toggleSegmentation3D(self):
self._showSegmentationIn3D = not self._showSegmentationIn3D
if self._showSegmentationIn3D:
self._segmentation_3d_label = self._renderMgr.addObject()
else:
self._renderMgr.removeObject(self._segmentation_3d_label)
self._update_rendering()
def _update_rendering(self):
if not self.render:
return
op = self.topLevelOperatorView
if not self._renderMgr.ready:
self._renderMgr.setup(op.InputData.meta.shape[1:4])
# remove nonexistent objects
self._shownObjects3D = dict((k, v) for k, v in self._shownObjects3D.iteritems()
if k in op.MST.value.object_lut.keys())
lut = numpy.zeros(len(op.MST.value.objects.lut), dtype=numpy.int32)
for name, label in self._shownObjects3D.iteritems():
objectSupervoxels = op.MST.value.object_lut[name]
lut[objectSupervoxels] = label
if self._showSegmentationIn3D:
# Add segmentation as label, which is green
lut[:] = numpy.where( op.MST.value.segmentation.lut == 2, self._segmentation_3d_label, lut )
self._renderMgr.volume = lut[op.MST.value.regionVol] # (Advanced indexing)
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
op = self.topLevelOperatorView
ctable = self._doneSegmentationLayer.colorTable
for name, label in self._shownObjects3D.iteritems():
color = QColor(ctable[op.MST.value.object_names[name]])
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
if self._showSegmentationIn3D:
self._renderMgr.setColor(self._segmentation_3d_label, (0.0, 1.0, 0.0)) # Green
def getNextLabelName(self):
示例9: GraphCutsGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setup [as 別名]
#.........這裏部分代碼省略.........
self._drawer.layout().addSpacerItem( QSpacerItem(0,0,vPolicy=QSizePolicy.Expanding) )
def updateDrawerFromOperator():
minValue, maxValue = (0,255)
if self.topLevelOperatorView.MinValue.ready():
minValue = self.topLevelOperatorView.MinValue.value
if self.topLevelOperatorView.MaxValue.ready():
maxValue = self.topLevelOperatorView.MaxValue.value
thresholdWidget.setValue(minValue, maxValue)
self.topLevelOperatorView.MinValue.notifyDirty( bind(updateDrawerFromOperator) )
self.topLevelOperatorView.MaxValue.notifyDirty( bind(updateDrawerFromOperator) )
updateDrawerFromOperator()
@traceLogged(traceLogger)
def initViewerControlUi(self):
localDir = os.path.split(__file__)[0]
self._viewerControlUi = uic.loadUi( os.path.join( localDir, "viewerControls.ui" ) )
# Connect checkboxes
def nextCheckState(checkbox):
checkbox.setChecked( not checkbox.isChecked() )
self._viewerControlUi.checkShowPredictions.nextCheckState = partial(nextCheckState, self._viewerControlUi.checkShowPredictions)
self._viewerControlUi.checkShowSegmentation.nextCheckState = partial(nextCheckState, self._viewerControlUi.checkShowSegmentation)
self._viewerControlUi.checkShowPredictions.clicked.connect( self.handleShowPredictionsClicked )
self._viewerControlUi.checkShowSegmentation.clicked.connect( self.handleShowSegmentationClicked )
# The editor's layerstack is in charge of which layer movement buttons are enabled
model = self.editor.layerStack
self._viewerControlUi.viewerControls.setupConnections(model)
def _initShortcuts(self):
mgr = ShortcutManager()
shortcutGroupName = "Predictions"
togglePredictions = QShortcut( QKeySequence("p"), self, member=self._viewerControlUi.checkShowPredictions.click )
mgr.register( shortcutGroupName,
"Toggle Prediction Layer Visibility",
togglePredictions,
self._viewerControlUi.checkShowPredictions )
toggleSegmentation = QShortcut( QKeySequence("s"), self, member=self._viewerControlUi.checkShowSegmentation.click )
mgr.register( shortcutGroupName,
"Toggle Segmentaton Layer Visibility",
toggleSegmentation,
self._viewerControlUi.checkShowSegmentation )
toggleLivePredict = QShortcut( QKeySequence("l"), self, member=self.labelingDrawerUi.liveUpdateButton.toggle )
mgr.register( shortcutGroupName,
"Toggle Live Prediction Mode",
toggleLivePredict,
self.labelingDrawerUi.liveUpdateButton )
def _setup_contexts(self, layer):
def callback(pos, clayer=layer):
name = clayer.name
if name in self._renderedLayers:
label = self._renderedLayers.pop(name)
self._renderMgr.removeObject(label)
self._update_rendering()
else:
label = self._renderMgr.addObject()