Python vtk.vtkColorTransferFunction() Examples
The following are 2
code examples of vtk.vtkColorTransferFunction().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vtk
, or try the search function
.
Example #1
Source File: wvtk.py From pyCGNS with GNU Lesser General Public License v2.1 | 6 votes |
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)
Example #2
Source File: volumerendering.py From Medical-Image-Analysis-IPython-Tutorials with Apache License 2.0 | 4 votes |
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]