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


Python vtk.vtkMarchingCubes函数代码示例

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


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

示例1: __init__

    def __init__(self, volume, level=None):
        self._surface_algorithm = None
        self._renderer = None
        self._actor = None
        self._mapper = None
        self._volume_array = None

        self._float_array = _vtk.vtkFloatArray()
        self._image_data = _vtk.vtkImageData()
        self._image_data.GetPointData().SetScalars(self._float_array)
        self._setup_data(_numpy.float32(volume))

        self._surface_algorithm = _vtk.vtkMarchingCubes()
        self._surface_algorithm.SetInputData(self._image_data)
        self._surface_algorithm.ComputeNormalsOn()

        if level is not None:
            try:
                self.set_multiple_levels(iter(level))
            except TypeError:
                self.set_level(0, level)

        self._mapper = _vtk.vtkPolyDataMapper()
        self._mapper.SetInputConnection(self._surface_algorithm.GetOutputPort())
        self._mapper.ScalarVisibilityOn() # new
        self._actor = _vtk.vtkActor()
        self._actor.SetMapper(self._mapper)
开发者ID:ekeberg,项目名称:Python-tools,代码行数:27,代码来源:vtk_tools.py

示例2: __init__

    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)
        # initialise any mixins we might have
        NoConfigModuleMixin.__init__(self)


        # we'll be playing around with some vtk objects, this could
        # be anything
        self._thresh = vtk.vtkThresholdPoints()
        # this is wacked syntax!
        self._thresh.ThresholdByUpper(1)
        self._reconstructionFilter = vtk.vtkSurfaceReconstructionFilter()
        self._reconstructionFilter.SetInput(self._thresh.GetOutput())
        self._mc = vtk.vtkMarchingCubes()
        self._mc.SetInput(self._reconstructionFilter.GetOutput())
        self._mc.SetValue(0, 0.0)

        module_utils.setup_vtk_object_progress(self, self._thresh,
                                           'Extracting points...')
        module_utils.setup_vtk_object_progress(self, self._reconstructionFilter,
                                           'Reconstructing...')
        module_utils.setup_vtk_object_progress(self, self._mc,
                                           'Extracting surface...')

        self._iObj = self._thresh
        self._oObj = self._mc
        
        self._viewFrame = self._createViewFrame({'threshold' :
                                                 self._thresh,
                                                 'reconstructionFilter' :
                                                 self._reconstructionFilter,
                                                 'marchingCubes' :
                                                 self._mc})
开发者ID:fvpolpeta,项目名称:devide,代码行数:34,代码来源:reconstructSurface.py

示例3: Execute

    def Execute(self):

        if self.Image == None:
            self.PrintError('Error: No Image.')

        extent = self.Image.GetExtent()
        translateExtent = vtk.vtkImageTranslateExtent()
        translateExtent.SetInputData(self.Image)
        translateExtent.SetTranslation(-extent[0],-extent[2],-extent[4])
        translateExtent.Update()

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

        marchingCubes = vtk.vtkMarchingCubes()
        marchingCubes.SetInputConnection(translateExtent.GetOutputPort())
        marchingCubes.SetValue(0,self.Level)
        marchingCubes.Update()

        self.Surface = marchingCubes.GetOutput()

        if self.Connectivity == 1:
            connectivityFilter = vtk.vtkPolyDataConnectivityFilter()
            connectivityFilter.SetInputData(self.Surface)
            connectivityFilter.SetExtractionModeToLargestRegion()
            connectivityFilter.Update()
            self.Surface = connectivityFilter.GetOutput()
开发者ID:151706061,项目名称:vmtk,代码行数:27,代码来源:vmtkmarchingcubes.py

示例4: __init__

    def __init__(self, renderer, interactor):

        self.connect = ConnectFilter()
        self.deci = DecimateFilter()
        self.marchingCubes = vtk.vtkMarchingCubes()

        self.prog = ProgressBarDialog(
            title='Rendering surface %s' % self.label,
            parent=None,
            msg='Marching cubes ....',
            size=(300,40),
                                 )
        def start(o, event):
            self.prog.show()
            while gtk.events_pending(): gtk.main_iteration()


        def progress(o, event):
            val = o.GetProgress()
            self.prog.bar.set_fraction(val)            
            while gtk.events_pending(): gtk.main_iteration()
            
        def end(o, event):
            self.prog.hide()
            while gtk.events_pending(): gtk.main_iteration()

        self.marchingCubes.AddObserver('StartEvent', start)
        self.marchingCubes.AddObserver('ProgressEvent', progress)
        self.marchingCubes.AddObserver('EndEvent', end)
        self.renderer = renderer
        self.interactor = interactor
        self.isoActor = None
        
        self.update_pipeline()
开发者ID:alexsavio,项目名称:nidoodles,代码行数:34,代码来源:surf_params.py

示例5: __init__

    def __init__(self, brain_data, isoval=34):
        # Setup Surface Rendering

        # Gaussian smoothing of surface rendering for aesthetics
        # Adds significant delay to rendering
        self.cortexSmoother = vtk.vtkImageGaussianSmooth()
        self.cortexSmoother.SetDimensionality(3)
        self.cortexSmoother.SetRadiusFactors(0.5, 0.5, 0.5)
        self.cortexSmoother.SetInput(brain_data.GetOutput())

        # Apply a marching cubes algorithm to extract surface contour with
        # isovalue of 30 (can change to adjust proper rendering of tissue
        self.cortexExtractor = vtk.vtkMarchingCubes()
        self.cortexExtractor.SetInput(self.cortexSmoother.GetOutput())
        self.cortexExtractor.SetValue(0, isoval)
        self.cortexExtractor.ComputeNormalsOn()

        # Map/Paint the polydata associated with the surface rendering
        self.cortexMapper = vtk.vtkPolyDataMapper()
        self.cortexMapper.SetInput(self.cortexExtractor.GetOutput())
        self.cortexMapper.ScalarVisibilityOff()

        # Color the cortex (RGB)
        self.cortexProperty = vtk.vtkProperty()
        self.cortexProperty.SetColor(1, 1, 1)
        self.cortexProperty.SetOpacity(1);

        # Set the actor to adhere to mapped surface and inherit properties
        self.SetMapper(self.cortexMapper)
        self.SetProperty(self.cortexProperty)
        self.cortexExtractor.Update()
开发者ID:akhambhati,项目名称:NiftyElectrodeMapper,代码行数:31,代码来源:cortex.py

示例6: initialize

    def initialize(self):
        #self._vtk_widget.Initialize()
        super(SurfaceViewer, self).initialize()
        
        self._surface_algorithm = vtk.vtkMarchingCubes()
        if vtk_tools.VTK_VERSION >= 6:
            self._surface_algorithm.SetInputData(self._image_data)
        else:
            self._surface_algorithm.SetInput(self._image_data)
        self._surface_algorithm.ComputeNormalsOn()
        self._surface_algorithm.SetValue(0, self._surface_level)

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(self._surface_algorithm.GetOutputPort())
        mapper.ScalarVisibilityOff()
        self._actor = vtk.vtkActor()
        self._actor.GetProperty().SetColor(0., 1., 0.)
        self._actor.SetMapper(mapper)
        self._renderer.AddViewProp(self._actor)
        self._renderer.Render()
        self._vtk_widget.Render()
        
        self._level_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self._level_slider.setMaximum(self._SLIDER_MAXIMUM)
        self._level_slider.valueChanged.connect(self._slider_changed)
        self._level_slider.setValue(self._INITIAL_SLIDER_POSITION)
        
        self._layout.addWidget(self._level_slider)
        self._vtk_widget.Render()
开发者ID:ekeberg,项目名称:Python-tools,代码行数:29,代码来源:eke_plot_image_3d.py

示例7: __init__

    def __init__(self, module_manager, contourFilterText):

        # call parent constructor
        ModuleBase.__init__(self, module_manager)

        self._contourFilterText = contourFilterText
        if contourFilterText == 'marchingCubes':
            self._contourFilter = vtk.vtkMarchingCubes()
        else: # contourFilter == 'contourFilter'
            self._contourFilter = vtk.vtkContourFilter()

        module_utils.setup_vtk_object_progress(self, self._contourFilter,
                                           'Extracting iso-surface')

        # now setup some defaults before our sync
        self._config.isoValue = 128;

        self._viewFrame = None
        self._createViewFrame()

        # transfer these defaults to the logic
        self.config_to_logic()

        # then make sure they come all the way back up via self._config
        self.logic_to_config()
        self.config_to_view()
开发者ID:fvpolpeta,项目名称:devide,代码行数:26,代码来源:contourFLTBase.py

示例8: __init__

 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkMarchingCubes(), 'Processing.',
         ('vtkImageData',), ('vtkPolyData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkMarchingCubes.py

示例9: main

def main(argv):
  if len(argv) < 2:
    print "usage:",argv[0]," data.vtk"
    exit(1)
  data_fn = argv[1]
  reader = vtk.vtkStructuredPointsReader()
  reader.SetFileName(data_fn)
  reader.Update()
  data = reader.GetOutput()
  skin = vtk.vtkMarchingCubes()
  skin.ComputeNormalsOn()
  skin.ComputeGradientsOn()
  skin.SetValue(0, rgb[0][0])
  skin.SetInput(data)
  skin_mapper = vtk.vtkPolyDataMapper()
  skin_mapper.SetInputConnection(skin.GetOutputPort())
  skin_mapper.ScalarVisibilityOff()
  skin_actor = vtk.vtkActor()
  skin_property = vtk.vtkProperty()
  skin_property.SetColor(rgb[0][1], rgb[0][2], rgb[0][3])
  skin_property.SetOpacity(opacity[0][1])
  skin_actor.SetProperty(skin_property)
  skin_actor.SetMapper(skin_mapper)
  bone = vtk.vtkMarchingCubes()
  bone.ComputeNormalsOn()
  bone.ComputeGradientsOn()
  bone.SetValue(0, rgb[1][0])
  bone.SetInput(data)
  bone_mapper = vtk.vtkPolyDataMapper()
  bone_mapper.SetInputConnection(bone.GetOutputPort())
  bone_mapper.ScalarVisibilityOff()
  bone_actor = vtk.vtkActor()
  bone_actor.GetProperty().SetColor(rgb[1][1], rgb[1][2], rgb[1][3])
  bone_actor.GetProperty().SetOpacity(opacity[1][1])
  bone_actor.SetMapper(bone_mapper)
  renderer = vtk.vtkRenderer()
  renderWin = vtk.vtkRenderWindow()
  renderWin.AddRenderer(renderer)
  renderInteractor = vtk.vtkRenderWindowInteractor()
  renderInteractor.SetRenderWindow(renderWin)
  renderer.AddActor(skin_actor)
  #renderer.AddActor(bone_actor)
  renderer.SetBackground(0,0,0)
  renderWin.SetSize(400, 400)
  renderInteractor.Initialize()
  renderWin.Render()
  renderInteractor.Start()
开发者ID:daniel-perry,项目名称:visualization,代码行数:47,代码来源:isosurface_render.py

示例10: createIsoSurface

	def createIsoSurface(self,configuration):
		marchingCube = vtk.vtkMarchingCubes()
		marchingCube.SetInputConnection(self.reader.GetOutputPort())
		marchingCube.SetValue(0,configuration.getIsoValue())
		marchingCube.ComputeNormalsOn()
		self.outputPortForMapper = marchingCube.GetOutputPort()
		self.createMapper()
		self.createActor()
		self.modifyActorIso(configuration)
		self.finalizePipeline()
开发者ID:kvkenyon,项目名称:projects,代码行数:10,代码来源:assignment1.py

示例11: __init__

    def __init__(self, parent = None):
        super(VTKFrame, self).__init__(parent)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0.1, 0.2, 0.4)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        sphereSource = vtk.vtkSphereSource()
        sphereSource.SetPhiResolution(20)
        sphereSource.SetThetaResolution(20)
        sphereSource.Update()

        bounds = [1, 1, 1, 1, 1, 1]
        sphereSource.GetOutput().GetBounds(bounds)
        for i in range(0, 6, 2):
            range_ = bounds[i+1] - bounds[i]
            bounds[i] = bounds[i] - 0.1 * range_
            bounds[i+1] = bounds[i+1] + 0.1 * range_

        voxelModeller = vtk.vtkVoxelModeller()
        voxelModeller.SetSampleDimensions(50, 50, 50)
        voxelModeller.SetModelBounds(bounds)
        voxelModeller.SetScalarTypeToFloat()
        voxelModeller.SetMaximumDistance(0.1)

        voxelModeller.SetInputConnection(sphereSource.GetOutputPort())
        voxelModeller.Update()

        volume = vtk.vtkImageData()
        volume.DeepCopy(voxelModeller.GetOutput())

        surface = vtk.vtkMarchingCubes()
        surface.SetInput(volume)
        surface.SetValue(0, 0.5)
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(surface.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:53,代码来源:marchingcubes.py

示例12: vtk_iso

def vtk_iso(vol, iso_thresh=1):
    im_data = vol.tostring()
    img = vtk.vtkImageImport()
    img.CopyImportVoidPointer(im_data, len(im_data))
    img.SetDataScalarType(vtk.VTK_UNSIGNED_SHORT)
    img.SetNumberOfScalarComponents(1)
    img.SetDataExtent(0, vol.shape[2]-1, 0, vol.shape[1]-1, 0, vol.shape[0]-1)
    img.SetWholeExtent(0, vol.shape[2]-1, 0, vol.shape[1]-1, 0, vol.shape[0]-1)
    iso = vtk.vtkMarchingCubes()
    iso.SetInput(img.GetOutput())
    iso.SetValue(0, iso_thresh)
    return iso,img
开发者ID:cni,项目名称:Psych204A_OLD,代码行数:12,代码来源:vtk_render.py

示例13: __init__

	def __init__(self, inputs = (1,1)):
		"""
		Initialization
		"""
		self.defaultLower = 0
		self.defaultUpper = 255
		lib.ProcessingFilter.ProcessingFilter.__init__(self,(1,1))
		self.contour = vtk.vtkMarchingCubes()
		self.decimate = vtk.vtkDecimatePro()
		self.descs = {"Simplify": "Simplify surface", "IsoValue":"Iso-surface value", 
		"PreserveTopology":"PreserveTopology"}
		self.filterDesc = "Creates iso-surface as polygons\nInput: Binary image (Grayscale image)\nOutput: Surface mesh";
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:12,代码来源:CreatePolydata.py

示例14: adjust_contour

 def adjust_contour(self, volume, contourValue, mapper):
     """Adjust or create an isocontour using the Marching Cubes surface at the given 
     value using the given mapper
     """
 	self._view_frame.SetStatusText("Calculating new volumerender...")
 	contour = vtk.vtkMarchingCubes()
 	contour.SetValue(0,contourValue)
 	contour.SetInput(volume)
 	mapper.SetInput(contour.GetOutput())
 	mapper.Update()
 	self.render()
 	self._view_frame.SetStatusText("Calculated new volumerender")
开发者ID:fvpolpeta,项目名称:devide,代码行数:12,代码来源:EmphysemaViewer.py

示例15: DisplayLevelSetSurface

    def DisplayLevelSetSurface(self,levelSets,value=0.0):
      
        marchingCubes = vtk.vtkMarchingCubes()
        marchingCubes.SetInputData(levelSets)
        marchingCubes.SetValue(0,value)
        marchingCubes.Update()

        self.OutputText('Displaying.\n')

        self.SurfaceViewer.Surface = marchingCubes.GetOutput()
        self.SurfaceViewer.Display = 0
        self.SurfaceViewer.Opacity = 0.5
        self.SurfaceViewer.BuildView()
开发者ID:vmtk,项目名称:vmtk,代码行数:13,代码来源:vmtklevelsetsegmentation.py


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