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

Python astra.astra_dict函数代码示例

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

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



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

示例1: run

 def run(self, iterations):
     self.fn = getFilterFile(self.fd, self.pg, iterations, self.rg, self.osz)
     if os.path.exists(self.fn):
         flt = np.load(self.fn)
         self.v[:] = self.customFBP(flt)
         return
     nd = self.nd
     if self.osz:
         nds = self.osz
     else:
         nds = nd
     na = len(self.ang)
     pgc = astra.create_proj_geom('parallel',1.0,nd,self.ang)
     vgc = astra.create_vol_geom((nds,nds))
     pidc = astra.create_projector('strip',pgc,vgc)
     x = np.zeros((nds,nds))
     xs = np.zeros((nds,nds))
     sf = np.zeros((na,nd))
     vid = astra.data2d.create('-vol',vgc)
     sid = astra.data2d.create('-sino',pgc)
     cfg = astra.astra_dict('FP')
     cfg['ProjectorId']=pidc
     cfg['ProjectionDataId']=sid
     cfg['VolumeDataId']=vid
     fpid = astra.algorithm.create(cfg)
     cfg = astra.astra_dict('BP')
     cfg['ProjectorId']=pidc
     cfg['ProjectionDataId']=sid
     cfg['ReconstructionDataId']=vid
     bpid = astra.algorithm.create(cfg)
     vc = astra.data2d.get_shared(vid)
     sc = astra.data2d.get_shared(sid)
     x[nds//2,nds//2]=1
     alp = 1./(na*nds)
     if self.rg:
         if self.rg*alp >=0.1:
             alp = 0.1/self.rg
     astra.log.info('Computing filter...')
     for i in range(iterations):
         if i%10==0: astra.log.info('{:.2f} % done'.format(100*float(i)/iterations))
         xs+=x
         vc[:] = x
         astra.algorithm.run(fpid)
         astra.algorithm.run(bpid)
         if self.rg:
             dx = x[:-1,:] - x[1:,:]
             dy = x[:,:-1] - x[:,1:]
             x[:-1,:] -= self.rg*dx*alp
             x[1:,:] += self.rg*dx*alp
             x[:,:-1] -= self.rg*dy*alp
             x[:,1:] += self.rg*dy*alp
         x -= vc*alp
     vc[:] = xs
     astra.algorithm.run(fpid)
     flt = sc.copy()*alp
     astra.algorithm.delete([fpid,bpid])
     astra.algorithm.delete([vid,sid])
     np.save(self.fn,flt)
     self.v[:] = self.customFBP(flt)
     astra.projector.delete(pidc)
开发者ID:dmpelt,项目名称:pysirtfbp,代码行数:60,代码来源:astra_plugin.py


示例2: astrarecon

def astrarecon(tilt_data,tilt_angles,iterations=1,geometry='parallel3d',SO_dist=1.0,OD_dist=1.0):
    proj_shape = np.shape(tilt_data)
    recon_shape = (proj_shape[2],proj_shape[2],proj_shape[1])
    
    vol_geom = astra.create_vol_geom(recon_shape)

    angles = np.pi*tilt_angles/180
    
    if geometry == 'parallel3d':
        proj_geom = astra.create_proj_geom(geometry, 1.0, 1.0, proj_shape[1], proj_shape[2], angles)
        cfg = astra.astra_dict('SIRT3D_CUDA')
    elif geometry == 'cone':
        proj_geom = astra.create_proj_geom(geometry, 1.0, 1.0, proj_shape[1], proj_shape[2], angles, SO_dist, OD_dist)
        cfg = astra.astra_dict('FDK_CUDA')
        
    proj_id = astra.data3d.create('-proj3d', proj_geom, np.swapaxes(tilt_data,0,1))
    
    rec_id = astra.data3d.create('-vol', vol_geom)
    
    cfg['ReconstructionDataId'] = rec_id
    cfg['ProjectionDataId'] = proj_id
    
    alg_id = astra.algorithm.create(cfg)
    
    astra.algorithm.run(alg_id, iterations)
    
    rec = astra.data3d.get(rec_id)
    
    astra.algorithm.delete(alg_id)
    astra.data3d.delete(rec_id)
    astra.data3d.delete(proj_id)
    
    return(rec)
开发者ID:TomSlater,项目名称:edx_abs,代码行数:33,代码来源:tools_3d.py


示例3: init

 def init(self, volume_data=1, projection_data=1):
     # Create volume geometry
     self.volume_geom = astra.create_vol_geom(self.num_voxel)
 
     # Create projection geometry
     self.projection_geom = astra.create_proj_geom(self.geometry_type,
                                        self.detector_spacing_x, self.detector_spacing_y,
                                        self.det_row_count, self.det_col_count,
                                        self.angles,
                                        self.source_origin, self.origin_detector)
 
     # Allocate and store volume data in ASTRA memory
     self.volume_id = astra.data3d.create('-vol', self.volume_geom, volume_data)
 
     # Allocate and store projection data in ASTRA memeory
     self.projection_id = astra.data3d.create('-sino', self.projection_geom, projection_data)
     
     # Create algorithm object: forward projector
     cfg = astra.astra_dict('FP3D_CUDA')
     cfg['option'] = {'GPUindex': self.gpu_index}
     cfg['ProjectionDataId'] = self.projection_id
     cfg['VolumeDataId'] = self.volume_id
     self.forward_alg_id = astra.algorithm.create(cfg)
     
     # Create algorithm object: backward projector
     cfg = astra.astra_dict('BP3D_CUDA')
     cfg['option'] = {'GPUindex': self.gpu_index}
     cfg['ProjectionDataId'] = self.projection_id
     cfg['ReconstructionDataId'] = self.volume_id
     self.backward_alg_id = astra.algorithm.create(cfg)
开发者ID:moosmann,项目名称:python,代码行数:30,代码来源:test4.py


示例4: __init__

    def __init__(self, geometry_type='cone',
                 num_voxel=(100, 100, 100),
                 det_row_count=100, det_col_count=100,
                 angles=np.linspace(0, 2 * np.pi, 180, endpoint=False),
                 det_col_spacing=1.0, det_row_spacing=1.0,
                 source_origin=100.0, origin_detector=10.0,
                 volume_data=1, projection_data=1,
                 gpu_index=0):
        self.geometry_type = geometry_type
        self.num_voxel = num_voxel
        self.detector_spacing_x = det_col_spacing
        self.detector_spacing_y = det_row_spacing
        self.det_row_count = det_row_count
        self.det_col_count = det_col_count
        self.angles = angles
        self.source_origin = source_origin
        self.origin_detector = origin_detector
        self.volume_data = volume_data
        self.projection_data = projection_data
        self.gpu_index = gpu_index

        # Create volume geometry
        self.volume_geom = astra.create_vol_geom(self.num_voxel)

        # Create projection geometry
        self.projection_geom = astra.create_proj_geom(
            self.geometry_type,
            self.detector_spacing_x, self.detector_spacing_y,
            self.det_row_count, self.det_col_count,
            self.angles,
            self.source_origin, self.origin_detector)

        # Allocate and store volume data in ASTRA memory
        self.volume_id = astra.data3d.create(
            '-vol',
            self.volume_geom,
            self.volume_data)

        # Allocate and store projection data in ASTRA memory
        self.projection_id = astra.data3d.create(
            '-sino',
            self.projection_geom,
            self.projection_data)

        # Create algorithm object: forward projector
        cfg = astra.astra_dict('FP3D_CUDA')
        cfg['option'] = {'GPUindex': self.gpu_index}
        cfg['ProjectionDataId'] = self.projection_id
        cfg['VolumeDataId'] = self.volume_id
        self.forward_alg_id = astra.algorithm.create(cfg)

        # Create algorithm object: backward projector
        cfg = astra.astra_dict('BP3D_CUDA')
        # classmethod?
        cfg['option'] = {'GPUindex': self.gpu_index}
        cfg['ProjectionDataId'] = self.projection_id
        cfg['ReconstructionDataId'] = self.volume_id
        self.backward_alg_id = astra.algorithm.create(cfg)
开发者ID:moosmann,项目名称:astra,代码行数:58,代码来源:pyastra.py


示例5: _fp_id

    def _fp_id(self):
        """Create algorithms object of forward projection."""

        geom_type = self.geom.geom_type.lower()
        cfg = None

        if geom_type in self.type2d:
            cfg = astra.astra_dict('FP_CUDA')
        elif geom_type in self.type3d:
            cfg = astra.astra_dict('FP3D_CUDA')
        cfg['option'] = {'GPUindex': self.gpu_index}
        cfg['ProjectionDataId'] = self.proj_id
        cfg['VolumeDataId'] = self.vol_id

        return astra.algorithm.create(cfg)
开发者ID:moosmann,项目名称:astra,代码行数:15,代码来源:pyastra.py


示例6: backward

    def backward(self, proj_vector=None):
        """Backprojection."""

        # Store projection data in ASTRA memory
        if proj_vector is None:
            astra.data3d.store(self.proj_id,
                               self.proj.data.reshape(
                                   self.geom.det_row_count,
                                   self.geom.angles.size,
                                   self.geom.det_col_count))
        else:
            astra.data3d.store(self.proj_id,
                               proj_vector.data.reshape(
                                   self.geom.det_row_count,
                                   self.geom.angles.size,
                                   self.geom.det_col_count))

        # Create algorithm object
        cfg = astra.astra_dict('BP3D_CUDA')
        cfg['option'] = {'GPUindex': self.gpu_index}
        cfg['ProjectionDataId'] = self.proj_id
        cfg['ReconstructionDataId'] = self.volume_id
        self.bp_id = astra.algorithm.create(cfg)

        # Run algorithms
        astra.algorithm.run(self.bp_id)

        # Retrieve projection from ASTRA memory
        self.vol.data[:] = np.ravel(astra.data3d.get(self.volume_id))
开发者ID:moosmann,项目名称:astra,代码行数:29,代码来源:pyastra.py


示例7: cfg_setup

 def cfg_setup(self):
     cfg = astra.astra_dict(self.name)
     cfg['ReconstructionDataId'] = self.rec_id
     cfg['ProjectionDataId'] = self.sino_id
     if 'CUDA' in self.name:
         cfg['option'] = {'GPUindex': self.parameters['GPU_index']}
     return cfg
开发者ID:r-atwood,项目名称:Savu,代码行数:7,代码来源:base_astra_recon.py


示例8: astra_rec_cuda

def astra_rec_cuda(tomo, center, recon, theta, vol_geom, niter, proj_type, gpu_index, opts):
    # Lazy import ASTRA
    import astra as astra_mod
    nslices, nang, ndet = tomo.shape
    cfg = astra_mod.astra_dict(opts['method'])
    if 'extra_options' in opts:
        # NOTE: we are modifying 'extra_options' and so need to make a copy
        cfg['option'] = copy.deepcopy(opts['extra_options'])
    else:
        cfg['option'] = {}
    if gpu_index is not None:
        cfg['option']['GPUindex'] = gpu_index
    oc = None
    const_theta = np.ones(nang)
    proj_geom = astra_mod.create_proj_geom(
        'parallel', 1.0, ndet, theta.astype(np.float64))
    for i in range(nslices):
        if center[i] != oc:
            oc = center[i]
            proj_geom['option'] = {
                'ExtraDetectorOffset':
                (center[i] - ndet / 2.) * const_theta}
        pid = astra_mod.create_projector(proj_type, proj_geom, vol_geom)
        cfg['ProjectorId'] = pid
        sid = astra_mod.data2d.link('-sino', proj_geom, tomo[i])
        cfg['ProjectionDataId'] = sid
        vid = astra_mod.data2d.link('-vol', vol_geom, recon[i])
        cfg['ReconstructionDataId'] = vid
        alg_id = astra_mod.algorithm.create(cfg)
        astra_mod.algorithm.run(alg_id, niter)
        astra_mod.algorithm.delete(alg_id)
        astra_mod.data2d.delete(vid)
        astra_mod.data2d.delete(sid)
        astra_mod.projector.delete(pid)
开发者ID:tomopy,项目名称:tomopy,代码行数:34,代码来源:wrappers.py


示例9: astra_rec_cpu

def astra_rec_cpu(tomo, center, recon, theta, vol_geom, niter, proj_type, opts):
    # Lazy import ASTRA
    import astra as astra_mod
    nslices, nang, ndet = tomo.shape
    cfg = astra_mod.astra_dict(opts['method'])
    if 'extra_options' in opts:
        cfg['option'] = opts['extra_options']
    proj_geom = astra_mod.create_proj_geom('parallel', 1.0, ndet, theta.astype(np.float64))
    pid = astra_mod.create_projector(proj_type, proj_geom, vol_geom)
    sino = np.zeros((nang, ndet), dtype=np.float32)
    sid = astra_mod.data2d.link('-sino', proj_geom, sino)
    cfg['ProjectorId'] = pid
    cfg['ProjectionDataId'] = sid
    for i in range(nslices):
        shft = int(np.round(ndet / 2. - center[i]))
        if not shft == 0:
            sino[:] = np.roll(tomo[i], shft)
            l = shft
            r = ndet + shft
            if l < 0:
                l = 0
            if r > ndet:
                r = ndet
            sino[:, :l] = 0
            sino[:,  r:] = 0
        else:
            sino[:] = tomo[i]
        vid = astra_mod.data2d.link('-vol', vol_geom, recon[i])
        cfg['ReconstructionDataId'] = vid
        alg_id = astra_mod.algorithm.create(cfg)
        astra_mod.algorithm.run(alg_id, niter)
        astra_mod.algorithm.delete(alg_id)
        astra_mod.data2d.delete(vid)
    astra_mod.data2d.delete(sid)
    astra_mod.projector.delete(pid)
开发者ID:michael-sutherland,项目名称:tomopy,代码行数:35,代码来源:wrappers.py


示例10: reconstruct

    def reconstruct(self, sinogram, centre_of_rotation, angles, shape, center):

        ctr = centre_of_rotation
        width = sinogram.shape[1]
        pad = 50

        sino = np.nan_to_num(sinogram)

        # pad the array so that the centre of rotation is in the middle
        alen = ctr
        blen = width - ctr
        mid = width / 2.0

        if (ctr > mid):
            plow = pad
            phigh = (alen - blen) + pad
        else:
            plow = (blen - alen) + pad
            phigh = pad

        logdata = np.log(sino+1)
        sinogram = np.pad(logdata, ((0, 0), (int(plow), int(phigh))),
                          mode='reflect')

        width = sinogram.shape[1]

        vol_geom = astra.create_vol_geom(shape[0], shape[1])
        proj_geom = astra.create_proj_geom('parallel', 1.0, width,
                                           np.deg2rad(angles))

        sinogram_id = astra.data2d.create("-sino", proj_geom, sinogram)

        # Create a data object for the reconstruction
        rec_id = astra.data2d.create('-vol', vol_geom)

        proj_id = astra.create_projector('strip', proj_geom, vol_geom)

        cfg = astra.astra_dict(self.parameters['reconstruction_type'])
        cfg['ReconstructionDataId'] = rec_id
        cfg['ProjectionDataId'] = sinogram_id
        cfg['ProjectorId'] = proj_id

        # Create the algorithm object from the configuration structure
        alg_id = astra.algorithm.create(cfg)
        # Run 20 iterations of the algorithm
        itterations = int(self.parameters['number_of_iterations'])
        # This will have a runtime in the order of 10 seconds.
        astra.algorithm.run(alg_id, itterations)
        # Get the result
        rec = astra.data2d.get(rec_id)

        # Clean up.
        astra.algorithm.delete(alg_id)
        astra.data2d.delete(rec_id)
        astra.data2d.delete(sinogram_id)

        return rec
开发者ID:nicwade,项目名称:Savu,代码行数:57,代码来源:astra_recon.py


示例11: forward

    def forward(self, vol_space_vector):
        """Forward projection."""

        if self.geom.vol_ndim == 2:

            # Store volume data in ASTRA memory
            astra.data2d.store(self.volume_id,
                               vol_space_vector.data.reshape(
                                   self.geom.vol_shape))

            # Create algorithm object
            cfg = astra.astra_dict('FP_CUDA')
            cfg['option'] = {'GPUindex': self.gpu_index}
            cfg['ProjectionDataId'] = self.proj_id
            cfg['VolumeDataId'] = self.volume_id
            self.fp_id = astra.algorithm.create(cfg)

            # Run algorithm
            astra.algorithm.run(self.fp_id)

            # Retrieve projection data from ASTRA memory
            return self.proj_space.element(self.scal_fac * np.ravel(
                astra.data2d.get(self.proj_id)))

        elif self.geom.vol_ndim == 3:

            # Store volume data in ASTRA memory
            astra.data3d.store(self.volume_id,
                               vol_space_vector.data.reshape(
                                   self.geom.vol_shape))

            # Create algorithm object
            cfg = astra.astra_dict('FP3D_CUDA')
            cfg['option'] = {'GPUindex': self.gpu_index}
            cfg['ProjectionDataId'] = self.proj_id
            cfg['VolumeDataId'] = self.volume_id
            self.fp_id = astra.algorithm.create(cfg)

            # Run algorithm
            astra.algorithm.run(self.fp_id)

            # Retrieve projection data from ASTRA memory
            return self.proj_space.element(self.scal_fac * np.ravel(
                astra.data3d.get(self.proj_id)))
开发者ID:moosmann,项目名称:astra,代码行数:44,代码来源:pyastra.py


示例12: _fbp_id

    def _fbp_id(self):
        """Create algorithms object of back-projection."""

        geom_type = self.geom.geom_type.lower()

        if geom_type == 'parallel3d':
            return None

        cfg = None

        if geom_type in self.type2d:
            cfg = astra.astra_dict('FBP_CUDA')
        elif geom_type == 'cone':
            cfg = astra.astra_dict('FDK_CUDA')

        cfg['option'] = {'GPUindex': self.gpu_index}
        cfg['ProjectionDataId'] = self.proj_id
        cfg['ReconstructionDataId'] = self.vol_id

        return astra.algorithm.create(cfg)
开发者ID:moosmann,项目名称:astra,代码行数:20,代码来源:pyastra.py


示例13: set_config

 def set_config(self, rec_id, sino_id, proj_geom, vol_geom):
     cfg = astra.astra_dict(self.alg)
     cfg['ReconstructionDataId'] = rec_id
     cfg['ProjectionDataId'] = sino_id
     if 'FBP' in self.alg:
         fbp_filter = self.parameters['FBP_filter'] if 'FBP_filter' in \
             self.parameters.keys() else 'none'
         cfg['FilterType'] = fbp_filter
     if 'projector' in self.parameters.keys():
         proj_id = astra.create_projector(
             self.parameters['projector'], proj_geom, vol_geom)
         cfg['ProjectorId'] = proj_id
     cfg = self.set_options(cfg)
     return cfg
开发者ID:DiamondLightSource,项目名称:Savu,代码行数:14,代码来源:base_astra_recon.py


示例14: run_algorithm

 def run_algorithm(self, alg, n_it, data):
     rec_id = astra.data2d.create('-vol', self.vol_geom)
     sino_id = astra.data2d.create('-sino', self.proj_geom, data)
     cfg = astra.astra_dict(alg)
     cfg['ReconstructionDataId'] = rec_id
     cfg['ProjectionDataId'] = sino_id
     alg_id = astra.algorithm.create(cfg)
     print("Running %s" %alg)
     astra.algorithm.run(alg_id, n_it)
     rec = astra.data2d.get(rec_id)
     astra.algorithm.delete(alg_id)
     astra.data2d.delete(rec_id)
     astra.data2d.delete(sino_id)
     return rec
开发者ID:pierrepaleo,项目名称:portal,代码行数:14,代码来源:tomography.py


示例15: cg_alg

def cg_alg(proj_id, sid, vid):
    # CG algorithm
    cfg = astra.astra_dict('CG')
    cfg['ProjectorId'] = proj_id
    cfg['ProjectionDataId'] = sid
    cfg['ReconstructionDataId'] = vid
    cfg['option'] = {}
    alg_id = astra.algorithm.create(cfg)
    astra.algorithm.run(alg_id, 100)
    rec = astra.data2d.get(vid)
    rec = np.flipud(rec)
    plt.imsave('rec_cg.png', rec, cmap = plt.cm.gray)
    save_one_image(rec, 'reconstruct', 'rec_cg_.png')

    astra.algorithm.delete(alg_id)
    return rec
开发者ID:ingacheva,项目名称:ChambollePock_TVminimization,代码行数:16,代码来源:main.py


示例16: set_config

 def set_config(self, rec_id, sino_id, proj_geom, vol_geom):
     cfg = astra.astra_dict(self.alg)
     cfg['ReconstructionDataId'] = rec_id
     cfg['ProjectionDataId'] = sino_id
     if 'FBP' in self.alg:
         cfg['FilterType'] = self.parameters['FBP_filter']
     if 'projector' in self.parameters.keys():
         proj_id = astra.create_projector(
             self.parameters['projector'], proj_geom, vol_geom)
         cfg['ProjectorId'] = proj_id
     # mask not currently working correctly for SIRT or SART algorithms
     sirt_or_sart = [a for a in ['SIRT', 'SART'] if a in self.alg]
     if self.mask_id and not sirt_or_sart:
         cfg['option'] = {}
         cfg['option']['ReconstructionMaskId'] = self.mask_id
     cfg = self.set_options(cfg)
     return cfg
开发者ID:FedeMPouzols,项目名称:Savu,代码行数:17,代码来源:base_astra_recon.py


示例17: cp_alg

def cp_alg(proj_id, sid, vid):
    # CP algorithm
    cfg = astra.astra_dict('CP')
    cfg['ProjectorId'] = proj_id
    cfg['ProjectionDataId'] = sid
    cfg['ReconstructionDataId'] = vid
    cfg['option'] = {}
    cfg['option']['its_PM'] = 150
    cfg['option']['Lambda'] = 10000.0
    alg_id = astra.algorithm.create(cfg)
    astra.algorithm.run(alg_id, 100)
    rec = astra.data2d.get(vid)
    rec = np.flipud(rec)
    rec = rec.astype('float32')
    plt.imsave('rec_cp.png', rec, cmap = plt.cm.gray)
    save_one_image(rec, 'reconstruct', 'rec_cp_.png')

    astra.algorithm.delete(alg_id)
    return rec
开发者ID:ingacheva,项目名称:ChambollePock_TVminimization,代码行数:19,代码来源:main.py


示例18: reconstruct3D

    def reconstruct3D(self, sinogram, angles, shape, depth, alg_name, iterations):
        
        det_rows = sinogram.shape[0]
        det_cols = sinogram.shape[2]

#        sinogram = np.transpose(sinogram, (2,1,0))
                      
        vol_geom = astra.create_vol_geom(shape[0], depth, shape[1])
        
        proj_geom = astra.create_proj_geom('parallel3d', 1.0, 1.0, det_cols, \
                                            det_rows, np.deg2rad(angles))
                                            
        sinogram_id = astra.data3d.create("-sino", proj_geom, sinogram)

        # Create a data object for the reconstruction
        rec_id = astra.data3d.create('-vol', vol_geom)
                
        cfg = astra.astra_dict(alg_name)
        cfg['ReconstructionDataId'] = rec_id
        cfg['ProjectionDataId'] = sinogram_id
         
        # Create the algorithm object from the configuration structure
        alg_id = astra.algorithm.create(cfg)
        
        # This will have a runtime in the order of 10 seconds.
        astra.algorithm.run(alg_id, iterations)
        
        
        #if "CUDA" in params[0] and "FBP" not in params[0]:
        #self.res += astra.algorithm.get_res_norm(alg_id)**2
        #print math.sqrt(self.res)
        
        # Get the result
        rec = astra.data3d.get(rec_id)

        astra.algorithm.delete(alg_id)
        astra.data3d.delete(rec_id)
        astra.data3d.delete(sinogram_id)

        rec = rec[:160,:160,1]                

        return rec
开发者ID:yskashyap,项目名称:Savu,代码行数:42,代码来源:base_astra_recon.py


示例19: run_all_experiment

def run_all_experiment(proj_id, sid, vid, sino):
    cfg = astra.astra_dict('CP')
    cfg['ProjectorId'] = proj_id
    cfg['ProjectionDataId'] = sid
    cfg['ReconstructionDataId'] = vid
    cfg['option'] = {}
    cfg['option']['its_PM'] = 100

    for i in np.arange(1.0, 1.01, 0.1):
        cfg['option']['Lambda'] = i
        alg_id = astra.algorithm.create(cfg)
        astra.algorithm.run(alg_id, 100)
        rec = astra.data2d.get(vid)
        rec = np.flipud(rec)
        rec = rec.astype('float32')
        tv, l2 = calculate_error(proj_id, rec, sino)
        print 'tv rec: ', tv, 'l2 norm rec: ', l2
        astra.algorithm.delete(alg_id)
    
        plt.imsave('rec_cp_Lamda_' + str(i) + '.png', rec, cmap = plt.cm.gray)
        save_one_image(rec, 'reconstruct', 'rec_cp_Lamda_' + str(i) + '_.png')
    return
开发者ID:ingacheva,项目名称:ChambollePock_TVminimization,代码行数:22,代码来源:main.py


示例20: reconstruct2D

    def reconstruct2D(self, sinogram, angles, shape, alg_name, iterations):
        
        vol_geom = astra.create_vol_geom(shape[0], shape[1])
        
        proj_geom = astra.create_proj_geom('parallel', 1.0, sinogram.shape[1],
                                           np.deg2rad(angles))

        sinogram_id = astra.data2d.create("-sino", proj_geom, sinogram)

        # Create a data object for the reconstruction
        rec_id = astra.data2d.create('-vol', vol_geom)
        
        cfg = astra.astra_dict(alg_name)
        cfg['ReconstructionDataId'] = rec_id
        cfg['ProjectionDataId'] = sinogram_id
        
        if not "CUDA" in alg_name:
            proj_id = astra.create_projector('strip', proj_geom, vol_geom)
            cfg['ProjectorId'] = proj_id
         
        # Create the algorithm object from the configuration structure
        alg_id = astra.algorithm.create(cfg)
        
        # This will have a runtime in the order of 10 seconds.
        astra.algorithm.run(alg_id, iterations)
        
        if "CUDA" in alg_name and "FBP" not in alg_name:
                self.res += astra.algorithm.get_res_norm(alg_id)**2
                print math.sqrt(self.res)
        
        # Get the result
        rec = astra.data2d.get(rec_id)

        astra.algorithm.delete(alg_id)
        astra.data2d.delete(rec_id)
        astra.data2d.delete(sinogram_id)
        
        return rec
开发者ID:mjn19172,项目名称:Savu,代码行数:38,代码来源:base_astra_recon.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python astra.create_proj_geom函数代码示例发布时间:2022-05-24
下一篇:
Python model.DBSession类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap