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

Python vtk.vtkImageImport函数代码示例

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

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



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

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


示例2: numpy2VTK

def numpy2VTK(img,spacing=[1.0,1.0,1.0]):
    importer = vtk.vtkImageImport()
    
    img_data = img.astype('uint8')
    img_string = img_data.tostring() # type short
    dim = img.shape
    
    importer.CopyImportVoidPointer(img_string, len(img_string))
    importer.SetDataScalarType(VTK_UNSIGNED_CHAR)
    importer.SetNumberOfScalarComponents(1)
    
    extent = importer.GetDataExtent()
    importer.SetDataExtent(extent[0], extent[0] + dim[2] - 1,
                           extent[2], extent[2] + dim[1] - 1,
                           extent[4], extent[4] + dim[0] - 1)
    importer.SetWholeExtent(extent[0], extent[0] + dim[2] - 1,
                            extent[2], extent[2] + dim[1] - 1,
                            extent[4], extent[4] + dim[0] - 1)
    importer.SetDataSpacing( spacing[2], spacing[1], spacing[0])
    importer.SetDataOrigin( 0,0,0 )

    # flip = vtk.vtkImageFlip()
    # flip.SetFilteredAxis(2)
    # flip.SetInput(importer.GetOutput())

    return importer
开发者ID:151706061,项目名称:IRTK,代码行数:26,代码来源:vtkTools.py


示例3: getMaskFromPoints

def getMaskFromPoints(points, mx, my, mz, value=255):
    """
	Create a mask where all given points are set to value (between 0-255)
	"""
    if value > 255:
        value = 255
    elif value < 0:
        value = 0

    size = mx * my
    pointStructString = "%dB" % size
    pointData = []
    for y in range(0, my):
        for x in range(0, mx):
            pointData.append(value * points.get((x, y), 0))
    packedPointString = struct.pack(pointStructString, *pointData)

    importer = vtk.vtkImageImport()
    importer.CopyImportVoidPointer(packedPointString, mx * my)
    importer.SetDataScalarTypeToUnsignedChar()
    importer.SetNumberOfScalarComponents(1)
    importer.SetDataExtent(0, mx - 1, 0, my - 1, 0, 0)
    importer.SetWholeExtent(0, mx - 1, 0, my - 1, 0, 0)

    importer.Update()

    append = vtk.vtkImageAppend()
    append.SetAppendAxis(2)
    for z in range(0, mz):
        append.SetInput(z, importer.GetOutput())
    append.Update()
    image2 = append.GetOutput()
    return image2
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:33,代码来源:ImageOperations.py


示例4: axonComparison

def axonComparison(axons, N):
    axonsToRender = []
    for i in range(N):
        axon = axons.pop(random.randrange(len(axons)))
        axonsToRender.append(axon)
    bins = main.BINS
    data_matrix = numpy.zeros([500, 500, 500], dtype=numpy.uint16)
    dataImporter = vtk.vtkImageImport()
    data_string = data_matrix.tostring()
    dataImporter.CopyImportVoidPointer(data_string, len(data_string))
    dataImporter.SetDataScalarTypeToUnsignedChar()
    dataImporter.SetNumberOfScalarComponents(1)
    dataImporter.SetDataExtent(0, 500, 0, 500, 0, 500)
    dataImporter.SetWholeExtent(0, 500, 0, 500, 0, 500)
    volumeProperty = vtk.vtkVolumeProperty()
    compositeFunction = vtk.vtkVolumeRayCastCompositeFunction()
    volumeMapper = vtk.vtkVolumeRayCastMapper()
    volumeMapper.SetVolumeRayCastFunction(compositeFunction)
    volumeMapper.SetInputConnection(dataImporter.GetOutputPort())
    volume = vtk.vtkVolume()
    volume.SetMapper(volumeMapper)
    volume.SetProperty(volumeProperty)
    renderer = vtk.vtkRenderer()
    renderWin = vtk.vtkRenderWindow()
    renderWin.AddRenderer(renderer)
    renderInteractor = vtk.vtkRenderWindowInteractor()
    renderInteractor.SetRenderWindow(renderWin)
    renderer.SetBackground(1, 1, 1)
    renderWin.SetSize(400, 400)
    for axon in axonsToRender:
        renderer = Utils.renderSingleAxon(axon, renderer, [random.random(), random.random(), random.random()])
    renderWin.AddObserver("AbortCheckEvent", exitCheck)
    renderInteractor.Initialize()
    renderWin.Render()
    renderInteractor.Start()
开发者ID:EthanGlasserman,项目名称:Brainbow,代码行数:35,代码来源:Draw.py


示例5: ConvertNumpyVTKImage

def ConvertNumpyVTKImage(NumpyImageData, arrayName , dim, vtkOrigin ):
  # Create initial image
  # imports raw data and stores it.
  dataImporter = vtk.vtkImageImport()
  # array is converted to a string of chars and imported.
  # numpy array stored as ROW MAJOR
  # MUST write out in COLUMN MAJOR format to be the same as VTK
  data_string = NumpyImageData.tostring(order='F')
  dataImporter.CopyImportVoidPointer(data_string, len(data_string))
  # The type of the newly imported data is set to unsigned char (uint8)
  dataImporter.SetDataScalarTypeToDouble()
  # Because the data that is imported only contains an intensity value (it isnt RGB-coded or someting similar), the importer
  # must be told this is the case.
  dataImporter.SetNumberOfScalarComponents(1)
  # The following two functions describe how the data is stored and the dimensions of the array it is stored in. For this
  # simple case, all axes are of length 75 and begins with the first element. For other data, this is probably not the case.
  # I have to admit however, that I honestly dont know the difference between SetDataExtent() and SetWholeExtent() although
  # VTK complains if not both are used.
  dataImporter.SetDataExtent( 0, dim[0]-1, 0, dim[1]-1, 0, dim[2]-1)
  dataImporter.SetWholeExtent(0, dim[0]-1, 0, dim[1]-1, 0, dim[2]-1)
  dataImporter.SetDataSpacing( spacing )
  dataImporter.SetDataOrigin(  vtkOrigin  )
  dataImporter.SetScalarArrayName(  arrayName  )
  dataImporter.Update()
  return dataImporter.GetOutput()
开发者ID:ImageGuidedTherapyLab,项目名称:MotionCorrection,代码行数:25,代码来源:backgroundCorrection.py


示例6: vtk_marching_cubes

def vtk_marching_cubes(field,iso=0.5):

    import vtk

    int_field = (np.minimum(field*255,255)).astype(np.uint8)
    nx, ny, nz = int_field.shape
    data_string = int_field.tostring('F')

    reader = vtk.vtkImageImport()
    reader.CopyImportVoidPointer(data_string, len(data_string))
    reader.SetDataScalarTypeToUnsignedChar()
    reader.SetNumberOfScalarComponents(1)
    reader.SetDataExtent(0, nx - 1, 0, ny - 1, 0, nz - 1)
    reader.SetWholeExtent(0, nx - 1, 0, ny - 1, 0, nz - 1)
    reader.Update()

    contour = vtk.vtkImageMarchingCubes()
    if vtk.VTK_MAJOR_VERSION <= 5:
        contour.SetInput(reader.GetOutput())
    else:
        contour.SetInputData(reader.GetOutput())   
    contour.ComputeNormalsOn()
    contour.ComputeGradientsOn()
    contour.SetValue(0,int(iso*255))
    contour.Update()

    field_polydata = contour.GetOutput()

    polydata_points = np.array([field_polydata.GetPoints().GetPoint(p) for p in xrange(field_polydata.GetPoints().GetNumberOfPoints())])
    polydata_triangles =  np.array([[field_polydata.GetCell(t).GetPointIds().GetId(i) for i in xrange(3)] for t in xrange(field_polydata.GetNumberOfCells())])

    return polydata_points, polydata_triangles
开发者ID:VirtualPlants,项目名称:cellcomplex,代码行数:32,代码来源:implicit_surfaces.py


示例7: write_data

def write_data(data,x,y,z):
    siz = x*y*z
    fs="%dH"%siz
    print "min(data)=",min(data),"max(data)=",max(data)
    print "size=",siz,"len of data=",len(data)
    ss = struct.pack(fs,*data)
    print "min(ss)=",min(ss),"max(ss)=",max(ss),"len(ss)=",len(ss)
    
    
    importer=vtk.vtkImageImport()
    importer.CopyImportVoidPointer(ss,len(ss))
    importer.SetDataScalarTypeToUnsignedShort()
    #importer.SetDataScalarTypeToUnsignedChar()
    #importer.SetDataScalarType(5)
    importer.SetNumberOfScalarComponents(1)
    importer.SetDataExtent(0,x-1,0,y-1,0,z-1)
    importer.SetWholeExtent(0,x-1,0,y-1,0,z-1)
    importer.Update()
    image = importer.GetOutput()
    #print image
    print "Image scalar range=",image.GetScalarRange()
    print "Image scalar type=",image.GetScalarTypeAsString()
    #print image
    
    writer = vtk.vtkXMLImageDataWriter()
    writer.SetInput(image)
    writer.SetFileName("output.vti")
    print "Writing..."
    writer.Write()
    print "done"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:30,代码来源:test_plot_track.py


示例8: __init__

 def __init__(self):
     self.__vtkimport=vtk.vtkImageImport()
     self.__vtkimport.SetDataScalarTypeToFloat()
     self.__vtkimport.SetNumberOfScalarComponents(1)
     self.__filePattern=self.__defaultFilePattern
     self.__data = None
     self._irs = vtk.vtkImageReslice()
开发者ID:neurodebian,项目名称:PyLocator,代码行数:7,代码来源:vtkNifti.py


示例9: __init__

    def __init__(self):
        """ Class constructor """

        # Initialize the OpenCV object responsible for acquire the images
        self.capture = cv2.VideoCapture(0)

        # Initialize the VTK object that is going to translate the image
        self.image = vtk.vtkImageImport()
        self.image.SetDataScalarTypeToUnsignedChar()

        # Three color layers
        self.image.SetNumberOfScalarComponents(3)

        # Image dimensions
        width, height = self.size
        self.image.SetDataExtent(0, width-1, 0, height-1, 0, 0)
        self.image.SetWholeExtent(0, width-1, 0, height-1, 0, 0)
        self.update()

        # Initialize render and assign the deepest layer
        self.render = vtk.vtkRenderer()
        self.render.SetLayer(0)
        self.render.InteractiveOff()

        # In VTK renders objects are shown through actors, like in a movie
        self.image_actor = vtk.vtkImageActor()
        image_port = self.image.GetOutputPort()
        self.image_actor.GetMapper().SetInputConnection(image_port)

        # Place actor into action
        self.render.AddActor(self.image_actor)
开发者ID:asrob-uc3m,项目名称:augmented-fpv,代码行数:31,代码来源:background.py


示例10: numpy2VTK

def numpy2VTK(img,spacing=[1.0,1.0,1.0]):
    # evolved from code from Stou S.,
    # on http://www.siafoo.net/snippet/314
    importer = vtk.vtkImageImport()
    
    img_data = img.astype('uint8')
    img_string = img_data.tostring() # type short
    dim = img.shape
    
    importer.CopyImportVoidPointer(img_string, len(img_string))
    importer.SetDataScalarType(VTK_UNSIGNED_CHAR)
    importer.SetNumberOfScalarComponents(1)
    
    extent = importer.GetDataExtent()
    importer.SetDataExtent(extent[0], extent[0] + dim[2] - 1,
                           extent[2], extent[2] + dim[1] - 1,
                           extent[4], extent[4] + dim[0] - 1)
    importer.SetWholeExtent(extent[0], extent[0] + dim[2] - 1,
                            extent[2], extent[2] + dim[1] - 1,
                            extent[4], extent[4] + dim[0] - 1)

    importer.SetDataSpacing( spacing[0], spacing[1], spacing[2])
    importer.SetDataOrigin( 0,0,0 )

    return importer
开发者ID:151706061,项目名称:Medical-Image-Analysis-IPython-Tutorials,代码行数:25,代码来源:volumerendering.py


示例11: __init__

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


示例12: __init__

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        self.reader = vtk.vtkDICOMImageReader()

        #self.viewerL = vtk.vtkImageViewer2()
        #self.viewerR = vtk.vtkImageViewer2()

        self.renL = vtk.vtkRenderer()
        self.ui.leftVtk.GetRenderWindow().AddRenderer(self.renL)
        self.renR = vtk.vtkRenderer()
        self.ui.rightVtk.GetRenderWindow().AddRenderer(self.renR)

        self.mapperL = vtk.vtkImageMapper()
        self.mapperL.SetInputConnection(self.reader.GetOutputPort())
        self.mapperR = vtk.vtkImageMapper()

        self.actorL = vtk.vtkActor2D()
        self.actorL.SetMapper(self.mapperL)
        self.actorR = vtk.vtkActor2D()
        self.actorR.SetMapper(self.mapperR)

        self.renL.AddActor2D(self.actorL)
        self.renR.AddActor2D(self.actorR)

        self.importer = vtk.vtkImageImport()
        self.mapperR.SetInputConnection(self.importer.GetOutputPort())

        self.loadImage(os.path.join(STARTINGPATH, FILENAME))
        self.setWindowingAlg()
开发者ID:MKozuch,项目名称:MIEnhancer,代码行数:32,代码来源:ImagingEnhancer.py


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


示例14: convertNpyToVtk

 def convertNpyToVtk(imgNpy):
     assert(imgNpy.dtype == np.uint8)
     nx, ny, nz = imgNpy.shape
     dataImporter = vtk.vtkImageImport()
     dataString = imgNpy.tostring(order='F')
     dataImporter.CopyImportVoidPointer(dataString, len(dataString))
     dataImporter.SetDataScalarTypeToUnsignedChar()
     dataImporter.SetNumberOfScalarComponents(1)
     dataImporter.SetDataExtent(0, nx-1, 0, ny-1, 0, nz-1)
     dataImporter.SetWholeExtent(0, nx-1, 0, ny-1, 0, nz-1)
     dataImporter.Update()
     return dataImporter.GetOutput()
开发者ID:lirenzhucn,项目名称:ManualRegistrationTool,代码行数:12,代码来源:ManualRegistrationTool.py


示例15: _createLogic

    def _createLogic(self):
        # input
        self._imageStack = None
        # optional input
        self._inputTransformStack = None
        # output is a transform stack
        self._transformStack = transformStackClass(self)

        self._ipw1 = None
        self._ipw2 = None

        # some control variables
        self._pairNumber = -1
        
        # we need to have two converters from itk::Image to vtkImageData,
        # hmmmm kay?
        self._transform1 = itk.itkEuler2DTransform_New()
        self._transform1.SetIdentity()
        print self._transform1.GetParameters()


        self._rescaler1 = itk.itkRescaleIntensityImageFilterF2F2_New()
        self._rescaler1.SetOutputMinimum(0)
        self._rescaler1.SetOutputMaximum(255)
        self._itkExporter1 = itk.itkVTKImageExportF2_New()
        self._itkExporter1.SetInput(self._rescaler1.GetOutput())
        self._vtkImporter1 = vtk.vtkImageImport()
        CVIPy.ConnectITKF2ToVTK(self._itkExporter1.GetPointer(),
                                self._vtkImporter1)

        self._resampler2 = None

        self._rescaler2 = itk.itkRescaleIntensityImageFilterF2F2_New()
        self._rescaler2.SetOutputMinimum(0)
        self._rescaler2.SetOutputMaximum(255)
        self._itkExporter2 = itk.itkVTKImageExportF2_New()
        self._itkExporter2.SetInput(self._rescaler2.GetOutput())
        self._vtkImporter2 = vtk.vtkImageImport()
        CVIPy.ConnectITKF2ToVTK(self._itkExporter2.GetPointer(),
                                self._vtkImporter2)
开发者ID:fvpolpeta,项目名称:devide,代码行数:40,代码来源:register2D.py


示例16: read_data

def read_data(filepattern, data_spacing, data_extent):
    dims = data_extent[1] + 1, data_extent[3] + 1
    dtype = np.dtype('B')
    file_range = xrange(1, data_extent[5] + 1)
    dat = np.array([np.reshape(np.fromfile(filepattern % i, dtype=dtype), dims)
                    for i in file_range]).tostring()
    data_reader = vtk.vtkImageImport()
    data_reader.CopyImportVoidPointer(dat, len(dat))
    data_reader.SetDataScalarTypeToUnsignedChar()
    data_reader.SetNumberOfScalarComponents(1)
    data_reader.SetDataSpacing(*data_spacing)
    data_reader.SetDataExtent(*data_extent)
    data_reader.SetWholeExtent(*data_extent)
    return data_reader
开发者ID:chielk,项目名称:beautiful_data,代码行数:14,代码来源:frog.py


示例17: save_vtk_image

def save_vtk_image(images, dst, i):    
    image_import = vtk.vtkImageImport()
    image_import.CopyImportVoidPointer(images.tostring(), len(images.tostring()))
    image_import.SetDataScalarTypeToUnsignedChar()
    image_import.SetNumberOfScalarComponents(1)
    image_import.SetDataExtent(0, images.shape[2] - 1, 0, images.shape[1] - 1, 0, images.shape[0] - 1)
    image_import.SetWholeExtent(0, images.shape[2] - 1, 0, images.shape[1] - 1, 0, images.shape[0] - 1)
    volume = vtk.vtkVolume()
    volume_mapper = vtk.vtkVolumeRayCastMapper()
    alpha_channel_func = vtk.vtkPiecewiseFunction()
    alpha_channel_func.AddPoint(0, 0.0)
#    alpha_channel_func.AddPoint(64, 0.3)
#    alpha_channel_func.AddPoint(128, 0.5)
    alpha_channel_func.AddPoint(100, 1.0)
    alpha_channel_func.ClampingOn()
    color_func = vtk.vtkPiecewiseFunction()
    color_func.AddPoint(5, 0.3)
    color_func.AddPoint(25, 0.5)
    color_func.AddPoint(125, 0.7)
    color_func.AddPoint(255, 1.0)
    volume_property = vtk.vtkVolumeProperty()
    volume_property.SetColor(color_func)
    volume_property.SetInterpolationTypeToLinear()
    volume_property.SetScalarOpacity(alpha_channel_func)
    volume.SetProperty(volume_property)
    volume_ray_cast_func = vtk.vtkVolumeRayCastMIPFunction()
    volume_mapper.SetInputConnection(image_import.GetOutputPort())
    volume_mapper.SetVolumeRayCastFunction(volume_ray_cast_func)
#    volume_mapper.SetSampleDistance(1)
#    volume_mapper.SetAutoAdjustSampleDistances(0)
#    volume_mapper.SetImageSampleDistance(1)
    volume.SetMapper(volume_mapper)
    
    ren = vtk.vtkRenderer()
    ren.AddVolume(volume)
    ren.SetBackground(0, 0, 0)
    renWin = vtk.vtkRenderWindow()
    renWin.SetSize(1024, 1024)
    renWin.AddRenderer(ren)
    renWin.Render()
    
    window_2_image = vtk.vtkWindowToImageFilter()
    window_2_image.SetInput(renWin)
    window_2_image.Update()
    
    png_writer = vtk.vtkPNGWriter()
    png_writer.SetFileName(dst + '%05d'%(i) + '.png')
    png_writer.SetInput(window_2_image.GetOutput())
    png_writer.Write()
开发者ID:sulei1324,项目名称:lab_codes,代码行数:49,代码来源:funs.py


示例18: sitk2vtk

def sitk2vtk(img):

    size     = list(img.GetSize())
    origin   = list(img.GetOrigin())
    spacing  = list(img.GetSpacing())
    sitktype = img.GetPixelID()
    vtktype  = pixelmap[sitktype]
    ncomp    = img.GetNumberOfComponentsPerPixel()

    # there doesn't seem to be a way to specify the image orientation in VTK

    # convert the SimpleITK image to a numpy array
    i2 = sitk.GetArrayFromImage(img)
    i2_string = i2.tostring()

    # send the numpy array to VTK with a vtkImageImport object
    dataImporter = vtk.vtkImageImport()

    dataImporter.CopyImportVoidPointer( i2_string, len(i2_string) )

    dataImporter.SetDataScalarType(vtktype)

    dataImporter.SetNumberOfScalarComponents(ncomp)

    # VTK expects 3-dimensional parameters
    if len(size) == 2:
        size.append(1)

    if len(origin) == 2:
        origin.append(0.0)

    if len(spacing) == 2:
        spacing.append(spacing[0])

    # Set the new VTK image's parameters
    #
    dataImporter.SetDataExtent (0, size[0]-1, 0, size[1]-1, 0, size[2]-1)
    dataImporter.SetWholeExtent(0, size[0]-1, 0, size[1]-1, 0, size[2]-1)

    dataImporter.SetDataOrigin(origin)
    dataImporter.SetDataSpacing(spacing)

    dataImporter.Update()

    vtk_image = dataImporter.GetOutput()
    return vtk_image
开发者ID:IMAGE-ET,项目名称:dicom2stl,代码行数:46,代码来源:sitk2vtk.py


示例19: to_vtk_image

def to_vtk_image(image):
    image = np.flipud(image.copy()).astype('uint8')

    imageString = image.tostring()
    imageImporter = vtk.vtkImageImport()
    imageImporter.CopyImportVoidPointer(imageString, len(imageString))
    imageImporter.SetDataScalarTypeToUnsignedChar()
    imageImporter.SetNumberOfScalarComponents(3)
    imageImporter.SetDataExtent(0, image.shape[1]-1,
                                0, image.shape[0]-1,
                                0, 0)
    imageImporter.SetWholeExtent(0, image.shape[1]-1,
                                 0, image.shape[0]-1,
                                 0, 0)
    imageImporter.Update()

    return imageImporter
开发者ID:selaux,项目名称:master-of-bones,代码行数:17,代码来源:to_vtk.py


示例20: toVtkImageData

def toVtkImageData(a):    
    importer = vtkImageImport()

    #FIXME
    #In all cases I have seen, it is needed to reverse the shape here
    #Does that hold universally, and do we understand why?
    reverseShape = True
    
    importer.SetDataScalarType(__numpyTypeToVtkType(a.dtype))
    if reverseShape:
        importer.SetDataExtent(0,a.shape[2]-1,0,a.shape[1]-1,0,a.shape[0]-1)
        importer.SetWholeExtent(0,a.shape[2]-1,0,a.shape[1]-1,0,a.shape[0]-1)
    else:
        importer.SetDataExtent(0,a.shape[0]-1,0,a.shape[1]-1,0,a.shape[2]-1)
        importer.SetWholeExtent(0,a.shape[0]-1,0,a.shape[1]-1,0,a.shape[2]-1)
    importer.SetImportVoidPointer(a)
    importer.Update()
    return importer.GetOutput() 
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:18,代码来源:numpy2vtk.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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