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


Python vtk.vtkImageMapToColors函数代码示例

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


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

示例1: __init__

    def __init__(self):
        
        self.interactor = None
        self.image_original = None
        self.image_threshold = None
        self.render = None
    
        self.lut = vtk.vtkLookupTable()
        self.lut_original = vtk.vtkLookupTable()
        self.image_color = vtk.vtkImageMapToColors()
        self.blend = blend = vtk.vtkImageBlend()
        self.map = map = vtk.vtkImageMapper()
        
        self.actor = actor = vtk.vtkImageActor()
        self.actor2 = actor2 = vtk.vtkImageActor()
        self.actor3 = actor3 = vtk.vtkImageActor()
        
        self.image_color_o = vtk.vtkImageMapToColors()
        
        self.operation_type = 0
        self.w = None
   
        self.slice = 0
        self.clicked = 0
        self.orientation = AXIAL

        self.w = (200, 1200)
开发者ID:151706061,项目名称:invesalius3,代码行数:27,代码来源:editor.py

示例2: writeAllImageSlices

def writeAllImageSlices(imgfn,pathfn,ext,output_dir):
    reader = vtk.vtkMetaImageReader()
    reader.SetFileName(imgfn)
    reader.Update()
    img = reader.GetOutput()

    parsed_path = parsePathFile(pathfn)
    slices = getAllImageSlices(img,parsed_path,ext)

    writer = vtk.vtkJPEGWriter()

    table = vtk.vtkLookupTable()
    scalar_range = img.GetScalarRange()
    table.SetRange(scalar_range[0], scalar_range[1]) # image intensity range
    table.SetValueRange(0.0, 1.0) # from black to white
    table.SetSaturationRange(0.0, 0.0) # no color saturation
    table.SetRampToLinear()
    table.Build()

    # Map the image through the lookup table
    color = vtk.vtkImageMapToColors()
    color.SetLookupTable(table)

    mkdir(output_dir)
    for i in range(len(slices)):
        color.SetInputData(slices[i])
        writer.SetInputConnection(color.GetOutputPort())
        writer.SetFileName(output_dir+'{}.jpg'.format(i))
        writer.Update()
        writer.Write()
开发者ID:gmaher,项目名称:tcl_code,代码行数:30,代码来源:utility.py

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

示例4: _set_colour

    def _set_colour(self, imagedata, colour):
        scalar_range = int(imagedata.GetScalarRange()[1])
        r, g, b = colour

        # map scalar values into colors
        lut_mask = vtk.vtkLookupTable()
        lut_mask.SetNumberOfColors(256)
        lut_mask.SetHueRange(const.THRESHOLD_HUE_RANGE)
        lut_mask.SetSaturationRange(1, 1)
        lut_mask.SetValueRange(0, 255)
        lut_mask.SetRange(0, 255)
        lut_mask.SetNumberOfTableValues(256)
        lut_mask.SetTableValue(0, 0, 0, 0, 0.0)
        lut_mask.SetTableValue(1, 1-r, 1-g, 1-b, 0.50)
        lut_mask.SetRampToLinear()
        lut_mask.Build()

        # map the input image through a lookup table
        img_colours_mask = vtk.vtkImageMapToColors()
        img_colours_mask.SetLookupTable(lut_mask)
        img_colours_mask.SetOutputFormatToRGBA()
        img_colours_mask.SetInput(imagedata)
        img_colours_mask.Update()

        return img_colours_mask.GetOutput()
开发者ID:dragonlet,项目名称:invesalius3,代码行数:25,代码来源:cursor_actors.py

示例5: __init__

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

示例6: __init__

    def __init__(self, ren):
        self.volume = self.LoadVolume()
        self.ren = ren

        # next initialize the pipeline
        self.slicer = vtk.vtkImageReslice()
        self.slicer.SetInput( self.volume )
        self.slicer.SetOutputDimensionality(2)

        # the next filter provides a mechanism for slice selection
        self.selector = SliceSelector(self.volume)
        self.slicer.SetResliceAxes( self.selector.GetDirectionCosines() )
        self.slicer.SetResliceAxesOrigin( self.selector.GetAxesOrigin() )

        # setup link for adjusting the contrast of the image
        r = self.volume.GetScalarRange()
        self.lutBuilder = LUTBuilder(r[0],r[1],1)
        lut = self.lutBuilder.Build()

        self.colors = vtk.vtkImageMapToColors()
        self.colors.SetInputConnection( self.slicer.GetOutputPort() )
        self.colors.SetLookupTable( lut )

        self.actor = vtk.vtkImageActor()
        self.actor.SetInput( self.colors.GetOutput() )
开发者ID:ewong718,项目名称:freesurfer,代码行数:25,代码来源:ImagePipeline.py

示例7: getMIP

def getMIP(imageData, color):
    """
	A function that will take a volume and do a simple
				 maximum intensity projection that will be converted to a
				 wxBitmap
	"""
    maxval = imageData.GetScalarRange()[1]
    imageData.SetUpdateExtent(imageData.GetWholeExtent())

    if maxval > 255:
        shiftscale = vtk.vtkImageShiftScale()
        shiftscale.SetInputConnection(imageData.GetProducerPort())
        shiftscale.SetScale(255.0 / maxval)
        shiftscale.SetOutputScalarTypeToUnsignedChar()
        imageData = shiftscale.GetOutput()

    mip = vtkbxd.vtkImageSimpleMIP()
    mip.SetInputConnection(imageData.GetProducerPort())

    if color == None:
        output = optimize.execute_limited(mip)
        return output

    if mip.GetOutput().GetNumberOfScalarComponents() == 1:
        ctf = getColorTransferFunction(color)

        maptocolor = vtk.vtkImageMapToColors()
        maptocolor.SetInputConnection(mip.GetOutputPort())
        maptocolor.SetLookupTable(ctf)
        maptocolor.SetOutputFormatToRGB()
        imagedata = optimize.execute_limited(maptocolor)

    else:
        imagedata = output = optimize.execute_limited(mip)
    return imagedata
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:35,代码来源:ImageOperations.py

示例8: do_colour_mask

    def do_colour_mask(self, imagedata):
        scalar_range = int(imagedata.GetScalarRange()[1])
        r, g, b = self.current_mask.colour

        # map scalar values into colors
        lut_mask = vtk.vtkLookupTable()
        lut_mask.SetNumberOfColors(256)
        lut_mask.SetHueRange(const.THRESHOLD_HUE_RANGE)
        lut_mask.SetSaturationRange(1, 1)
        lut_mask.SetValueRange(0, 255)
        lut_mask.SetRange(0, 255)
        lut_mask.SetNumberOfTableValues(256)
        lut_mask.SetTableValue(0, 0, 0, 0, 0.0)
        lut_mask.SetTableValue(1, 0, 0, 0, 0.0)
        lut_mask.SetTableValue(254, r, g, b, 1.0)
        lut_mask.SetTableValue(255, r, g, b, 1.0)
        lut_mask.SetRampToLinear()
        lut_mask.Build()
        # self.lut_mask = lut_mask

        # map the input image through a lookup table
        img_colours_mask = vtk.vtkImageMapToColors()
        img_colours_mask.SetLookupTable(lut_mask)
        img_colours_mask.SetOutputFormatToRGBA()
        img_colours_mask.SetInput(imagedata)
        img_colours_mask.Update()
        # self.img_colours_mask = img_colours_mask

        return img_colours_mask.GetOutput()
开发者ID:ruppert,项目名称:invesalius3,代码行数:29,代码来源:slice_.py

示例9: _on_new_image_attrib

    def _on_new_image_attrib(self, attrib):
        ((w, h, num_channels), dtype) = attrib
        if self._image_handler.is_depth_image():
            assert num_channels == 1, num_channels
            assert dtype in (np.uint16, np.float32), dtype
            # TODO(eric.cousineau): Delegate to outside of `ImageWidget`?
            # This is depth-image specific.
            # For now, just set arbitrary values.

            depth_range = self._get_depth_range()
            lower_color = (1, 1, 1)  # White
            upper_color = (0, 0, 0)  # Black
            nan_color = (0.5, 0.5, 1)  # Light blue - No return.
            inf_color = (0.5, 0, 0.)  # Dark red - Too far / too close.

            # Use `vtkColorTransferFunction` as it provides a more intuitive
            # interpolating interface for me (Eric) than `vtkLookupTable`,
            # since it permits direct specification of RGB values.
            coloring = vtk.vtkColorTransferFunction()
            coloring.AddRGBPoint(depth_range[0], *lower_color)
            coloring.AddRGBPoint(depth_range[1], *upper_color)
            coloring.SetNanColor(*nan_color)
            # @note `coloring.SetAboveRangeColor` doesn't seem to work?
            coloring.AddRGBPoint(depth_range[1] + 10000, *inf_color)
            coloring.SetClamping(True)
            coloring.SetScaleToLinear()

            self._depth_mapper = vtk.vtkImageMapToColors()
            self._depth_mapper.SetLookupTable(coloring)
            vtk_SetInputData(self._depth_mapper, self._image)
            vtk_SetInputData(self._image_actor, self._depth_mapper.GetOutput())
            self._image_actor.GetMapper().SetInputConnection(
                self._depth_mapper.GetOutputPort())
        else:
            # Direct connection.
            self._depth_mapper = None
            vtk_SetInputData(self._image_actor, self._image)

        # Must render first.
        self._view.render()

        # Fit image to view.
        # TODO(eric.cousineau): No idea why this is needed; it worked for
        # VTK 5, but no longer for VTK 6+?
        camera = self._view.camera()
        camera.ParallelProjectionOn()
        camera.SetFocalPoint(0, 0, 0)
        camera.SetPosition(0, 0, -1)
        camera.SetViewUp(0, -1, 0)
        self._view.resetCamera()

        image_height, image_width = get_vtk_image_shape(self._image)[:2]
        view_width, view_height = self._view.renderWindow().GetSize()

        aspect_ratio = float(view_width) / view_height
        parallel_scale = max(image_width / aspect_ratio, image_height) / 2.0
        camera.SetParallelScale(parallel_scale)
开发者ID:RobotLocomotion,项目名称:drake,代码行数:57,代码来源:show_image.py

示例10: setImage

    def setImage(self, dicomfile):
        logging.debug("In VTKImageView::setImage()")
        if dicomfile:
            if os.path.exists(dicomfile):
                self.reader = vtkgdcm.vtkGDCMImageReader()
                self.reader.SetFileName(dicomfile)
                self.reader.Update()

                vtkImageData = self.reader.GetOutput()
                vtkImageData.UpdateInformation()
                srange = vtkImageData.GetScalarRange()

                cast = vtk.vtkImageCast()
                cast.SetInput(vtkImageData)
                cast.SetOutputScalarType(4)
                cast.Update()
                cast.GetOutput().SetUpdateExtentToWholeExtent()

                table = vtk.vtkLookupTable()
                table.SetNumberOfColors(256)
                table.SetHueRange(0.0, 0.0)
                table.SetSaturationRange(0.0, 0.0)
                table.SetValueRange(0.0, 1.0)
                table.SetAlphaRange(1.0, 1.0)
                table.SetRange(srange)
                table.SetRampToLinear()
                table.Build()

                color = vtk.vtkImageMapToColors()
                color.SetLookupTable(table)
                color.SetInputConnection(cast.GetOutputPort())
                color.Update()

                self.cast = vtk.vtkImageMapToWindowLevelColors()
                self.cast.SetOutputFormatToLuminance()
                self.cast.SetInputConnection(color.GetOutputPort())
                self.cast.SetWindow(255.0)
                self.cast.SetLevel(127.0)
                self.cast.Update()
                self.cast.UpdateWholeExtent()

                self.render.RemoveActor(self.actor)
                self.actor = vtk.vtkImageActor()
                self.actor.SetInput(self.cast.GetOutput())
                self.render.AddActor(self.actor)
                self.render.ResetCamera()
                self.Render()
            else:
                self.render.RemoveActor(self.actor)
                self.Render()
        else:
            self.render.RemoveActor(self.actor)
            self.Render()
开发者ID:aevum,项目名称:moonstone,代码行数:53,代码来源:vtkimageview.py

示例11: updateRendering

	def updateRendering(self):
		"""
		Update the Rendering of this module
		"""
		data = self.getInput(1)
		x,y,z = self.dataUnit.getDimensions()
		data = optimize.optimize(image = data, updateExtent = (0, x-1, 0, y-1, 0, z-1))
		if data.GetNumberOfScalarComponents() > 3:
			extract = vtk.vtkImageExtractComponents()
			extract.SetInput(data)
			extract.SetComponents(1, 1, 1)
			data = extract.GetOutput()
		if data.GetNumberOfScalarComponents() > 1:
			self.luminance.SetInput(data)
			data = self.luminance.GetOutput()
		
		z = self.parameters["Slice"]
		ext = (0, x - 1, 0, y - 1, z, z)

		voi = vtk.vtkExtractVOI()
		voi.SetVOI(ext)
		voi.SetInput(data)
		slice = voi.GetOutput()
		self.geometry.SetInput(slice)         
		
		self.warp.SetInput(self.geometry.GetOutput())
		self.warp.SetScaleFactor(self.parameters["Scale"])		
		self.merge.SetGeometry(self.warp.GetOutput())
		
		if slice.GetNumberOfScalarComponents() == 1:
			maptocol = vtk.vtkImageMapToColors()
			ctf = self.getInputDataUnit(1).getColorTransferFunction()
			maptocol.SetInput(slice)
			maptocol.SetLookupTable(ctf)
			maptocol.Update()
			scalars = maptocol.GetOutput()
		else:
			scalars = slice
			
		self.merge.SetScalars(scalars)
		data = self.merge.GetOutput()
		
		if self.parameters["Normals"]:
			self.normals.SetInput(data)
			self.normals.SetFeatureAngle(self.parameters["FeatureAngle"])
			print "Feature angle=", self.parameters["FeatureAngle"]            
			data = self.normals.GetOutput()
		
		self.mapper.SetInput(data)
		self.mapper.Update()
		VisualizationModule.updateRendering(self)
		self.parent.Render()
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:52,代码来源:WarpScalar.py

示例12: vtkRemapImageColor

def vtkRemapImageColor(img, ranges=[0,2000],mapRange=[0,1.0],satRange=[0.0,0.0]):
    table = vtk.vtkLookupTable()
    table.SetRange(ranges) # image intensity range
    table.SetValueRange(mapRange) # from black to white
    table.SetSaturationRange(satRange) # no color saturation
    table.SetRampToLinear()
    table.Build()

    # Map the image through the lookup table
    color = vtk.vtkImageMapToColors()
    color.SetLookupTable(table)
    color.SetInputData(img)
    color.Update()
    return color.GetOutput()
开发者ID:gmaher,项目名称:tcl_code,代码行数:14,代码来源:utility.py

示例13: vtkImageDataToPreviewBitmap

def vtkImageDataToPreviewBitmap(dataunit, timepoint, color, width=0, height=0, getvtkImage=0):
    """
	A function that will take a volume and do a simple
				 Maximum Intensity Projection that will be converted to a
				 wxBitmap
	"""
    imagedata = dataunit.getMIP(timepoint, None, small=1, noColor=1)
    vtkImg = imagedata

    if not color:
        color = dataunit.getColorTransferFunction()

    ctf = getColorTransferFunction(color)
    minval, maxval = ctf.GetRange()
    imax = imagedata.GetScalarRange()[1]
    if maxval > imax:
        step = float((maxval - minval) / imax)
        ctf2 = vtk.vtkColorTransferFunction()
        Logging.info("Creating CTF in range %d, %d with steps %d" % (int(minval), int(maxval), int(step)))
        for i in range(int(minval), int(maxval), int(step)):
            red, green, blue = ctf.GetColor(i)
            ctf2.AddRGBPoint(i / step, red, green, blue)
        ctf = ctf2
    maptocolor = vtk.vtkImageMapToColors()
    maptocolor.SetInputConnection(imagedata.GetProducerPort())
    maptocolor.SetLookupTable(ctf)
    maptocolor.SetOutputFormatToRGB()
    maptocolor.Update()
    imagedata = maptocolor.GetOutput()

    image = vtkImageDataToWxImage(imagedata)
    xSize, ySize = image.GetWidth(), image.GetHeight()
    if not width and height:
        aspect = float(xSize) / ySize
        width = aspect * height
    if not height and width:
        aspect = float(ySize) / xSize
        height = aspect * width
    if not width and not height:
        width = height = 64
    image.Rescale(width, height)

    bitmap = image.ConvertToBitmap()
    ret = [bitmap]
    if getvtkImage:
        ret.append(vtkImg)
        return ret
    return bitmap
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:48,代码来源:ImageOperations.py

示例14: do_colour_image

    def do_colour_image(self, imagedata):
        # map scalar values into colors
        lut_bg = vtk.vtkLookupTable()
        lut_bg.SetTableRange(imagedata.GetScalarRange())
        lut_bg.SetSaturationRange(self.saturation_range)
        lut_bg.SetHueRange(self.hue_range)
        lut_bg.SetValueRange(self.value_range)
        lut_bg.Build()

        # map the input image through a lookup table
        img_colours_bg = vtk.vtkImageMapToColors()
        img_colours_bg.SetOutputFormatToRGB()
        img_colours_bg.SetLookupTable(lut_bg)
        img_colours_bg.SetInput(imagedata)
        img_colours_bg.Update()

        return img_colours_bg.GetOutput()
开发者ID:ruppert,项目名称:invesalius3,代码行数:17,代码来源:slice_.py

示例15: __create_background

    def __create_background(self, imagedata):
        thresh_min, thresh_max = imagedata.GetScalarRange()
        Publisher.sendMessage("Update threshold limits list", (thresh_min, thresh_max))

        # map scalar values into colors
        lut_bg = self.lut_bg = vtk.vtkLookupTable()
        lut_bg.SetTableRange(thresh_min, thresh_max)
        lut_bg.SetSaturationRange(0, 0)
        lut_bg.SetHueRange(0, 0)
        lut_bg.SetValueRange(0, 1)
        lut_bg.Build()

        # map the input image through a lookup table
        img_colours_bg = self.img_colours_bg = vtk.vtkImageMapToColors()
        img_colours_bg.SetOutputFormatToRGBA()
        img_colours_bg.SetLookupTable(lut_bg)
        img_colours_bg.SetInput(imagedata)

        return img_colours_bg.GetOutput()
开发者ID:ruppert,项目名称:invesalius3,代码行数:19,代码来源:slice_.py


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