本文整理匯總了Python中volumina.view3d.volumeRendering.RenderingManager.update方法的典型用法代碼示例。如果您正苦於以下問題:Python RenderingManager.update方法的具體用法?Python RenderingManager.update怎麽用?Python RenderingManager.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類volumina.view3d.volumeRendering.RenderingManager
的用法示例。
在下文中一共展示了RenderingManager.update方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
#.........這裏部分代碼省略.........
labelSlots = LabelingGui.LabelingSlots()
labelSlots.labelInput = topLevelOperatorView.LabelInputs
labelSlots.labelOutput = topLevelOperatorView.LabelImages
labelSlots.labelEraserValue = topLevelOperatorView.opLabelPipeline.opLabelArray.eraser
labelSlots.labelDelete = topLevelOperatorView.opLabelPipeline.DeleteLabel
labelSlots.labelNames = topLevelOperatorView.LabelNames
self.__cleanup_fns = []
# We provide our own UI file (which adds an extra control for interactive mode)
if labelingDrawerUiPath is None:
labelingDrawerUiPath = os.path.split(__file__)[0] + '/labelingDrawer.ui'
# Base class init
super(PixelClassificationGui, self).__init__( parentApplet, labelSlots, topLevelOperatorView, labelingDrawerUiPath )
self.topLevelOperatorView = topLevelOperatorView
self.interactiveModeActive = False
# Immediately update our interactive state
self.toggleInteractive( not self.topLevelOperatorView.FreezePredictions.value )
self._currentlySavingPredictions = False
self.labelingDrawerUi.labelListView.support_merges = True
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.initFeatSelDlg()
self.labelingDrawerUi.suggestFeaturesButton.clicked.connect(self.show_feature_selection_dialog)
self.featSelDlg.accepted.connect(self.update_features_from_dialog)
self.labelingDrawerUi.suggestFeaturesButton.setEnabled(False)
self.topLevelOperatorView.LabelNames.notifyDirty( bind(self.handleLabelSelectionChange) )
self.__cleanup_fns.append( partial( self.topLevelOperatorView.LabelNames.unregisterDirty, bind(self.handleLabelSelectionChange) ) )
self._initShortcuts()
self._bookmarks_window = BookmarksWindow(self, self.topLevelOperatorView)
# FIXME: We MUST NOT enable the render manager by default,
# since it will drastically slow down the app for large volumes.
# For now, we leave it off by default.
# To re-enable rendering, we need to allow the user to render a segmentation
# and then initialize the render manager on-the-fly.
# (We might want to warn the user if her volume is not small.)
self.render = False
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
示例2: Counting3dGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
class Counting3dGui(LabelingGui):
###########################################
### AppletGuiInterface Concrete Methods ###
###########################################
def centralWidget( self ):
return self
def reset(self):
# Base class first
super(Counting3dGui, self).reset()
# 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)
def viewerControlWidget(self):
return self._viewerControlUi
###########################################
###########################################
@traceLogged(traceLogger)
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
# 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(Counting3dGui, self).__init__( labelSlots, topLevelOperatorView, labelingDrawerUiPath )
self.op = topLevelOperatorView
#self.clickReporter.rightClickReceived.connect( self._handleEditorRightClick )
self.topLevelOperatorView = topLevelOperatorView
self.shellRequestSignal = shellRequestSignal
self.guiControlSignal = guiControlSignal
self.predictionSerializer = predictionSerializer
self.interactiveModeActive = False
self._currentlySavingPredictions = False
self.labelingDrawerUi.savePredictionsButton.clicked.connect(self.onSavePredictionsButtonClicked)
self.labelingDrawerUi.savePredictionsButton.setIcon( QIcon(ilastikIcons.Save) )
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._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
self.initCounting()
def initCounting(self):
self._addNewLabel()
self._addNewLabel()
self.labelingDrawerUi.SigmaLine.setText("1")
self.labelingDrawerUi.UnderBox.setRange(0,1000000)
self.labelingDrawerUi.UnderBox.setValue(1)
self.labelingDrawerUi.OverBox.setRange(0,1000000)
self.labelingDrawerUi.OverBox.setValue(1)
self.labelingDrawerUi.UnderBox.setKeyboardTracking(False)
self.labelingDrawerUi.OverBox.setKeyboardTracking(False)
self.labelingDrawerUi.EpsilonBox.setKeyboardTracking(False)
self.labelingDrawerUi.EpsilonBox.setDecimals(6)
for option in self.op.options:
print "option", option
self.labelingDrawerUi.SVROptions.addItem('+'.join(option.values()), (option,))
self.labelingDrawerUi.DebugButton.pressed.connect(self._debug)
#self.labelingDrawerUi.TrainButton.pressed.connect(self._train)
#self.labelingDrawerUi.PredictionButton.pressed.connect(self.updateDensitySum)
self.labelingDrawerUi.SVROptions.currentIndexChanged.connect(self._updateSVROptions)
self._updateSVROptions()
self.labelingDrawerUi.OverBox.valueChanged.connect(self._updateOverMult)
self.labelingDrawerUi.UnderBox.valueChanged.connect(self._updateUnderMult)
#.........這裏部分代碼省略.........
示例3: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
class CarvingGui(LabelingGui):
def __init__(self, parentApplet, topLevelOperatorView, drawerUiPath=None ):
self.topLevelOperatorView = topLevelOperatorView
#members
self._doneSegmentationLayer = None
self._showSegmentationIn3D = False
#self._showUncertaintyLayer = False
#end: members
labelingSlots = LabelingGui.LabelingSlots()
labelingSlots.labelInput = topLevelOperatorView.WriteSeeds
labelingSlots.labelOutput = topLevelOperatorView.opLabelArray.Output
labelingSlots.labelEraserValue = topLevelOperatorView.opLabelArray.EraserLabelValue
labelingSlots.labelNames = topLevelOperatorView.LabelNames
labelingSlots.labelDelete = topLevelOperatorView.opLabelArray.DeleteLabel
labelingSlots.maxLabelValue = topLevelOperatorView.opLabelArray.MaxLabelValue
# We provide our own UI file (which adds an extra control for interactive mode)
directory = os.path.split(__file__)[0]
if drawerUiPath is None:
drawerUiPath = os.path.join(directory, 'carvingDrawer.ui')
self.dialogdirCOM = os.path.join(directory, 'carvingObjectManagement.ui')
self.dialogdirSAD = os.path.join(directory, 'saveAsDialog.ui')
super(CarvingGui, self).__init__(parentApplet, labelingSlots, topLevelOperatorView, drawerUiPath)
self.labelingDrawerUi.currentObjectLabel.setText("<not saved yet>")
# Init special base class members
self.minLabelNumber = 2
self.maxLabelNumber = 2
mgr = ShortcutManager()
ActionInfo = ShortcutManager.ActionInfo
#set up keyboard shortcuts
mgr.register( "3", ActionInfo( "Carving",
"Run interactive segmentation",
"Run interactive segmentation",
self.labelingDrawerUi.segment.click,
self.labelingDrawerUi.segment,
self.labelingDrawerUi.segment ) )
# Disable 3D view by default
self.render = False
tagged_shape = defaultdict(lambda: 1)
tagged_shape.update( topLevelOperatorView.InputData.meta.getTaggedShape() )
is_3d = (tagged_shape['x'] > 1 and tagged_shape['y'] > 1 and tagged_shape['z'] > 1)
if is_3d:
try:
self._renderMgr = RenderingManager( self.editor.view3d )
self._shownObjects3D = {}
self.render = True
except:
self.render = False
# Segmentation is toggled on by default in _after_init, below.
# (We can't enable it until the layers are all present.)
self._showSegmentationIn3D = False
self._segmentation_3d_label = None
self.labelingDrawerUi.segment.clicked.connect(self.onSegmentButton)
self.labelingDrawerUi.segment.setEnabled(True)
self.topLevelOperatorView.Segmentation.notifyDirty( bind( self._update_rendering ) )
self.topLevelOperatorView.HasSegmentation.notifyValueChanged( bind( self._updateGui ) )
## uncertainty
#self.labelingDrawerUi.pushButtonUncertaintyFG.setEnabled(False)
#self.labelingDrawerUi.pushButtonUncertaintyBG.setEnabled(False)
#def onUncertaintyFGButton():
# logger.debug( "uncertFG button clicked" )
# pos = self.topLevelOperatorView.getMaxUncertaintyPos(label=2)
# self.editor.posModel.slicingPos = (pos[0], pos[1], pos[2])
#self.labelingDrawerUi.pushButtonUncertaintyFG.clicked.connect(onUncertaintyFGButton)
#def onUncertaintyBGButton():
# logger.debug( "uncertBG button clicked" )
# pos = self.topLevelOperatorView.getMaxUncertaintyPos(label=1)
# self.editor.posModel.slicingPos = (pos[0], pos[1], pos[2])
#self.labelingDrawerUi.pushButtonUncertaintyBG.clicked.connect(onUncertaintyBGButton)
#def onUncertaintyCombo(value):
# if value == 0:
# value = "none"
# self.labelingDrawerUi.pushButtonUncertaintyFG.setEnabled(False)
# self.labelingDrawerUi.pushButtonUncertaintyBG.setEnabled(False)
# self._showUncertaintyLayer = False
# else:
# if value == 1:
# value = "localMargin"
# elif value == 2:
# value = "exchangeCount"
# elif value == 3:
# value = "gabow"
#.........這裏部分代碼省略.........
示例4: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
#.........這裏部分代碼省略.........
def labelBackground():
self.selectLabel(0)
def labelObject():
self.selectLabel(1)
self._labelControlUi.labelListModel.allowRemove(False)
bg = QShortcut(QKeySequence("1"), self, member=labelBackground, ambiguousMember=labelBackground)
mgr.register("Carving", "Select background label", bg)
fg = QShortcut(QKeySequence("2"), self, member=labelObject, ambiguousMember=labelObject)
mgr.register("Carving", "Select object label", fg)
def layerIndexForName(name):
return self.layerstack.findMatchingIndex(lambda x: x.name == name)
def addLayerToggleShortcut(layername, shortcut):
def toggle():
row = layerIndexForName(layername)
self.layerstack.selectRow(row)
layer = self.layerstack[row]
layer.visible = not layer.visible
self.viewerControlWidget().layerWidget.setFocus()
shortcut = QShortcut(QKeySequence(shortcut), self, member=toggle, ambiguousMember=toggle)
mgr.register("Carving", "Toggle layer %s" % layername, shortcut)
addLayerToggleShortcut("done", "d")
addLayerToggleShortcut("segmentation", "s")
addLayerToggleShortcut("raw", "r")
addLayerToggleShortcut("pmap", "v")
addLayerToggleShortcut("hints","h")
'''
def updateLayerTimings():
s = "Layer timings:\n"
for l in self.layerstack:
s += "%s: %f sec.\n" % (l.name, l.averageTimePerTile)
self.labelingDrawerUi.layerTimings.setText(s)
t = QTimer(self)
t.setInterval(1*1000) # 10 seconds
t.start()
t.timeout.connect(updateLayerTimings)
'''
def makeColortable():
self._doneSegmentationColortable = [QColor(0,0,0,0).rgba()]
for i in range(254):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
self._doneSegmentationColortable.append(QColor(r,g,b).rgba())
self._doneSegmentationColortable[1:17] = colortables.default16
makeColortable()
self._doneSegmentationLayer = None
def onRandomizeColors():
if self._doneSegmentationLayer is not None:
print "randomizing colors ..."
makeColortable()
self._doneSegmentationLayer.colorTable = self._doneSegmentationColortable
if self.render and self._renderMgr.ready:
self._update_rendering()
#self.labelingDrawerUi.randomizeColors.clicked.connect(onRandomizeColors)
def handleEditorRightClick(self, position5d, globalWindowCoordinate):
names = self.topLevelOperatorView.opCarving.doneObjectNamesForPosition(position5d[1:4])
op = self.topLevelOperatorView.opCarving
示例5: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
class CarvingGui(LabelingGui):
def __init__(self, parentApplet, topLevelOperatorView, drawerUiPath=None ):
self.topLevelOperatorView = topLevelOperatorView
#members
self._doneSegmentationLayer = None
self._showSegmentationIn3D = False
self._showUncertaintyLayer = False
#end: members
labelingSlots = LabelingGui.LabelingSlots()
labelingSlots.labelInput = topLevelOperatorView.WriteSeeds
labelingSlots.labelOutput = topLevelOperatorView.opLabelArray.Output
labelingSlots.labelEraserValue = topLevelOperatorView.opLabelArray.EraserLabelValue
labelingSlots.labelNames = topLevelOperatorView.LabelNames
labelingSlots.labelDelete = topLevelOperatorView.opLabelArray.DeleteLabel
labelingSlots.maxLabelValue = topLevelOperatorView.opLabelArray.MaxLabelValue
labelingSlots.labelsAllowed = topLevelOperatorView.LabelsAllowed
# We provide our own UI file (which adds an extra control for interactive mode)
directory = os.path.split(__file__)[0]
if drawerUiPath is None:
drawerUiPath = os.path.join(directory, 'carvingDrawer.ui')
self.dialogdirCOM = os.path.join(directory, 'carvingObjectManagement.ui')
self.dialogdirSAD = os.path.join(directory, 'saveAsDialog.ui')
rawInputSlot = topLevelOperatorView.RawData
super(CarvingGui, self).__init__(parentApplet, labelingSlots, topLevelOperatorView, drawerUiPath, rawInputSlot)
self.labelingDrawerUi.currentObjectLabel.setText("<not saved yet>")
# Init special base class members
self.minLabelNumber = 2
self.maxLabelNumber = 2
mgr = ShortcutManager()
ActionInfo = ShortcutManager.ActionInfo
#set up keyboard shortcuts
mgr.register( "3", ActionInfo( "Carving",
"Run interactive segmentation",
"Run interactive segmentation",
self.labelingDrawerUi.segment.click,
self.labelingDrawerUi.segment,
self.labelingDrawerUi.segment ) )
try:
self.render = True
self._shownObjects3D = {}
self._renderMgr = RenderingManager(
renderer=self.editor.view3d.qvtk.renderer,
qvtk=self.editor.view3d.qvtk)
except:
self.render = False
# Segmentation is toggled on by default in _after_init, below.
# (We can't enable it until the layers are all present.)
self._showSegmentationIn3D = False
self._segmentation_3d_label = None
self.labelingDrawerUi.segment.clicked.connect(self.onSegmentButton)
self.labelingDrawerUi.segment.setEnabled(True)
self.topLevelOperatorView.Segmentation.notifyDirty( bind( self._update_rendering ) )
self.topLevelOperatorView.HasSegmentation.notifyValueChanged( bind( self._updateGui ) )
## uncertainty
self.labelingDrawerUi.pushButtonUncertaintyFG.setEnabled(False)
self.labelingDrawerUi.pushButtonUncertaintyBG.setEnabled(False)
def onUncertaintyFGButton():
logger.debug( "uncertFG button clicked" )
pos = self.topLevelOperatorView.getMaxUncertaintyPos(label=2)
self.editor.posModel.slicingPos = (pos[0], pos[1], pos[2])
self.labelingDrawerUi.pushButtonUncertaintyFG.clicked.connect(onUncertaintyFGButton)
def onUncertaintyBGButton():
logger.debug( "uncertBG button clicked" )
pos = self.topLevelOperatorView.getMaxUncertaintyPos(label=1)
self.editor.posModel.slicingPos = (pos[0], pos[1], pos[2])
self.labelingDrawerUi.pushButtonUncertaintyBG.clicked.connect(onUncertaintyBGButton)
def onUncertaintyCombo(value):
if value == 0:
value = "none"
self.labelingDrawerUi.pushButtonUncertaintyFG.setEnabled(False)
self.labelingDrawerUi.pushButtonUncertaintyBG.setEnabled(False)
self._showUncertaintyLayer = False
else:
if value == 1:
value = "localMargin"
elif value == 2:
value = "exchangeCount"
elif value == 3:
value = "gabow"
else:
raise RuntimeError("unhandled case '%r'" % value)
self.labelingDrawerUi.pushButtonUncertaintyFG.setEnabled(True)
self.labelingDrawerUi.pushButtonUncertaintyBG.setEnabled(True)
#.........這裏部分代碼省略.........
示例6: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
#.........這裏部分代碼省略.........
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)
self._renderMgr.removeObject(label)
self._update_rendering()
else:
label = self._renderMgr.addObject()
self._renderedLayers[clayer.name] = label
self._update_rendering()
if self.render:
layer.contexts.append(('Toggle 3D rendering', callback))
def setupLayers(self):
"""
Called by our base class when one of our data slots has changed.
This function creates a layer for each slot we want displayed in the volume editor.
"""
# Base class provides the label layer.
layers = super(PixelClassificationGui, self).setupLayers()
ActionInfo = ShortcutManager.ActionInfo
# Add the uncertainty estimate layer
uncertaintySlot = self.topLevelOperatorView.UncertaintyEstimate
if uncertaintySlot.ready():
uncertaintySrc = LazyflowSource(uncertaintySlot)
uncertaintyLayer = AlphaModulatedLayer( uncertaintySrc,
tintColor=QColor( Qt.cyan ),
range=(0.0, 1.0),
normalize=(0.0, 1.0) )
uncertaintyLayer.name = "Uncertainty"
uncertaintyLayer.visible = False
uncertaintyLayer.opacity = 1.0
uncertaintyLayer.shortcutRegistration = ( "u", ActionInfo( "Prediction Layers",
"Uncertainty",
"Show/Hide Uncertainty",
示例7: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
#.........這裏部分代碼省略.........
# 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()
self._renderedLayers[clayer.name] = label
self._update_rendering()
if self.render:
layer.contexts.append(('Toggle 3D rendering', callback))
def setupLayers(self):
"""
Called by our base class when one of our data slots has changed.
This function creates a layer for each slot we want displayed in the volume editor.
"""
# Base class provides the label layer.
layers = super(PixelClassificationGui, self).setupLayers()
# Add the uncertainty estimate layer
uncertaintySlot = self.topLevelOperatorView.UncertaintyEstimate
if uncertaintySlot.ready():
uncertaintySrc = LazyflowSource(uncertaintySlot)
uncertaintyLayer = AlphaModulatedLayer( uncertaintySrc,
tintColor=QColor( Qt.cyan ),
range=(0.0, 1.0),
normalize=(0.0, 1.0) )
uncertaintyLayer.name = "Uncertainty"
uncertaintyLayer.visible = False
uncertaintyLayer.opacity = 1.0
uncertaintyLayer.shortcutRegistration = (
"Prediction Layers",
"Show/Hide Uncertainty",
QShortcut( QKeySequence("u"), self.viewerControlWidget(), uncertaintyLayer.toggleVisible ),
uncertaintyLayer )
示例8: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
class CarvingGui(LabelingGui):
def __init__(self, topLevelOperatorView, drawerUiPath=None ):
self.topLevelOperatorView = topLevelOperatorView
labelingSlots = LabelingGui.LabelingSlots()
labelingSlots.labelInput = topLevelOperatorView.WriteSeeds
labelingSlots.labelOutput = topLevelOperatorView.opLabelArray.Output
labelingSlots.labelEraserValue = topLevelOperatorView.opLabelArray.EraserLabelValue
labelingSlots.labelDelete = topLevelOperatorView.opLabelArray.DeleteLabel
labelingSlots.maxLabelValue = topLevelOperatorView.opLabelArray.MaxLabelValue
labelingSlots.labelsAllowed = topLevelOperatorView.LabelsAllowed
# We provide our own UI file (which adds an extra control for interactive mode)
directory = os.path.split(__file__)[0]
if drawerUiPath is None:
drawerUiPath = os.path.join(directory, 'carvingDrawer.ui')
self.dialogdirCOM = os.path.join(directory, 'carvingObjectManagement.ui')
self.dialogdirSAD = os.path.join(directory, 'saveAsDialog.ui')
rawInputSlot = topLevelOperatorView.RawData
super(CarvingGui, self).__init__(labelingSlots, topLevelOperatorView, drawerUiPath, rawInputSlot)
# Init special base class members
self.minLabelNumber = 2
self.maxLabelNumber = 2
mgr = ShortcutManager()
#set up keyboard shortcuts
segmentShortcut = QShortcut(QKeySequence("3"), self, member=self.labelingDrawerUi.segment.click,
ambiguousMember=self.labelingDrawerUi.segment.click)
mgr.register("Carving", "Run interactive segmentation", segmentShortcut, self.labelingDrawerUi.segment)
self._doneSegmentationLayer = None
self._showSegmentationIn3D = False
#volume rendering
try:
self.render = True
self._shownObjects3D = {}
self._renderMgr = RenderingManager(
renderer=self.editor.view3d.qvtk.renderer,
qvtk=self.editor.view3d.qvtk)
except:
self.render = False
self.labelingDrawerUi.segment.clicked.connect(self.onSegmentButton)
self.labelingDrawerUi.segment.setEnabled(True)
self.topLevelOperatorView.Segmentation.notifyDirty( bind( self._update_rendering ) )
def onUncertaintyFGButton():
print "uncertFG button clicked"
pos = self.topLevelOperatorView.getMaxUncertaintyPos(label=2)
self.editor.posModel.slicingPos = (pos[0], pos[1], pos[2])
self.labelingDrawerUi.pushButtonUncertaintyFG.clicked.connect(onUncertaintyFGButton)
self.labelingDrawerUi.pushButtonUncertaintyFG.setEnabled(True)
def onUncertaintyBGButton():
print "uncertBG button clicked"
pos = self.topLevelOperatorView.getMaxUncertaintyPos(label=1)
self.editor.posModel.slicingPos = (pos[0], pos[1], pos[2])
self.labelingDrawerUi.pushButtonUncertaintyBG.clicked.connect(onUncertaintyBGButton)
self.labelingDrawerUi.pushButtonUncertaintyBG.setEnabled(True)
def onBackgroundPrioritySpin(value):
print "background priority changed to %f" % value
self.topLevelOperatorView.BackgroundPriority.setValue(value)
self.labelingDrawerUi.backgroundPrioritySpin.valueChanged.connect(onBackgroundPrioritySpin)
def onuncertaintyCombo(value):
if value == 0:
value = "none"
if value == 1:
value = "localMargin"
if value == 2:
value = "exchangeCount"
if value == 3:
value = "gabow"
print "uncertainty changed to %r" % value
self.topLevelOperatorView.UncertaintyType.setValue(value)
self.labelingDrawerUi.uncertaintyCombo.currentIndexChanged.connect(onuncertaintyCombo)
def onBackgroundPriorityDirty(slot, roi):
oldValue = self.labelingDrawerUi.backgroundPrioritySpin.value()
newValue = self.topLevelOperatorView.BackgroundPriority.value
if newValue != oldValue:
self.labelingDrawerUi.backgroundPrioritySpin.setValue(newValue)
self.topLevelOperatorView.BackgroundPriority.notifyDirty(onBackgroundPriorityDirty)
def onNoBiasBelowDirty(slot, roi):
oldValue = self.labelingDrawerUi.noBiasBelowSpin.value()
newValue = self.topLevelOperatorView.NoBiasBelow.value
if newValue != oldValue:
self.labelingDrawerUi.noBiasBelowSpin.setValue(newValue)
self.topLevelOperatorView.NoBiasBelow.notifyDirty(onNoBiasBelowDirty)
#.........這裏部分代碼省略.........
示例9: GraphCutsGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import update [as 別名]
class GraphCutsGui(LabelingGui):
"""
"""
###########################################
### AppletGuiInterface Concrete Methods ###
###########################################
def appletDrawer(self):
return self.getAppletDrawerUi()
def viewerControlWidget(self):
return self._viewerControlUi
###########################################
###########################################
@traceLogged(traceLogger)
def __init__(self, topLevelOperatorView):
"""
"""
with Tracer(traceLogger):
self.topLevelOperatorView = topLevelOperatorView
super(GraphCutsGui, self).__init__(self.topLevelOperatorView)
# 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
# Base class init
super(GraphCutsGui, self).__init__( labelSlots, topLevelOperatorView, labelingDrawerUiPath )
self.topLevelOperatorView = topLevelOperatorView
self.interactiveModeActive = False
self._currentlySavingPredictions = False
self.labelingDrawerUi.savePredictionsButton.clicked.connect(self.onSavePredictionsButtonClicked)
self.labelingDrawerUi.savePredictionsButton.setIcon( QIcon(ilastikIcons.Save) )
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._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
def initAppletDrawerUi(self):
with Tracer(traceLogger):
# Load the ui file (find it in our own directory)
localDir = os.path.split(__file__)[0]
self._drawer = uic.loadUi(localDir+"/drawer.ui")
layout = QVBoxLayout()
layout.setSpacing(0)
self._drawer.setLayout( layout )
thresholdWidget = ThresholdingWidget(self)
thresholdWidget.valueChanged.connect( self.handleThresholdGuiValuesChanged )
self._drawer.layout().addWidget( thresholdWidget )
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)
#.........這裏部分代碼省略.........