• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python api.AlphaModulatedLayer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中volumina.api.AlphaModulatedLayer的典型用法代码示例。如果您正苦于以下问题:Python AlphaModulatedLayer类的具体用法?Python AlphaModulatedLayer怎么用?Python AlphaModulatedLayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AlphaModulatedLayer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _initPredictionLayers

    def _initPredictionLayers(self, predictionSlot):
        opLane = self.topLevelOperatorView
        if not opLane.LabelNames.ready() or not opLane.PmapColors.ready():
            return []

        layers = []
        colors = opLane.PmapColors.value
        names = opLane.LabelNames.value

        # Use a slicer to provide a separate slot for each channel layer
        opSlicer = OpMultiArraySlicer2( parent=opLane.viewed_operator().parent )
        opSlicer.Input.connect( predictionSlot )
        opSlicer.AxisFlag.setValue('c')

        for channel, channelSlot in enumerate(opSlicer.Slices):
            if channelSlot.ready() and channel < len(colors) and channel < len(names):
                drange = channelSlot.meta.drange or (0.0, 1.0)
                predictsrc = LazyflowSource(channelSlot)
                predictLayer = AlphaModulatedLayer( predictsrc,
                                                    tintColor=QColor(*colors[channel]),
                                                    # FIXME: This is weird.  Why are range and normalize both set to the same thing?
                                                    range=drange,
                                                    normalize=drange )
                predictLayer.opacity = 0.25
                predictLayer.visible = True
                predictLayer.name = names[channel]
                layers.append(predictLayer)

        return layers
开发者ID:JensNRAD,项目名称:ilastik_public,代码行数:29,代码来源:pixelClassificationDataExportGui.py


示例2: setupPredictionLayers

    def setupPredictionLayers(self, predictionChannels, name_suffix):
        """
        Setup the layers for predicted class probabilities
        """
        
        labels = self.labelListData
        layers = []
        # Add each of the predictions
        for channel, predictionSlot in enumerate(predictionChannels):
            if predictionSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                predictsrc = LazyflowSource(predictionSlot)
                predictLayer = AlphaModulatedLayer( predictsrc,
                                                    tintColor=ref_label.color,
                                                    range=(0.0, 1.0),
                                                    normalize=(0.0, 1.0) )
                predictLayer.opacity = 0.25
                predictLayer.visible = self._viewerControlUi.liveUpdateButton.isChecked()
                predictLayer.visibleChanged.connect(self.updateShowPredictionCheckbox)

                def setLayerColor(c):
                    predictLayer.tintColor = c
                def setLayerName(n):
                    newName = "Prediction for %s %s" % (ref_label.name, name_suffix)
                    predictLayer.name = newName
                setLayerName(ref_label.name)

                ref_label.colorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setLayerName)
                layers.append(predictLayer)
        return layers
开发者ID:jennyhong,项目名称:ilastik,代码行数:31,代码来源:autocontextClassificationGui.py


示例3: _initPredictionLayers

    def _initPredictionLayers(self, predictionSlot):
        layers = []

        opLane = self.topLevelOperatorView
        colors = opLane.PmapColors.value
        names = opLane.LabelNames.value

        # Use a slicer to provide a separate slot for each channel layer
        opSlicer = OpMultiArraySlicer2( parent=opLane.viewed_operator() )
        opSlicer.Input.connect( predictionSlot )
        opSlicer.AxisFlag.setValue('c')

        for channel, channelSlot in enumerate(opSlicer.Slices):
            if channelSlot.ready() and channel < len(colors) and channel < len(names):
                predictsrc = LazyflowSource(channelSlot)
                predictLayer = AlphaModulatedLayer( predictsrc,
                                                    tintColor=QColor(*colors[channel]),
                                                    range=(0.0, 1.0),
                                                    normalize=(0.0, 1.0) )
                predictLayer.opacity = 0.25
                predictLayer.visible = True
                predictLayer.name = names[channel]
                layers.append(predictLayer)

        return layers
开发者ID:jennyhong,项目名称:ilastik,代码行数:25,代码来源:pixelClassificationBatchResultsGui.py


示例4: _initPredictionLayers

    def _initPredictionLayers(self, predictionSlot):
        opLane = self.topLevelOperatorView
        layers = []

        # Use a slicer to provide a separate slot for each channel layer
        opSlicer = OpMultiArraySlicer2(parent=opLane.viewed_operator().parent)
        opSlicer.Input.connect(predictionSlot)
        opSlicer.AxisFlag.setValue('c')

        for channel, predictionSlot in enumerate(opSlicer.Slices):
            if predictionSlot.ready():
                predictsrc = LazyflowSource(predictionSlot)
                predictLayer = AlphaModulatedLayer(predictsrc, range=(0.0, 1.0), normalize=(0.0, 1.0))
                predictLayer.opacity = 0.25
                predictLayer.visible = True

                def setPredLayerName(n, predictLayer_=predictLayer, initializing=False):
                    """
                    function for setting the names for every Channel
                    """
                    if not initializing and predictLayer_ not in self.layerstack:
                        # This layer has been removed from the layerstack already.
                        # Don't touch it.
                        return
                    newName = "Prediction for %s" % n
                    predictLayer_.name = newName

                setPredLayerName(channel, initializing=True)

                layers.append(predictLayer)

        return layers
开发者ID:ilastik,项目名称:ilastik,代码行数:32,代码来源:nnClassificationDataExportGui.py


示例5: addPredictionLayer

 def addPredictionLayer(self, icl, ref_label):
     
     selector=OpSingleChannelSelector(self.g)
     selector.inputs["Input"].connect(self.pCache.outputs['Output'])
     selector.inputs["Index"].setValue(icl)
             
     if self.checkInteractive.isChecked():
         self.pCache.inputs["fixAtCurrent"].setValue(False)
     else:
         self.pCache.inputs["fixAtCurrent"].setValue(True)
     
     predictsrc = LazyflowSource(selector.outputs["Output"][0])
     def srcName(newName):
         predictsrc.setObjectName("Prediction for %s" % ref_label.name)
     srcName("")
     
     predictLayer = AlphaModulatedLayer(predictsrc, tintColor=ref_label.color)
     predictLayer.nameChanged.connect(srcName)
     
     def setLayerColor(c):
         print "as the color of label '%s' has changed, setting layer's '%s' tint color to %r" % (ref_label.name, predictLayer.name, c)
         predictLayer.tintColor = c
     ref_label.colorChanged.connect(setLayerColor)
     def setLayerName(n):
         newName = "Prediction for %s" % ref_label.name
         print "as the name of label '%s' has changed, setting layer's '%s' name to '%s'" % (ref_label.name, predictLayer.name, newName)
         predictLayer.name = newName
     setLayerName(ref_label.name)
     ref_label.nameChanged.connect(setLayerName)
     
     predictLayer.ref_object = ref_label
     #make sure that labels (index = 0) stay on top!
     self.layerstack.insert(1, predictLayer )
     self.fixableOperators.append(self.pCache)
开发者ID:LimpingTwerp,项目名称:techpreview,代码行数:34,代码来源:classificationWorkflow_cc.py


示例6: setupLayers

    def setupLayers(self):
        """
        which layers will be shown in the layerviewergui.
        Triggers the prediciton by setting the layer on visible
        """

        inputSlot = self.topLevelOperator.InputImage

        layers = []

        for channel, predictionSlot in enumerate(self.topLevelOperator.PredictionProbabilityChannels):
            if predictionSlot.ready():
                predictsrc = LazyflowSource(predictionSlot)
                predictionLayer = AlphaModulatedLayer(predictsrc, range=(0.0, 1.0), normalize=(0.0, 1.0))
                predictionLayer.visible = self.drawer.liveUpdateButton.isChecked()
                predictionLayer.opacity = 0.25
                predictionLayer.visibleChanged.connect(self.updateShowPredictionCheckbox)

                def setPredLayerName(n, predictLayer_=predictionLayer, initializing=False):
                    """
                    function for setting the names for every Channel
                    """
                    if not initializing and predictLayer_ not in self.layerstack:
                        # This layer has been removed from the layerstack already.
                        # Don't touch it.
                        return
                    newName = "Prediction for %s" % n
                    predictLayer_.name = newName

                setPredLayerName(channel, initializing=True)

                layers.append(predictionLayer)

        # always as last layer
        if inputSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(inputSlot)
            rawLayer.visible = True
            rawLayer.opacity = 1.0
            rawLayer.name = "Raw Data (display only)"
            layers.append(rawLayer)


        return layers
开发者ID:ilastik,项目名称:ilastik,代码行数:43,代码来源:nnClassGui.py


示例7: _initPredictionLayers

    def _initPredictionLayers(self, predictionSlot):
        opLane = self.topLevelOperatorView
        if not opLane.LabelNames.ready() or not opLane.PmapColors.ready():
            return []

        layers = []
        colors = opLane.PmapColors.value
        names = opLane.LabelNames.value

        if predictionSlot.ready():
            if 'c' in predictionSlot.meta.getAxisKeys():
                num_channels = predictionSlot.meta.getTaggedShape()['c']
            else:
                num_channels = 1
            if num_channels != len(names) or num_channels != len(colors):
                names = ["Label {}".format(n) for n in range(1, num_channels+1)]
                colors = num_channels * [(0, 0, 0)] # it doesn't matter, if the pmaps color is not known,
                                                    # we are either initializing and it will be rewritten or
                                                    # something is very wrong elsewhere

        # Use a slicer to provide a separate slot for each channel layer
        opSlicer = OpMultiArraySlicer2( parent=opLane.viewed_operator().parent )
        opSlicer.Input.connect( predictionSlot )
        opSlicer.AxisFlag.setValue('c')

        for channel, channelSlot in enumerate(opSlicer.Slices):
            if channelSlot.ready() and channel < len(colors) and channel < len(names):
                drange = channelSlot.meta.drange or (0.0, 1.0)
                predictsrc = LazyflowSource(channelSlot)
                predictLayer = AlphaModulatedLayer( predictsrc,
                                                    tintColor=QColor(*colors[channel]),
                                                    # FIXME: This is weird.  Why are range and normalize both set to the same thing?
                                                    range=drange,
                                                    normalize=drange )
                predictLayer.opacity = 0.25
                predictLayer.visible = True
                predictLayer.name = names[channel]
                layers.append(predictLayer)

        return layers
开发者ID:ilastik,项目名称:ilastik,代码行数:40,代码来源:pixelClassificationDataExportGui.py


示例8: _initPredictionLayers

    def _initPredictionLayers(self, predictionSlot):
        layers = []

        colors = []
        names = []

        opLane = self.topLevelOperatorView

        if opLane.PmapColors.ready():
            colors = opLane.PmapColors.value
        if opLane.LabelNames.ready():
            names = opLane.LabelNames.value

        # Use a slicer to provide a separate slot for each channel layer
        opSlicer = OpMultiArraySlicer2(parent=opLane.viewed_operator().parent)
        opSlicer.Input.connect(predictionSlot)
        opSlicer.AxisFlag.setValue("c")

        colors = map(lambda c: QColor(*c), colors)
        for channel in range(len(colors), len(opSlicer.Slices)):
            colors.append(PredictionViewerGui.DefaultColors[channel])

        for channel in range(len(names), len(opSlicer.Slices)):
            names.append("Class {}".format(channel + 1))

        for channel, channelSlot in enumerate(opSlicer.Slices):
            if channelSlot.ready() and channel < len(colors) and channel < len(names):
                predictsrc = LazyflowSource(channelSlot)
                predictLayer = AlphaModulatedLayer(
                    predictsrc, tintColor=colors[channel], range=(0.0, 1.0), normalize=(0.0, 1.0)
                )
                predictLayer.opacity = 0.25
                predictLayer.visible = True
                predictLayer.name = names[channel]
                layers.append(predictLayer)

        return layers
开发者ID:nkrasows,项目名称:ilastik,代码行数:37,代码来源:predictionViewerGui.py


示例9: _initPredictionLayers

    def _initPredictionLayers(self, predictionSlot):
        layers = []
        opLane = self.topLevelOperatorView

        # Use a slicer to provide a separate slot for each channel layer
        opSlicer = OpMultiArraySlicer2( parent=opLane.viewed_operator().parent )
        opSlicer.Input.connect( predictionSlot )
        opSlicer.AxisFlag.setValue('c')

        for channel, channelSlot in enumerate(opSlicer.Slices):
            if channelSlot.ready():
                drange = channelSlot.meta.drange or (0.0, 1.0)
                predictsrc = LazyflowSource(channelSlot)
                predictLayer = AlphaModulatedLayer( predictsrc,
                                                    tintColor=QColor.fromRgba(self._colorTable16[channel+1]),
                                                    # FIXME: This is weird.  Why are range and normalize both set to the same thing?
                                                    range=drange,
                                                    normalize=drange )
                predictLayer.opacity = 1.0
                predictLayer.visible = True
                predictLayer.name = "Probability Channel #{}".format( channel+1 )
                layers.append(predictLayer)

        return layers
开发者ID:fdiego,项目名称:ilastik,代码行数:24,代码来源:objectClassificationDataExportGui.py


示例10: setupLayers

    def setupLayers(self):
        layers = []        
        op = self.topLevelOperatorView
        binct = [QColor(Qt.black), QColor(Qt.white)]
        ct = self._createDefault16ColorColorTable()
        ct[0]=0
        # Show the cached output, since it goes through a blocked cache
        
        if op.CachedOutput.ready():
            outputSrc = LazyflowSource(op.CachedOutput)
            outputLayer = ColortableLayer(outputSrc, binct)
            outputLayer.name = "Output (Cached)"
            outputLayer.visible = False
            outputLayer.opacity = 1.0
            layers.append(outputLayer)

        #FIXME: We have to do that, because lazyflow doesn't have a way to make an operator partially ready
        curIndex = self._drawer.tabWidget.currentIndex()
        if curIndex==1:
            if op.BigRegions.ready():
                lowThresholdSrc = LazyflowSource(op.BigRegions)
                lowThresholdLayer = ColortableLayer(lowThresholdSrc, binct)
                lowThresholdLayer.name = "Big Regions"
                lowThresholdLayer.visible = False
                lowThresholdLayer.opacity = 1.0
                layers.append(lowThresholdLayer)
    
            if op.FilteredSmallLabels.ready():
                filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels )
                filteredSmallLabelsLayer.name = "Filtered Small Labels"
                filteredSmallLabelsLayer.visible = False
                filteredSmallLabelsLayer.opacity = 1.0
                layers.append(filteredSmallLabelsLayer)
    
            if op.SmallRegions.ready():
                highThresholdSrc = LazyflowSource(op.SmallRegions)
                highThresholdLayer = ColortableLayer(highThresholdSrc, binct)
                highThresholdLayer.name = "Small Regions"
                highThresholdLayer.visible = False
                highThresholdLayer.opacity = 1.0
                layers.append(highThresholdLayer)
        elif curIndex==0:
            if op.BeforeSizeFilter.ready():
                thSrc = LazyflowSource(op.BeforeSizeFilter)
                thLayer = ColortableLayer(thSrc, binct)
                thLayer.name = "Thresholded Labels"
                thLayer.visible = False
                thLayer.opacity = 1.0
                layers.append(thLayer)
        
        # Selected input channel, smoothed.
        if op.Smoothed.ready():
            smoothedLayer = self.createStandardLayerFromSlot( op.Smoothed )
            smoothedLayer.name = "Smoothed Input"
            smoothedLayer.visible = True
            smoothedLayer.opacity = 1.0
            layers.append(smoothedLayer)
        
        # Show the selected channel
        if op.InputChannel.ready():
            drange = op.InputChannel.meta.drange
            if drange is None:
                drange = (0.0, 1.0)
            channelSrc = LazyflowSource(op.InputChannel)
            channelLayer = AlphaModulatedLayer( channelSrc,
                                                tintColor=QColor(self._channelColors[op.Channel.value]),
                                                range=drange,
                                                normalize=drange )
            channelLayer.name = "Input Ch{}".format(op.Channel.value)
            channelLayer.opacity = 1.0
            #channelLayer.visible = channelIndex == op.Channel.value # By default, only the selected input channel is visible.    
            layers.append(channelLayer)
        
        # Show the raw input data
        rawSlot = self.topLevelOperatorView.RawInput
        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,代码行数:83,代码来源:thresholdTwoLevelsGui.py


示例11: setupLayers

    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

        if ilastik_config.getboolean('ilastik', 'debug'):

            # Add the label projection layer.
            labelProjectionSlot = self.topLevelOperatorView.opLabelPipeline.opLabelArray.Projection2D
            if labelProjectionSlot.ready():
                projectionSrc = LazyflowSource(labelProjectionSlot)
                try:
                    # This colortable requires matplotlib
                    from volumina.colortables import jet
                    projectionLayer = ColortableLayer( projectionSrc, 
                                                       colorTable=[QColor(0,0,0,128).rgba()]+jet(N=255), 
                                                       normalize=(0.0, 1.0) )
                except (ImportError, RuntimeError):
                    pass
                else:
                    projectionLayer.name = "Label Projection"
                    projectionLayer.visible = False
                    projectionLayer.opacity = 1.0
                    layers.append(projectionLayer)

        # Show the mask over everything except labels
        maskSlot = self.topLevelOperatorView.PredictionMasks
        if maskSlot.ready():
            maskLayer = self._create_binary_mask_layer_from_slot( maskSlot )
            maskLayer.name = "Mask"
            maskLayer.visible = True
            maskLayer.opacity = 1.0
            layers.append( maskLayer )

        # 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",
                                                                       uncertaintyLayer.toggleVisible,
                                                                       self.viewerControlWidget(),
                                                                       uncertaintyLayer ) )
            layers.append(uncertaintyLayer)

        labels = self.labelListData

        # Add each of the segmentations
        for channel, segmentationSlot in enumerate(self.topLevelOperatorView.SegmentationChannels):
            if segmentationSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                segsrc = LazyflowSource(segmentationSlot)
                segLayer = AlphaModulatedLayer( segsrc,
                                                tintColor=ref_label.pmapColor(),
                                                range=(0.0, 1.0),
                                                normalize=(0.0, 1.0) )

                segLayer.opacity = 1
                segLayer.visible = False #self.labelingDrawerUi.liveUpdateButton.isChecked()
                segLayer.visibleChanged.connect(self.updateShowSegmentationCheckbox)

                def setLayerColor(c, segLayer_=segLayer, initializing=False):
                    if not initializing and segLayer_ not in self.layerstack:
                        # This layer has been removed from the layerstack already.
                        # Don't touch it.
                        return
                    segLayer_.tintColor = c
                    self._update_rendering()

                def setSegLayerName(n, segLayer_=segLayer, initializing=False):
                    if not initializing and segLayer_ not in self.layerstack:
                        # This layer has been removed from the layerstack already.
                        # Don't touch it.
                        return
                    oldname = segLayer_.name
                    newName = "Segmentation (%s)" % n
                    segLayer_.name = newName
                    if not self.render:
                        return
                    if oldname in self._renderedLayers:
                        label = self._renderedLayers.pop(oldname)
                        self._renderedLayers[newName] = label

                setSegLayerName(ref_label.name, initializing=True)

                ref_label.pmapColorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setSegLayerName)
#.........这里部分代码省略.........
开发者ID:DerThorsten,项目名称:ilastik,代码行数:101,代码来源:pixelClassificationGui.py


示例12: setupLayers

    def setupLayers(self):

        # Base class provides the label layer.
        layers = super(ObjectClassificationGui, self).setupLayers()

        binarySlot = self.op.BinaryImages
        segmentedSlot = self.op.SegmentationImages
        rawSlot = self.op.RawImages

        #This is just for colors
        labels = self.labelListData
        
        for channel, probSlot in enumerate(self.op.PredictionProbabilityChannels):
            if probSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                probsrc = LazyflowSource(probSlot)
                probLayer = AlphaModulatedLayer( probsrc,
                                                 tintColor=ref_label.pmapColor(),
                                                 range=(0.0, 1.0),
                                                 normalize=(0.0, 1.0) )
                probLayer.opacity = 0.25
                #probLayer.visible = self.labelingDrawerUi.checkInteractive.isChecked()
                #False, because it's much faster to draw predictions without these layers below
                probLayer.visible = False
                probLayer.setToolTip("Probability that the object belongs to class {}".format(channel+1))
                    
                def setLayerColor(c, predictLayer_=probLayer, ch=channel, initializing=False):
                    if not initializing and predictLayer_ not in self.layerstack:
                        # This layer has been removed from the layerstack already.
                        # Don't touch it.
                        return
                    predictLayer_.tintColor = c

                def setLayerName(n, predictLayer_=probLayer, initializing=False):
                    if not initializing and predictLayer_ not in self.layerstack:
                        # This layer has been removed from the layerstack already.
                        # Don't touch it.
                        return
                    newName = "Prediction for %s" % n
                    predictLayer_.name = newName

                setLayerName(ref_label.name, initializing=True)
                ref_label.pmapColorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setLayerName)
                layers.append(probLayer)

        predictionSlot = self.op.PredictionImages
        if predictionSlot.ready():
            predictsrc = LazyflowSource(predictionSlot)
            self._colorTable16_forpmaps[0] = 0
            predictLayer = ColortableLayer(predictsrc,
                                           colorTable=self._colorTable16_forpmaps)

            predictLayer.name = self.PREDICTION_LAYER_NAME
            predictLayer.ref_object = None
            predictLayer.visible = self.labelingDrawerUi.checkInteractive.isChecked()
            predictLayer.opacity = 0.5
            predictLayer.setToolTip("Classification results, assigning a label to each object")
            
            # This weakref stuff is a little more fancy than strictly necessary.
            # The idea is to use the weakref's callback to determine when this layer instance is destroyed by the garbage collector,
            #  and then we disconnect the signal that updates that layer.
            weak_predictLayer = weakref.ref( predictLayer )
            colortable_changed_callback = bind( self._setPredictionColorTable, weak_predictLayer )
            self._labelControlUi.labelListModel.dataChanged.connect( colortable_changed_callback )
            weak_predictLayer2 = weakref.ref( predictLayer, partial(self._disconnect_dataChange_callback, colortable_changed_callback) )
            # We have to make sure the weakref isn't destroyed because it is responsible for calling the callback.
            # Therefore, we retain it by adding it to a list.
            self._retained_weakrefs.append( weak_predictLayer2 )

            # Ensure we're up-to-date (in case this is the first time the prediction layer is being added.
            for row in range( self._labelControlUi.labelListModel.rowCount() ):
                self._setPredictionColorTableForRow( predictLayer, row )

            # put right after Labels, so that it is visible after hitting "live
            # predict".
            layers.insert(1, predictLayer)

        badObjectsSlot = self.op.BadObjectImages
        if badObjectsSlot.ready():
            ct_black = [0, QColor(Qt.black).rgba()]
            badSrc = LazyflowSource(badObjectsSlot)
            badLayer = ColortableLayer(badSrc, colorTable = ct_black)
            badLayer.name = "Ambiguous objects"
            badLayer.setToolTip("Objects with infinite or invalid values in features")
            badLayer.visible = False
            layers.append(badLayer)

        if segmentedSlot.ready():
            ct = colortables.create_default_16bit()
            objectssrc = LazyflowSource(segmentedSlot)
            ct[0] = QColor(0, 0, 0, 0).rgba() # make 0 transparent
            objLayer = ColortableLayer(objectssrc, ct)
            objLayer.name = "Objects"
            objLayer.opacity = 0.5
            objLayer.visible = False
            objLayer.setToolTip("Segmented objects (labeled image/connected components)")
            layers.append(objLayer)

        if binarySlot.ready():
#.........这里部分代码省略.........
开发者ID:CVML,项目名称:ilastik,代码行数:101,代码来源:objectClassificationGui.py


示例13: setupLayers

    def setupLayers(self, currentImageIndex):
        """
        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(currentImageIndex)

        labels = self.labelListData

        # Add the uncertainty estimate layer
        uncertaintySlot = self.pipeline.UncertaintyEstimate[currentImageIndex]
        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 )
            layers.append(uncertaintyLayer)

        # Add each of the predictions
        for channel, predictionSlot in enumerate(self.pipeline.PredictionProbabilityChannels[currentImageIndex]):
            if predictionSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                predictsrc = LazyflowSource(predictionSlot)
                predictLayer = AlphaModulatedLayer( predictsrc,
                                                    tintColor=ref_label.color,
                                                    range=(0.0, 1.0),
                                                    normalize=(0.0, 1.0) )
                predictLayer.opacity = 0.25
                predictLayer.visible = self.labelingDrawerUi.checkInteractive.isChecked()
                predictLayer.visibleChanged.connect(self.updateShowPredictionCheckbox)

                def setLayerColor(c):
                    predictLayer.tintColor = c
                def setLayerName(n):
                    newName = "Prediction for %s" % ref_label.name
                    predictLayer.name = newName
                setLayerName(ref_label.name)

                ref_label.colorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setLayerName)
                layers.append(predictLayer)

        # Add each of the segementations
        for channel, segmentationSlot in enumerate(self.pipeline.SegmentationChannels[currentImageIndex]):
            if segmentationSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                segsrc = LazyflowSource(segmentationSlot)
                segLayer = AlphaModulatedLayer( segsrc,
                                                tintColor=ref_label.color,
                                                range=(0.0, 1.0),
                                                normalize=(0.0, 1.0) )
                segLayer.opacity = 1
                segLayer.visible = self.labelingDrawerUi.checkInteractive.isChecked()
                segLayer.visibleChanged.connect(self.updateShowSegmentationCheckbox)

                def setLayerColor(c):
                    segLayer.tintColor = c
                def setLayerName(n):
                    newName = "Segmentation (%s)" % ref_label.name
                    segLayer.name = newName
                setLayerName(ref_label.name)

                ref_label.colorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setLayerName)
                layers.append(segLayer)

        # Add the raw data last (on the bottom)
        inputDataSlot = self.pipeline.InputImages[currentImageIndex]
        if inputDataSlot.ready():
            inputLayer = self.createStandardLayerFromSlot( inputDataSlot )
            inputLayer.name = "Input Data"
            inputLayer.visible = True
            inputLayer.opacity = 1.0
            
            def toggleTopToBottom():
                index = self.layerstack.layerIndex( inputLayer )
                self.layerstack.selectRow( index )
                if index == 0:
                    self.layerstack.moveSelectedToBottom()
                else:
                    self.layerstack.moveSelectedToTop()

            inputLayer.shortcutRegistration = (
                "Prediction Layers",
                "Bring Input To Top/Bottom",
                QShortcut( QKeySequence("i"), self.viewerControlWidget(), toggleTopToBottom),
                inputLayer )
            layers.append(inputLayer)
        
        return layers
开发者ID:kemaleren,项目名称:ilastik,代码行数:100,代码来源:pixelClassificationGui.py


示例14: setupLayers

    def setupLayers(self):
        layers = []        
        op = self.topLevelOperatorView
        binct = [QColor(Qt.black), QColor(Qt.white)]
        binct[0] = 0
        ct = create_default_16bit()
        ct[0]=0
        # Show the cached output, since it goes through a blocked cache
        
        if op.CachedOutput.ready():
            outputSrc = LazyflowSource(op.CachedOutput)
            outputLayer = ColortableLayer(outputSrc, ct)
            outputLayer.name = "Final output"
            outputLayer.visible = False
            outputLayer.opacity = 1.0
            outputLayer.setToolTip("Results of thresholding and size filter")
            layers.append(outputLayer)
            
        if op.InputImage.ready():
            numChannels = op.InputImage.meta.getTaggedShape()['c']
            
            for channel in range(numChannels):
                channelProvider = OpSingleChannelSelector(parent=op.InputImage.getRealOperator().parent)
                channelProvider.Input.connect(op.InputImage)
                channelProvider.Index.setValue( channel )
                channelSrc = LazyflowSource( channelProvider.Output )
                inputChannelLayer = AlphaModulatedLayer( channelSrc,
                                                    tintColor=QColor(self._channelColors[channel]),
                                                    range=(0.0, 1.0),
                                                    normalize=(0.0, 1.0) )
                inputChannelLayer.opacity = 0.5
                inputChannelLayer.visible = True
                inputChannelLayer.name = "Input Channel " + str(channel)
                inputChannelLayer.setToolTip("Select input channel " + str(channel) + \
                                             " if this prediction image contains the objects of interest.")                    
                layers.append(inputChannelLayer)
                
        if self._showDebug:
            #FIXME: We have to do that, because lazyflow doesn't have a way to make an operator partially ready
            curIndex = self._drawer.tabWidget.currentIndex()
            if curIndex==1:
                if op.BigRegions.ready():
                    lowThresholdSrc = LazyflowSource(op.BigRegions)
                    lowThresholdLayer = ColortableLayer(lowThresholdSrc, binct)
                    lowThresholdLayer.name = "After low threshold"
                    lowThresholdLayer.visible = False
                    lowThresholdLayer.opacity = 1.0
                    lowThresholdLayer.setToolTip("Results of thresholding with the low pixel value threshold")
                    layers.append(lowThresholdLayer)
        
                if op.FilteredSmallLabels.ready():
                    filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels )
                    filteredSmallLabelsLayer.name = "After high threshold and size filter"
                    filteredSmallLabelsLayer.visible = False
                    filteredSmallLabelsLayer.opacity = 1.0
                    filteredSmallLabelsLayer.setToolTip("Results of thresholding with the high pixel value threshold,\
                                                         followed by the size filter")
                    layers.append(filteredSmallLabelsLayer)
        
                if op.SmallRegions.ready():
                    highThresholdSrc = LazyflowSource(op.SmallRegions)
                    highThresholdLayer = ColortableLayer(highThresholdSrc, binct)
                    highThresholdLayer.name = "After high threshold"
                    highThresholdLayer.visible = False
                    highThresholdLayer.opacity = 1.0
                    highThresholdLayer.setToolTip("Results of thresholding with the high pixel value threshold")
                    layers.append(highThresholdLayer)
            elif curIndex==0:
                if op.BeforeSizeFilter.ready():
                    thSrc = LazyflowSource(op.BeforeSizeFilter)
                    thLayer = ColortableLayer(thSrc, ct)
                    thLayer.name = "Before size filter"
                    thLayer.visible = False
                    thLayer.opacity = 1.0
                    thLayer.setToolTip("Results of thresholding before the size filter is applied")
                    layers.append(thLayer)
            
            # Selected input channel, smoothed.
            if op.Smoothed.ready():
                smoothedLayer = self.createStandardLayerFromSlot( op.Smoothed )
                smoothedLayer.name = "Smoothed input"
                smoothedLayer.visible = True
                smoothedLayer.opacity = 1.0
                smoothedLayer.setToolTip("Selected channel data, smoothed with a Gaussian with user-defined sigma")
                layers.append(smoothedLayer)
                
        
        # Show the raw input data
        rawSlot = self.topLevelOperatorView.RawInput
        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,代码行数:97,代码来源:thresholdTwoLevelsGui.py


示例15: setupLayers

    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 )
            layers.append(uncertaintyLayer)

        labels = self.labelListData

        # Add each of the segmentations
        for channel, segmentationSlot in enumerate(self.topLevelOperatorView.SegmentationChannels):
            if segmentationSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                segsrc = LazyflowSource(segmentationSlot)
                segLayer = AlphaModulatedLayer( segsrc,
                                                tintColor=ref_label.pmapColor(),
                                                range=(0.0, 1.0),
                                                normalize=(0.0, 1.0) )

                segLayer.opacity = 1
                segLayer.visible = False #self.labelingDrawerUi.liveUpdateButton.isChecked()
                segLayer.visibleChanged.connect(self.updateShowSegmentationCheckbox)

                def setLayerColor(c, segLayer=segLayer):
                    segLayer.tintColor = c
                    self._update_rendering()

                def setSegLayerName(n, segLayer=segLayer):
                    oldname = segLayer.name
                    newName = "Segmentation (%s)" % n
                    segLayer.name = newName
                    if not self.render:
                        return
                    if oldname in self._renderedLayers:
                        label = self._renderedLayers.pop(oldname)
                        self._renderedLayers[newName] = label

                setSegLayerName(ref_label.name)

                ref_label.pmapColorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setSegLayerName)
                #check if layer is 3d before adding the "Toggle 3D" option
                #this check is done this way to match the VolumeRenderer, in
                #case different 3d-axistags should be rendered like t-x-y
                #_axiskeys = segmentationSlot.meta.getAxisKeys()
                if len(segmentationSlot.meta.shape) == 4:
                    #the Renderer will cut out the last shape-dimension, so
                    #we're checking for 4 dimensions
                    self._setup_contexts(segLayer)
                layers.append(segLayer)
        
        # Add each of the predictions
        for channel, predictionSlot in enumerate(self.topLevelOperatorView.PredictionProbabilityChannels):
            if predictionSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                predictsrc = LazyflowSource(predictionSlot)
                predictLayer = AlphaModulatedLayer( predictsrc,
                                                    tintColor=ref_label.pmapColor(),
                                                    range=(0.0, 1.0),
                                           

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.ColortableLayer类代码示例发布时间:2022-05-26
下一篇:
Python jsonapi.loads函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap