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

Python vtk.vtkImageChangeInformation函数代码示例

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

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



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

示例1: addT2transvisualize

    def addT2transvisualize(self, T2images, image_pos_pat, image_ori_pat, T2dims, T2spacing, sideBreast, interact):
        '''Added to build second reference frame and display T2 overlayed into T1 reference frame'''
        # Proceed to build reference frame for display objects based on DICOM coords   
        [transformed_T2image, transform_cube] = self.dicomTransform(T2images, image_pos_pat, image_ori_pat)
        
        #alignR = int(raw_input('\nAlign right? Yes:1 No:0 : '))
        #if alignR:
        if(sideBreast=="Right"):
            zf1 = self.T1spacing[2]*self.T1extent[5] + self.T1origin[2]
            self.T2origin[2] = zf1 - T2spacing[2]*self.T2extent[5] # this is z-span
        else:
            self.T2origin[2] = self.T1origin[2]
        
        # Change info origin
        translated_T2image = vtk.vtkImageChangeInformation()
        translated_T2image.SetInput( transformed_T2image )
        translated_T2image.SetOutputOrigin(self.T2origin)
        translated_T2image.Update()
        
        # Set up ortogonal planes
        self.xImagePlaneWidget.SetInput( translated_T2image.GetOutput() )
        self.xImagePlaneWidget.SetSliceIndex(0)
        self.yImagePlaneWidget.SetInput( translated_T2image.GetOutput() )
        self.yImagePlaneWidget.SetSliceIndex(0)
        self.zImagePlaneWidget.SetInput( translated_T2image.GetOutput() )
        self.zImagePlaneWidget.SetSliceIndex(0)
                    
        # Create a text property for both cube axes
        tprop = vtk.vtkTextProperty()
        tprop.SetColor(0.5, 0.5, 0)
        tprop.ShadowOff()
        
        # Update the reneder window to receive new image !Important*****
        self.renderer1.Modified()
        self.renWin1.Modified()
        
        # Create a vtkCubeAxesActor2D.  Use the outer edges of the bounding box to
        # draw the axes.  Add the actor to the renderer.
        axesT2 = vtk.vtkCubeAxesActor2D()
        axesT2.SetInput(translated_T2image.GetOutput())
        axesT2.SetCamera(self.renderer1.GetActiveCamera())
        axesT2.SetLabelFormat("%6.4g")
        axesT2.SetFlyModeToOuterEdges()
        axesT2.SetFontFactor(1.2)
        axesT2.SetAxisTitleTextProperty(tprop)
        axesT2.SetAxisLabelTextProperty(tprop)      
        self.renderer1.AddViewProp(axesT2)
        
        ### Update T2Images
        t_T2images = vtk.vtkImageChangeInformation()
        t_T2images.SetInput( T2images )
        t_T2images.SetOutputOrigin(self.T2origin)
        t_T2images.Update()        

        ############                
        if(interact==True):
            interactor = self.renWin1.GetInteractor()
            interactor.Start()
            
        return 
开发者ID:xieyanfu,项目名称:extractFeatures,代码行数:60,代码来源:display.py


示例2: transform_all_images

def transform_all_images(register, image_datas, defining_image):
    image_list = list()
    idx = 0
    transform_list = register.convert_transforms_to_vtk()
    image_datas = [image_datas[0]]
    info = vtk.vtkImageChangeInformation()
    info.SetInput(defining_image)
    info.CenterImageOn()
        
    for image in image_datas:
        change = vtk.vtkImageChangeInformation()
        change.SetInput(image)
        change.CenterImageOn()
        #change.SetOutputSpacing(1,1,1)
        #spacing = image.GetSpacing()
        
        if 1:
            trans = vtk.vtkTransform()
            # this is right except scaling is 1/correct
            tx = transform_list[idx]
            trans.Concatenate(tx)
            #trans = tx
            #trans.Scale(-1,-1,-1)
            trans.Inverse()
            #trans.Scale(-1,-1,-1)
        if 0:
            transform = numpy.zeros(15)
            transform2 = numpy.zeros(15)
            tform = register._subjects[idx].transform
            # rotation and translation are "already inverted"
            # from images being in LPS
            transform[0:6] = tform[0:6]
            # invert scaling
            transform[6:9] = numpy.divide(1.0, tform[6:9])
            # invert shear
            transform2[6:9] = 1.0
            transform2[9:15] = tform[9:15]             
            reg_ops = wma.register.RegistrationInformation()
            trans = reg_ops.convert_transform_to_vtk(transform)
            trans2 = reg_ops.convert_transform_to_vtk(transform2)
            trans2.Scale(-1,-1,-1)
            trans2.Inverse()
            trans.Concatenate(trans2)
            
        resample = vtk.vtkImageReslice()
        #resample.SetResliceAxesDirectionCosines(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
        #resample.SetResliceAxesDirectionCosines(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0)
        #resample.SetInput(image)
        resample.SetInput(change.GetOutput())
        resample.SetResliceTransform(trans)
        print trans
        #resample.SetInformationInput(info.GetOutput())
        #resample.SetOutputSpacing(spacing)
        resample.Update()
        #resample.SetOutputOrigin(origin)
        image_list.append(resample.GetOutput())
        idx += 1
    del resample
    return image_list
开发者ID:RuizhiLiao,项目名称:whitematteranalysis,代码行数:59,代码来源:test_read_vol.py


示例3: __init__

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

        self._reader = vtkgdcm.vtkGDCMImageReader()
        # NB NB NB: for now we're SWITCHING off the VTK-compatible
        # Y-flip, until the X-mirror issues can be solved.
        self._reader.SetFileLowerLeft(1)
        self._ici = vtk.vtkImageChangeInformation()
        self._ici.SetInputConnection(0, self._reader.GetOutputPort(0))

        # create output MedicalMetaData and populate it with the
        # necessary bindings.
        mmd = MedicalMetaData()
        mmd.medical_image_properties = \
                self._reader.GetMedicalImageProperties()
        mmd.direction_cosines = \
                self._reader.GetDirectionCosines()
        self._output_mmd = mmd

        module_utils.setup_vtk_object_progress(self, self._reader,
                                           'Reading DICOM data')

        self._view_frame = None
        self._file_dialog = None
        self._config.dicom_filenames = []
        # if this is true, module will still try to load set even if
        # IPP sorting fails by sorting images alphabetically
        self._config.robust_spacing = False

        self.sync_module_logic_with_config()
开发者ID:fvpolpeta,项目名称:devide,代码行数:30,代码来源:DICOMReader.py


示例4: Execute

    def Execute(self):

        if not self.KSpace:
            self.PrintError("Error: no KSpace.")

        ifft = vtk.vtkImageRFFT()
        ifft.SetInput(self.KSpace)
        ifft.SetDimensionality(self.KSpaceDimensionality)
        ifft.Update()

        ifftMagnitude = vtk.vtkImageMagnitude()
        ifftMagnitude.SetInput(ifft.GetOutput())
        ifftMagnitude.Update()

        origin = self.KSpace.GetOrigin()
        kspacing = self.KSpace.GetSpacing()
        dimensions = self.KSpace.GetDimensions()
        spacing = [
            1.0 / (dimensions[0] * kspacing[0]),
            1.0 / (dimensions[1] * kspacing[1]),
            1.0 / (dimensions[2] * kspacing[2]),
        ]

        imageInformation = vtk.vtkImageChangeInformation()
        imageInformation.SetInput(ifftMagnitude.GetOutput())
        imageInformation.SetOutputSpacing(spacing)
        imageInformation.SetOutputOrigin(origin)
        imageInformation.Update()

        self.Image = imageInformation.GetOutput()
开发者ID:alexmbcm,项目名称:FEMRI,代码行数:30,代码来源:femrikspacetoimage.py


示例5: _handlerVoiSaveButton

    def _handlerVoiSaveButton(self, event):
        input_data = self.getPrimaryInput()
        filename = self.controlFrame.voiFilenameText.GetValue()
        if input_data and self._voi_widget.GetEnabled() and filename:
            # see if we need to reset to zero origin
            zor = self.controlFrame.voiResetToOriginCheck.GetValue()

            extractVOI = vtk.vtkExtractVOI()
            extractVOI.SetInput(input_data)
            extractVOI.SetVOI(self._currentVOI)

            writer = vtk.vtkXMLImageDataWriter()
            writer.SetDataModeToBinary()
            writer.SetFileName(filename)
            
            if zor:
                ici = vtk.vtkImageChangeInformation()
                ici.SetOutputExtentStart(0,0,0)
                ici.SetInput(extractVOI.GetOutput())
                writer.SetInput(ici.GetOutput())

            else:
                writer.SetInput(extractVOI.GetOutput())

            writer.Write()
开发者ID:sanguinariojoe,项目名称:devide,代码行数:25,代码来源:slice3dVWR.py


示例6: __init__

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

        # setup config
        self._config.resolution = 40

        # and then our scripted config
        configList = [
            ('Resolution: ', 'resolution', 'base:int', 'text',
             'x, y and z resolution of sampled volume.  '
             'According to the article, should be 40 to be '
             'at Nyquist.')]

        # now create the necessary VTK modules
        self._es = vtk.vtkImageEllipsoidSource()
        self._es.SetOutputScalarTypeToFloat()

        self._ic = vtk.vtkImageChangeInformation()
        self._ic.SetInputConnection(self._es.GetOutputPort())

        self._output = vtk.vtkImageData()

        # mixin ctor
        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self})

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


示例7: buildPipeline

 def buildPipeline(self):
     """ execute() -> None
     Dispatch the vtkRenderer to the actual rendering widget
     """        
     self.initialOrigin = self.input.GetOrigin()
     self.initialExtent = self.input.GetExtent()
     self.initialSpacing = self.input.GetSpacing()
     self.initialAoi = self.getUnscaledWorldExtent( self.initialExtent, self.initialSpacing ) 
     self.currentAoi = list( self.initialAoi )
             
     self.clip = vtk.vtkExtractVOI()  
     self.inputModule.inputToAlgorithm( self.clip )
     
     self.pad = vtk.vtkImageMagnify()
     self.pad.InterpolateOn()
     self.pad.SetInputConnection( self.clip.GetOutputPort() ) 
     
     self.imageInfo = vtk.vtkImageChangeInformation()
     self.imageInfo.SetInputConnection( self.pad.GetOutputPort() ) 
     self.imageInfo.SetOutputOrigin( self.initialOrigin[0], self.initialOrigin[1], self.initialOrigin[2] )
     self.imageInfo.SetOutputExtentStart( self.initialExtent[0], self.initialExtent[2], self.initialExtent[4] )
     self.imageInfo.SetOutputSpacing( self.initialSpacing[0], self.initialSpacing[1], self.initialSpacing[2] )
     
     self.setExtent( self.initialExtent )          
     self.set3DOutput( port=self.imageInfo.GetOutputPort() )
开发者ID:imclab,项目名称:vistrails,代码行数:25,代码来源:ResampleModule.py


示例8: __init__

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


示例9: buildPipeline

    def buildPipeline(self):
        """ execute() -> None
        Dispatch the vtkRenderer to the actual rendering widget
        """  
        module = self.getRegisteredModule()
        world_map =  None # wmod.forceGetInputFromPort( "world_map", None ) if wmod else None
        opacity =  wmod.forceGetInputFromPort( "opacity",   0.4  )  if wmod else 0.4  
        map_border_size =  wmod.forceGetInputFromPort( "map_border_size", 20  )  if wmod else 20  
            
        self.y0 = -90.0  
        dataPosition = None
        if world_map == None:
            self.map_file = defaultMapFile
            self.map_cut = defaultMapCut
        else:
            self.map_file = world_map[0].name
            self.map_cut = world_map[1]
        
        self.world_cut = wmod.forceGetInputFromPort( "world_cut", -1 )  if wmod else getFunctionParmStrValues( module, "world_cut", -1 )
        roi_size = [ self.roi[1] - self.roi[0], self.roi[3] - self.roi[2] ] 
        map_cut_size = [ roi_size[0] + 2*map_border_size, roi_size[1] + 2*map_border_size ]
        data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
      
        if self.world_cut == -1: 
            if  (self.roi <> None): 
                if roi_size[0] > 180:             
                    self.ComputeCornerPosition()
                    self.world_cut = NormalizeLon( self.x0 )
                else:
                    dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
            else:
                self.world_cut = self.map_cut
        
        self.imageInfo = vtk.vtkImageChangeInformation()        
        image_reader = vtk.vtkJPEGReader()      
        image_reader.SetFileName(  self.map_file )
        baseImage = image_reader.GetOutput() 
        new_dims = None
        if dataPosition == None:    
            baseImage = self.RollMap( baseImage ) 
            new_dims = baseImage.GetDimensions()
        else:                       
            baseImage, new_dims = self.getBoundedMap( baseImage, dataPosition, map_cut_size ) 
        
        scale = [ map_cut_size[0]/new_dims[0], map_cut_size[1]/new_dims[1], 1 ]
#        printArgs( " baseMap: ", extent=baseImage.GetExtent(), spacing=baseImage.GetSpacing(), origin=baseImage.GetOrigin() )        
                  
        self.baseMapActor = vtk.vtkImageActor()
        self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
        self.baseMapActor.SetScale( scale )
        self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
        self.baseMapActor.SetOpacity( opacity )
#        self.baseMapActor.SetDisplayExtent( -1,  0,  0,  0,  0,  0 )
#Positioning map at location %s, size = %s, roi = %s" % ( str( ( self.x0, self.y0) ), str( map_cut_size ), str( ( NormalizeLon( self.roi[0] ), NormalizeLon( self.roi[1] ), self.roi[2], self.roi[3] ) ) )
        self.baseMapActor.SetPosition( self.x0, self.y0, 0.1 )
        self.baseMapActor.SetInput( baseImage )
        
        self.renderer.AddActor( self.baseMapActor )
开发者ID:imclab,项目名称:vistrails,代码行数:58,代码来源:WorldMapModule.py


示例10: __init__

    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        NoConfigModuleMixin.__init__(
            self, {'Module (self)' : self})

        self.sync_module_logic_with_config()    
        self._ir = vtk.vtkImageReslice()
        self._ici = vtk.vtkImageChangeInformation()
开发者ID:fvpolpeta,项目名称:devide,代码行数:10,代码来源:DICOMAligner.py


示例11: build

    def build( self, **args ):
        if self.enableBasemap:              
#            print " @@@ MapManager: build "
            world_map =  None                 
            dataPosition = None
            if world_map == None:
                self.map_file = defaultMapFile
                self.map_cut = defaultMapCut
            else:
                self.map_file = world_map[0].name
                self.map_cut = world_map[1]
            
#            data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
                      
            if self.world_cut == -1: 
                if  (self.roi <> None): 
                    if self.roi_size[0] > 180:             
                        self.ComputeCornerPosition()
                        self.world_cut = self.NormalizeMapLon( self.x0 )
                    else:
                        dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
                else:
                    self.world_cut = self.map_cut
            
            self.imageInfo = vtk.vtkImageChangeInformation()        
            self.image_reader = vtk.vtkJPEGReader()      
            self.image_reader.SetFileName(  self.map_file )
            self.image_reader.Update()
            world_image = self.image_reader.GetOutput() 
            self.sphericalBaseImage = self.RollMap( world_image )  
            new_dims, scale = None, None
            if dataPosition == None:    
                self.baseImage = self.RollMap( world_image ) 
                new_dims = self.baseImage.GetDimensions()
                scale = [ 360.0/new_dims[0], 180.0/new_dims[1], 1 ]
                self.width = 360.0
            else:                       
                self.baseImage, new_dims = self.getBoundedMap( world_image, dataPosition ) 
                scale = [ self.map_cut_size[0]/new_dims[0], self.map_cut_size[1]/new_dims[1], 1 ]
                self.width = self.map_cut_size[0]          
                              
            self.baseMapActor = vtk.vtkImageActor()
            self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
            self.baseMapActor.SetScale( scale )
            self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
            self.baseMapActor.SetOpacity( self.map_opacity )
            mapCorner = [ self.x0, self.y0 ]
            self.baseMapActor.SetPosition( mapCorner[0], mapCorner[1], 0.05 )
            extent = self.baseImage.GetExtent()
#             print " @@@ baseImage.GetExtent: ", str( extent )
#             print " @@@ baseImage.Position: ", str( self.x0 )
#             print " @@@ baseImage.Size: ", str( self.map_cut_size )
            if vtk.VTK_MAJOR_VERSION <= 5:  self.baseMapActor.SetInput(self.baseImage)
            else:                           self.baseMapActor.SetInputData(self.baseImage)        
            self.mapCenter = [ self.x0 + self.map_cut_size[0]/2.0, self.y0 + self.map_cut_size[1]/2.0 ]  
开发者ID:doutriaux1,项目名称:uvcdat,代码行数:55,代码来源:MapManager.py


示例12: build

    def build( self, **args ):
        if self.enableBasemap:              
            world_map =  None                 
            dataPosition = None
            if world_map == None:
                self.map_file = defaultMapFile
                self.map_cut = defaultMapCut
            else:
                self.map_file = world_map[0].name
                self.map_cut = world_map[1]
            
            roi_size = [ self.roi[1] - self.roi[0], self.roi[3] - self.roi[2] ] 
            map_cut_size = [ roi_size[0] + 2*self.map_border_size, roi_size[1] + 2*self.map_border_size ]
            if map_cut_size[0] > 360.0: map_cut_size[0] = 360.0
            if map_cut_size[1] > 180.0: map_cut_size[1] = 180.0
#            data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
                      
            if self.world_cut == -1: 
                if  (self.roi <> None): 
                    if roi_size[0] > 180:             
                        self.ComputeCornerPosition()
                        self.world_cut = self.NormalizeMapLon( self.x0 )
                    else:
                        dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
                else:
                    self.world_cut = self.map_cut
            
            self.imageInfo = vtk.vtkImageChangeInformation()        
            self.image_reader = vtk.vtkJPEGReader()      
            self.image_reader.SetFileName(  self.map_file )
            self.image_reader.Update()
            world_image = self.image_reader.GetOutput() 
            self.sphericalBaseImage = self.RollMap( world_image )  
            new_dims, scale = None, None
            if dataPosition == None:    
                self.baseImage = self.RollMap( world_image ) 
                new_dims = self.baseImage.GetDimensions()
                scale = [ 360.0/new_dims[0], 180.0/new_dims[1], 1 ]
            else:                       
                self.baseImage, new_dims = self.getBoundedMap( world_image, dataPosition, map_cut_size, self.map_border_size )             
                scale = [ map_cut_size[0]/new_dims[0], map_cut_size[1]/new_dims[1], 1 ]
                              
            self.baseMapActor = vtk.vtkImageActor()
            self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
            self.baseMapActor.SetScale( scale )
            self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
            self.baseMapActor.SetOpacity( self.map_opacity )
            mapCorner = [ self.x0, self.y0 ]
            self.baseMapActor.SetPosition( mapCorner[0], mapCorner[1], 0.1 )
            if vtk.VTK_MAJOR_VERSION <= 5:  self.baseMapActor.SetInput(self.baseImage)
            else:                           self.baseMapActor.SetInputData(self.baseImage)        
            self.mapCenter = [ self.x0 + map_cut_size[0]/2.0, self.y0 + map_cut_size[1]/2.0 ]  
开发者ID:UV-CDAT,项目名称:UVIS_DV3D,代码行数:52,代码来源:MapManager.py


示例13: magnify_multiply_imagedata

def magnify_multiply_imagedata(reader, zSpacing=1.0):
    logging.debug("In data.magnify_multiply_imagedata()")
    imagedata = reader.GetOutput()
    imagedata.UpdateInformation()
    spacing = imagedata.GetSpacing()
    # dimensions = imagedata.GetDimensions()
    # if dimensions[0] > 256 and dimensions[1] > 256:
    #    spacing = [x/0.5 for x in spacing]

    change = vtk.vtkImageChangeInformation()
    change.SetInput(imagedata)
    change.SetOutputOrigin(imagedata.GetOrigin())
    change.SetOutputSpacing(spacing[0], spacing[1], zSpacing)
    change.Update()

    return vtk.vtkImageData.SafeDownCast(change.GetOutput())
开发者ID:aevum,项目名称:moonstone,代码行数:16,代码来源:data.py


示例14: Update

    def Update(self):
        # If a dummy input is defined  then, probaby a diagnostic run asking
        # for output data type is performed. In such case, just generate a
        # blank ImageData object just to be able to determine filter's output
        # data type.
        if self._padding == (0, 0, 0):
            self._output = self._input
            return

        # XXX: (note the date: Mon Mar 25 22:57:45 CET 2013)
        # Ok, when we arrived here, it means that we're doing sometging
        # significant.
        source = self._input
        self._output = vtk.vtkImageData()

        padx, pady, padz = self._padding
        initial_extent = self._input.GetWholeExtent()
        sx, sy, sz = self._input.GetSpacing()

        if __debug__:
            print "\tInitial image extent: " + str(initial_extent)
            print "\tInitial image origin: " + str(self._input.GetOrigin())
            print "\tRequested padding: %d, %d, %d" % (padx, pady, padz)

        translator = vtk.vtkImageChangeInformation()
        translator.SetExtentTranslation(padx, pady, padz)
        translator.SetOriginTranslation(-padx*sx, -pady*sy, -padz*sz)
        translator.SetInput(source)

        # Now we actually pad the image filling the extended canvas with the
        # "0" value.
        pad_filter = vtk.vtkImageConstantPad()
        pad_filter.SetConstant(0)
        pad_filter.SetOutputWholeExtent(initial_extent[0], initial_extent[1]+2*padx,
                                        initial_extent[2], initial_extent[3]+2*pady,
                                        initial_extent[4], initial_extent[5]+2*padz)
        pad_filter.SetInput(translator.GetOutput())
        pad_filter.Update()

        # Assign the resulting image to the output
        self._output = pad_filter.GetOutput()

        if __debug__:
            print "\tFinal image extent: " + str(self._output.GetWholeExtent())
            print "\tFinal image origin: " + str(self._output.GetOrigin())
开发者ID:baishi,项目名称:3dbar,代码行数:45,代码来源:pipeline.py


示例15: loadFilesWithSeriesReader

  def loadFilesWithSeriesReader(self,imageIOName,files,name):
    """ Explicitly use the named imageIO to perform the loading
    """

    reader = vtkITK.vtkITKArchetypeImageSeriesScalarReader()
    reader.SetArchetype(files[0]);
    for f in files:
      reader.AddFileName(slicer.util.toVTKString(f))
    reader.SetSingleFile(0);
    reader.SetOutputScalarTypeToNative()
    reader.SetDesiredCoordinateOrientationToNative()
    reader.SetUseNativeOriginOn()
    if imageIOName == "GDCM":
      reader.SetDICOMImageIOApproachToGDCM()
    elif imageIOName == "DCMTK":
      reader.SetDICOMImageIOApproachToDCMTK()
    else:
      raise Exception("Invalid imageIOName of %s" % imageIOName)
    logging.info("Loading with imageIOName: %s" % imageIOName)
    reader.Update()

    slicer.modules.reader = reader
    if reader.GetErrorCode() != vtk.vtkErrorCode.NoError:
      errorStrings = (imageIOName, vtk.vtkErrorCode.GetStringFromErrorCode(reader.GetErrorCode()))
      logging.error("Could not read scalar volume using %s approach.  Error is: %s" % errorStrings)
      return


    imageChangeInformation = vtk.vtkImageChangeInformation()
    imageChangeInformation.SetInputConnection(reader.GetOutputPort())
    imageChangeInformation.SetOutputSpacing( 1, 1, 1 )
    imageChangeInformation.SetOutputOrigin( 0, 0, 0 )
    imageChangeInformation.Update()

    name = slicer.mrmlScene.GenerateUniqueName(slicer.util.toVTKString(name))
    volumeNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeNode", name)
    volumeNode.SetAndObserveImageData(imageChangeInformation.GetOutputDataObject(0))
    slicer.vtkMRMLVolumeArchetypeStorageNode.SetMetaDataDictionaryFromReader(volumeNode, reader)
    volumeNode.SetRASToIJKMatrix(reader.GetRasToIjkMatrix())
    volumeNode.CreateDefaultDisplayNodes()

    slicer.modules.DICOMInstance.reader = reader
    slicer.modules.DICOMInstance.imageChangeInformation = imageChangeInformation

    return(volumeNode)
开发者ID:Slicer,项目名称:Slicer,代码行数:45,代码来源:DICOMScalarVolumePlugin.py


示例16: RollMap

    def RollMap( self, baseImage ):
#        baseImage.Update()
        if self.world_cut  == self.map_cut: return baseImage
        baseExtent = baseImage.GetExtent()
        baseSpacing = baseImage.GetSpacing()
        x0 = baseExtent[0]
        x1 = baseExtent[1]
        newCut = self.NormalizeMapLon( self.world_cut )
        delCut = newCut - self.map_cut
#        print "  %%%%%% Roll Map %%%%%%: world_cut=%.1f, map_cut=%.1f, newCut=%.1f " % ( float(self.world_cut), float(self.map_cut), float(newCut) )
        imageLen = x1 - x0 + 1
        sliceSize =  imageLen * ( delCut / 360.0 )
        sliceCoord = int( round( x0 + sliceSize) )        
        extent = list( baseExtent ) 
        
        extent[0:2] = [ x0, x0 + sliceCoord - 1 ]
        clip0 = vtk.vtkImageClip()
        if vtk.VTK_MAJOR_VERSION <= 5:  clip0.SetInput( baseImage )
        else:                           clip0.SetInputData( baseImage )                
        clip0.SetOutputWholeExtent( extent[0], extent[1], extent[2], extent[3], extent[4], extent[5] )
        
        extent[0:2] = [ x0 + sliceCoord, x1 ]
        clip1 = vtk.vtkImageClip()
        if vtk.VTK_MAJOR_VERSION <= 5:  clip1.SetInput( baseImage )
        else:                           clip1.SetInputData( baseImage )                
        clip1.SetOutputWholeExtent( extent[0], extent[1], extent[2], extent[3], extent[4], extent[5] )
        
        append = vtk.vtkImageAppend()
        append.SetAppendAxis( 0 )
        append.SetInputConnection ( clip1.GetOutputPort() )
        append.AddInputConnection ( clip0.GetOutputPort() )           
        
        imageInfo = vtk.vtkImageChangeInformation()
        imageInfo.SetInputConnection( append.GetOutputPort() ) 
        imageInfo.SetOutputOrigin( 0.0, 0.0, 0.0 )
        imageInfo.SetOutputExtentStart( 0, 0, 0 )
        imageInfo.SetOutputSpacing( baseSpacing[0], baseSpacing[1], baseSpacing[2] )
        
        imageInfo.Update()
        result = imageInfo.GetOutput() 
        return result
开发者ID:charlesdoutriaux,项目名称:uvcdat-devel,代码行数:41,代码来源:StructuredGridPlot.py


示例17: getTimepoint

	def getTimepoint(self, n, onlyDims = 0):
		"""
		Return the nth timepoint
		"""
		if not self.readers:
			self.getReadersFromFilenames()

		if self.is3DImage():
			if not self.readers:
				raise Logging.GUIError("Attempt to read bad timepoint", "Timepoint %d is not defined by the given filenames" % n)
			self.reader = self.readers[0]
			minZ = n * self.slicesPerTimepoint
			maxZ = (n+1) * self.slicesPerTimepoint - 1
			extract = vtk.vtkExtractVOI()
			extract.SetInput(self.reader.GetOutput())
			extract.SetVOI(0, self.x - 1, 0, self.y - 1, minZ, maxZ)
			changeInfo = vtk.vtkImageChangeInformation()
			changeInfo.SetInput(extract.GetOutput())
			changeInfo.SetOutputOrigin(0, 0, 0)
			changeInfo.SetExtentTranslation((0,0,-minZ))
			data = changeInfo.GetOutput()
		else:
			if n >= len(self.readers):
				n = 0
				raise Logging.GUIError("Attempt to read bad timepoint", "Timepoint %d is not defined by the given filenames" % n)
			
			self.reader = self.readers[n]
			data = self.reader.GetOutput()

		if not self.voxelsize:
			size = data.GetSpacing()
			x, y, z = [size.GetElement(x) for x in range(0, 3)]
			self.voxelsize = (x, y, z)
			print "Read voxel size", self.voxelsize

		if onlyDims:
			return
		
		return data
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:39,代码来源:FileListDataSource.py


示例18: Execute

    def Execute(self):

        if not self.Image:
            self.PrintError('Error: no Image.')

        fft = vtk.vtkImageFFT()
        fft.SetInput(self.Image)
        fft.SetDimensionality(self.KSpaceDimensionality)
        fft.Update()

        origin = self.Image.GetOrigin()
        spacing = self.Image.GetSpacing()
        dimensions = self.Image.GetDimensions()
        kspacing = [1.0/(dimensions[0]*spacing[0]),1.0/(dimensions[1]*spacing[1]),1.0/(dimensions[2]*spacing[2])]
  
        imageInformation = vtk.vtkImageChangeInformation()
        imageInformation.SetInput(fft.GetOutput())
        imageInformation.SetOutputSpacing(kspacing)
        imageInformation.SetOutputOrigin(origin)
        imageInformation.Update()
        
        self.KSpace = imageInformation.GetOutput()
开发者ID:151706061,项目名称:FEMRI,代码行数:22,代码来源:femriimagetokspace.py


示例19: RollMap

 def RollMap( self, baseImage ):
     baseImage.Update()
     if self.world_cut  == self.map_cut: return baseImage
     baseExtent = baseImage.GetExtent()
     baseSpacing = baseImage.GetSpacing()
     x0 = baseExtent[0]
     x1 = baseExtent[1]
     newCut = NormalizeLon( self.world_cut )
     delCut = NormalizeLon( self.map_cut - newCut )
     imageLen = x1 - x0 + 1
     sliceSize =  imageLen * ( delCut / 360.0 )
     sliceCoord = int( round( x0 + sliceSize) )        
     extent = list( baseExtent ) 
     
     extent[0:2] = [ x0, x0 + sliceCoord - 1 ]
     clip0 = vtk.vtkImageClip()
     clip0.SetInput( baseImage )
     clip0.SetOutputWholeExtent( extent[0], extent[1], extent[2], extent[3], extent[4], extent[5] )
     
     extent[0:2] = [ x0 + sliceCoord, x1 ]
     clip1 = vtk.vtkImageClip()
     clip1.SetInput( baseImage )
     clip1.SetOutputWholeExtent( extent[0], extent[1], extent[2], extent[3], extent[4], extent[5] )
     
     append = vtk.vtkImageAppend()
     append.SetAppendAxis( 0 )
     append.AddInput( clip1.GetOutput() )          
     append.AddInput( clip0.GetOutput() )
     
     imageInfo = vtk.vtkImageChangeInformation()
     imageInfo.SetInputConnection( append.GetOutputPort() ) 
     imageInfo.SetOutputOrigin( 0.0, 0.0, 0.0 )
     imageInfo.SetOutputExtentStart( 0, 0, 0 )
     imageInfo.SetOutputSpacing( baseSpacing[0], baseSpacing[1], baseSpacing[2] )
     
     result = imageInfo.GetOutput() 
     result.Update()
     return result
开发者ID:imclab,项目名称:vistrails,代码行数:38,代码来源:WorldMapModule.py


示例20: transformVolume

 def transformVolume(self, inputVolume, outputVolume, transformationMatrix):
     # Normalize matrix so it preserve its scaling (diagonal elements are
     # equal to 1)
     M = self.__normalizeMatrix(transformationMatrix)
     
     reader = vtk.vtkStructuredPointsReader()
     reader.SetFileName(inputVolume)
     reader.Update()
     reader.GetOutput().UpdateInformation()
     
     matrix = vtk.vtkMatrix4x4()
     matrix.DeepCopy((
         M[0,0], M[0,1], M[0,2], M[0,3],
         M[1,0], M[1,1], M[1,2], M[1,3],
         M[2,0], M[2,1], M[2,2], M[2,3],
         M[3,0], M[3,1], M[3,2], M[3,3]
         ))
     
     # Extract a slice in the desired orientation
     reslice = vtk.vtkImageReslice()
     reslice.SetInputConnection(reader.GetOutputPort())
     reslice.SetResliceAxes(matrix)
     reslice.AutoCropOutputOff()
     reslice.SetInterpolationModeToNearestNeighbor()
     #reslice.SetInterpolationModeToLinear()
     
     print >>sys.stderr,'M=\n',M
     ch = vtk.vtkImageChangeInformation()
     ch.SetInput(reslice.GetOutput())
     ch.SetOutputOrigin(*OUTPUT_VOLUME_ORIGIN)
     ch.SetOutputSpacing(*OUTPUT_VOLUME_SPACING)
     ch.Update() 
     
     writer = vtk.vtkStructuredPointsWriter()
     writer.SetFileTypeToBinary()
     writer.SetInput(ch.GetOutput())
     writer.SetFileName(outputVolume)
     writer.Update()
开发者ID:baishi,项目名称:3dbar,代码行数:38,代码来源:preprocess_volume.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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