本文整理匯總了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)
示例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]