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


Python vtk.vtkColorTransferFunction函数代码示例

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


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

示例1: createItemToolbar

    def createItemToolbar(self):
        """
		Method to create a toolbar for the window that allows use to select processed channel
		"""
        # Pass flag force which indicates that we do want an item toolbar
        # although we only have one input channel
        n = GUI.FilterBasedTaskPanel.FilterBasedTaskPanel.createItemToolbar(self, force=1)
        for i, tid in enumerate(self.toolIds):
            self.dataUnit.setOutputChannel(i, 0)
            self.toolMgr.toggleTool(tid, 0)

        ctf = vtk.vtkColorTransferFunction()
        ctf.AddRGBPoint(0, 0, 0, 0)
        ctf.AddRGBPoint(255, 1, 1, 1)
        imagedata = self.itemMips[0]

        ctf = vtk.vtkColorTransferFunction()
        ctf.AddRGBPoint(0, 0, 0, 0)
        ctf.AddRGBPoint(255, 1, 1, 1)
        maptocolor = vtk.vtkImageMapToColors()
        maptocolor.SetInput(imagedata)
        maptocolor.SetLookupTable(ctf)
        maptocolor.SetOutputFormatToRGB()
        maptocolor.Update()
        imagedata = maptocolor.GetOutput()

        bmp = lib.ImageOperations.vtkImageDataToWxImage(imagedata).ConvertToBitmap()
        bmp = self.getChannelItemBitmap(bmp, (255, 255, 255))
        toolid = wx.NewId()
        name = "Manipulation"
        self.toolMgr.addChannelItem(name, bmp, toolid, lambda e, x=n, s=self: s.setPreviewedData(e, x))

        self.toolIds.append(toolid)
        self.dataUnit.setOutputChannel(len(self.toolIds), 1)
        self.toolMgr.toggleTool(toolid, 1)
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:35,代码来源:ManipulationPanel.py

示例2: _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

示例3: _setupColorFunction

    def _setupColorFunction(self, minV, maxV):

        # Create a color transfer function to be used for both the balls and arrows.
        self._colorTransferFunction = vtk.vtkColorTransferFunction()
        self._colorTransferFunction.AddRGBPoint(minV, 1.0, 0.0, 0.0)
        self._colorTransferFunction.AddRGBPoint(0.5*(minV + maxV), 0.0, 1.0, 0.0)
        self._colorTransferFunction.AddRGBPoint(maxV, 0.0, 0.0, 1.0)
开发者ID:Andrew-AbiMansour,项目名称:PyDEM,代码行数:7,代码来源:visualize.py

示例4: onSetSelectedObjects

	def onSetSelectedObjects(self, obj, event, objects, isROI = 0):
		"""
		An event handler for highlighting selected objects
		"""
		if not self.ctf:
			self.ctf = self.dataUnit.getColorTransferFunction()
		if not objects:
			
			self.dataUnit.getSettings().set("ColorTransferFunction", self.ctf)
			lib.messenger.send(None, "data_changed", 0)
			return

		if not isROI:
			# Since these object id's come from the list indices, instead of being the actual
			# intensity values, we need to add 2 to each object value to account for the
			# pseudo objects 0 and 1 produced by the segmentation results
			objects = [x + 2 for x in objects]
		self.selections = objects
		ctf = vtk.vtkColorTransferFunction()
		minval, maxval = self.ctf.GetRange()
		hv = 0.4
		ctf.AddRGBPoint(0, 0, 0, 0)
		ctf.AddRGBPoint(1, 0, 0, 0)
		ctf.AddRGBPoint(2, hv, hv, hv)
		ctf.AddRGBPoint(maxval, hv, hv, hv)
		for obj in objects:
			val = [0, 0, 0]
			if obj - 1 not in objects:
				ctf.AddRGBPoint(obj - 1, hv, hv, hv)
			ctf.AddRGBPoint(obj, 0.0, 1.0, 0.0)
			if obj + 1 not in objects:
				ctf.AddRGBPoint(obj + 1, hv, hv, hv)
		print "Setting CTF where highlighted=", objects
		self.dataUnit.getSettings().set("ColorTransferFunction", ctf)
		lib.messenger.send(None, "data_changed", 0)
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:35,代码来源:TrackingFilters.py

示例5: TestColorTransferFunction

def TestColorTransferFunction(int ,  char):
    # Set up a 2D scene, add an XY chart to it
    view = vtk.vtkContextView()
    view.GetRenderer().SetBackground(1.0, 1.0, 1.0)
    view.GetRenderWindow().SetSize(400, 300)
    
    chart = vtk.vtkChartXY()
    chart.SetTitle('Chart')
    view.GetScene().AddItem(chart)
    
    colorTransferFunction = vtk.vtkColorTransferFunction()
    colorTransferFunction.AddHSVSegment(50.,0.,1.,1.,85.,0.3333,1.,1.)
    colorTransferFunction.AddHSVSegment(85.,0.3333,1.,1.,170.,0.6666,1.,1.)
    colorTransferFunction.AddHSVSegment(170.,0.6666,1.,1.,200.,0.,1.,1.)
    
    colorTransferFunction.Build()
    
    colorTransferItem = vtk.vtkColorTransferFunctionItem()
    colorTransferItem.SetColorTransferFunction(colorTransferFunction)
    chart.AddPlot(colorTransferItem)
    
    controlPointsItem = vtk.vtkColorTransferControlPointsItem()
    controlPointsItem.SetColorTransferFunction(colorTransferFunction)
    controlPointsItem.SetUserBounds(0., 255., 0., 1.)
    chart.AddPlot(controlPointsItem)
    
    # Finally render the scene and compare the image to a reference image
    view.GetRenderWindow().SetMultiSamples(1)
    if view.GetContext().GetDevice().IsA( "vtkOpenGLContextDevice2D") :
      view.GetInteractor().Initialize()
      view.GetInteractor().Start()
    else:
        print 'GL version 2 or higher is required.'
    
    return EXIT_SUCCESS
开发者ID:behollis,项目名称:DBSViewer,代码行数:35,代码来源:TestColorTransferFunction.py

示例6: __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

示例7: updateTransferFunction

	def updateTransferFunction(self):
		r, g, b = self.color

		# Transfer functions and properties
		if not self.colorFunction:
			self.colorFunction = vtkColorTransferFunction()
		else:
			self.colorFunction.RemoveAllPoints()
		self.colorFunction.AddRGBPoint(self.minimum, r*0.7, g*0.7, b*0.7)
		self.colorFunction.AddRGBPoint(self.maximum, r, g, b)

		if not self.opacityFunction:
			self.opacityFunction = vtkPiecewiseFunction()
		else:
			self.opacityFunction.RemoveAllPoints()
		self.opacityFunction.AddPoint(self.minimum, 0)
		self.opacityFunction.AddPoint(self.lowerBound, 0)
		self.opacityFunction.AddPoint(self.lowerBound+0.0001, self.opacity)
		self.opacityFunction.AddPoint(self.upperBound-0.0001, self.opacity)
		self.opacityFunction.AddPoint(self.upperBound, 0)
		self.opacityFunction.AddPoint(self.maximum+0.0001, 0)

		self.volProp.SetColor(self.colorFunction)
		self.volProp.SetScalarOpacity(self.opacityFunction)

		self.updatedTransferFunction.emit()
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:26,代码来源:VolumeVisualizationSimple.py

示例8: testGetRangeNoArg

    def testGetRangeNoArg(self):
        cmap = vtk.vtkColorTransferFunction()

        crange = cmap.GetRange()
        self.assertEqual(len(crange), 2)
        self.assertEqual(crange[0], 0.0)
        self.assertEqual(crange[1], 0.0)
开发者ID:inviCRO,项目名称:VTK,代码行数:7,代码来源:TestGetRangeColorTransferFunction.py

示例9: testGetRangeDoubleStarArg

    def testGetRangeDoubleStarArg(self):
        cmap = vtk.vtkColorTransferFunction()

        localRange = [-1, -1]
        cmap.GetRange(localRange)
        self.assertEqual(localRange[0], 0.0)
        self.assertEqual(localRange[1], 0.0)
开发者ID:inviCRO,项目名称:VTK,代码行数:7,代码来源:TestGetRangeColorTransferFunction.py

示例10: __init__

	def __init__(self, n = -1):
		"""
		Method: __init__
		Constructor
		"""
		DataUnitSettings.__init__(self, n)
		
		self.set("Type", "Colocalization")
		self.registerCounted("ColocalizationLowerThreshold", 1)
		self.registerCounted("ColocalizationUpperThreshold", 1)
		self.register("ColocalizationDepth", 1)
		self.register("CalculateThresholds")
		
		for i in ["PValue", "RObserved", "RRandMean", "RRandSD",
				  "NumIterations", "ColocCount", "Method", "PSF",
				  "Ch1ThresholdMax", "Ch2ThresholdMax", "PearsonImageAbove",
				  "PearsonImageBelow", "PearsonWholeImage", "M1", "M2",
				  "ThresholdM1", "ThresholdM2", "Slope", "Intercept",
				  "K1", "K2", "DiffStainIntCh1", "DiffStainIntCh2",
					  "DiffStainVoxelsCh1", "DiffStainVoxelsCh2",
				  "ColocAmount", "ColocPercent", "PercentageVolumeCh1",
				  "PercentageTotalCh1", "PercentageTotalCh2",
				  "PercentageVolumeCh2", "PercentageMaterialCh1", "PercentageMaterialCh2",
				  "SumOverThresholdCh1", "SumOverThresholdCh2", "SumCh1", "SumCh2",
				  "NonZeroCh1", "NonZeroCh2", "OverThresholdCh1", "OverThresholdCh2", "Ch2Lambda"]:
			self.register(i, 1)
		self.register("OutputScalar", 1)

		#self.register("ColocalizationColorTransferFunction",1)
		ctf = vtk.vtkColorTransferFunction()
		ctf.AddRGBPoint(0, 0, 0, 0)
		ctf.AddRGBPoint(255, 1.0, 1.0, 1.0)
		self.set("ColorTransferFunction", ctf)
		# This is used purely for remembering the ctf the user has set
		self.register("ColocalizationColorTransferFunction", 1)
开发者ID:giacomo21,项目名称:Image-analysis,代码行数:35,代码来源:ColocalizationSettings.py

示例11: originalObject

	def originalObject(self):
		colorTransferFunction = vtkColorTransferFunction()
		for index in range(len(self.nodes)):
			value = self.nodes[index]
			colorTransferFunction.AddRGBPoint(value[0], value[1], value[2], value[3], value[4], value[5])

		return colorTransferFunction
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:7,代码来源:vtkObjectWrapper.py

示例12: __init__

    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._volume_input = None

        self._opacity_tf = vtk.vtkPiecewiseFunction()
        self._colour_tf = vtk.vtkColorTransferFunction()
        self._lut = vtk.vtkLookupTable()

        # list of tuples, where each tuple (scalar_value, (r,g,b,a))
        self._config.transfer_function = [
                (0, (0,0,0), 0),
                (255, (255,255,255), 1)
                ]

        self._view_frame = None
        self._create_view_frame()
        self._bind_events()

        self.view()

        # all modules should toggle this once they have shown their
        # stuff.
        self.view_initialised = True

        self.config_to_logic()
        self.logic_to_config()
        self.config_to_view()
开发者ID:fvpolpeta,项目名称:devide,代码行数:28,代码来源:TransferFunctionEditor.py

示例13: 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

示例14: 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

示例15: GetDefaultColorMap

 def GetDefaultColorMap(dataRange):
     colorMap = vtk.vtkColorTransferFunction()
     colorMap.SetColorSpaceToLab()
     colorMap.AddRGBPoint(dataRange[0], 0.865, 0.865, 0.865)
     colorMap.AddRGBPoint(dataRange[1], 0.706, 0.016, 0.150)
     colorMap.Build()
     return colorMap
开发者ID:akeshavan,项目名称:mindboggle,代码行数:7,代码来源:vtkviewer.py


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