本文整理汇总了Python中volumina.api.GrayscaleLayer类的典型用法代码示例。如果您正苦于以下问题:Python GrayscaleLayer类的具体用法?Python GrayscaleLayer怎么用?Python GrayscaleLayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GrayscaleLayer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _onReady
def _onReady( self, slot ):
if slot is self.mainOperator.RawImage:
if slot.meta.shape and not self.rawsrc:
self.rawsrc = LazyflowSource( self.mainOperator.RawImage )
layerraw = GrayscaleLayer( self.rawsrc )
layerraw.name = "Raw"
self.layerstack.append( layerraw )
开发者ID:jennyhong,项目名称:ilastik,代码行数:7,代码来源:manualTrackingGui.py
示例2: setupLayers
def setupLayers(self):
mainOperator = self.topLevelOperatorView
layers = []
if mainOperator.ObjectCenterImage.ready():
self.centerimagesrc = LazyflowSource(mainOperator.ObjectCenterImage)
redct = [0, QColor(255, 0, 0).rgba()]
layer = ColortableLayer(self.centerimagesrc, redct)
layer.name = "Object centers"
layer.setToolTip("Object center positions, marked with a little red cross")
layer.visible = False
layers.append(layer)
ct = colortables.create_default_16bit()
if mainOperator.LabelImage.ready():
self.objectssrc = LazyflowSource(mainOperator.LabelImage)
self.objectssrc.setObjectName("LabelImage LazyflowSrc")
ct[0] = QColor(0, 0, 0, 0).rgba() # make 0 transparent
layer = ColortableLayer(self.objectssrc, ct)
layer.name = "Objects (connected components)"
layer.setToolTip("Segmented objects, shown in different colors")
layer.visible = False
layer.opacity = 0.5
layers.append(layer)
# white foreground on transparent background, even for labeled images
binct = [QColor(255, 255, 255, 255).rgba()]*65536
binct[0] = 0
if mainOperator.BinaryImage.ready():
self.binaryimagesrc = LazyflowSource(mainOperator.BinaryImage)
self.binaryimagesrc.setObjectName("Binary LazyflowSrc")
layer = ColortableLayer(self.binaryimagesrc, binct)
layer.name = "Binary image"
layer.setToolTip("Segmented objects, binary mask")
layers.append(layer)
## raw data layer
self.rawsrc = None
self.rawsrc = LazyflowSource(mainOperator.RawImage)
self.rawsrc.setObjectName("Raw Lazyflow Src")
layerraw = GrayscaleLayer(self.rawsrc)
layerraw.name = "Raw data"
layers.insert(len(layers), layerraw)
mainOperator.RawImage.notifyReady(self._onReady)
self.__cleanup_fns.append( partial( mainOperator.RawImage.unregisterReady, self._onReady ) )
mainOperator.RawImage.notifyMetaChanged(self._onMetaChanged)
self.__cleanup_fns.append( partial( mainOperator.RawImage.unregisterMetaChanged, self._onMetaChanged ) )
if mainOperator.BinaryImage.meta.shape:
self.editor.dataShape = mainOperator.BinaryImage.meta.shape
mainOperator.BinaryImage.notifyMetaChanged(self._onMetaChanged)
self.__cleanup_fns.append( partial( mainOperator.BinaryImage.unregisterMetaChanged, self._onMetaChanged ) )
return layers
开发者ID:burcin,项目名称:ilastik,代码行数:57,代码来源:objectExtractionGui.py
示例3: _onMetaChanged
def _onMetaChanged( self, slot ):
if slot is self.mainOperator.LabelImage:
if slot.meta.shape:
self.editor.dataShape = slot.meta.shape
if slot is self.mainOperator.RawImage:
if slot.meta.shape and not self.rawsrc:
self.rawsrc = LazyflowSource( self.mainOperator.RawImage )
layerraw = GrayscaleLayer( self.rawsrc )
layerraw.name = "Raw"
self.layerstack.append( layerraw )
开发者ID:jennyhong,项目名称:ilastik,代码行数:11,代码来源:manualTrackingGui.py
示例4: _onMetaChanged
def _onMetaChanged(self, slot):
#FiXME: why do we need that?
if slot is self.topLevelOperatorView.BinaryImage:
if slot.meta.shape:
self.editor.dataShape = slot.meta.shape
if slot is self.topLevelOperatorView.RawImage:
if slot.meta.shape and not self.rawsrc:
self.rawsrc = LazyflowSource(self.topLevelOperatorView.RawImage)
layerraw = GrayscaleLayer(self.rawsrc)
layerraw.name = "Raw data"
self.layerstack.append(layerraw)
开发者ID:burcin,项目名称:ilastik,代码行数:12,代码来源:objectExtractionGui.py
示例5: setupLayers
def setupLayers(self):
mainOperator = self.topLevelOperatorView
layers = []
if mainOperator.ObjectCenterImage.ready():
self.centerimagesrc = LazyflowSource(mainOperator.ObjectCenterImage)
#layer = RGBALayer(red=ConstantSource(255), alpha=self.centerimagesrc)
redct = [0, QColor(255, 0, 0).rgba()]
layer = ColortableLayer(self.centerimagesrc, redct)
layer.name = "Object Centers"
layer.visible = False
layers.append(layer)
ct = colortables.create_default_16bit()
if mainOperator.LabelImage.ready():
self.objectssrc = LazyflowSource(mainOperator.LabelImage)
self.objectssrc.setObjectName("LabelImage LazyflowSrc")
ct[0] = QColor(0, 0, 0, 0).rgba() # make 0 transparent
layer = ColortableLayer(self.objectssrc, ct)
layer.name = "Label Image"
layer.visible = False
layer.opacity = 0.5
layers.append(layer)
# white foreground on transparent background
binct = [QColor(0, 0, 0, 0).rgba(), QColor(255, 255, 255, 255).rgba()]
if mainOperator.BinaryImage.ready():
self.binaryimagesrc = LazyflowSource(mainOperator.BinaryImage)
self.binaryimagesrc.setObjectName("Binary LazyflowSrc")
layer = ColortableLayer(self.binaryimagesrc, binct)
layer.name = "Binary Image"
layers.append(layer)
## raw data layer
self.rawsrc = None
self.rawsrc = LazyflowSource(mainOperator.RawImage)
self.rawsrc.setObjectName("Raw Lazyflow Src")
layerraw = GrayscaleLayer(self.rawsrc)
layerraw.name = "Raw"
layers.insert(len(layers), layerraw)
mainOperator.RawImage.notifyReady(self._onReady)
mainOperator.RawImage.notifyMetaChanged(self._onMetaChanged)
if mainOperator.BinaryImage.meta.shape:
self.editor.dataShape = mainOperator.BinaryImage.meta.shape
mainOperator.BinaryImage.notifyMetaChanged(self._onMetaChanged)
return layers
开发者ID:bheuer,项目名称:ilastik,代码行数:49,代码来源:objectExtractionGui.py
示例6: _onMetaChanged
def _onMetaChanged( self, slot ):
if slot is self.mainOperator.LabelImage:
if slot.meta.shape:
self.editor.dataShape = slot.meta.shape
# maxt = slot.meta.shape[0] - 1
# self._setRanges()
# self._drawer.from_time.setValue(0)
# self._drawer.to_time.setValue(maxt)
if slot is self.mainOperator.RawImage:
if slot.meta.shape and not self.rawsrc:
self.rawsrc = LazyflowSource( self.mainOperator.RawImage )
layerraw = GrayscaleLayer( self.rawsrc )
layerraw.name = "Raw"
self.layerstack.append( layerraw )
开发者ID:bheuer,项目名称:ilastik,代码行数:16,代码来源:manualTrackingGui.py
示例7: _create_grayscale_layer_from_slot
def _create_grayscale_layer_from_slot(cls, slot, n_channels):
source = LazyflowSource(slot)
layer = GrayscaleLayer(source)
layer.numberOfChannels = n_channels
layer.set_range(0, slot.meta.drange)
normalize = cls._should_normalize_display(slot)
layer.set_normalize( 0, normalize )
return layer
开发者ID:DerThorsten,项目名称:ilastik,代码行数:8,代码来源:layerViewerGui.py
示例8: _create_grayscale_layer_from_slot
def _create_grayscale_layer_from_slot(cls, slot, n_channels):
#FIXME: move all of this stuff into the class constructor. Same for all
# _create_*layer_from_slot methods.
source = LazyflowSource(slot)
layer = GrayscaleLayer(source, window_leveling=True)
layer.numberOfChannels = n_channels
layer.set_range(0, slot.meta.drange)
normalize = cls._should_normalize_display(slot)
layer.set_normalize( 0, normalize )
return layer
开发者ID:ilastik,项目名称:ilastik,代码行数:10,代码来源:layerViewerGui.py
示例9: setupLayers
def setupLayers( self ):
layers = []
self.ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
self.ct[255] = QColor(0,0,0,255).rgba() # make -1 black
self.ct[-1] = QColor(0,0,0,255).rgba()
self.trackingsrc = LazyflowSource( self.topLevelOperatorView.TrackImage )
trackingLayer = ColortableLayer( self.trackingsrc, self.ct )
trackingLayer.name = "Manual Tracking"
trackingLayer.visible = True
trackingLayer.opacity = 0.8
def toggleTrackingVisibility():
trackingLayer.visible = not trackingLayer.visible
trackingLayer.shortcutRegistration = (
"Layer Visibilities",
"Toggle Manual Tracking Layer Visibility",
QtGui.QShortcut( QtGui.QKeySequence("e"), self.viewerControlWidget(), toggleTrackingVisibility),
trackingLayer )
layers.append(trackingLayer)
ct = colortables.create_random_16bit()
ct[1] = QColor(230,0,0,150).rgba()
ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
self.untrackedsrc = LazyflowSource( self.topLevelOperatorView.UntrackedImage )
untrackedLayer = ColortableLayer( self.untrackedsrc, ct )
untrackedLayer.name = "Untracked Objects"
untrackedLayer.visible = False
untrackedLayer.opacity = 0.8
layers.append(untrackedLayer)
self.objectssrc = LazyflowSource( self.topLevelOperatorView.BinaryImage )
ct = colortables.create_random_16bit()
ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
ct[1] = QColor(255,255,0,100).rgba()
objLayer = ColortableLayer( self.objectssrc, ct )
objLayer.name = "Objects"
objLayer.opacity = 0.8
objLayer.visible = True
def toggleObjectVisibility():
objLayer.visible = not objLayer.visible
objLayer.shortcutRegistration = (
"Layer Visibilities",
"Toggle Objects Layer Visibility",
QtGui.QShortcut( QtGui.QKeySequence("r"), self.viewerControlWidget(), toggleObjectVisibility),
objLayer )
layers.append(objLayer)
## raw data layer
self.rawsrc = None
self.rawsrc = LazyflowSource( self.mainOperator.RawImage )
rawLayer = GrayscaleLayer( self.rawsrc )
rawLayer.name = "Raw"
layers.insert( len(layers), rawLayer )
if self.topLevelOperatorView.LabelImage.meta.shape:
self.editor.dataShape = self.topLevelOperatorView.LabelImage.meta.shape
self.topLevelOperatorView.RawImage.notifyReady( self._onReady )
self.topLevelOperatorView.RawImage.notifyMetaChanged( self._onMetaChanged )
self._setDivisionsList()
self._setActiveTrackList()
return layers
开发者ID:jennyhong,项目名称:ilastik,代码行数:72,代码来源:manualTrackingGui.py
示例10: initGraph
def initGraph(self):
shape = self.inputProvider.outputs["Output"].shape
srcs = []
minMax = []
normalize = []
print "* Data has shape=%r" % (shape,)
#create a layer for each channel of the input:
slicer=OpMultiArraySlicer2(self.g)
slicer.inputs["Input"].connect(self.inputProvider.outputs["Output"])
slicer.inputs["AxisFlag"].setValue('c')
nchannels = shape[-1]
for ich in xrange(nchannels):
data=slicer.outputs['Slices'][ich][:].allocate().wait()
#find the minimum and maximum value for normalization
mm = (numpy.min(data), numpy.max(data))
print " - channel %d: min=%r, max=%r" % (ich, mm[0], mm[1])
minMax.append(mm)
if self._normalize_data:
normalize.append(mm)
else:
normalize.append((0,255))
layersrc = LazyflowSource(slicer.outputs['Slices'][ich], priority = 100)
layersrc.setObjectName("raw data channel=%d" % ich)
srcs.append(layersrc)
#FIXME: we shouldn't merge channels automatically, but for now it's prettier
layer1 = None
if nchannels == 1:
layer1 = GrayscaleLayer(srcs[0], range=minMax[0], normalize=normalize[0])
print " - showing raw data as grayscale"
elif nchannels==2:
layer1 = RGBALayer(red = srcs[0], normalizeR=normalize[0],
green = srcs[1], normalizeG=normalize[1], range=minMax[0:2]+[(0,255), (0,255)])
print " - showing channel 1 as red, channel 2 as green"
elif nchannels==3:
layer1 = RGBALayer(red = srcs[0], normalizeR=normalize[0],
green = srcs[1], normalizeG=normalize[1],
blue = srcs[2], normalizeB=normalize[2],
range = minMax[0:3])
print " - showing channel 1 as red, channel 2 as green, channel 3 as blue"
else:
print "only 1,2 or 3 channels supported so far"
return
print
layer1.name = "Input data"
layer1.ref_object = None
self.layerstack.append(layer1)
opImageList = Op5ToMulti(self.g)
opImageList.inputs["Input0"].connect(self.inputProvider.outputs["Output"])
#init the features operator
opPF = OpPixelFeaturesPresmoothed(self.g)
opPF.inputs["Input"].connect(opImageList.outputs["Outputs"])
opPF.inputs["Scales"].setValue(self.featScalesList)
self.opPF=opPF
#Caches the features
opFeatureCache = OpBlockedArrayCache(self.g)
opFeatureCache.inputs["innerBlockShape"].setValue((1,32,32,32,16))
opFeatureCache.inputs["outerBlockShape"].setValue((1,128,128,128,64))
opFeatureCache.inputs["Input"].connect(opPF.outputs["Output"])
opFeatureCache.inputs["fixAtCurrent"].setValue(False)
self.opFeatureCache=opFeatureCache
self.initLabels()
self.dataReadyToView.emit()
开发者ID:LimpingTwerp,项目名称:techpreview,代码行数:72,代码来源:classificationWorkflow_cc.py
示例11: initGraph
def initGraph(self):
shape = self.inputProvider.outputs["Output"].shape
srcs = []
minMax = []
print "* Data has shape=%r" % (shape,)
#create a layer for each channel of the input:
slicer=OpMultiArraySlicer2(self.g)
slicer.inputs["Input"].connect(self.inputProvider.outputs["Output"])
slicer.inputs["AxisFlag"].setValue('c')
nchannels = shape[-1]
for ich in xrange(nchannels):
if self._normalize_data:
data=slicer.outputs['Slices'][ich][:].allocate().wait()
#find the minimum and maximum value for normalization
mm = (numpy.min(data), numpy.max(data))
print " - channel %d: min=%r, max=%r" % (ich, mm[0], mm[1])
minMax.append(mm)
else:
minMax.append(None)
layersrc = LazyflowSource(slicer.outputs['Slices'][ich], priority = 100)
layersrc.setObjectName("raw data channel=%d" % ich)
srcs.append(layersrc)
#FIXME: we shouldn't merge channels automatically, but for now it's prettier
layer1 = None
if nchannels == 1:
layer1 = GrayscaleLayer(srcs[0], normalize=minMax[0])
layer1.set_range(0,minMax[0])
print " - showing raw data as grayscale"
elif nchannels==2:
layer1 = RGBALayer(red = srcs[0], normalizeR=minMax[0],
green = srcs[1], normalizeG=minMax[1])
layer1.set_range(0, minMax[0])
layer1.set_range(1, minMax[1])
print " - showing channel 1 as red, channel 2 as green"
elif nchannels==3:
layer1 = RGBALayer(red = srcs[0], normalizeR=minMax[0],
green = srcs[1], normalizeG=minMax[1],
blue = srcs[2], normalizeB=minMax[2])
layer1.set_range(0, minMax[0])
layer1.set_range(1, minMax[1])
layer1.set_range(2, minMax[2])
print " - showing channel 1 as red, channel 2 as green, channel 3 as blue"
else:
print "only 1,2 or 3 channels supported so far"
return
print
layer1.name = "Input data"
layer1.ref_object = None
self.layerstack.append(layer1)
self.workflow = PixelClassificationLazyflow( self.g, self.featScalesList, self.inputProvider.outputs["Output"])
self.initLabels()
self.startClassification()
self.dataReadyToView.emit()
开发者ID:opetra,项目名称:techpreview,代码行数:61,代码来源:classificationWorkflow.py
示例12: createStandardLayerFromSlot
def createStandardLayerFromSlot(cls, slot, lastChannelIsAlpha=False):
"""
Convenience function.
Generates a volumina layer using the given slot.
Chooses between grayscale or RGB depending on the number of channels in the slot.
* If *slot* has 1 channel or more than 4 channels, a GrayscaleLayer is created.
* If *slot* has 2 non-alpha channels, an RGBALayer is created with R and G channels.
* If *slot* has 3 non-alpha channels, an RGBALayer is created with R,G, and B channels.
* If *slot* has 4 channels, an RGBA layer is created
:param slot: The slot to generate a layer from
:param lastChannelIsAlpha: If True, the last channel in the slot is assumed to be an alpha channel.
If slot has 4 channels, this parameter has no effect.
"""
def getRange(meta):
if meta.drange is not None and meta.normalizeDisplay is False:
# do not normalize if the user provided a range and set normalization to False
return meta.drange
else:
# If we don't know the range of the data and normalization is allowed
# by the user, create a layer that is auto-normalized.
# See volumina.pixelpipeline.datasources for details.
#
# Even in the case of integer data, which has more than 255 possible values,
# (like uint16), it seems reasonable to use this setting as default
return None # means autoNormalize
shape = slot.meta.shape
try:
channelAxisIndex = slot.meta.axistags.index('c')
#assert channelAxisIndex < len(slot.meta.axistags), \
# "slot %s has shape = %r, axistags = %r, but no channel dimension" \
# % (slot.name, slot.meta.shape, slot.meta.axistags)
numChannels = shape[channelAxisIndex]
axisinfo = slot.meta.axistags["c"].description
except:
numChannels = 1
axisinfo = "" # == no info on channels given
rindex = None
bindex = None
gindex = None
aindex = None
if axisinfo == "" or axisinfo == "default":
# Examine channel dimension to determine Grayscale vs. RGB
if numChannels == 4:
lastChannelIsAlpha = True
if lastChannelIsAlpha:
assert numChannels <= 4, "Can't display a standard layer with more than four channels (with alpha). Your image has {} channels.".format(numChannels)
if numChannels == 1 or (numChannels > 4):
assert not lastChannelIsAlpha, "Can't have an alpha channel if there is no color channel"
source = LazyflowSource(slot)
layer = GrayscaleLayer(source)
layer.numberOfChannels = numChannels
normalize = getRange(slot.meta)
layer.set_normalize(0,normalize)
return layer
assert numChannels > 2 or (numChannels == 2 and not lastChannelIsAlpha), \
"Unhandled combination of channels. numChannels={}, lastChannelIsAlpha={}, axistags={}".format( numChannels, lastChannelIsAlpha, slot.meta.axistags )
rindex = 0
gindex = 1
if numChannels > 3 or (numChannels == 3 and not lastChannelIsAlpha):
bindex = 2
if lastChannelIsAlpha:
aindex = numChannels-1
elif axisinfo == "grayscale":
source = LazyflowSource(slot)
layer = GrayscaleLayer(source)
layer.numberOfChannels = numChannels
normalize = getRange(slot.meta)
layer.set_normalize(0,normalize)
return layer
elif axisinfo == "rgba":
rindex = 0
if numChannels>=2:
gindex = 1
if numChannels>=3:
bindex = 2
if numChannels>=4:
aindex = numChannels-1
else:
raise RuntimeError("unknown channel display mode")
redSource = None
if rindex is not None:
redProvider = OpSingleChannelSelector(parent=slot.getRealOperator().parent)
redProvider.Input.connect(slot)
redProvider.Index.setValue( rindex )
redSource = LazyflowSource( redProvider.Output )
#.........这里部分代码省略.........
开发者ID:hanslovsky,项目名称:ilastik,代码行数:101,代码来源:layerViewerGui.py
示例13: setupLayers
def setupLayers( self ):
layers = []
self.ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
self.ct[255] = QColor(0,0,0,255).rgba() # make -1 black
self.ct[-1] = QColor(0,0,0,255).rgba()
self.trackingsrc = LazyflowSource( self.topLevelOperatorView.TrackImage )
trackingLayer = ColortableLayer( self.trackingsrc, self.ct )
trackingLayer.name = "Manual Tracking"
trackingLayer.visible = True
trackingLayer.opacity = 0.8
layers.append(trackingLayer)
ct = colortables.create_random_16bit()
ct[1] = QColor(230,0,0,150).rgba()
ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
self.untrackedsrc = LazyflowSource( self.topLevelOperatorView.UntrackedImage )
untrackedLayer = ColortableLayer( self.untrackedsrc, ct )
untrackedLayer.name = "Untracked Objects"
untrackedLayer.visible = False
untrackedLayer.opacity = 0.8
layers.append(untrackedLayer)
self.objectssrc = LazyflowSource( self.topLevelOperatorView.BinaryImage )
# ct = colortables.create_default_8bit()
ct = colortables.create_random_16bit()
ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
ct[1] = QColor(255,255,0,100).rgba() # make 0 transparent
objLayer = ColortableLayer( self.objectssrc, ct )
objLayer.name = "Objects"
objLayer.opacity = 0.8
objLayer.visible = True
layers.append(objLayer)
## raw data layer
self.rawsrc = None
self.rawsrc = LazyflowSource( self.mainOperator.RawImage )
rawLayer = GrayscaleLayer( self.rawsrc )
rawLayer.name = "Raw"
layers.insert( len(layers), rawLayer )
if self.topLevelOperatorView.LabelImage.meta.shape:
self.editor.dataShape = self.topLevelOperatorView.LabelImage.meta.shape
# maxt = self.topLevelOperatorView.LabelImage.meta.shape[0] - 1
# maxx = self.topLevelOperatorView.LabelImage.meta.shape[1] - 1
# maxy = self.topLevelOperatorView.LabelImage.meta.shape[2] - 1
# maxz = self.topLevelOperatorView.LabelImage.meta.shape[3] - 1
#
# self._setRanges()
# self._drawer.from_time.setValue(0)
# self._drawer.to_time.setValue(maxt)
# self._drawer.from_x.setValue(0)
# self._drawer.to_x.setValue(maxx)
# self._drawer.from_y.setValue(0)
# self._drawer.to_y.setValue(maxy)
# self._drawer.from_z.setValue(0)
# self._drawer.to_z.setValue(maxz)
self.topLevelOperatorView.RawImage.notifyReady( self._onReady )
self.topLevelOperatorView.RawImage.notifyMetaChanged( self._onMetaChanged )
self._setDivisionsList()
self._setActiveTrackList()
return layers
开发者ID:bheuer,项目名称:ilastik,代码行数:68,代码来源:manualTrackingGui.py
注:本文中的volumina.api.GrayscaleLayer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论