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

Python vtk.vtkColorTransferFunction函数代码示例

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

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



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


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


示例17: __MakeLUT

 def __MakeLUT(self):
     '''
     Make a lookup table using vtkColorSeries.
     :return: An indexed lookup table.
     '''
     # Make the lookup table.
     pal = "../util/color_circle_Ajj.pal"
     tableSize = 255
     colorFunc = vtk.vtkColorTransferFunction()
     scalars = self.histo()[1]
     with open(pal) as f:
         lines = f.readlines()
         # lines.reverse()
         for i, line in enumerate(lines):
             l = line.strip()
             r, g, b = self.__hex2rgb(l[1:])
             # print scalars[i], r, g, b
             colorFunc.AddRGBPoint(scalars[i], r, g, b)
     lut = vtk.vtkLookupTable()
     lut.SetNumberOfTableValues(tableSize)
     lut.Build()
     for i in range(0, tableSize):
         rgb = list(colorFunc.GetColor(float(i)/tableSize))+[1]
         lut.SetTableValue(i, rgb)
     return lut
开发者ID:CreativeCodingLab,项目名称:DarkSkyVis,代码行数:25,代码来源:vtkDarkSkyFlow.py


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


示例19: setupLuts

  def setupLuts(self):
    self.luts = []

    # HSV (Blue to REd)  Default
    lut = vtk.vtkLookupTable()
    lut.SetHueRange(0.667, 0.0)
    lut.SetNumberOfColors(256)
    lut.Build()
    self.luts.append(lut)

    # Diverging (Cool to Warm) color scheme
    ctf = vtk.vtkColorTransferFunction()
    ctf.SetColorSpaceToDiverging()
    ctf.AddRGBPoint(0.0, 0.230, 0.299, 0.754)
    ctf.AddRGBPoint(1.0, 0.706, 0.016, 0.150)
    cc = list()
    for i in xrange(256):
      cc.append(ctf.GetColor(float(i) / 255.0))
    lut = vtk.vtkLookupTable()
    lut.SetNumberOfColors(256)
    for i, item in enumerate(cc):
      lut.SetTableValue(i, item[0], item[1], item[2], 1.0)
    lut.Build()
    self.luts.append(lut)

    # Shock
    ctf = vtk.vtkColorTransferFunction()
    min = 93698.4
    max = 230532
    ctf.AddRGBPoint(self._normalize(min, max,  93698.4),  0.0,         0.0,      1.0)
    ctf.AddRGBPoint(self._normalize(min, max, 115592.0),  0.0,         0.905882, 1.0)
    ctf.AddRGBPoint(self._normalize(min, max, 138853.0),  0.0941176,   0.733333, 0.027451)
    ctf.AddRGBPoint(self._normalize(min, max, 159378.0),  1.0,         0.913725, 0.00784314)
    ctf.AddRGBPoint(self._normalize(min, max, 181272.0),  1.0,         0.180392, 0.239216)
    ctf.AddRGBPoint(self._normalize(min, max, 203165.0),  1.0,         0.701961, 0.960784)
    ctf.AddRGBPoint(self._normalize(min, max, 230532.0),  1.0,         1.0,      1.0)
    cc = list()
    for i in xrange(256):
      cc.append(ctf.GetColor(float(i) / 255.0))
    lut = vtk.vtkLookupTable()
    lut.SetNumberOfColors(256)
    for i, item in enumerate(cc):
      lut.SetTableValue(i, item[0], item[1], item[2], 1.0)
    lut.Build()
    self.luts.append(lut)

    self.current_lut = self.luts[0]
开发者ID:rtung,项目名称:moose,代码行数:47,代码来源:ExodusResultRenderWidget.py


示例20: execute

	def execute(self, inputs, update = 0, last = 0):
		"""
		Execute the filter with given inputs and return the output
		"""
		if not lib.ProcessingFilter.ProcessingFilter.execute(self, inputs):
			return None
		
		image = self.getInput(1)
		min,max = self.dataUnit.getSourceDataUnits()[0].getScalarRange()
		self.eventDesc="Thresholding image"

		if not self.parameters["Demonstrate"]:
			if self.origCtf:
				self.dataUnit.getSettings().set("ColorTransferFunction", self.origCtf)
				if self.gui:
					self.gui.histograms[0].setReplacementCTF(None)
					self.gui.histograms[0].updatePreview(renew = 1)
			
			self.vtkfilter.SetInput(image)
			self.vtkfilter.ThresholdBetween(self.parameters["LowerThreshold"],self.parameters["UpperThreshold"])

			self.vtkfilter.SetReplaceIn(self.parameters["ReplaceIn"])
			if self.parameters["ReplaceIn"]:
				self.vtkfilter.SetInValue(self.parameters["ReplaceInValue"])
			
			self.vtkfilter.SetReplaceOut(self.parameters["ReplaceOut"])
			if self.parameters["ReplaceOut"]:
				self.vtkfilter.SetOutValue(self.parameters["ReplaceOutValue"])

			#if update:
			self.vtkfilter.Update()
			return self.vtkfilter.GetOutput()

		else:
			lower = self.parameters["LowerThreshold"]
			upper = self.parameters["UpperThreshold"]
			origCtf = self.dataUnit.getSourceDataUnits()[0].getColorTransferFunction()
			self.origCtf = origCtf
			ctf = vtk.vtkColorTransferFunction()
			ctf.AddRGBPoint(min, 0, 0, 0.0)
			if lower >= min + 1:
				ctf.AddRGBPoint(lower - 1, 0, 0, 1.0)
				ctf.AddRGBPoint(lower, 0, 0, 0)
			
			
			val = [0, 0, 0]
			origCtf.GetColor(max, val)
			r, g, b = val
			ctf.AddRGBPoint(upper, r, g, b)
			if upper <= max + 1:
				ctf.AddRGBPoint(upper + 1, 0, 0, 0)
				ctf.AddRGBPoint(max, 1.0, 0, 0)
			self.dataUnit.getSettings().set("ColorTransferFunction", ctf)
			if self.gui:
				self.gui.histograms[0].setReplacementCTF(ctf)
				self.gui.histograms[0].updatePreview(renew = 1)
				self.gui.histograms[0].Refresh()
			
			return image
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:59,代码来源:Threshold.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkCompositeDataPipeline函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkCollection函数代码示例发布时间: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