本文整理汇总了Python中volumina.layer.ColortableLayer类的典型用法代码示例。如果您正苦于以下问题:Python ColortableLayer类的具体用法?Python ColortableLayer怎么用?Python ColortableLayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ColortableLayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setupLayers
def setupLayers(self):
layers = []
opLane = self.topLevelOperatorView
# Supervoxels
watershedSlot = opLane.WatershedImage
if watershedSlot.ready():
colortable = []
for i in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
watershedLayer = ColortableLayer(LazyflowSource(watershedSlot), colortable)
watershedLayer.name = "Watershed"
watershedLayer.visible = False
watershedLayer.opacity = 1.0
layers.append(watershedLayer)
''' FIXME: disabled for 0.6 release
wsSourceSlot = opLane.WatershedSourceImage
if wsSourceSlot.ready():
wsSourceLayer = self.createStandardLayerFromSlot( wsSourceSlot )
wsSourceLayer.name = "Watershed Source"
wsSourceLayer.visible = False
wsSourceLayer.opacity = 1.0
layers.append( wsSourceLayer )
'''
filteredSlot = opLane.FilteredImage
if filteredSlot.ready():
filteredLayer = self.createStandardLayerFromSlot( filteredSlot )
filteredLayer.name = "Filtered Data"
filteredLayer.visible = False
filteredLayer.opacity = 1.0
layers.append( filteredLayer )
inputSlot = opLane.InputData
if inputSlot.ready():
inputLayer = self.createStandardLayerFromSlot( inputSlot )
inputLayer.name = "Input Data"
inputLayer.visible = True
inputLayer.opacity = 1.0
layers.append( inputLayer )
''' FIXME: disabled for 0.6 release
rawSlot = opLane.RawData
if rawSlot.ready():
rawLayer = self.createStandardLayerFromSlot( rawSlot )
rawLayer.name = "Raw Data"
rawLayer.visible = True
rawLayer.opacity = 1.0
layers.append( rawLayer )
'''
return layers
开发者ID:JensNRAD,项目名称:ilastik_public,代码行数:54,代码来源:preprocessingViewerGui.py
示例2: addFragmentSegmentationLayers
def addFragmentSegmentationLayers(mslot, name):
if mslot.ready():
for index, slot in enumerate(mslot):
if slot.ready():
raveler_label = slot.meta.selected_label
colortable = map(QColor.rgba, self._fragmentColors)
fragSegLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True)
fragSegLayer.name = "{} #{} ({})".format( name, index, raveler_label )
fragSegLayer.visible = False
fragSegLayer.opacity = 1.0
layers.append(fragSegLayer)
开发者ID:JaimeIvanCervantes,项目名称:ilastik,代码行数:11,代码来源:splitBodyPostprocessingGui.py
示例3: addFragmentSegmentationLayers
def addFragmentSegmentationLayers(mslot, name):
if mslot.ready():
for index, slot in enumerate(mslot):
if slot.ready():
raveler_label = slot.meta.selected_label
colortable = []
for i in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
colortable[0] = QColor(0,0,0,0).rgba()
fragSegLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True)
fragSegLayer.name = "{} #{} ({})".format( name, index, raveler_label )
fragSegLayer.visible = False
fragSegLayer.opacity = 1.0
layers.append(fragSegLayer)
开发者ID:christophdecker,项目名称:ilastik,代码行数:15,代码来源:splitBodySupervoxelExportGui.py
示例4: _add_segmentation_layer
def _add_segmentation_layer(self, data, name=None, visible=False):
'''
adds a segementation layer to the layerstack
:param data: numpy array (2D) containing the data
:param name: name of layer
:param visible: bool determining whether this layer should be set to visible
:return:
'''
assert len(data.shape) == 2
a, data_shape = createDataSource(data, True)
self.editor.dataShape = list(data_shape)
new_layer = ColortableLayer(a, self.colortable)
new_layer.visible = visible
new_layer.opacity = 0.5
if name is not None:
new_layer.name = name
self.layerstack.append(new_layer)
开发者ID:DerThorsten,项目名称:ilastik,代码行数:18,代码来源:FeatureSelectionDialog.py
示例5: setupLayers
def setupLayers( self ):
layers = []
self.translationsrc = self.mainOperator.TranslationVectorsDisplay
translationLayer = self.createStandardLayerFromSlot( self.translationsrc )
translationLayer.name = "Translation Vector"
translationLayer.opacity = 0.8
translationLayer.visible = False
layers.append(translationLayer)
ct = colortables.create_default_8bit()
ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
ct[1] = QColor(0,255,0,255).rgba() # foreground is green
self.warpedSrc = LazyflowSource( self.mainOperator.WarpedImage )
warpedLayer = ColortableLayer( self.warpedSrc, ct )
warpedLayer.name = "Translation Corrected Binary Image"
warpedLayer.visible = False
warpedLayer.opacity = 0.4
layers.append(warpedLayer)
ct = colortables.create_default_8bit()
ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
ct[1] = QColor(255,0,0,255).rgba() # foreground is read
self.binarySrc = LazyflowSource( self.mainOperator.BinaryImage )
binaryLayer = ColortableLayer( self.binarySrc, ct )
binaryLayer.name = "Binary Image"
binaryLayer.visible = True
binaryLayer.opacity = 0.8
layers.append(binaryLayer)
## raw data layer
self.rawsrc = LazyflowSource( self.mainOperator.RawImage )
rawLayer = GrayscaleLayer( self.rawsrc )
rawLayer.name = "Raw Image"
layers.insert( len(layers), rawLayer )
if self.topLevelOperatorView.TranslationVectors.meta.shape:
self.editor.dataShape = self.topLevelOperatorView.TranslationVectors.meta.shape
self.topLevelOperatorView.RawImage.notifyReady( self._onReady )
self.topLevelOperatorView.RawImage.notifyMetaChanged( self._onMetaChanged )
self._onParametersChanged()
self._drawer.methodBox.currentIndexChanged.connect(self._onMethodChanged)
self._drawer.templateSizeBox.valueChanged.connect(self._onMethodChanged)
self._drawer.maxTranslationBox.valueChanged.connect(self._onMethodChanged)
self._drawer.maxDiffValsBox.valueChanged.connect(self._onMethodChanged)
return layers
开发者ID:martinsch,项目名称:ilastik,代码行数:51,代码来源:opticalTranslationGui.py
示例6: setupLayers
def setupLayers(self):
layers = []
opLane = self.topLevelOperatorView
# Supervoxels
watershedSlot = opLane.WatershedImage
if watershedSlot.ready():
colortable = []
for i in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
watershedLayer = ColortableLayer(LazyflowSource(watershedSlot), colortable)
watershedLayer.name = "Watershed"
watershedLayer.visible = False
watershedLayer.opacity = 1.0
layers.append(watershedLayer)
filteredSlot = opLane.FilteredImage
if filteredSlot.ready():
filteredLayer = self.createStandardLayerFromSlot( filteredSlot )
filteredLayer.name = "Filtered Data"
filteredLayer.visible = False
filteredLayer.opacity = 1.0
layers.append( filteredLayer )
# Raw data
rawSlot = opLane.RawData
if rawSlot.ready():
rawLayer = self.createStandardLayerFromSlot( rawSlot )
rawLayer.name = "Raw Data"
rawLayer.visible = True
rawLayer.opacity = 1.0
layers.append( rawLayer )
return layers
开发者ID:bheuer,项目名称:ilastik,代码行数:36,代码来源:preprocessingViewerGui.py
示例7: setupLayers
def setupLayers( self ):
layers = []
def onButtonsEnabled(slot, roi):
currObj = self.topLevelOperatorView.opCarving.CurrentObjectName.value
hasSeg = self.topLevelOperatorView.opCarving.HasSegmentation.value
nzLB = self.topLevelOperatorView.opCarving.opLabeling.NonzeroLabelBlocks[:].wait()[0]
self.labelingDrawerUi.currentObjectLabel.setText("current object: %s" % currObj)
self.labelingDrawerUi.save.setEnabled(currObj != "" and hasSeg)
self.labelingDrawerUi.saveAs.setEnabled(currObj == "" and hasSeg)
#rethink this
#self.labelingDrawerUi.segment.setEnabled(len(nzLB) > 0)
#self.labelingDrawerUi.clear.setEnabled(len(nzLB) > 0)
self.topLevelOperatorView.opCarving.CurrentObjectName.notifyDirty(onButtonsEnabled)
self.topLevelOperatorView.opCarving.HasSegmentation.notifyDirty(onButtonsEnabled)
self.topLevelOperatorView.opCarving.opLabeling.NonzeroLabelBlocks.notifyDirty(onButtonsEnabled)
# Labels
labellayer, labelsrc = self.createLabelLayer(direct=True)
if labellayer is not None:
layers.append(labellayer)
# Tell the editor where to draw label data
self.editor.setLabelSink(labelsrc)
#uncertainty
uncert = self.topLevelOperatorView.opCarving.Uncertainty
if uncert.ready():
colortable = []
for i in range(256-len(colortable)):
r,g,b,a = i,0,0,i
colortable.append(QColor(r,g,b,a).rgba())
layer = ColortableLayer(LazyflowSource(uncert), colortable, direct=True)
layer.name = "uncertainty"
layer.visible = True
layer.opacity = 0.3
layers.append(layer)
#segmentation
seg = self.topLevelOperatorView.opCarving.Segmentation
#seg = self.topLevelOperatorView.opCarving.MST.value.segmentation
#temp = self._done_lut[self.MST.value.regionVol[sl[1:4]]]
if seg.ready():
#source = RelabelingArraySource(seg)
#source.setRelabeling(numpy.arange(256, dtype=numpy.uint8))
colortable = [QColor(0,0,0,0).rgba(), QColor(0,0,0,0).rgba(), QColor(0,255,0).rgba()]
for i in range(256-len(colortable)):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
layer = ColortableLayer(LazyflowSource(seg), colortable, direct=True)
layer.name = "segmentation"
layer.visible = True
layer.opacity = 0.3
layers.append(layer)
#done
done = self.topLevelOperatorView.opCarving.DoneObjects
if done.ready():
colortable = [QColor(0,0,0,0).rgba(), QColor(0,0,255).rgba()]
for i in range(254-len(colortable)):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
#have to use lazyflow because it provides dirty signals
layer = ColortableLayer(LazyflowSource(done), colortable, direct=True)
layer.name = "done"
layer.visible = False
layer.opacity = 0.5
layers.append(layer)
#hints
useLazyflow = True
ctable = [QColor(0,0,0,0).rgba(), QColor(255,0,0).rgba()]
ctable.extend( [QColor(255*random.random(), 255*random.random(), 255*random.random()) for x in range(254)] )
if useLazyflow:
hints = self.topLevelOperatorView.opCarving.HintOverlay
layer = ColortableLayer(LazyflowSource(hints), ctable, direct=True)
else:
hints = self.topLevelOperatorView.opCarving._hints
layer = ColortableLayer(ArraySource(hints), ctable, direct=True)
if not useLazyflow or hints.ready():
layer.name = "hints"
layer.visible = False
layer.opacity = 1.0
layers.append(layer)
#pmaps
useLazyflow = True
pmaps = self.topLevelOperatorView.opCarving._pmap
if pmaps is not None:
layer = GrayscaleLayer(ArraySource(pmaps), direct=True)
layer.name = "pmap"
layer.visible = False
layer.opacity = 1.0
layers.append(layer)
#done seg
#.........这里部分代码省略.........
开发者ID:fblumenthal,项目名称:ilastik,代码行数:101,代码来源:carvingGui.py
示例8: setupLayers
def setupLayers( self ):
logger.debug( "setupLayers" )
layers = []
def onButtonsEnabled(slot, roi):
currObj = self.topLevelOperatorView.CurrentObjectName.value
hasSeg = self.topLevelOperatorView.HasSegmentation.value
self.labelingDrawerUi.currentObjectLabel.setText(currObj)
self.labelingDrawerUi.save.setEnabled(hasSeg)
self.topLevelOperatorView.CurrentObjectName.notifyDirty(onButtonsEnabled)
self.topLevelOperatorView.HasSegmentation.notifyDirty(onButtonsEnabled)
self.topLevelOperatorView.opLabelArray.NonzeroBlocks.notifyDirty(onButtonsEnabled)
# Labels
labellayer, labelsrc = self.createLabelLayer(direct=True)
if labellayer is not None:
labellayer._allowToggleVisible = False
layers.append(labellayer)
# Tell the editor where to draw label data
self.editor.setLabelSink(labelsrc)
#uncertainty
#if self._showUncertaintyLayer:
# uncert = self.topLevelOperatorView.Uncertainty
# if uncert.ready():
# colortable = []
# for i in range(256-len(colortable)):
# r,g,b,a = i,0,0,i
# colortable.append(QColor(r,g,b,a).rgba())
# layer = ColortableLayer(LazyflowSource(uncert), colortable, direct=True)
# layer.name = "Uncertainty"
# layer.visible = True
# layer.opacity = 0.3
# layers.append(layer)
#segmentation
seg = self.topLevelOperatorView.Segmentation
#seg = self.topLevelOperatorView.MST.value.segmentation
#temp = self._done_lut[self.MST.value.supervoxelUint32[sl[1:4]]]
if seg.ready():
#source = RelabelingArraySource(seg)
#source.setRelabeling(numpy.arange(256, dtype=numpy.uint8))
colortable = [QColor(0,0,0,0).rgba(), QColor(0,0,0,0).rgba(), QColor(0,255,0).rgba()]
for i in range(256-len(colortable)):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
layer = ColortableLayer(LazyflowSource(seg), colortable, direct=True)
layer.name = "Segmentation"
layer.setToolTip("This layer displays the <i>current</i> segmentation. Simply add foreground and background " \
"labels, then press <i>Segment</i>.")
layer.visible = True
layer.opacity = 0.3
layers.append(layer)
#done
done = self.topLevelOperatorView.DoneObjects
if done.ready():
colortable = [QColor(0,0,0,0).rgba(), QColor(0,0,255).rgba()]
#have to use lazyflow because it provides dirty signals
layer = ColortableLayer(LazyflowSource(done), colortable, direct=True)
layer.name = "Completed segments (unicolor)"
layer.setToolTip("In order to keep track of which objects you have already completed, this layer " \
"shows <b>all completed object</b> in one color (<b>blue</b>). " \
"The reason for only one color is that for finding out which " \
"objects to label next, the identity of already completed objects is unimportant " \
"and destracting.")
layer.visible = False
layer.opacity = 0.5
layers.append(layer)
#done seg
doneSeg = self.topLevelOperatorView.DoneSegmentation
if doneSeg.ready():
layer = ColortableLayer(LazyflowSource(doneSeg), self._doneSegmentationColortable, direct=True)
layer.name = "Completed segments (one color per object)"
layer.setToolTip("<html>In order to keep track of which objects you have already completed, this layer " \
"shows <b>all completed object</b>, each with a random color.</html>")
layer.visible = False
layer.opacity = 0.5
self._doneSegmentationLayer = layer
layers.append(layer)
#supervoxel
sv = self.topLevelOperatorView.Supervoxels
if sv.ready():
colortable = []
for i in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
layer = ColortableLayer(LazyflowSource(sv), colortable, direct=True)
layer.name = "Supervoxels"
layer.setToolTip("<html>This layer shows the partitioning of the input image into <b>supervoxels</b>. The carving " \
"algorithm uses these tiny puzzle-piceces to piece together the segmentation of an " \
"object. Sometimes, supervoxels are too large and straddle two distinct objects " \
"(undersegmentation). In this case, it will be impossible to achieve the desired " \
#.........这里部分代码省略.........
开发者ID:JaimeIvanCervantes,项目名称:ilastik,代码行数:101,代码来源:carvingGui.py
示例9: setupLayers
def setupLayers(self):
layers = []
op = self.topLevelOperatorView
ravelerLabelsSlot = op.RavelerLabels
if ravelerLabelsSlot.ready():
colortable = []
for _ in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
ravelerLabelLayer = ColortableLayer(LazyflowSource(ravelerLabelsSlot), colortable, direct=True)
ravelerLabelLayer.name = "Raveler Labels"
ravelerLabelLayer.visible = False
ravelerLabelLayer.opacity = 0.4
layers.append(ravelerLabelLayer)
def addFragmentSegmentationLayers(mslot, name):
if mslot.ready():
for index, slot in enumerate(mslot):
if slot.ready():
raveler_label = slot.meta.selected_label
colortable = map(QColor.rgba, self._fragmentColors)
fragSegLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True)
fragSegLayer.name = "{} #{} ({})".format( name, index, raveler_label )
fragSegLayer.visible = False
fragSegLayer.opacity = 1.0
layers.append(fragSegLayer)
addFragmentSegmentationLayers( op.FragmentedBodies, "Saved Fragments" )
addFragmentSegmentationLayers( op.RelabeledFragments, "Relabeled Fragments" )
addFragmentSegmentationLayers( op.FilteredFragmentedBodies, "CC-Filtered Fragments" )
addFragmentSegmentationLayers( op.WatershedFilledBodies, "Watershed-filled Fragments" )
mslot = op.EditedRavelerBodies
for index, slot in enumerate(mslot):
if slot.ready():
raveler_label = slot.meta.selected_label
# 0=Black, 1=Transparent
colortable = [QColor(0, 0, 0).rgba(), QColor(0, 0, 0, 0).rgba()]
bodyMaskLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True)
bodyMaskLayer.name = "Raveler Body Mask #{} ({})".format( index, raveler_label )
bodyMaskLayer.visible = False
bodyMaskLayer.opacity = 1.0
layers.append(bodyMaskLayer)
finalSegSlot = op.FinalSegmentation
if finalSegSlot.ready():
colortable = []
for _ in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
finalLayer = ColortableLayer(LazyflowSource(finalSegSlot), colortable, direct=True)
finalLayer.name = "Final Segmentation"
finalLayer.visible = False
finalLayer.opacity = 0.4
layers.append(finalLayer)
inputSlot = op.InputData
if inputSlot.ready():
layer = GrayscaleLayer( LazyflowSource(inputSlot) )
layer.name = "WS Input"
layer.visible = False
layer.opacity = 1.0
layers.append(layer)
#raw data
rawSlot = self.topLevelOperatorView.RawData
rawLayer = None
if rawSlot.ready():
raw5D = self.topLevelOperatorView.RawData.value
rawLayer = GrayscaleLayer(ArraySource(raw5D), direct=True)
#rawLayer = GrayscaleLayer( LazyflowSource(rawSlot) )
rawLayer.name = "raw"
rawLayer.visible = True
rawLayer.opacity = 1.0
rawLayer.shortcutRegistration = ( "g", ShortcutManager.ActionInfo(
"Postprocessing",
"Raw Data to Top",
"Raw Data to Top",
partial(self._toggleRawDataPosition, rawLayer),
self.viewerControlWidget(),
rawLayer ) )
layers.append(rawLayer)
return layers
开发者ID:JaimeIvanCervantes,项目名称:ilastik,代码行数:86,代码来源:splitBodyPostprocessingGui.py
示例10: setupLayers
def setupLayers(self):
layers = []
op = self.topLevelOperatorView
ravelerLabelsSlot = op.RavelerLabels
if ravelerLabelsSlot.ready():
colortable = []
for _ in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
ravelerLabelLayer = ColortableLayer(LazyflowSource(ravelerLabelsSlot), colortable, direct=True)
ravelerLabelLayer.name = "Raveler Labels"
ravelerLabelLayer.visible = False
ravelerLabelLayer.opacity = 0.4
layers.append(ravelerLabelLayer)
supervoxelsSlot = op.Supervoxels
if supervoxelsSlot.ready():
colortable = []
for i in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
supervoxelsLayer = ColortableLayer(LazyflowSource(supervoxelsSlot), colortable)
supervoxelsLayer.name = "Input Supervoxels"
supervoxelsLayer.visible = False
supervoxelsLayer.opacity = 1.0
layers.append(supervoxelsLayer)
def addFragmentSegmentationLayers(mslot, name):
if mslot.ready():
for index, slot in enumerate(mslot):
if slot.ready():
raveler_label = slot.meta.selected_label
colortable = []
for i in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
colortable[0] = QColor(0,0,0,0).rgba()
fragSegLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True)
fragSegLayer.name = "{} #{} ({})".format( name, index, raveler_label )
fragSegLayer.visible = False
fragSegLayer.opacity = 1.0
layers.append(fragSegLayer)
addFragmentSegmentationLayers( op.MaskedSupervoxels, "Masked Supervoxels" )
addFragmentSegmentationLayers( op.FilteredMaskedSupervoxels, "Filtered Masked Supervoxels" )
addFragmentSegmentationLayers( op.HoleFilledSupervoxels, "Hole Filled Supervoxels" )
addFragmentSegmentationLayers( op.RelabeledSupervoxels, "Relabeled Supervoxels" )
mslot = op.EditedRavelerBodies
for index, slot in enumerate(mslot):
if slot.ready():
raveler_label = slot.meta.selected_label
# 0=Black, 1=Transparent
colortable = [QColor(0, 0, 0).rgba(), QColor(0, 0, 0, 0).rgba()]
bodyMaskLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True)
bodyMaskLayer.name = "Raveler Body Mask #{} ({})".format( index, raveler_label )
bodyMaskLayer.visible = False
bodyMaskLayer.opacity = 1.0
layers.append(bodyMaskLayer)
finalSegSlot = op.FinalSupervoxels
if finalSegSlot.ready():
colortable = []
for _ in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
finalLayer = ColortableLayer(LazyflowSource(finalSegSlot), colortable)
finalLayer.name = "Final Supervoxels"
finalLayer.visible = False
finalLayer.opacity = 0.4
layers.append(finalLayer)
inputSlot = op.InputData
if inputSlot.ready():
layer = GrayscaleLayer( LazyflowSource(inputSlot) )
layer.name = "WS Input"
layer.visible = False
layer.opacity = 1.0
layers.append(layer)
#raw data
rawSlot = self.topLevelOperatorView.RawData
if rawSlot.ready():
raw5D = self.topLevelOperatorView.RawData.value
layer = GrayscaleLayer(ArraySource(raw5D), direct=True)
#layer = GrayscaleLayer( LazyflowSource(rawSlot) )
layer.name = "raw"
layer.visible = True
layer.opacity = 1.0
layers.append(layer)
return layers
开发者ID:christophdecker,项目名称:ilastik,代码行数:94,代码来源:splitBodySupervoxelExportGui.py
示例11: setupLayers
def setupLayers(self):
layers = []
op = self.topLevelOperatorView
# Superpixels
if op.Superpixels.ready():
layer = ColortableLayer( LazyflowSource(op.Superpixels), self._sp_colortable )
layer.colortableIsRandom = True
layer.name = "Superpixels"
layer.visible = True
layer.opacity = 0.5
layers.append(layer)
del layer
# Debug layers
if op.debug_results:
for name, compressed_array in op.debug_results.items():
axiskeys = op.Superpixels.meta.getAxisKeys()[:-1] # debug images don't have a channel axis
permutation = map(lambda key: axiskeys.index(key) if key in axiskeys else None, 'txyzc')
arraysource = ArraySource( TransposedView(compressed_array, permutation) )
if compressed_array.dtype == np.uint32:
layer = ColortableLayer(arraysource, self._sp_colortable)
else:
layer = GrayscaleLayer(arraysource)
# TODO: Normalize? Maybe the drange should be included with the debug image.
layer.name = name
layer.visible = False
layer.opacity = 1.0
layers.append(layer)
del layer
# Threshold
if op.ThresholdedInput.ready():
layer = ColortableLayer( LazyflowSource(op.ThresholdedInput), self._threshold_colortable )
layer.name = "Thresholded Input"
layer.visible = True
layer.opacity = 1.0
layers.append(layer)
del layer
# Raw Data (grayscale)
if op.Input.ready():
layer = self._create_grayscale_layer_from_slot( op.Input, op.Input.meta.getTaggedShape()['c'] )
layer.name = "Input"
layer.visible = False
layer.opacity = 1.0
layers.append(layer)
del layer
# Raw Data (grayscale)
if op.RawData.ready():
layer = self.createStandardLayerFromSlot( op.RawData )
layer.name = "Raw Data"
layer.visible = True
layer.opacity = 1.0
layers.append(layer)
del layer
return layers
开发者ID:,项目名称:,代码行数:59,代码来源:
示例12: setupLayers
def setupLayers(self):
def findLayer(f, layerlist):
for l in layerlist:
if f(l):
return l
return None
layers = []
baseCarvingLayers = super(SplitBodyCarvingGui, self).setupLayers()
crosshairSlot = self.topLevelOperatorView.AnnotationCrosshairs
if crosshairSlot.ready():
# 0=Transparent, 1=pink
colortable = [QColor(0, 0, 0, 0).rgba(), QColor(236, 184, 201).rgba()]
crosshairLayer = ColortableLayer(LazyflowSource(crosshairSlot), colortable, direct=True)
crosshairLayer.name = "Annotation Points"
crosshairLayer.visible = True
crosshairLayer.opacity = 1.0
layers.append(crosshairLayer)
highlightedObjectSlot = self.topLevelOperatorView.CurrentRavelerObject
if highlightedObjectSlot.ready():
# 0=Transparent, 1=blue
colortable = [QColor(0, 0, 0, 0).rgba(), QColor(0, 0, 255).rgba()]
highlightedObjectLayer = ColortableLayer(LazyflowSource(highlightedObjectSlot), colortable, direct=True)
highlightedObjectLayer.name = "Current Raveler Object"
highlightedObjectLayer.visible = False
highlightedObjectLayer.opacity = 0.25
layers.append(highlightedObjectLayer)
remainingRavelerObjectSlot = self.topLevelOperatorView.CurrentRavelerObjectRemainder
if remainingRavelerObjectSlot.ready():
# 0=Transparent, 1=blue
colortable = [QColor(0, 0, 0, 0).rgba(), QColor(255, 0, 0).rgba()]
remainingObjectLayer = ColortableLayer(LazyflowSource(remainingRavelerObjectSlot), colortable, direct=True)
remainingObjectLayer.name = "Remaining Raveler Object"
remainingObjectLayer.visible = True
remainingObjectLayer.opacity = 0.25
layers.append(remainingObjectLayer)
fragmentSegSlot = self.topLevelOperatorView.CurrentFragmentSegmentation
if fragmentSegSlot.ready():
colortable = map(QColor.rgba, self._fragmentColors)
fragSegLayer = ColortableLayer(LazyflowSource(fragmentSegSlot), colortable, direct=True)
fragSegLayer.name = "Saved Fragments"
fragSegLayer.visible = True
fragSegLayer.opacity = 0.25
layers.append(fragSegLayer)
ravelerLabelsSlot = self.topLevelOperatorView.RavelerLabels
if ravelerLabelsSlot.ready():
colortable = []
for i in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
ravelerLabelLayer = ColortableLayer(LazyflowSource(ravelerLabelsSlot), colortable, direct=True)
ravelerLabelLayer.name = "Raveler Labels"
ravelerLabelLayer.visible = False
ravelerLabelLayer.opacity = 0.4
layers.append(ravelerLabelLayer)
maskedSegSlot = self.topLevelOperatorView.MaskedSegmentation
if maskedSegSlot.ready():
colortable = [QColor(0,0,0,0).rgba(), QColor(0,0,0,0).rgba(), QColor(0,255,0).rgba()]
maskedSegLayer = ColortableLayer(LazyflowSource(maskedSegSlot), colortable, direct=True)
maskedSegLayer.name = "Masked Segmentation"
maskedSegLayer.visible = True
maskedSegLayer.opacity = 0.3
layers.append(maskedSegLayer)
# Hide the original carving segmentation.
# TODO: Remove it from the list altogether?
carvingSeg = findLayer( lambda l: l.name == "segmentation", baseCarvingLayers )
if carvingSeg is not None:
carvingSeg.visible = False
def removeBaseLayer(layerName):
layer = findLayer(lambda l: l.name == layerName, baseCarvingLayers)
if layer:
baseCarvingLayers.remove(layer)
# Don't show carving layers that aren't relevant to the split-body workflow
removeBaseLayer( "uncertainty" )
removeBaseLayer( "done seg" )
removeBaseLayer( "pmap" )
removeBaseLayer( "hints" )
removeBaseLayer( "done" )
removeBaseLayer( "done" )
# Attach a shortcut to the raw data layer
if self.topLevelOperatorView.RawData.ready():
rawLayer = findLayer(lambda l: l.name == "raw", baseCarvingLayers)
assert rawLayer is not None, "Couldn't find the raw data layer. Did it's name change?"
rawLayer.shortcutRegistration = ( "Carving",
"Raw Data to Top",
QShortcut( QKeySequence("f"),
self.viewerControlWidget(),
partial(self._toggleRawDataPosition, rawLayer) ),
rawLayer )
#.........这里部分代码省略.........
开发者ID:JensNRAD,项目名称:ilastik_public,代码行数:101,代码来源:splitBodyCarvingGui.py
示例13: setupLayers
def setupLayers( self, currentImageIndex ):
layers = []
def onButtonsEnabled(slot, roi):
currObj = self._carvingApplet.topLevelOperator.opCarving[currentImageIndex].CurrentObjectName.value
hasSeg = self._carvingApplet.topLevelOperator.opCarving[currentImageIndex].HasSegmentation.value
nzLB = self._carvingApplet.topLevelOperator.opLabeling.NonzeroLabelBlocks[currentImageIndex][:].wait()[0]
self.labelingDrawerUi.currentObjectLabel.setText("current object: %s" % currObj)
self.labelingDrawerUi.save.setEnabled(currObj != "" and hasSeg)
self.labelingDrawerUi.saveAs.setEnabled(currObj == "" and hasSeg)
#rethink this
#self.labelingDrawerUi.segment.setEnabled(len(nzLB) > 0)
#self.labelingDrawerUi.clear.setEnabled(len(nzLB) > 0)
self._carvingApplet.topLevelOperator.opCarving[currentImageIndex].CurrentObjectName.notifyDirty(onButtonsEnabled)
self._carvingApplet.topLevelOperator.opCarving[currentImageIndex].HasSegmentation.notifyDirty(onButtonsEnabled)
self._carvingApplet.topLevelOperator.opLabeling.NonzeroLabelBlocks[currentImageIndex].notifyDirty(onButtonsEnabled)
# Labels
labellayer, labelsrc = self.createLabelLayer(currentImageIndex, direct=True)
if labellayer is not None:
layers.append(labellayer)
# Tell the editor where to draw label data
self.editor.setLabelSink(labelsrc)
#segmentation
seg = self._carvingApplet.topLevelOperator.opCarving.Segmentation[currentImageIndex]
#seg = self._carvingApplet.topLevelOperator.opCarving[0]._mst.segmentation
#temp = self._done_lut[self._mst.regionVol[sl[1:4]]]
if seg.ready():
#source = RelabelingArraySource(seg)
#source.setRelabeling(numpy.arange(256, dtype=numpy.uint8))
colortable = [QColor(0,0,0,0).rgba(), QColor(0,0,0,0).rgba(), QColor(0,255,0).rgba()]
for i in range(256-len(colortable)):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
#layer = DirectColorTableLayer(seg, colortable, lazyflow=True)
layer = ColortableLayer(LazyflowSource(seg), colortable, direct=True)
layer.name = "segmentation"
layer.visible = True
layer.opacity = 0.3
layers.append(layer)
#done
done = self._carvingApplet.topLevelOperator.opCarving.DoneObjects[currentImageIndex]
if done.ready():
colortable = [QColor(0,0,0,0).rgba(), QColor(0,0,255).rgba()]
for i in range(254-len(colortable)):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
#have to use lazyflow because it provides dirty signals
#layer = DirectColorTableLayer(done, colortable, lazyflow=True)
layer = ColortableLayer(LazyflowSource(done), colortable, direct=True)
layer.name = "done"
layer.visible = False
layer.opacity = 0.5
layers.append(layer)
doneSeg = self._carvingApplet.topLevelOperator.opCarving.DoneSegmentation[currentImageIndex]
if doneSeg.ready():
layer = ColortableLayer(LazyflowSource(doneSeg), self._doneSegmentationColortable, direct=True)
layer.name = "done seg"
layer.visible = False
layer.opacity = 0.5
self._doneSegmentationLayer = layer
layers.append(layer)
#supervoxel
sv = self._carvingApplet.topLevelOperator.opCarving.Supervoxels[currentImageIndex]
if sv.ready():
for i in range(256):
r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255)
colortable.append(QColor(r,g,b).rgba())
#layer = DirectColorTableLayer(sv, colortable, lazyflow=True)
layer = ColortableLayer(LazyflowSource(sv), colortable, direct=True)
layer.name = "supervoxels"
layer.visible = False
layer.opacity = 1.0
layers.append(layer)
#
# load additional layer: features / probability map
#
import h5py
f = h5py.File("pmap.h5")
pmap = f["data"].value
#
# here we load the actual raw data from an ArraySource rather than from a LazyflowSource for speed reasons
#
raw = self._carvingApplet.topLevelOperator.opCarving[0]._mst.raw
raw5D = numpy.zeros((1,)+raw.shape+(1,), dtype=raw.dtype)
raw5D[0,:,:,:,0] = raw[:,:,:]
#layer = DirectGrayscaleLayer(raw5D)
layer = GrayscaleLayer(ArraySource(raw5D), direct=True)
layer.name = "raw"
layer.visible = True
layer.opacity = 1.0
#.........这里部分代码省略.........
开发者ID:LimpingTwerp,项目名称:applet-workflows,代码行数:101,代码来源:carving.py
示例14: showStuff
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_()
开发者ID:soledis92,项目名称:Bachelor_Arbeit,代码行数:81,代码来源:view_cremi.py
示例15: setupLayers
def setupLayers( self ):
layers = []
def onButtonsEnabled(slot, roi):
|
请发表评论