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


Python EditUtil.getLabelImage方法代码示例

本文整理汇总了Python中EditUtil.EditUtil.getLabelImage方法的典型用法代码示例。如果您正苦于以下问题:Python EditUtil.getLabelImage方法的具体用法?Python EditUtil.getLabelImage怎么用?Python EditUtil.getLabelImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EditUtil.EditUtil的用法示例。


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

示例1: updateLabel

# 需要导入模块: from EditUtil import EditUtil [as 别名]
# 或者: from EditUtil.EditUtil import getLabelImage [as 别名]
  def updateLabel(self,value):
    if not self.fm:
      return
    self.fm.show(value)
    self.fm.Modified()
    self.fm.Update()

    EditUtil.getLabelImage().DeepCopy(self.fm.GetOutput())
    EditUtil.getLabelImage().Modified()

    EditUtil.markVolumeNodeAsModified(self.sliceLogic.GetLabelLayer().GetVolumeNode())
开发者ID:kingofpanda,项目名称:Slicer,代码行数:13,代码来源:FastMarchingEffect.py

示例2: percentMaxChanged

# 需要导入模块: from EditUtil import EditUtil [as 别名]
# 或者: from EditUtil.EditUtil import getLabelImage [as 别名]
    def percentMaxChanged(self, val):
        labelNode = self.logic.getLabelNode()
        labelImage = EditUtil.getLabelImage()
        spacing = labelNode.GetSpacing()
        dim = labelImage.GetDimensions()
        print dim
        totalVolume = spacing[0] * dim[0] + spacing[1] * dim[1] + spacing[2] * dim[2]

        percentVolumeStr = "%.5f" % (totalVolume * val / 100.0)
        self.percentVolume.text = "(maximum total volume: " + percentVolumeStr + " mL)"
开发者ID:ZeneticX,项目名称:Slicer,代码行数:12,代码来源:FastMarchingEffect.py

示例3: percentMaxChanged

# 需要导入模块: from EditUtil import EditUtil [as 别名]
# 或者: from EditUtil.EditUtil import getLabelImage [as 别名]
  def percentMaxChanged(self, val):
    labelNode = self.logic.getLabelNode()
    labelImage = EditUtil.getLabelImage()
    spacing = labelNode.GetSpacing()
    if vtk.VTK_MAJOR_VERSION <= 5:
      dim = labelImage.GetDimensions()
      totalVolume = spacing[0]*(dim[1]+1)+spacing[1]*(dim[3]+1)+spacing[2]*(dim[5]+1)
    else:
      dim = labelImage.GetDimensions()
      print dim
      totalVolume = spacing[0]*dim[0]+spacing[1]*dim[1]+spacing[2]*dim[2]

      percentVolumeStr = "%.5f" % (totalVolume*val/100.)
    self.percentVolume.text = '(maximum total volume: '+percentVolumeStr+' mL)'
开发者ID:kingofpanda,项目名称:Slicer,代码行数:16,代码来源:FastMarchingEffect.py

示例4: fastMarching

# 需要导入模块: from EditUtil import EditUtil [as 别名]
# 或者: from EditUtil.EditUtil import getLabelImage [as 别名]
  def fastMarching(self,percentMax):

    self.fm = None
    # allocate a new filter each time March is hit
    bgImage = EditUtil.getBackgroundImage()
    labelImage = EditUtil.getLabelImage()

    # collect seeds
    if vtk.VTK_MAJOR_VERSION <= 5:
      dim = bgImage.GetWholeExtent()
    else:
      dim = bgImage.GetDimensions()
      print dim
    # initialize the filter
    self.fm = slicer.vtkPichonFastMarching()
    scalarRange = bgImage.GetScalarRange()
    depth = scalarRange[1]-scalarRange[0]

    # this is more or less arbitrary; large depth values will bring the
    # algorithm to the knees
    scaleValue = 0
    shiftValue = 0

    if depth>300:
      scaleValue = 300./depth
    if scalarRange[0] < 0:
      shiftValue = scalarRange[0]*-1

    if scaleValue or shiftValue:
      rescale = vtk.vtkImageShiftScale()
      if vtk.VTK_MAJOR_VERSION <= 5:
        rescale.SetInput(bgImage)
      else:
        rescale.SetInputData(bgImage)
      rescale.SetScale(scaleValue)
      rescale.SetShift(shiftValue)
      rescale.Update()
      bgImage = rescale.GetOutput()
      scalarRange = bgImage.GetScalarRange()
      depth = scalarRange[1]-scalarRange[0]

    print('Input scalar range: '+str(depth))
    if vtk.VTK_MAJOR_VERSION <= 5:
      self.fm.init(dim[1]+1, dim[3]+1, dim[5]+1, depth, 1, 1, 1)
    else:
      self.fm.init(dim[0], dim[1], dim[2], depth, 1, 1, 1)

    caster = vtk.vtkImageCast()
    caster.SetOutputScalarTypeToShort()
    if vtk.VTK_MAJOR_VERSION <= 5:
      caster.SetInput(bgImage)
      caster.Update()
      self.fm.SetInput(caster.GetOutput())
    else:
      caster.SetInputData(bgImage)
      self.fm.SetInputConnection(caster.GetOutputPort())

    # self.fm.SetOutput(labelImage)

    if vtk.VTK_MAJOR_VERSION <= 5:
      npoints = int((dim[1]+1)*(dim[3]+1)*(dim[5]+1)*percentMax/100.)
    else:
      npoints = int(dim[0]*dim[1]*dim[2]*percentMax/100.)

    self.fm.setNPointsEvolution(npoints)
    print('Setting active label to '+str(EditUtil.getLabel()))
    self.fm.setActiveLabel(EditUtil.getLabel())

    nSeeds = self.fm.addSeedsFromImage(labelImage)
    if nSeeds == 0:
      return 0

    self.fm.Modified()
    self.fm.Update()

    # TODO: need to call show() twice for data to be updated
    self.fm.show(1)
    self.fm.Modified()
    self.fm.Update()

    self.fm.show(1)
    self.fm.Modified()
    self.fm.Update()

    self.undoRedo.saveState()

    EditUtil.getLabelImage().DeepCopy(self.fm.GetOutput())
    EditUtil.markVolumeNodeAsModified(self.sliceLogic.GetLabelLayer().GetVolumeNode())
    # print('FastMarching output image: '+str(output))
    print('FastMarching march update completed')

    return npoints
开发者ID:kingofpanda,项目名称:Slicer,代码行数:94,代码来源:FastMarchingEffect.py


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