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


Python vtk.vtkColorTransferFunction方法代码示例

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


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

示例1: LookupTable

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkColorTransferFunction [as 别名]
def LookupTable(self):
        self.lut = vtk.vtkColorTransferFunction()
        self.lut.SetColorSpaceToRGB()
        self.lut.SetScaleToLinear()
        text = vtk.vtkTextProperty()
        text.SetFontFamilyToArial()
        text.SetFontSize(12)
        text.SetColor(self.color)
        self.scalarbar = vtk.vtkScalarBarActor()
        self.scalarbar.SetLookupTable(self.lut)
        self.scalarbar.SetNumberOfLabels(5)
        self.scalarbar.SetLabelTextProperty(text)
        self.scalarbar.SetTitleTextProperty(text)
        self.scalarbarwidget = vtk.vtkScalarBarWidget()
        self.scalarbarwidget.ResizableOff()
        self.scalarbarwidget.RepositionableOff()
        self.scalarbarwidget.GetScalarBarRepresentation().SetScalarBarActor(self.scalarbar)
        self.scalarbarwidget.GetScalarBarRepresentation().PickableOff()
        self.scalarbarwidget.GetScalarBarRepresentation().SetPosition(0.9, 0.4)
        self.scalarbarwidget.GetScalarBarRepresentation().SetOrientation(1) 
开发者ID:pyCGNS,项目名称:pyCGNS,代码行数:22,代码来源:wvtk.py

示例2: volumeRender

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkColorTransferFunction [as 别名]
def volumeRender(img, tf=[],spacing=[1.0,1.0,1.0]):
    importer = numpy2VTK(img,spacing)

    # Transfer Functions
    opacity_tf = vtk.vtkPiecewiseFunction()
    color_tf = vtk.vtkColorTransferFunction()

    if len(tf) == 0:
        tf.append([img.min(),0,0,0,0])
        tf.append([img.max(),1,1,1,1])

    for p in tf:
        color_tf.AddRGBPoint(p[0], p[1], p[2], p[3])
        opacity_tf.AddPoint(p[0], p[4])

    # working on the GPU
    # volMapper = vtk.vtkGPUVolumeRayCastMapper()
    # volMapper.SetInputConnection(importer.GetOutputPort())

    # # The property describes how the data will look
    # volProperty =  vtk.vtkVolumeProperty()
    # volProperty.SetColor(color_tf)
    # volProperty.SetScalarOpacity(opacity_tf)
    # volProperty.ShadeOn()
    # volProperty.SetInterpolationTypeToLinear()

    # working on the CPU
    volMapper = vtk.vtkVolumeRayCastMapper()
    compositeFunction = vtk.vtkVolumeRayCastCompositeFunction()
    compositeFunction.SetCompositeMethodToInterpolateFirst()
    volMapper.SetVolumeRayCastFunction(compositeFunction)
    volMapper.SetInputConnection(importer.GetOutputPort())

    # The property describes how the data will look
    volProperty =  vtk.vtkVolumeProperty()
    volProperty.SetColor(color_tf)
    volProperty.SetScalarOpacity(opacity_tf)
    volProperty.ShadeOn()
    volProperty.SetInterpolationTypeToLinear()
    
    # Do the lines below speed things up?
    # pix_diag = 5.0
    # volMapper.SetSampleDistance(pix_diag / 5.0)    
    # volProperty.SetScalarOpacityUnitDistance(pix_diag) 
    

    vol = vtk.vtkVolume()
    vol.SetMapper(volMapper)
    vol.SetProperty(volProperty)
    
    return [vol] 
开发者ID:curiale,项目名称:Medical-Image-Analysis-IPython-Tutorials,代码行数:53,代码来源:volumerendering.py


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