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

Python vtk.vtkImageShiftScale函数代码示例

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

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



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

示例1: Execute

    def Execute(self):

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

        if self.MapRanges:
            if self.InputRange == [0.0,0.0]:
                self.InputRange = self.Image.GetScalarRange()
            if self.InputRange[1] == self.InputRange[0]:
                self.PrintError('Error: Input range has zero width. Cannot map values')
            self.Shift = -self.InputRange[0]
            self.Scale = (self.OutputRange[1] - self.OutputRange[0]) / (self.InputRange[1] - self.InputRange[0])

        shiftScale = vtk.vtkImageShiftScale()
        shiftScale.SetInput(self.Image)
        shiftScale.SetShift(self.Shift)
        shiftScale.SetScale(self.Scale)

        if self.OutputType == 'double':
            shiftScale.SetOutputScalarTypeToDouble()
        elif self.OutputType == 'uchar':
            shiftScale.SetOutputScalarTypeToUnsignedChar()
        elif self.OutputType == 'char':
            shiftScale.SetOutputScalarTypeToChar()
        elif self.OutputType == 'ushort':
            shiftScale.SetOutputScalarTypeToUnsignedShort()
        elif self.OutputType == 'short':
            shiftScale.SetOutputScalarTypeToShort()
        elif self.OutputType == 'ulong':
            shiftScale.SetOutputScalarTypeToUnsignedLong()
        elif self.OutputType == 'long':
            shiftScale.SetOutputScalarTypeToLong()
        elif self.OutputType == 'uint':
            shiftScale.SetOutputScalarTypeToUnsignedInt()
        elif self.OutputType == 'int':
            shiftScale.SetOutputScalarTypeToInt()
        elif self.OutputType == 'float':
            shiftScale.SetOutputScalarTypeToFloat()

        if self.OutputType != 'unchanged':
            if self.ClampOverflowOn:
                shiftScale.ClampOverflowOn()

        shiftScale.ClampOverflowOff()
        shiftScale.Update()

        self.Image = shiftScale.GetOutput()

        if self.MapRanges and self.OutputRange[0] != 0.0:
            shiftScale2 = vtk.vtkImageShiftScale()
            shiftScale2.SetInput(self.Image)
            shiftScale2.SetShift(self.OutputRange[0])
            shiftScale2.SetScale(1.0)
            shiftScale2.Update()
            self.Image = shiftScale2.GetOutput()
开发者ID:ChaliZhg,项目名称:vmtk,代码行数:55,代码来源:vmtkimageshiftscale.py


示例2: __init__

    def __init__(self, comedi, cfg_dict):
        self._comedi = comedi
        self._cfg = cfg_dict

        # we'll store our local bindings here
        self._d1 = None
        self._d2m = None
        self._conf = None
        self._cmap_range = [-1024, 3072]
        self._cmap_type = CMAP_BLUE_TO_YELLOW_PL

        # color scales thingy
        self._color_scales = vtk_kit.color_scales.ColorScales()

        # instantiate us a slice viewer
        rwi,ren = comedi.get_compvis_vtk()
        self._sv = comedi_utils.CMSliceViewer(rwi, ren)
        # now make our own MapToColors
        ct = 32
        lut = self._sv.ipws[0].GetLookupTable()
        self._cmaps = [vtktudoss.vtkCVImageMapToColors() for _ in range(3)]
        for i,cmap in enumerate(self._cmaps):
            cmap.SetLookupTable(lut)
            cmap.SetConfidenceThreshold(ct)
            self._sv.ipws[i].SetColorMap(cmap)

        self._set_confidence_threshold_ui(ct)


        comedi.sync_slice_viewers.add_slice_viewer(self._sv)

        # now build up the VTK pipeline #############################
        # we'll use these to scale data between 0 and max.
        self._ss1 = vtk.vtkImageShiftScale()
        self._ss1.SetOutputScalarTypeToShort()
        self._ss2 = vtk.vtkImageShiftScale()
        self._ss2.SetOutputScalarTypeToShort()

        # we have to cast the confidence to shorts as well
        self._ssc = vtk.vtkImageShiftScale()
        self._ssc.SetOutputScalarTypeToShort()

        self._iac = vtk.vtkImageAppendComponents()
        # data1 will form the context
        self._iac.SetInput(0, self._ss1.GetOutput())
        # subtraction will form the focus
        self._iac.SetInput(1, self._ss2.GetOutput())
        # third input will be the confidence
        self._iac.SetInput(2, self._ssc.GetOutput())

        # event bindings ############################################
        self._bind_events()
开发者ID:fvpolpeta,项目名称:devide,代码行数:52,代码来源:comedi_comparison_modes.py


示例3: SetupTextureMapper

    def SetupTextureMapper(self):
        if not self.GetInput():
            return
        
        mapper3D = vtk.vtkVolumeTextureMapper3D.SafeDownCast(self.__VolumeTextureMapper)
        if mapper3D and not self.GetRenderWindow().GetNeverRendered():
            if not mapper3D.IsRenderSupported(self.__VolumeProperty):
#               try the ATI fragment program implementation
                mapper3D.SetPreferredMethodToFragmentProgram()
                if not mapper3D.IsRenderSupported(self.__VolumeProperty):
                    print "Warning: 3D texture volume rendering is not supported by your hardware, switching to 2D texture rendering."
                    newMapper = vtk.vtkVolumeTextureMapper2D()
                    newMapper.CroppingOn()
                    newMapper.SetCroppingRegionFlags (0x7ffdfff)
                    
                    range = self.GetInput().GetScalarRange()
                    shift = 0 - range[0]
                    scale = 65535.0 / (range[1]-range[0])
                    
                    scaler = vtk.vtkImageShiftScale()
                    scaler.SetInput(self.GetInput())
                    scaler.SetShift(shift)
                    scaler.SetScale(scale)
                    scaler.SetOutputScalarTypeToUnsignedShort()
                    scaler.Update()
                    newMapper.SetInput(scaler.GetOutput())
#                    del scaler
                    self.__Callback.SetVolumeMapper(newMapper)
                    self.__VolumeMapper = newMapper
                    self.__VolumeMapper.SetMapper(newMapper)
开发者ID:jackyko1991,项目名称:vtkpythonext,代码行数:30,代码来源:vtkPythonViewImage3D.py


示例4: WritePNGImageFile

 def WritePNGImageFile(self):
     if self.OutputFileName == "":
         self.PrintError("Error: no OutputFileName.")
     self.PrintLog("Writing PNG image file.")
     outputImage = self.Image
     if self.Image.GetScalarTypeAsString() != "unsigned char":
         shiftScale = vtk.vtkImageShiftScale()
         shiftScale.SetInput(self.Image)
         if self.WindowLevel[0] == 0.0:
             scalarRange = self.Image.GetScalarRange()
             shiftScale.SetShift(-scalarRange[0])
             shiftScale.SetScale(255.0 / (scalarRange[1] - scalarRange[0]))
         else:
             shiftScale.SetShift(-(self.WindowLevel[1] - self.WindowLevel[0] / 2.0))
             shiftScale.SetScale(255.0 / self.WindowLevel[0])
         shiftScale.SetOutputScalarTypeToUnsignedChar()
         shiftScale.ClampOverflowOn()
         shiftScale.Update()
         outputImage = shiftScale.GetOutput()
     writer = vtk.vtkPNGWriter()
     writer.SetInput(outputImage)
     if self.Image.GetDimensions()[2] == 1:
         writer.SetFileName(self.OutputFileName)
     else:
         writer.SetFilePrefix(self.OutputFileName)
         writer.SetFilePattern("%s%04d.png")
     writer.Write()
开发者ID:abhishek101hi,项目名称:vmtk,代码行数:27,代码来源:vmtkimagewriter.py


示例5: 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)
		self.vtkfilter.SetInput(image)
		
		self.vtkfilter.SetConsiderAnisotropy(self.parameters["ConsiderAnisotropy"])
		self.vtkfilter.SetAlgorithm(self.parameters["Algorithm"])
		data = self.vtkfilter.GetOutput()
		if self.parameters["CastToUnsignedChar"]:
			self.vtkfilter.Update()
			cast = vtk.vtkImageShiftScale()
			x0, x1 = data.GetScalarRange()
			print data
			print "Scalar range=",x0,x1
			cast.SetInput(self.vtkfilter.GetOutput())
			cast.SetOutputScalarTypeToUnsignedChar()
			#cast.SetClampOverflow(1)
			cast.SetScale(255.0/x1)
			print "Setting scale to ", 255.0/x1
			data = cast.GetOutput()
		if update:
			self.vtkfilter.Update()
		return data  
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:28,代码来源:EuclideanDistance.py


示例6: getIntensityScaledData

	def getIntensityScaledData(self, data):
		"""
		Return the data shifted and scaled to appropriate intensity range
		"""
		if not self.explicitScale:
			return data
		
		if self.intensityScale == -1:
			return data
		
		if not self.shift:
			self.shift = vtk.vtkImageShiftScale()
			self.shift.SetOutputScalarTypeToUnsignedChar()
			self.shift.SetClampOverflow(1)
		
		self.shift.SetInputConnection(data.GetProducerPort())
		# Need to call this or it will remember the whole extent it got from resampling
		self.shift.UpdateWholeExtent()

		if self.intensityScale:
			self.shift.SetScale(self.intensityScale)
			currScale = self.intensityScale
		else:
			minval, maxval = self.originalScalarRange
			scale = 255.0 / maxval
			self.shift.SetScale(scale)
			currScale = scale
		
		self.shift.SetShift(self.intensityShift)
		
		Logging.info("Intensity shift = %d, scale = %f"%(self.intensityShift, currScale), kw="datasource")
		
		return self.shift.GetOutput()
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:33,代码来源:DataSource.py


示例7: Execute

    def Execute(self):

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

        if self.OutputType == 'uchar' and self.ShiftScale:
            shiftScale = vtk.vtkImageShiftScale()
            shiftScale.SetInputData(self.Image)
            if self.WindowLevel[0] == 0.0:
                scalarRange = self.Image.GetScalarRange()
                scale = 255.0
                if (scalarRange[1]-scalarRange[0]) > 0.0:
                    scale = 255.0/(scalarRange[1]-scalarRange[0])
                shiftScale.SetShift(-scalarRange[0])
                shiftScale.SetScale(scale)
            else:
                shiftScale.SetShift(-(self.WindowLevel[1]-self.WindowLevel[0]/2.0))
                shiftScale.SetScale(255.0/self.WindowLevel[0])
            shiftScale.SetOutputScalarTypeToUnsignedChar()
            shiftScale.ClampOverflowOn()
            shiftScale.Update()
            self.Image = shiftScale.GetOutput()
        else:
            cast = vtk.vtkImageCast()
            cast.SetInputData(self.Image)
            if self.OutputType == 'float':
                cast.SetOutputScalarTypeToFloat()
            elif self.OutputType == 'double':
                cast.SetOutputScalarTypeToDouble()
            elif self.OutputType == 'uchar':
                cast.SetOutputScalarTypeToUnsignedChar()
            elif self.OutputType == 'short':
                cast.SetOutputScalarTypeToShort()
            cast.Update()
            self.Image = cast.GetOutput()
开发者ID:samsmu,项目名称:vmtk,代码行数:35,代码来源:vmtkimagecast.py


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


示例9: __init__

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


示例10: Execute

    def Execute(self):

        if self.Image == None:
            self.PrintError("Error: No input image.")

        if self.OutputType == "uchar" and self.ShiftScale:
            shiftScale = vtk.vtkImageShiftScale()
            shiftScale.SetInput(self.Image)
            if self.WindowLevel[0] == 0.0:
                scalarRange = self.Image.GetScalarRange()
                shiftScale.SetShift(-scalarRange[0])
                shiftScale.SetScale(255.0 / (scalarRange[1] - scalarRange[0]))
            else:
                shiftScale.SetShift(-(self.WindowLevel[1] - self.WindowLevel[0] / 2.0))
                shiftScale.SetScale(255.0 / self.WindowLevel[0])
            shiftScale.SetOutputScalarTypeToUnsignedChar()
            shiftScale.ClampOverflowOn()
            shiftScale.Update()
            self.Image = shiftScale.GetOutput()
        else:
            cast = vtk.vtkImageCast()
            cast.SetInput(self.Image)
            if self.OutputType == "float":
                cast.SetOutputScalarTypeToFloat()
            elif self.OutputType == "double":
                cast.SetOutputScalarTypeToDouble()
            elif self.OutputType == "uchar":
                cast.SetOutputScalarTypeToUnsignedChar()
            elif self.OutputType == "short":
                cast.SetOutputScalarTypeToShort()
            cast.Update()
            self.Image = cast.GetOutput()
开发者ID:haehn,项目名称:vmtk,代码行数:32,代码来源:vmtkimagecast.py


示例11: DownsampleImage

    def DownsampleImage(self, image, nbits=8):
        """Downsamples an image"""

        image.SetReleaseDataFlag(1)

        # get the min and max values from the image
        (minval, maxval) = image.GetScalarRange()

        # create an 8-bit version of this image
        _filter = vtk.vtkImageShiftScale()
        _filter.SetInput(image.GetRealImage())
        _filter.SetShift(-minval)
        try:
            if nbits == 8:
                _filter.SetScale(255.0 / (maxval - minval))
            elif nbits == 16:
                _filter.SetScale(65535.0 / (maxval - minval))
        except ZeroDivisionError:
            logging.exception("DownsampleImage")
            _filter.SetScale(1.0)
        if nbits == 8:
            _filter.SetOutputScalarTypeToUnsignedChar()
        elif nbits == 16:
            _filter.SetOutputScalarTypeToShort()
        elif nbits == 32:
            _filter.SetOutputScalarTypeToFloat()
        elif nbits == 64:
            _filter.SetOutputScalarTypeToDouble()

        _filter.AddObserver('ProgressEvent', self.HandleVTKProgressEvent)
        _filter.SetProgressText("Downsampling to %d-bit..." % nbits)
        logging.info("Image downsampled to {0}-bit".format(nbits))
        _filter.Update()

        return MVImage.MVImage(_filter.GetOutputPort(), input=image)
开发者ID:andyTsing,项目名称:MicroView,代码行数:35,代码来源:MicroViewImageProcessor.py


示例12: WriteTIFFImageFile

 def WriteTIFFImageFile(self):
     if (self.OutputFileName == ''):
         self.PrintError('Error: no OutputFileName.')
     self.PrintLog('Writing TIFF image file.')
     outputImage = self.Image
     if self.Image.GetScalarTypeAsString() != 'unsigned char':
         shiftScale = vtk.vtkImageShiftScale()
         shiftScale.SetInputData(self.Image)
         if self.WindowLevel[0] == 0.0:
             scalarRange = self.Image.GetScalarRange()
             shiftScale.SetShift(-scalarRange[0])
             shiftScale.SetScale(255.0/(scalarRange[1]-scalarRange[0]))
         else: 
             shiftScale.SetShift(-(self.WindowLevel[1]-self.WindowLevel[0]/2.0))
             shiftScale.SetScale(255.0/self.WindowLevel[0])
         shiftScale.SetOutputScalarTypeToUnsignedChar()
         shiftScale.ClampOverflowOn()
         shiftScale.Update()
         outputImage = shiftScale.GetOutput()
     writer = vtk.vtkTIFFWriter()
     writer.SetInputData(outputImage)
     if self.Image.GetDimensions()[2] == 1:
         writer.SetFileName(self.OutputFileName)
     else:
         writer.SetFilePrefix(self.OutputFileName)
         writer.SetFilePattern("%s%04d.tif")
     writer.Write()
开发者ID:vmtk,项目名称:vmtk,代码行数:27,代码来源:vmtkimagewriter.py


示例13: Rescale

def Rescale(combo, ZeroPoint):
    """Rescale to legal pixel values [-1, 1] --> [0, MaxScaledValue]"""
    scaled = vtk.vtkImageShiftScale()
    scaled.SetInputConnection(combo.GetOutputPort())
    scaled.SetShift(1.)
    scaled.SetScale(ZeroPoint + 1)
    scaled.SetOutputScalarTypeToUnsignedShort()

    return scaled
开发者ID:jiahao,项目名称:openqube,代码行数:9,代码来源:viz.vtkGaussians.py


示例14: __init__

    def __init__(self,renWin):
        self.renWin = renWin
        self.zBuffFilter = vtk.vtkWindowToImageFilter()
        self.zBuffFilter.SetInput(self.renWin)
        self.zBuffFilter.SetInputBufferTypeToZBuffer()

        self.scaledZBuff = vtk.vtkImageShiftScale()
        self.scaledZBuff.SetOutputScalarTypeToUnsignedChar()
        self.scaledZBuff.SetInputConnection(self.zBuffFilter.GetOutputPort())
        self.scaledZBuff.SetShift(0)
        self.scaledZBuff.SetScale(255)
开发者ID:gnastacast,项目名称:dvrk-vtk-registration,代码行数:11,代码来源:vtkTools.py


示例15: __init__

	def __init__(self):
		"""
		Initialization
		"""		   
		lib.ProcessingFilter.ProcessingFilter.__init__(self, (1, 1))
		self.vtkfilter = vtk.vtkImageShiftScale()
		self.vtkfilter.AddObserver("ProgressEvent", lib.messenger.send)
		lib.messenger.connect(self.vtkfilter, 'ProgressEvent', self.updateProgress)
		self.eventDesc = "Applying a shift and scale to image intensity"
		self.descs = {"Shift": "Shift:", "Scale": "Scale:", "AutoScale": "Scale to max range of data type", "NoOverflow":"Prevent over/underflow", "Scale8bit": "Scale to 8-bit range (0-255)"}
		self.filterDesc = "Shifts pixel/voxel intensities and then scales them, corresponding roughly to the adjustment of brightness and contrast, respectively\nInput: Grayscale image\nOutput: Grayscale image"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:11,代码来源:ShiftScale.py


示例16: __init__

	def __init__(self):
		"""
		Initialization
		"""		   
		lib.ProcessingFilter.ProcessingFilter.__init__(self, (1, 1))
		self.vtkfilter = vtk.vtkImageShiftScale()
		self.vtkfilter.AddObserver("ProgressEvent", lib.messenger.send)
		lib.messenger.connect(self.vtkfilter, 'ProgressEvent', self.updateProgress)
		self.eventDesc = "Applying an Automatic background subtraction"
		self.descs = {"SmallestNonZeroValue":"Use smallest non-zero value as background",
		"FirstPeak":"First peak in histogram","MostCommon":"Most common value"}
		self.filterDesc = "Removes background by subtracting a certain value from the intensity of every pixel/voxel\nInput: Grayscale image\nOutput: Grayscale image"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:12,代码来源:AutoBackgroundSubtract.py


示例17: _handleFailedImage

def _handleFailedImage(idiff, pngr, img_fname):
    """Writes all the necessary images when an image comparison
    failed."""
    f_base, f_ext = os.path.splitext(img_fname)

    # write out the difference file in full.
    pngw = vtk.vtkPNGWriter()
    pngw.SetFileName(_getTempImagePath(f_base + ".diff.png"))
    pngw.SetInput(idiff.GetOutput())
    pngw.Write()
    
    # write the difference image scaled and gamma adjusted for the
    # dashboard.
    sz = pngr.GetOutput().GetDimensions()
    if sz[1] <= 250.0:
        mag = 1.0
    else:
        mag = 250.0/sz[1]

    shrink = vtk.vtkImageResample()
    shrink.SetInput(idiff.GetOutput())
    shrink.InterpolateOn()
    shrink.SetAxisMagnificationFactor(0, mag)
    shrink.SetAxisMagnificationFactor(1, mag)

    gamma = vtk.vtkImageShiftScale()
    gamma.SetInput(shrink.GetOutput())
    gamma.SetShift(0)
    gamma.SetScale(10)

    jpegw = vtk.vtkJPEGWriter()
    jpegw.SetFileName(_getTempImagePath(f_base + ".diff.small.jpg"))
    jpegw.SetInput(gamma.GetOutput())
    jpegw.SetQuality(85)
    jpegw.Write()

    # write out the image that was generated.
    shrink.SetInput(idiff.GetInput())
    jpegw.SetInput(shrink.GetOutput())
    jpegw.SetFileName(_getTempImagePath(f_base + ".test.small.jpg"))
    jpegw.Write()

    # write out the valid image that matched.
    shrink.SetInput(idiff.GetImage())
    jpegw.SetInput(shrink.GetOutput())
    jpegw.SetFileName(_getTempImagePath(f_base + ".small.jpg"))
    jpegw.Write()
开发者ID:SRabbelier,项目名称:Casam,代码行数:47,代码来源:Testing.py


示例18: dicom_to_png

def dicom_to_png(imagedata, dir):
    logging.debug("In data.dicom_to_png()")
    shiftScale = vtk.vtkImageShiftScale()
    shiftScale.SetOutputScalarTypeToUnsignedShort()
    shiftScale.SetInput(imagedata)
    inp = shiftScale.GetInput()
    minv, maxv = inp.GetScalarRange()
    shiftScale.SetShift(-minv)
    shiftScale.SetScale(65535 / (maxv - minv))
    w = vtk.vtkPNGWriter()
    w.SetFileDimensionality(3)
    w.SetInput(shiftScale.GetOutput())
    w.SetFilePattern("%s%d.png")
    if not os.path.exists(dir):
        os.mkdir(dir)
    w.SetFilePrefix(dir)
    w.Write()
开发者ID:aevum,项目名称:moonstone,代码行数:17,代码来源:data.py


示例19: Display

    def Display(self):

        wholeExtent = self.Image.GetWholeExtent()

        self.SliceVOI[0] = wholeExtent[0]
        self.SliceVOI[1] = wholeExtent[1]
        self.SliceVOI[2] = wholeExtent[2]
        self.SliceVOI[3] = wholeExtent[3]
        self.SliceVOI[4] = wholeExtent[4]
        self.SliceVOI[5] = wholeExtent[5]

        self.SliceVOI[self.Axis*2] = wholeExtent[self.Axis*2]
        self.SliceVOI[self.Axis*2+1] = wholeExtent[self.Axis*2]

        range = self.Image.GetScalarRange()

        imageShifter = vtk.vtkImageShiftScale()
        imageShifter.SetInput(self.Image)
        imageShifter.SetShift(-1.0*range[0])
        imageShifter.SetScale(255.0/(range[1]-range[0]))
        imageShifter.SetOutputScalarTypeToUnsignedChar()

        widgetImage = imageShifter.GetOutput()

        self.ImageActor.SetInput(widgetImage)
        self.ImageActor.SetDisplayExtent(self.SliceVOI)
        self.vmtkRenderer.Renderer.AddActor(self.ImageActor)

        self.ImageTracerWidget.SetCaptureRadius(1.5)
        self.ImageTracerWidget.SetViewProp(self.ImageActor)
        self.ImageTracerWidget.SetInput(widgetImage)
        self.ImageTracerWidget.ProjectToPlaneOn()
        self.ImageTracerWidget.SetProjectionNormal(self.Axis)
        self.ImageTracerWidget.PlaceWidget()
        self.ImageTracerWidget.SetAutoClose(self.AutoClose)
        self.ImageTracerWidget.AddObserver("StartInteractionEvent",self.SetWidgetProjectionPosition)
        self.ImageTracerWidget.AddObserver("EndInteractionEvent",self.GetLineFromWidget)

        interactorStyle = vtk.vtkInteractorStyleImage()
        self.vmtkRenderer.RenderWindowInteractor.SetInteractorStyle(interactorStyle)

        self.vmtkRenderer.Render()
开发者ID:greenHandProgramer,项目名称:LungcareEDotnet,代码行数:42,代码来源:vmtkimagelinetracer.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

		roi = self.parameters["ROI"][1]
		scripting.wantWholeDataset = 1
		imagedata = self.getInput(1)
		imagedata.SetUpdateExtent(imagedata.GetWholeExtent())
		imagedata.Update()

		itkOrig = self.convertVTKtoITK(imagedata)
		itkOrig.DisconnectPipeline()

		mx, my, mz = self.dataUnit.getDimensions()
		n, maskImage = lib.ImageOperations.getMaskFromROIs([roi], mx, my, mz)
		itkLabel = self.convertVTKtoITK(maskImage)
		itkLabel = self.castITKImage(itkLabel, itkOrig)
		#vtkToItk2 = itk.VTKImageToImageFilter.IUC3.New()
		#vtkToItk2.SetInput(maskImage)
		#itkLabel = vtkToItk2.GetOutput()
		#itkLabel.Update()

		labelStats = itk.LabelStatisticsImageFilter[itkOrig, itkLabel].New()
		labelStats.SetInput(0, itkOrig)
		labelStats.SetInput(1, itkLabel)
		labelStats.Update()
		
		avgint = labelStats.GetMean(255)
		print "Subtract from image:",avgint

		shift = vtk.vtkImageShiftScale()
		shift.SetInput(imagedata)
		shift.SetClampOverflow(1)
		shift.SetScale(1)
		shift.SetShift(-avgint)
		
		return shift.GetOutput()
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:40,代码来源:SubtractROI.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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