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


Python vtk.vtkVolume函数代码示例

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


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


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