• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vtk.vtkVolume函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

  def __init__(self, name, image_data):
    if not isinstance(image_data, vtk.vtkImageData):
      raise TypeError("input has to be vtkImageData")

    self.name = name

    # Create transfer mapping scalar value to opacity.
    opacity_function = vtk.vtkPiecewiseFunction()
    opacity_function.AddPoint(0,   0.0)
    opacity_function.AddPoint(127, 0.0)
    opacity_function.AddPoint(128, 0.2)
    opacity_function.AddPoint(255, 0.2)
    
    # Create transfer mapping scalar value to color.
    color_function = vtk.vtkColorTransferFunction()
    color_function.SetColorSpaceToHSV()
    color_function.AddHSVPoint(0,   0.0, 0.0, 0.0)
    color_function.AddHSVPoint(127, 0.0, 0.0, 0.0)
    color_function.AddHSVPoint(128, 0.0, 0.0, 1.0)
    color_function.AddHSVPoint(255, 0.0, 0.0, 1.0)
    
    volume_property = vtk.vtkVolumeProperty()
    volume_property.SetColor(color_function)
    volume_property.SetScalarOpacity(opacity_function)
    volume_property.ShadeOn()
    volume_property.SetInterpolationTypeToLinear()
    
    volume_mapper = vtk.vtkSmartVolumeMapper()
    volume_mapper.SetInputData(image_data)
    
    self.volume = vtk.vtkVolume()
    self.volume.SetMapper(volume_mapper)
    self.volume.SetProperty(volume_property)
开发者ID:papazov3d,项目名称:invipy,代码行数:33,代码来源:vtkvol.py


示例2: _create_pipeline

    def _create_pipeline(self):
        # setup our pipeline

        self._otf = vtk.vtkPiecewiseFunction()
        self._ctf = vtk.vtkColorTransferFunction()

        self._volume_property = vtk.vtkVolumeProperty()
        self._volume_property.SetScalarOpacity(self._otf)
        self._volume_property.SetColor(self._ctf)
        self._volume_property.ShadeOn()
        self._volume_property.SetAmbient(0.1)
        self._volume_property.SetDiffuse(0.7)
        self._volume_property.SetSpecular(0.2)
        self._volume_property.SetSpecularPower(10)

        self._volume_raycast_function = vtk.vtkVolumeRayCastMIPFunction()
        self._volume_mapper = vtk.vtkVolumeRayCastMapper()

        # can also used FixedPoint, but then we have to use:
        # SetBlendModeToMaximumIntensity() and not SetVolumeRayCastFunction
        #self._volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()
        
        self._volume_mapper.SetVolumeRayCastFunction(
            self._volume_raycast_function)

        
        module_utils.setup_vtk_object_progress(self, self._volume_mapper,
                                           'Preparing render.')

        self._volume = vtk.vtkVolume()
        self._volume.SetProperty(self._volume_property)
        self._volume.SetMapper(self._volume_mapper)
开发者ID:fvpolpeta,项目名称:devide,代码行数:32,代码来源:MIPRender.py


示例3: initUI

    def initUI(self):
        self.frame = QtGui.QFrame()      
         
        self.widgetLayout = QtGui.QVBoxLayout()
        self.setLayout(self.widgetLayout)
        self.widgetLayout.addWidget(self.frame)
        self.frameLayout = QtGui.QVBoxLayout()
        self.frame.setLayout(self.frameLayout)
        
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.frameLayout.addWidget(self.vtkWidget)
        
        self.sliceNumber = QtGui.QLineEdit("50")
        self.sliceConfirm = QtGui.QPushButton("confirm")
        self.sliceConfirm.clicked.connect(self.showLayer)
        self.sliceButtonLayout = QtGui.QHBoxLayout()
        self.sliceButtonLayout.addWidget(self.sliceNumber)
        self.sliceButtonLayout.addWidget(self.sliceConfirm)
        
        self.frameLayout.addLayout(self.sliceButtonLayout)
        
        self.volume = vtk.vtkVolume()
        
        self.ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
        
        self.show()
        self.iren.Initialize()
 
        self.setGeometry(300, 300, 300, 150)
        self.setWindowTitle('Layer View')    
        self.show()
开发者ID:JonathanWang1,项目名称:somethingMyOwn,代码行数:33,代码来源:layerView.py


示例4: __init__

 def __init__(self, img, color):
     self.volume = vtk.vtkVolume()
     self.__color = color
     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(1, 1, 1)
     self.__smoother.SetInputConnection(dataImporter.GetOutputPort())
     volumeMapper = vtk.vtkSmartVolumeMapper()
     volumeMapper.SetInputConnection(self.__smoother.GetOutputPort())
     self.__volumeProperty = vtk.vtkVolumeProperty()
     self.__colorFunc = vtk.vtkColorTransferFunction()
     self.__alpha = vtk.vtkPiecewiseFunction()
     for i in range(256):
         self.__colorFunc.AddRGBPoint(i, i * color[0], i * color[1], i * color[2])
     self.__alpha.AddPoint(5, .01)
     self.__alpha.AddPoint(10, .03)
     self.__alpha.AddPoint(50, .1)
     self.__alpha.AddPoint(150, .2)
     self.__volumeProperty.SetColor(self.__colorFunc)
     self.__volumeProperty.SetScalarOpacity(self.__alpha)
     self.volume.SetMapper(volumeMapper)
     self.volume.SetProperty(self.__volumeProperty)
开发者ID:LeeKamentsky,项目名称:q3dstack,代码行数:28,代码来源:q3dstack.py


示例5: volumeRender

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])

    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()

    vol = vtk.vtkVolume()
    vol.SetMapper(volMapper)
    vol.SetProperty(volProperty)
    
    return [vol]
开发者ID:zadacka,项目名称:MSC_Project,代码行数:30,代码来源:kevin_numpy_converter.py


示例6: axonComparison

def axonComparison(axons, N):
    axonsToRender = []
    for i in range(N):
        axon = axons.pop(random.randrange(len(axons)))
        axonsToRender.append(axon)
    bins = main.BINS
    data_matrix = numpy.zeros([500, 500, 500], dtype=numpy.uint16)
    dataImporter = vtk.vtkImageImport()
    data_string = data_matrix.tostring()
    dataImporter.CopyImportVoidPointer(data_string, len(data_string))
    dataImporter.SetDataScalarTypeToUnsignedChar()
    dataImporter.SetNumberOfScalarComponents(1)
    dataImporter.SetDataExtent(0, 500, 0, 500, 0, 500)
    dataImporter.SetWholeExtent(0, 500, 0, 500, 0, 500)
    volumeProperty = vtk.vtkVolumeProperty()
    compositeFunction = vtk.vtkVolumeRayCastCompositeFunction()
    volumeMapper = vtk.vtkVolumeRayCastMapper()
    volumeMapper.SetVolumeRayCastFunction(compositeFunction)
    volumeMapper.SetInputConnection(dataImporter.GetOutputPort())
    volume = vtk.vtkVolume()
    volume.SetMapper(volumeMapper)
    volume.SetProperty(volumeProperty)
    renderer = vtk.vtkRenderer()
    renderWin = vtk.vtkRenderWindow()
    renderWin.AddRenderer(renderer)
    renderInteractor = vtk.vtkRenderWindowInteractor()
    renderInteractor.SetRenderWindow(renderWin)
    renderer.SetBackground(1, 1, 1)
    renderWin.SetSize(400, 400)
    for axon in axonsToRender:
        renderer = Utils.renderSingleAxon(axon, renderer, [random.random(), random.random(), random.random()])
    renderWin.AddObserver("AbortCheckEvent", exitCheck)
    renderInteractor.Initialize()
    renderWin.Render()
    renderInteractor.Start()
开发者ID:EthanGlasserman,项目名称:Brainbow,代码行数:35,代码来源:Draw.py


示例7: __init__

 def __init__(self, input=None, MinOpacity=0.0, MaxOpacity=0.1) :
   import qt
   import vtk
   from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
   self.__MinOpacity__ = MinOpacity
   self.__MaxOpacity__ = MaxOpacity
   # every QT app needs an app
   self.__app__ = qt.QApplication(['itkviewer'])
   # create the widget
   self.__widget__ = QVTKRenderWindowInteractor()
   self.__ren__ = vtk.vtkRenderer()
   self.__widget__.GetRenderWindow().AddRenderer(self.__ren__)
   self.__itkvtkConverter__ = None
   self.__volumeMapper__ = vtk.vtkVolumeTextureMapper2D()
   self.__volume__ = vtk.vtkVolume()
   self.__volumeProperty__ = vtk.vtkVolumeProperty()
   self.__volume__.SetMapper(self.__volumeMapper__)
   self.__volume__.SetProperty(self.__volumeProperty__)
   self.__ren__.AddVolume(self.__volume__)
   self.__outline__ = None
   self.__outlineMapper__ = None
   self.__outlineActor__ = None
   self.AdaptColorAndOpacity(0, 255)
   if input :
     self.SetInput(input)
     self.AdaptColorAndOpacity()
开发者ID:giacomo21,项目名称:Image-analysis,代码行数:26,代码来源:itkvtkExtras.py


示例8: _createPipeline

    def _createPipeline(self):
        # setup our pipeline
        self._splatMapper = vtkdevide.vtkOpenGLVolumeShellSplatMapper()
        self._splatMapper.SetOmegaL(0.9)
        self._splatMapper.SetOmegaH(0.9)
        # high-quality rendermode
        self._splatMapper.SetRenderMode(0)

        self._otf = vtk.vtkPiecewiseFunction()
        self._otf.AddPoint(0.0, 0.0)
        self._otf.AddPoint(0.9, 0.0)
        self._otf.AddPoint(1.0, 1.0)

        self._ctf = vtk.vtkColorTransferFunction()
        self._ctf.AddRGBPoint(0.0, 0.0, 0.0, 0.0)
        self._ctf.AddRGBPoint(0.9, 0.0, 0.0, 0.0)
        self._ctf.AddRGBPoint(1.0, 1.0, 0.937, 0.859)

        self._volumeProperty = vtk.vtkVolumeProperty()
        self._volumeProperty.SetScalarOpacity(self._otf)
        self._volumeProperty.SetColor(self._ctf)
        self._volumeProperty.ShadeOn()
        self._volumeProperty.SetAmbient(0.1)
        self._volumeProperty.SetDiffuse(0.7)
        self._volumeProperty.SetSpecular(0.2)
        self._volumeProperty.SetSpecularPower(10)

        self._volume = vtk.vtkVolume()
        self._volume.SetProperty(self._volumeProperty)
        self._volume.SetMapper(self._splatMapper)
开发者ID:fvpolpeta,项目名称:devide,代码行数:30,代码来源:shellSplatSimple.py


示例9: get_volume

    def get_volume(self, color_file=None, volume_opacity=0.25):
        """
        Default Volume Rendering
        Return vtkActor. For volume rendering it is vtkVolume
        """
        if not self.flag_read:
            sys.stderr.write('No Image Loaded.')
            return

        # TEST
        print self.is_blank_image()

        transfer_func = self.get_transfer_functioin(color_file, volume_opacity)
        prop_volume = vtk.vtkVolumeProperty()
        prop_volume.ShadeOff()
        prop_volume.SetColor(transfer_func[0])
        prop_volume.SetScalarOpacity(transfer_func[1])
        prop_volume.SetGradientOpacity(transfer_func[2])
        prop_volume.SetInterpolationTypeToLinear()
        prop_volume.SetAmbient(0.4)
        prop_volume.SetDiffuse(0.6)
        prop_volume.SetSpecular(0.2)

        mapper = vtk.vtkSmartVolumeMapper()
        mapper.SetRequestedRenderMode(0)
        # mapper = vtk.vtkGPUVolumeRayCastMapper()
        mapper.SetInputData(self.reader)

        actor = vtk.vtkVolume()
        actor.SetMapper(mapper)

        actor.SetProperty(prop_volume)

        return actor
开发者ID:quentan,项目名称:Work_Test_4,代码行数:34,代码来源:medical_object.py


示例10: create_volume_rendering

    def create_volume_rendering(self):

        opacityfunction=vtk.vtkPiecewiseFunction()

        opacityfunction.AddPoint(0,0.0)
        opacityfunction.AddPoint(0.1,0.01)
        opacityfunction.AddPoint(1,0.02)
        opacityfunction.AddPoint(1.5,0.03)

        volproperty=vtk.vtkVolumeProperty()
        volproperty.SetColor(self.arrowColor)
        volproperty.SetScalarOpacity(opacityfunction)
        volproperty.ShadeOn()
        volproperty.SetInterpolationTypeToLinear()


        volumeMapper = vtk.vtkGPUVolumeRayCastMapper()
        volumeMapper.SetInputConnection(self.vol_reader.GetOutputPort())
        volumeMapper.SetSampleDistance(0.01)

        volume = vtk.vtkVolume()
        volume.SetMapper(volumeMapper)
        volume.SetProperty(volproperty)

        return volume
开发者ID:svelezsaffon,项目名称:Diffusion_Tensor_Visualization_VTK,代码行数:25,代码来源:fa_hyper.py


示例11: RenderVTKVolume

def RenderVTKVolume(image, volprops):
    volmap = vtk.vtkVolumeRayCastMapper()
    volmap.SetVolumeRayCastFunction(vtk.vtkVolumeRayCastCompositeFunction())
    volmap.SetInputConnection(image.GetOutputPort())

    vol = vtk.vtkVolume()
    vol.SetMapper(volmap)
    vol.SetProperty(volprops)

    #Standard VTK stuff
    ren = vtk.vtkRenderer()
    ren.AddVolume(vol)
    ren.SetBackground((1, 1, 1))

    renwin = vtk.vtkRenderWindow()
    renwin.AddRenderer(ren)

    istyle = vtk.vtkInteractorStyleSwitch()
    istyle.SetCurrentStyleToTrackballCamera()

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renwin)
    iren.SetInteractorStyle(istyle)

    renwin.Render()
    iren.Start()
开发者ID:jiahao,项目名称:openqube,代码行数:26,代码来源:viz.vtkGaussians.py


示例12: volumeRender

def volumeRender(reader,ren,renWin):
	#Create transfer mapping scalar value to opacity
	opacityTransferFunction = vtk.vtkPiecewiseFunction()
	opacityTransferFunction.AddPoint(1, 0.0)
	opacityTransferFunction.AddPoint(100, 0.1)
	opacityTransferFunction.AddPoint(255,1.0)

	colorTransferFunction = vtk.vtkColorTransferFunction()
	colorTransferFunction.AddRGBPoint(0.0,0.0,0.0,0.0)	
	colorTransferFunction.AddRGBPoint(64.0,1.0,0.0,0.0)	
	colorTransferFunction.AddRGBPoint(128.0,0.0,0.0,1.0)	
	colorTransferFunction.AddRGBPoint(192.0,0.0,1.0,0.0)	
	colorTransferFunction.AddRGBPoint(255.0,0.0,0.2,0.0)	

	volumeProperty = vtk.vtkVolumeProperty()
	volumeProperty.SetColor(colorTransferFunction)
	volumeProperty.SetScalarOpacity(opacityTransferFunction)
	volumeProperty.ShadeOn()
	volumeProperty.SetInterpolationTypeToLinear()

	compositeFunction = vtk.vtkVolumeRayCastCompositeFunction()
	volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
	volumeMapper.SetInputConnection(reader.GetOutputPort())

	volume = vtk.vtkVolume()
	volume.SetMapper(volumeMapper)
	volume.SetProperty(volumeProperty)

	ren.RemoveAllViewProps()

	ren.AddVolume(volume)
	ren.SetBackground(1,1,1)

	renWin.Render()
开发者ID:kvkenyon,项目名称:projects,代码行数:34,代码来源:App.py


示例13: setVolumeVisualization

    def setVolumeVisualization(self, volumeVisualization):
        """
		Updates the volume property. It actually removes the volume,
		creates a new volume and sets the updated volume property and
		then adds the new volume to the renderer.
		Just updating the vtkVolumeProperty gives artifacts and seems
		to not work correctly.
		:type volumeVisualization: volumeVisualization
		"""
        self.volumeVisualization = volumeVisualization

        if self.imageData is None or self.volumeVisualization is None:
            if self.volume is not None:
                self.renderer.RemoveViewProp(self.volume)
                self.volume = None
            return

        if self.volume is None:
            self.volume = vtkVolume()
            self.renderer.AddViewProp(self.volume)

        self.volumeVisualization.setMapper(self.mapper)
        self.mapper.SetShaderType(self.volumeVisualization.shaderType())
        if self.volume.GetProperty() != self.volumeVisualization.volProp:
            self.volume.SetProperty(self.volumeVisualization.volProp)
        if self.volume.GetMapper() != self.mapper:
            self.volume.SetMapper(self.mapper)

        self.render()
开发者ID:rcockbur,项目名称:3DMedicalVisualizationTool,代码行数:29,代码来源:RenderWidget.py


示例14: rebuildVolume

 def rebuildVolume( self ):
     self.volume = vtk.vtkVolume()
     self.volume.SetMapper( self.volumeMapper ) 
     self.volume.SetScale( 1.0, 1.0, 1.0 )   
     self.volume.SetMapper(self.volumeMapper)
     self.volume.SetProperty(self.volumeProperty)        
     self.volume.SetPosition( self.pos )
     self.setVolRenderCfg( None, False )
     self.renderer.AddVolume( self.volume )
开发者ID:arulalant,项目名称:uvcdat,代码行数:9,代码来源:VolumeViewer.py


示例15: _create_pipeline

    def _create_pipeline(self):
        # setup our pipeline

        self._volume_property = vtk.vtkVolumeProperty()
        self._volume_property.ShadeOn()

        self._volume_mapper = None

        self._volume = vtk.vtkVolume()
        self._volume.SetProperty(self._volume_property)
        self._volume.SetMapper(self._volume_mapper)
开发者ID:fvpolpeta,项目名称:devide,代码行数:11,代码来源:VolumeRender.py


示例16: test_wrap_vtk

 def test_wrap_vtk(self):
     """Test if the wrap_vtk function works."""
     o = vtk.vtkVolume()
     w = tvtk_helper.wrap_vtk(o)
     self.assertEqual(w.__class__.__name__, 'Volume')
     w1 = tvtk_helper.wrap_vtk(w)
     self.assertEqual(w, w1)
     del w1, w, o
     class A:
         pass
     a = A()
     w = tvtk_helper.wrap_vtk(a)
     self.assertEqual(a, w)
开发者ID:GaelVaroquaux,项目名称:mayavi,代码行数:13,代码来源:test_tvtk.py


示例17: __init__

 def __init__ (self, mod_m): 
     debug ("In Volume::__init__ ()")
     Common.state.busy ()
     Base.Objects.Module.__init__ (self, mod_m)
     self.actor = self.act = vtk.vtkVolume ()
     self.data_out = self.mod_m.GetOutput ()
     self._initialize ()
     self._gui_init ()
     self.legend = VolumeLegend(self.renwin, mod_m)
     self.legend.update_lut(self.actor.GetProperty())
     self.renwin.add_actors(self.legend.get_scalar_bar())
     self.renwin.Render ()
     Common.state.idle ()
开发者ID:sldion,项目名称:DNACC,代码行数:13,代码来源:Volume.py


示例18: volumeRender

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:151706061,项目名称:Medical-Image-Analysis-IPython-Tutorials,代码行数:51,代码来源:volumerendering.py


示例19: BuildView

    def BuildView(self):

        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self) 

        if self.Volume:
            self.vmtkRenderer.Renderer.RemoveVolume(self.Volume)

        if (self.ArrayName != ''):
            self.Image.GetPointData().SetActiveScalars(self.ArrayName)

        scalarRange = [0.0, 0.0]

        if self.WindowLevel[0] > 0.0:
            scalarRange = [self.WindowLevel[1] - self.WindowLevel[0]/2.0, self.WindowLevel[1] + self.WindowLevel[0]/2.0]
        else:
            scalarRange = self.Image.GetScalarRange()

        colorTransferFunction = vtk.vtkColorTransferFunction()
        colorTransferFunction.AddRGBPoint(scalarRange[0], 0.0, 0.0, 0.0)
        colorTransferFunction.AddRGBPoint(scalarRange[1], 1.0, 1.0, 1.0)

        volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
        volumeMapper.SetInput(self.Image)
        volumeMapper.SetBlendModeToMaximumIntensity()
        if self.AutoSampleDistance:
            volumeMapper.AutoAdjustSampleDistancesOn()
        else:
            volumeMapper.SetSampleDistance(self.SampleDistance)
        
        volumeProperty = vtk.vtkVolumeProperty()
        volumeProperty.ShadeOn()
        volumeProperty.SetInterpolationTypeToLinear()
        volumeProperty.SetColor(colorTransferFunction)
        
        self.Volume = vtk.vtkVolume()
        self.Volume.SetMapper(volumeMapper)
        self.Volume.SetProperty(volumeProperty)
      
        self.vmtkRenderer.Renderer.AddVolume(self.Volume)

        if (self.Display == 1):
            self.vmtkRenderer.Render()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
开发者ID:ChaliZhg,项目名称:vmtk,代码行数:50,代码来源:vmtkimagemipviewer.py


示例20: load_atlas

def load_atlas(path, intensities, signs):
    '''
    path: path to atlas file
    opacity: opacity of overlayed atlas brain
    '''
    nifti_reader = vtk.vtkNIFTIImageReader()
    nifti_reader.SetFileName(path)
    nifti_reader.Update()


    # intensities = intensities/math.sqrt(np.mean(intensities**2))

    # The following class is used to store transparencyv-values for later
    # retrival. In our case, we want the value 0 to be completly opaque
    alphaChannelFunc = vtk.vtkPiecewiseFunction()
    alphaChannelFunc.AddPoint(0, 0.0)
    for i in range(len(intensities)):
        alphaChannelFunc.AddPoint(i+1, intensities[i])

    # This class stores color data and can create color tables from a few color
    # points. For this demo, we want the three cubes to be of the colors red
    # green and blue.
    colorFunc = vtk.vtkColorTransferFunction()
    colorFunc.AddRGBPoint(0, 0.0, 0.0, 0.0)
    for i in range(len(signs)):
        if signs[i] < 0: colorFunc.AddRGBPoint(i+1, 0.0, 0.0, intensities[i])
        elif signs[i] > 0: colorFunc.AddRGBPoint(i+1, intensities[i], 0.0, 0.0)
        else: colorFunc.AddRGBPoint(i+1, 1.0, 1.0, 1.0)

    # The previous two classes stored properties. Because we want to apply
    # these properties to the volume we want to render, we have to store them
    # in a class that stores volume prpoperties.
    volumeProperty = vtk.vtkVolumeProperty()
    volumeProperty.SetColor(colorFunc)
    volumeProperty.SetScalarOpacity(alphaChannelFunc)
    volumeProperty.ShadeOn()

    # We can finally create our volume. We also have to specify the data for
    # it, as well as how the data will be rendered.
    volumeMapper = vtk.vtkSmartVolumeMapper()
    volumeMapper.SetInputDataObject(nifti_reader.GetOutput())

    # The class vtkVolume is used to pair the preaviusly declared volume as
    # well as the properties to be used when rendering that volume.
    volume = vtk.vtkVolume()
    volume.SetMapper(volumeMapper)
    volume.SetProperty(volumeProperty)

    return volume
开发者ID:TangRunze,项目名称:LLG,代码行数:49,代码来源:eigen_surface.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkVolume16Reader函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkVertex函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap