当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkImageThreshold函数代码示例

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


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

示例1: getImageMask

def getImageMask(inputVtkImageData):
    """
    @type  inputVtkImageData: C{vtkImageData}
    @param inputVtkImageData: Image data to be normalized
    
    @rtype: C{vtkImageData}
    @return: Normalized (0-1) image data
    """
    t = vtk.vtkImageThreshold()
    #t.ThresholdBetween(1,255)
    t.ThresholdByUpper(114)
    t.ReplaceInOn()
    t.SetReplaceIn(0)
    t.ReplaceOutOn()
    t.SetReplaceOut(255)
    t.SetInput(inputVtkImageData)
        
    norm = vtk.vtkImageNormalize()
    norm.SetInput(t.GetOutput())
    #norm.SetInput(inputVtkImageData)
    norm.Update()

    d = vtk.vtkImageDilateErode3D()
    d.SetKernelSize(4,4,4)
    d.SetDilateValue(1)
    d.SetErodeValue(0)
    d.SetInput(norm.GetOutput())
    return d.GetOutput()
开发者ID:pmajka,项目名称:3dbar-extensions,代码行数:28,代码来源:volume_merger.py

示例2: splitPerStructureVolumes

  def splitPerStructureVolumes(masterNode, mergeNode):
    """Make a separate label map node for each non-empty label value in the
    merged label map"""

    colorNode = mergeNode.GetDisplayNode().GetColorNode()

    accum = vtk.vtkImageAccumulate()
    accum.SetInputConnection(mergeNode.GetImageDataConnection())
    accum.Update()
    lo = int(accum.GetMin()[0])
    hi = int(accum.GetMax()[0])

    thresholder = vtk.vtkImageThreshold()
    for index in xrange(lo,hi+1):
      logging.info( "Splitting label %d..."%index )
      thresholder.SetInputConnection( mergeNode.GetImageDataConnection() )
      thresholder.SetInValue( index )
      thresholder.SetOutValue( 0 )
      thresholder.ReplaceInOn()
      thresholder.ReplaceOutOn()
      thresholder.ThresholdBetween( index, index )
      thresholder.SetOutputScalarType( mergeNode.GetImageData().GetScalarType() )
      thresholder.Update()
      if thresholder.GetOutput().GetScalarRange() != (0.0, 0.0):
        structureName = colorNode.GetColorName(index)
        logging.info( "Creating structure volume %s..."%structureName )
        structureVolume = EditUtil.structureVolume( masterNode, structureName )
        if not structureVolume:
          EditUtil.addStructure( masterNode, mergeNode, index )
        structureVolume = EditUtil.structureVolume( masterNode, structureName )
        structureVolume.GetImageData().DeepCopy( thresholder.GetOutput() )
        EditUtil.markVolumeNodeAsModified(structureVolume)
开发者ID:gregsharp,项目名称:Slicer,代码行数:32,代码来源:EditUtil.py

示例3: onApply

  def onApply(self):

    import vtkSegmentationCorePython as vtkSegmentationCore

    # Get modifier labelmap and parameters

    operation = self.scriptedEffect.parameter("Operation")

    if operation in self.operationsRequireModifierSegment:

      # Get modifier segment
      segmentationNode = self.scriptedEffect.parameterSetNode().GetSegmentationNode()
      segmentation = segmentationNode.GetSegmentation()
      modifierSegmentID = self.modifierSegmentID()
      if not modifierSegmentID:
        logging.error("Operation {0} requires a selected modifier segment".format(operation))
        return
      modifierSegment = segmentation.GetSegment(modifierSegmentID)
      modifierSegmentLabelmap = modifierSegment.GetRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationBinaryLabelmapRepresentationName())

      if operation == LOGICAL_COPY:
        self.scriptedEffect.modifySelectedSegmentByLabelmap(modifierSegmentLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeSet)
      elif operation == LOGICAL_UNION:
        self.scriptedEffect.modifySelectedSegmentByLabelmap(modifierSegmentLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeAdd)
      elif operation == LOGICAL_SUBTRACT:
        self.scriptedEffect.modifySelectedSegmentByLabelmap(modifierSegmentLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeRemove)
      elif operation == LOGICAL_INTERSECT:
        selectedSegmentLabelmap = self.scriptedEffect.selectedSegmentLabelmap()
        intersectionLabelmap = vtkSegmentationCore.vtkOrientedImageData()
        vtkSegmentationCore.vtkOrientedImageDataResample.MergeImage(selectedSegmentLabelmap, modifierSegmentLabelmap, intersectionLabelmap, vtkSegmentationCore.vtkOrientedImageDataResample.OPERATION_MINIMUM, selectedSegmentLabelmap.GetExtent())
        selectedSegmentLabelmapExtent = selectedSegmentLabelmap.GetExtent()
        modifierSegmentLabelmapExtent = modifierSegmentLabelmap.GetExtent()
        commonExtent = [max(selectedSegmentLabelmapExtent[0], modifierSegmentLabelmapExtent[0]),
          min(selectedSegmentLabelmapExtent[1], modifierSegmentLabelmapExtent[1]),
          max(selectedSegmentLabelmapExtent[2], modifierSegmentLabelmapExtent[2]),
          min(selectedSegmentLabelmapExtent[3], modifierSegmentLabelmapExtent[3]),
          max(selectedSegmentLabelmapExtent[4], modifierSegmentLabelmapExtent[4]),
          min(selectedSegmentLabelmapExtent[5], modifierSegmentLabelmapExtent[5])]
        self.scriptedEffect.modifySelectedSegmentByLabelmap(intersectionLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeSet, commonExtent)

    elif operation == LOGICAL_INVERT:
      selectedSegmentLabelmap = self.scriptedEffect.selectedSegmentLabelmap()
      inverter = vtk.vtkImageThreshold()
      inverter.SetInputData(selectedSegmentLabelmap)
      inverter.SetInValue(1)
      inverter.SetOutValue(0)
      inverter.ReplaceInOn()
      inverter.ThresholdByLower(0)
      inverter.SetOutputScalarType(vtk.VTK_UNSIGNED_CHAR)
      inverter.Update()
      selectedSegmentLabelmap.DeepCopy(inverter.GetOutput())
      self.scriptedEffect.modifySelectedSegmentByLabelmap(selectedSegmentLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeSet)

    elif operation == LOGICAL_CLEAR or operation == LOGICAL_FILL:
      selectedSegmentLabelmap = self.scriptedEffect.selectedSegmentLabelmap()
      vtkSegmentationCore.vtkOrientedImageDataResample.FillImage(selectedSegmentLabelmap, 1 if operation == LOGICAL_FILL else 0, selectedSegmentLabelmap.GetExtent())
      self.scriptedEffect.modifySelectedSegmentByLabelmap(selectedSegmentLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeSet)

    else:
      logging.error("Uknown operation: {0}".format(operation))
开发者ID:ZeneticX,项目名称:Slicer,代码行数:60,代码来源:SegmentEditorLogicalEffect.py

示例4: onApply

  def onApply(self):
    try:
      # Get master volume image data
      import vtkSegmentationCorePython as vtkSegmentationCore
      masterImageData = self.scriptedEffect.masterVolumeImageData()
      # Get modifier labelmap
      modifierLabelmap = self.scriptedEffect.defaultModifierLabelmap()
      originalImageToWorldMatrix = vtk.vtkMatrix4x4()
      modifierLabelmap.GetImageToWorldMatrix(originalImageToWorldMatrix)
      # Get parameters
      min = self.scriptedEffect.doubleParameter("MinimumThreshold")
      max = self.scriptedEffect.doubleParameter("MaximumThreshold")

      self.scriptedEffect.saveStateForUndo()

      # Perform thresholding
      thresh = vtk.vtkImageThreshold()
      thresh.SetInputData(masterImageData)
      thresh.ThresholdBetween(min, max)
      thresh.SetInValue(1)
      thresh.SetOutValue(0)
      thresh.SetOutputScalarType(modifierLabelmap.GetScalarType())
      thresh.Update()
      modifierLabelmap.DeepCopy(thresh.GetOutput())
    except IndexError:
      logging.error('apply: Failed to threshold master volume!')
      pass

    # Apply changes
    self.scriptedEffect.modifySelectedSegmentByLabelmap(modifierLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeSet)

    # De-select effect
    self.scriptedEffect.selectEffect("")
开发者ID:BRAINSia,项目名称:Slicer,代码行数:33,代码来源:SegmentEditorThresholdEffect.py

示例5: __init__

  def __init__(self):
    self.lookupTable = vtk.vtkLookupTable()
    self.lookupTable.SetRampToLinear()
    self.lookupTable.SetNumberOfTableValues(2)
    self.lookupTable.SetTableRange(0, 1)
    self.lookupTable.SetTableValue(0,  0, 0, 0,  0)
    self.colorMapper = vtk.vtkImageMapToRGBA()
    self.colorMapper.SetOutputFormatToRGBA()
    self.colorMapper.SetLookupTable(self.lookupTable)
    self.thresholdFilter = vtk.vtkImageThreshold()
    self.thresholdFilter.SetInValue(1)
    self.thresholdFilter.SetOutValue(0)
    self.thresholdFilter.SetOutputScalarTypeToUnsignedChar()

    # Feedback actor
    self.mapper = vtk.vtkImageMapper()
    self.dummyImage = vtk.vtkImageData()
    self.dummyImage.AllocateScalars(vtk.VTK_UNSIGNED_INT, 1)
    self.mapper.SetInputData(self.dummyImage)
    self.actor = vtk.vtkActor2D()
    self.actor.VisibilityOff()
    self.actor.SetMapper(self.mapper)
    self.mapper.SetColorWindow(255)
    self.mapper.SetColorLevel(128)

    # Setup pipeline
    self.colorMapper.SetInputConnection(self.thresholdFilter.GetOutputPort())
    self.mapper.SetInputConnection(self.colorMapper.GetOutputPort())
开发者ID:BRAINSia,项目名称:Slicer,代码行数:28,代码来源:SegmentEditorThresholdEffect.py

示例6: ROIfromImages

  def ROIfromImages(self,inputImage,ROIImage,radius,iterations,connectivity,newROI):
    #TODO: sistemare valori
    #col=self.ROI.GetDisplayNode().GetColorNode()
    bg=0
    fg=1

    if newROI:
      #slicer.util.delayDisplay('thresholding...')
      thresh = vtk.vtkImageThreshold()
      thresh.SetInputData(inputImage)

      lo, hi = inputImage.GetScalarRange()
      min=lo + 0.25 * (hi-lo)
      max=hi

      thresh.ThresholdBetween(min, max)
      thresh.SetInValue(fg)
      thresh.SetOutValue(bg)
      thresh.SetOutputScalarType(ROIImage.GetScalarType())
      thresh.Modified()
      thresh.Update()

      ROIImage.DeepCopy(thresh.GetOutput())

      try:
        self.markVolumeNodeAsModified(self.ROI)
      except:
        pass

    if radius>0:
      ImageBuffer = vtk.vtkImageData()
      ImageBuffer.DeepCopy(ROIImage)

      eroder = slicer.vtkImageErodeExt()
      eroder.SetInputData(ROIImage)
      eroder.SetOutput(ImageBuffer)
      
      #slicer.util.delayDisplay('create kernel')
      #eroder.SetForeground(fg)
      eroder.SetbutForeground(True)
      eroder.SetBackground(bg)
      eroder.setRadius(radius,radius,1)
      if connectivity==0:
        eroder.SetNeighborTo8()
      elif connectivity==1:
        eroder.SetNeighborTo4()
      else:
        eroder.setConnectivity2D()
        
      for f in range(1,int(ROIImage.GetScalarRange()[1]+1)):
        eroder.SetForeground(f)

        #slicer.util.delayDisplay('eroding label = ' + str(f))

        for n in range(iterations):
          ImageBuffer.DeepCopy(ROIImage)
          eroder.Update()
          ROIImage.DeepCopy(ImageBuffer)
          
      eroder.SetOutput(None)
开发者ID:gina-belmonte,项目名称:SlicerExtension-QASuite,代码行数:60,代码来源:ErodeImage.py

示例7: __init__

 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkImageThreshold(), 'Processing.',
         ('vtkImageData',), ('vtkImageData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkImageThreshold.py

示例8: onApply

  def onApply(self):
    try:
      # Get master volume image data
      import vtkSegmentationCore
      masterImageData = vtkSegmentationCore.vtkOrientedImageData()
      self.scriptedEffect.masterVolumeImageData(masterImageData)
      # Get edited labelmap
      editedLabelmap = self.scriptedEffect.parameterSetNode().GetEditedLabelmap()
      # Get parameters
      min = self.scriptedEffect.doubleParameter("MinimumThreshold")
      max = self.scriptedEffect.doubleParameter("MaximumThreshold")

      # Save state for undo
      #TODO:
      #self.undoRedo.saveState()

      # Perform thresholding
      thresh = vtk.vtkImageThreshold()
      thresh.SetInputData(masterImageData)
      thresh.ThresholdBetween(min, max)
      thresh.SetInValue(1)
      thresh.SetOutValue(0)
      thresh.SetOutputScalarType(editedLabelmap.GetScalarType())
      thresh.Update()
      editedLabelmap.DeepCopy(thresh.GetOutput())
    except IndexError:
      logging.error('apply: Failed to threshold master volume!')
      pass

    # Notify editor about changes.
    # This needs to be called so that the changes are written back to the edited segment
    self.scriptedEffect.apply()
    
    # De-select effect
    self.scriptedEffect.selectEffect("")
开发者ID:ming-hai,项目名称:SlicerRT,代码行数:35,代码来源:SegmentEditorThresholdEffect.py

示例9: computeStatistics

  def computeStatistics(self, segmentID):
    import vtkSegmentationCorePython as vtkSegmentationCore
    requestedKeys = self.getRequestedKeys()

    segmentationNode = slicer.mrmlScene.GetNodeByID(self.getParameterNode().GetParameter("Segmentation"))

    if len(requestedKeys)==0:
      return {}

    containsLabelmapRepresentation = segmentationNode.GetSegmentation().ContainsRepresentation(
      vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationBinaryLabelmapRepresentationName())
    if not containsLabelmapRepresentation:
      return {}

    segment = segmentationNode.GetSegmentation().GetSegment(segmentID)
    segBinaryLabelName = vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationBinaryLabelmapRepresentationName()
    segmentLabelmap = segment.GetRepresentation(segBinaryLabelName)

    if (not segmentLabelmap
      or not segmentLabelmap.GetPointData()
      or not segmentLabelmap.GetPointData().GetScalars()):
      # No input label data
      return {}

    # We need to know exactly the value of the segment voxels, apply threshold to make force the selected label value
    labelValue = 1
    backgroundValue = 0
    thresh = vtk.vtkImageThreshold()
    thresh.SetInputData(segmentLabelmap)
    thresh.ThresholdByLower(0)
    thresh.SetInValue(backgroundValue)
    thresh.SetOutValue(labelValue)
    thresh.SetOutputScalarType(vtk.VTK_UNSIGNED_CHAR)
    thresh.Update()

    #  Use binary labelmap as a stencil
    stencil = vtk.vtkImageToImageStencil()
    stencil.SetInputData(thresh.GetOutput())
    stencil.ThresholdByUpper(labelValue)
    stencil.Update()

    stat = vtk.vtkImageAccumulate()
    stat.SetInputData(thresh.GetOutput())
    stat.SetStencilData(stencil.GetOutput())
    stat.Update()

    # Add data to statistics list
    cubicMMPerVoxel = reduce(lambda x,y: x*y, segmentLabelmap.GetSpacing())
    ccPerCubicMM = 0.001
    stats = {}
    if "voxel_count" in requestedKeys:
      stats["voxel_count"] = stat.GetVoxelCount()
    if "volume_mm3" in requestedKeys:
      stats["volume_mm3"] = stat.GetVoxelCount() * cubicMMPerVoxel
    if "volume_cm3" in requestedKeys:
      stats["volume_cm3"] = stat.GetVoxelCount() * cubicMMPerVoxel * ccPerCubicMM
    return stats
开发者ID:Slicer,项目名称:Slicer,代码行数:57,代码来源:LabelmapSegmentStatisticsPlugin.py

示例10: growCut

  def growCut(self):
    growCutFilter = vtkITK.vtkITKGrowCutSegmentationImageFilter()
    background = self.getScopedBackground()
    gestureInput = self.getScopedLabelInput()
    growCutOutput = self.getScopedLabelOutput()

    if not self.areInputsValid():
      logging.warning(self.getInvalidInputsMessage())

    # set the make a zero-valued volume for the output
    # TODO: maybe this should be done in numpy as a one-liner
    thresh = vtk.vtkImageThreshold()
    thresh.ReplaceInOn()
    thresh.ReplaceOutOn()
    thresh.SetInValue(0)
    thresh.SetOutValue(0)
    thresh.SetOutputScalarType( vtk.VTK_SHORT )
    if vtk.VTK_MAJOR_VERSION <= 5:
      thresh.SetInput( gestureInput )
    else:
      thresh.SetInputData( gestureInput )
    thresh.SetOutput( growCutOutput )
    thresh.Update()
    growCutOutput.DeepCopy( gestureInput )

    if vtk.VTK_MAJOR_VERSION <= 5:
      growCutFilter.SetInput( 0, background )
      growCutFilter.SetInput( 1, gestureInput )
      growCutFilter.SetInput( 2, growCutOutput )
    else:
      growCutFilter.SetInputData( 0, background )
      growCutFilter.SetInputData( 1, gestureInput )
      growCutFilter.SetInputConnection( 2, thresh.GetOutputPort() )

    objectSize = 5. # TODO: this is a magic number
    contrastNoiseRatio = 0.8 # TODO: this is a magic number
    priorStrength = 0.003 # TODO: this is a magic number
    segmented = 2 # TODO: this is a magic number
    conversion = 1000 # TODO: this is a magic number

    spacing = gestureInput.GetSpacing()
    voxelVolume = reduce(lambda x,y: x*y, spacing)
    voxelAmount = objectSize / voxelVolume
    voxelNumber = round(voxelAmount) * conversion

    cubeRoot = 1./3.
    oSize = int(round(pow(voxelNumber,cubeRoot)))

    growCutFilter.SetObjectSize( oSize )
    growCutFilter.SetContrastNoiseRatio( contrastNoiseRatio )
    growCutFilter.SetPriorSegmentConfidence( priorStrength )
    growCutFilter.Update()

    growCutOutput.DeepCopy( growCutFilter.GetOutput() )

    self.applyScopedLabel()
开发者ID:kingofpanda,项目名称:Slicer,代码行数:56,代码来源:GrowCutEffect.py

示例11: applyThreshold

 def applyThreshold(labelNode, outValue):
   imageData = labelNode.GetImageData()
   backgroundValue = 0
   thresh = vtk.vtkImageThreshold()
   thresh.SetInputData(imageData)
   thresh.ThresholdByLower(0)
   thresh.SetInValue(backgroundValue)
   thresh.SetOutValue(outValue)
   thresh.SetOutputScalarType(vtk.VTK_UNSIGNED_CHAR)
   thresh.Update()
   labelNode.SetAndObserveImageData(thresh.GetOutput())
开发者ID:QIICR,项目名称:Reporting,代码行数:11,代码来源:CustomSegmentEditor.py

示例12: preview

  def preview(self,color=None):

    if not self.editUtil.getBackgroundImage() or not self.editUtil.getLabelImage():
      return

    #
    # make a lookup table where inside the threshold is opaque and colored
    # by the label color, while the background is transparent (black)
    # - apply the threshold operation to the currently visible background
    #   (output of the layer logic's vtkImageReslice instance)
    #

    if not color:
      color = self.getPaintColor

    if not self.lut:
      self.lut = vtk.vtkLookupTable()

    self.lut.SetRampToLinear()
    self.lut.SetNumberOfTableValues( 2 )
    self.lut.SetTableRange( 0, 1 )
    self.lut.SetTableValue( 0,  0, 0, 0,  0 )
    r,g,b,a = color
    self.lut.SetTableValue( 1,  r, g, b,  a )

    if not self.map:
      self.map = vtk.vtkImageMapToRGBA()
    self.map.SetOutputFormatToRGBA()
    self.map.SetLookupTable( self.lut )

    if not self.thresh:
      self.thresh = vtk.vtkImageThreshold()
    sliceLogic = self.sliceWidget.sliceLogic()
    backgroundLogic = sliceLogic.GetBackgroundLayer()
    if vtk.VTK_MAJOR_VERSION <= 5:
      self.thresh.SetInput( backgroundLogic.GetReslice().GetOutput() )
    else:
      self.thresh.SetInputConnection( backgroundLogic.GetReslice().GetOutputPort() )
    self.thresh.ThresholdBetween( self.min, self.max )
    self.thresh.SetInValue( 1 )
    self.thresh.SetOutValue( 0 )
    self.thresh.SetOutputScalarTypeToUnsignedChar()
    if vtk.VTK_MAJOR_VERSION <= 5:
      self.map.SetInput( self.thresh.GetOutput() )
      self.map.Update()
      self.cursorMapper.SetInput( self.map.GetOutput() )
    else:
      self.map.SetInputConnection( self.thresh.GetOutputPort() )
      self.cursorMapper.SetInputConnection( self.map.GetOutputPort() )

    self.cursorActor.VisibilityOn()

    self.sliceView.scheduleRender()
开发者ID:kingofpanda,项目名称:Slicer,代码行数:53,代码来源:ThresholdEffect.py

示例13: __init__

 def __init__(self, img, threshold, xysmoothing, zsmoothing, color, alpha):
     dataImporter = vtk.vtkImageImport()
     simg = np.ascontiguousarray(img, np.uint8)
     dataImporter.CopyImportVoidPointer(simg.data, len(simg.data))
     dataImporter.SetDataScalarTypeToUnsignedChar()
     dataImporter.SetNumberOfScalarComponents(1)
     dataImporter.SetDataExtent(0, simg.shape[2]-1, 0, simg.shape[1]-1, 0, simg.shape[0]-1)
     dataImporter.SetWholeExtent(0, simg.shape[2]-1, 0, simg.shape[1]-1, 0, simg.shape[0]-1)
     self.__smoother = vtk.vtkImageGaussianSmooth()
     self.__smoother.SetStandardDeviation(xysmoothing, xysmoothing, zsmoothing)
     self.__smoother.SetInputConnection(dataImporter.GetOutputPort())
     self.__threshold = vtk.vtkImageThreshold()
     self.__threshold.SetInputConnection(self.__smoother.GetOutputPort())
     self.__threshold.ThresholdByUpper(threshold)
     self.__threshold.ReplaceInOn()
     self.__threshold.SetInValue(1)
     self.__threshold.ReplaceOutOn()
     self.__threshold.SetOutValue(0)
     self.__threshold.Update()
     contour = vtk.vtkDiscreteMarchingCubes()
     contour.SetInputConnection(self.__threshold.GetOutputPort())
     contour.ComputeNormalsOn()
     contour.SetValue(0, 1)
     contour.Update()
     smoother = vtk.vtkWindowedSincPolyDataFilter()
     smoother.SetInputConnection(contour.GetOutputPort())
     smoother.NonManifoldSmoothingOn()
     smoother.NormalizeCoordinatesOn()
     smoother.Update()
     triangleCellNormals=vtk.vtkPolyDataNormals()
     triangleCellNormals.SetInputConnection(smoother.GetOutputPort())
     triangleCellNormals.ComputeCellNormalsOn()
     triangleCellNormals.ComputePointNormalsOff()
     triangleCellNormals.ConsistencyOn()
     triangleCellNormals.AutoOrientNormalsOn()
     triangleCellNormals.Update()
     triangleCellAn = vtk.vtkMeshQuality()
     triangleCellAn.SetInputConnection(triangleCellNormals.GetOutputPort())
     triangleCellAn.SetTriangleQualityMeasureToArea()
     triangleCellAn.SaveCellQualityOn()
     triangleCellAn.Update()
     mapper = vtk.vtkPolyDataMapper()
     mapper.SetInputConnection(triangleCellAn.GetOutputPort())
     mapper.ScalarVisibilityOn()
     mapper.SetScalarRange(.3, 1)
     mapper.SetScalarModeToUsePointData()
     colorLookupTable = vtk.vtkLookupTable()
     colorLookupTable.SetHueRange(.6, 1)
     colorLookupTable.Build()
     mapper.SetLookupTable(colorLookupTable)
     self.SetMapper(mapper)
     self.GetProperty().SetColor(*color)
     self.GetProperty().SetOpacity(alpha)
开发者ID:LeeKamentsky,项目名称:q3dstack,代码行数:53,代码来源:q3dstack.py

示例14: __init__

    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)
        NoConfigModuleMixin.__init__(self)

        # these will be our markers
        self._inputPoints = None

        # we can't connect the image input directly to the masksource,
        # so we have to keep track of it separately.
        self._inputImage = None
        self._inputImageObserverID = None

        # we need to modify the mask (I) as well.  The problem with a
        # ProgrammableFilter is that you can't request GetOutput() before
        # the input has been set... 
        self._maskSource = vtk.vtkProgrammableSource()
        self._maskSource.SetExecuteMethod(self._maskSourceExecute)
        
        # we'll use this to synthesise a volume according to the seed points
        self._markerSource = vtk.vtkProgrammableSource()
        self._markerSource.SetExecuteMethod(self._markerSourceExecute)
        # second input is J (the marker)

        # we'll use this to change the markerImage into something we can use
        self._imageThreshold = vtk.vtkImageThreshold()
        # everything equal to or above 1.0 will be "on"
        self._imageThreshold.ThresholdByUpper(1.0)
        self._imageThresholdObserverID = self._imageThreshold.AddObserver(
            'EndEvent', self._observerImageThreshold)
        
        self._viewFrame = self._createViewFrame(
            {'Module (self)' : self})

        # we're not going to give imageErode any input... that's going to
        # to happen manually in the execute_module function :)
        self._imageErode = vtk.vtkImageContinuousErode3D()
        self._imageErode.SetKernelSize(3,3,3)

        module_utils.setup_vtk_object_progress(self, self._imageErode,
                                           'Performing greyscale 3D erosion')
        

        self._sup = vtk.vtkImageMathematics()
        self._sup.SetOperationToMax()
        self._sup.SetInput1(self._imageErode.GetOutput())
        self._sup.SetInput2(self._maskSource.GetStructuredPointsOutput())

        # pass the data down to the underlying logic
        self.config_to_logic()
        # and all the way up from logic -> config -> view to make sure
        self.syncViewWithLogic()
开发者ID:fvpolpeta,项目名称:devide,代码行数:52,代码来源:modifyHomotopySlow.py

示例15: create_overlay

    def create_overlay(self, emphysemavalue, severeemphysemavalue):
        """Creates an overlay for the slice-based volume view
           0: no emphysema
           1: moderate emphysema
           2: severe emphysema
        """
        
    	self._view_frame.SetStatusText("Creating Overlay...")
    	mask = vtk.vtkImageMask()
    	mask2 = vtk.vtkImageMask()
    	threshold = vtk.vtkImageThreshold()
    	threshold2 = vtk.vtkImageThreshold()
    	math=vtk.vtkImageMathematics()
    
    	mask.SetInput(self.image_data)
    	mask.SetMaskInput(self.mask_data)
    
    	threshold.SetInput(mask.GetOutput())
    	threshold.ThresholdByLower(emphysemavalue)
    	threshold.SetOutValue(0)
    	threshold.SetInValue(1)

    	threshold2.SetInput(mask.GetOutput())
    	threshold2.ThresholdByLower(severeemphysemavalue)
    	threshold2.SetOutValue(1)
    	threshold2.SetInValue(2)

    	math.SetOperationToMultiply()
    	math.SetInput1(threshold.GetOutput())
    	math.SetInput2(threshold2.GetOutput())

    	math.Update()

    	overlay = math.GetOutput()
    	self.slice_viewer1.set_overlay_input(None)
    	self.slice_viewer1.set_overlay_input(overlay)
    	self.render()
    	self._view_frame.SetStatusText("Created Overlay")
开发者ID:fvpolpeta,项目名称:devide,代码行数:38,代码来源:EmphysemaViewer.py


注:本文中的vtk.vtkImageThreshold函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。