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

Python astra.create_projector函数代码示例

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

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



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

示例1: recon_sirt_fbp

def recon_sirt_fbp(im, angles, iter, temppath ):
	"""Reconstruct a sinogram with the SIRT-FBP algorithm (Pelt, 2015).

	Parameters
	----------
	im : array_like
		Sinogram image data as numpy array.

    iter : int
		Number of iterations to be used for the computation of SIRT filter.

	angles : double
		Value in radians representing the number of angles of the input sinogram.
	
	"""
	# Create ASTRA geometries:
	vol_geom = astra.create_vol_geom(im.shape[1] , im.shape[1])
	proj_geom = astra.create_proj_geom('parallel', 1.0, im.shape[1], linspace(0,angles,im.shape[0],False))
	proj = astra.create_projector('cuda', proj_geom, vol_geom)
	p = astra.OpTomo(proj)

	# Register plugin with ASTRA
	astra.plugin.register(sirtfbp.plugin)

	# Create the ASTRA projector
	im_rec = p.reconstruct('SIRT-FBP',im, iter, extraOptions={'filter_dir':temppath})
	
	return im_rec.astype(float32)
开发者ID:ElettraSciComp,项目名称:STP-Core,代码行数:28,代码来源:rec_sirt_fbp.py


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


示例3: bp0

def bp0(sino, det_col=111, num_angles=222, voxel_size_mm=1):
    """Wrapper for astra forward projector

    :param sino:
    :param projector_id:
    :return: backprojected sinogram
    """

    vol_geom = astra.create_vol_geom(sino.shape)
    proj_id = astra.create_projector(
        'cuda',
        astra.create_proj_geom('parallel', 1.0, det_col,
                               np.linspace(0, np.pi, num_angles, False)),
        vol_geom)


    rec_id, backprojection = astra.create_backprojection(sino * voxel_size_mm,
                                                   proj_id)

    # rec_id, backprojection = astra.create_backprojection(sino, projector_id)

    # backprojection /= sino.shape[0]
    # backprojection *= np.pi
    astra.data2d.delete(rec_id)
    astra.projector.delete(proj_id)

    return backprojection
开发者ID:moosmann,项目名称:astra,代码行数:27,代码来源:projector_scaling.py


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


示例5: pid

def pid(number_of_angles):
    """Return projector ID.
    :param number_of_angles:
    :return:
    """
    return astra.create_projector('cuda', astra.create_proj_geom('parallel',
    1.0, vshape[0], np.linspace(0, np.pi, number_of_angles, False)), vol_geom)
开发者ID:moosmann,项目名称:astra,代码行数:7,代码来源:projector_scaling.py


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


示例7: astrafp

def astrafp(im, ang, prj="cuda"):
    proj_geom = astra.create_proj_geom("parallel", 1.0, im.shape[0], np.array([ang, 0]))
    vol_geom = astra.create_vol_geom(im.shape)
    pid = astra.create_projector(prj, proj_geom, vol_geom)
    w = astra.OpTomo(pid)
    fpim = w * im
    astra.projector.delete(pid)
    return fpim[0 : im.shape[0]]
开发者ID:lorentz-phantom,项目名称:lorentz-phantom,代码行数:8,代码来源:forwproj.py


示例8: __init__

 def __init__(self, n_pixels, n_angles, rayperdetec=None):
     '''
     Initialize the ASTRA toolbox with a simple parallel configuration.
     The image is assumed to be square, and the detector count is equal to the number of rows/columns.
     '''
     self.vol_geom = astra.create_vol_geom(n_pixels, n_pixels)
     self.proj_geom = astra.create_proj_geom('parallel', 1.0, n_pixels, np.linspace(0,np.pi,n_angles,False))
     self.proj_id = astra.create_projector('cuda', self.proj_geom, self.vol_geom)
开发者ID:pierrepaleo,项目名称:ChambollePock,代码行数:8,代码来源:tomo_operators.py


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


示例10: astra_reconstruction

 def astra_reconstruction(self, sino, vol_geom, proj_geom):
     # currently hard-coded - for 3D version only!
     #sino = np.transpose(sino, (1, 0, 2))
     self.sino_id = self.astra_function.create("-sino", proj_geom, sino)
     # Create a data object for the reconstruction
     self.rec_id = self.astra_function.create('-vol', vol_geom)
     cfg = self.cfg_setup()
     if self.alg_type is '2D' and not "CUDA" in self.name:
         proj_id = astra.create_projector('strip', proj_geom, vol_geom)
         cfg['ProjectorId'] = proj_id
     return self.run_astra(cfg)
开发者ID:r-atwood,项目名称:Savu,代码行数:11,代码来源:base_astra_recon.py


示例11: _basic_par2d_fp

def _basic_par2d_fp(type):
  import astra
  import numpy as np
  vg = astra.create_vol_geom(2, 32)
  pg = astra.create_proj_geom('parallel', 1, 32, [0])
  proj_id = astra.create_projector(type, pg, vg)
  vol = np.random.rand(2, 32)
  (sino_id, sino) = astra.create_sino(vol, proj_id)
  astra.data2d.delete(sino_id)
  astra.projector.delete(proj_id)
  err = np.max(np.abs(sino[0,:] - np.sum(vol,axis=0)))
  return err < 1e-6
开发者ID:astra-toolbox,项目名称:astra-toolbox,代码行数:12,代码来源:tests.py


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


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


示例14: geom_setup_2D

    def geom_setup_2D(self, dim_det_cols):
        in_pData = self.get_plugin_in_datasets()[0]
        cor = self.cor + self.pad_amount

        sino_shape = in_pData.get_shape()
        nCols = sino_shape[dim_det_cols]
        self.p_low, self.p_high = \
            self.array_pad(cor[0], nCols + 2*self.pad_amount)
        sino_width = \
            sino_shape[1] + self.p_low + self.p_high + 2*self.pad_amount

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

        self.rec_id = self.astra_function.create('-vol', vol_geom)
        self.cfg = self.cfg_setup()
        if self.alg_type is '2D' and "CUDA" not in self.name:
            proj_id = astra.create_projector('strip', self.proj_geom, vol_geom)
            self.cfg['ProjectorId'] = proj_id
开发者ID:rcatwood,项目名称:Savu,代码行数:20,代码来源:base_astra_recon.py


示例15: fp0

def fp0(image, det_col=111, num_angles=222, voxel_size_mm=1):
    """Wrapper for astra forward projector

    :param image:
    :return: sinogram
    """

    vol_geom = astra.create_vol_geom(image.shape)
    proj_id = astra.create_projector(
        'cuda',
        astra.create_proj_geom('parallel', 1.0, det_col,
                               np.linspace(0, np.pi, num_angles, False)),
        vol_geom)

    sino_id, sino = astra.create_sino(image, proj_id)
    sino *= voxel_size_mm

    astra.data2d.delete(sino_id)
    astra.projector.delete(proj_id)

    return sino
开发者ID:moosmann,项目名称:astra,代码行数:21,代码来源:projector_scaling.py


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


示例17: astra_run

def astra_run(*args):
    # Lazy import ASTRA
    import astra as astra_mod

    # Get shared arrays
    tomo = mproc.SHARED_TOMO
    recon = mproc.SHARED_ARRAY

    # Unpack arguments
    nang = args[0]
    nslices = args[1]
    ndet = args[2]
    centers = args[3]
    angles = args[4]
    num_gridx = args[5]['num_gridx']
    num_gridy = args[5]['num_gridy']
    opts = args[5]['options']
    istart = args[6]
    iend = args[7]

    # Check options
    for o in needed_options['astra']:
        if o not in opts:
            logger.error("Option %s needed for ASTRA reconstruction." % (o,))
            raise ValueError()
    for o in default_options['astra']:
        if o not in opts:
            opts[o] = default_options['astra'][o]

    # Create ASTRA geometries
    vol_geom = astra_mod.create_vol_geom((num_gridx, num_gridy))
    proj_geom = astra_mod.create_proj_geom(
        'parallel', 1.0, ndet, angles.astype(np.float64))

    # Create ASTRA data id
    sino = np.zeros((nang, ndet), dtype=np.float32)

    # Create ASTRA config
    cfg = astra_mod.astra_dict(opts['method'])

    if opts['proj_type'] != 'cuda':
        pi = astra_mod.create_projector(opts['proj_type'], proj_geom, vol_geom)
        sid = astra_mod.data2d.link('-sino', proj_geom, sino)
        cfg['ProjectorId'] = pi
        cfg['ProjectionDataId'] = sid
        use_cuda = False
    else:
        use_cuda = True

    if 'extra_options' in opts:
        cfg['option'] = opts['extra_options']
    else:
        cfg['option'] = {}

    # Perform reconstruction
    for i in xrange(istart, iend):
        sino[:] = tomo[:, i, :]

        cfg['option']['z_id'] = i

        # Fix center of rotation
        if use_cuda:
            proj_geom['option'] = {
                'ExtraDetectorOffset':
                (centers[i] - ndet / 2.) * np.ones(nang)}
            sid = astra_mod.data2d.link('-sino', proj_geom, sino)
            cfg['ProjectionDataId'] = sid
            pi = astra_mod.create_projector(
                opts['proj_type'], proj_geom, vol_geom)
            cfg['ProjectorId'] = pi
        else:
            # Temporary workaround, will be fixed in later ASTRA version
            shft = int(np.round(ndet / 2. - centers[i]))
            sino[:] = np.roll(sino, shft)
            l = shft
            r = sino.shape[1] + shft
            if l < 0:
                l = 0
            if r > sino.shape[1]:
                r = sino.shape[1]
            sino[:, 0:l] = 0
            sino[:, r:sino.shape[1]] = 0

        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, opts['num_iter'])
        astra_mod.algorithm.delete(alg_id)
        astra_mod.data2d.delete(vid)
        if use_cuda:
            astra_mod.projector.delete(pi)
            astra_mod.data2d.delete(sid)

    # Clean up
    if not use_cuda:
        astra_mod.projector.delete(pi)
        astra_mod.data2d.delete(sid)
开发者ID:habi,项目名称:tomopy,代码行数:97,代码来源:wrappers.py


示例18: __init__

    def __init__(self, n_pixels, angles, rot_center=None, fullscan=False, super_sampling=None):
        """
        Initialize the ASTRA toolbox with a simple parallel configuration.
        The image is assumed to be square, and the detector count is equal to the number of rows/columns.

        n_pixels: integer
            number of pixels of one dimension of the image
        angles : integer or numpy.ndarray
            number of projection angles (if integer), or custom series of angles
        rot_center : float
            user-defined rotation center
        fullscan : boolean
            if True, use a 360 scan configuration
        super_sampling : integer
            Detector and Pixel supersampling
        """

        if isinstance(n_pixels, int):
            n_x, n_y = n_pixels, n_pixels
        else: # assuming iterable
            n_pixels = tuple(n_pixels)
            n_x, n_y = n_pixels
        angle_max = np.pi
        if fullscan: angle_max *= 2
        if isinstance(angles, int):
            angles = np.linspace(0, angle_max, angles, False)
        n_angles = angles.shape[0]

        self.vol_geom = astra.create_vol_geom(n_x, n_y)
        self.proj_geom = astra.create_proj_geom('parallel', 1.0, n_pixels, angles)

        if rot_center:
            o_angles = np.ones(n_angles) if isinstance(n_angles, int) else np.ones_like(n_angles)
            self.proj_geom['option'] = {'ExtraDetectorOffset': (rot_center - n_x / 2.) * o_angles}
        self.proj_id = astra.create_projector('cuda', self.proj_geom, self.vol_geom)

        # vg : Volume geometry
        self.vg = astra.projector.volume_geometry(self.proj_id)
        # pg : projection geometry
        self.pg = astra.projector.projection_geometry(self.proj_id)

        # ---- Configure Projector ------
        # sinogram shape
        self.sshape = astra.functions.geom_size(self.pg)
        # Configure projector
        self.cfg_proj = astra.creators.astra_dict('FP_CUDA')
        self.cfg_proj['ProjectorId'] = self.proj_id
        if super_sampling:
            self.cfg_proj['option'] = {'DetectorSuperSampling':super_sampling}

        # ---- Configure Backprojector ------
        # volume shape
        self.vshape = astra.functions.geom_size(self.vg)
        # Configure backprojector
        self.cfg_backproj = astra.creators.astra_dict('BP_CUDA')
        self.cfg_backproj['ProjectorId'] = self.proj_id
        if super_sampling:
            self.cfg_backproj['option'] = {'PixelSuperSampling':super_sampling}
        # -------------------
        self.rot_center = rot_center if rot_center else n_pixels/2
        self.n_pixels = n_pixels
        self.angles = angles
开发者ID:pierrepaleo,项目名称:portal,代码行数:62,代码来源:tomography.py


示例19: __init__

    def __init__(self, slice_shape, angles, dwidth=None, rot_center=None, fullscan=False, cudafbp=False, super_sampling=None):
        """
        Create a tomography parallel beam geometry.

        Parameters
        -----------
        slice_shape: int or tuple
            Shape of the slice. Can be in the form (n_x, n_y) or N.
            If the argument is an integer N, the slice is assumed to be square of dimensions (N, N).
            Mind that if providing (n_x, n_y), n_x is the number of columns of the image.
        angles: integer or numpy.ndarray
            Projection angles in radians.
            If this argument is an integer, the projections angles are linear between [0, pi[ if fullscan=False,
            or in [0, 2*pi[ if fullscan=True.
            If this argument is a 1D array, this means that custom angles (in radians) are provided.
        dwidth: (optional) integer
            detector width (number of pixels). If not provided, max(n_x, n_y) is taken.
        rot_center: (optional) float
            user-defined rotation center. If not provided, dwidth/2 is taken.
        fullscan: (optional) boolean, default is False
            if True, use a 360 scan geometry.
        cudafbp: (optionnal) boolean, default is False
            If True, use the built-in FBP of ASTRA instead of using Python to filter the projections.
        super_sampling: integer
            Detector and Pixel supersampling
        """

        if isinstance(slice_shape, int):
            n_x, n_y = slice_shape, slice_shape
        else:
            slice_shape = tuple(slice_shape)
            n_x, n_y = slice_shape
        if dwidth is None: dwidth = max(n_x, n_y)
        angle_max = np.pi
        if fullscan: angle_max *= 2

        if isinstance(angles, int):
                angles = np.linspace(0, angle_max, angles, False)
        n_angles = angles.shape[0]

        self.vol_geom = astra.create_vol_geom(n_x, n_y)
        self.proj_geom = astra.create_proj_geom('parallel', 1.0, dwidth, angles)

        if rot_center:
            o_angles = np.ones(n_angles) if isinstance(n_angles, int) else np.ones_like(n_angles)
            self.proj_geom['option'] = {'ExtraDetectorOffset': (rot_center - n_x / 2.) * o_angles}
        self.proj_id = astra.create_projector('cuda', self.proj_geom, self.vol_geom)

        # vg : Volume geometry
        self.vg = astra.projector.volume_geometry(self.proj_id)
        # pg : projection geometry
        self.pg = astra.projector.projection_geometry(self.proj_id)

        # ---- Configure Projector ------
        # sinogram shape
        self.sshape = astra.functions.geom_size(self.pg)
        # Configure projector
        self.cfg_proj = astra.creators.astra_dict('FP_CUDA')
        self.cfg_proj['ProjectorId'] = self.proj_id
        if super_sampling:
            self.cfg_proj['option'] = {'DetectorSuperSampling':super_sampling}

        # ---- Configure Backprojector ------
        # volume shape
        self.vshape = astra.functions.geom_size(self.vg)
        # Configure backprojector
        if cudafbp:
            self.cfg_backproj = astra.creators.astra_dict('FBP_CUDA')
            self.cfg_backproj['FilterType'] = 'Ram-Lak'
        else:
            self.cfg_backproj = astra.creators.astra_dict('BP_CUDA')
        self.cfg_backproj['ProjectorId'] = self.proj_id
        if super_sampling:
            self.cfg_backproj['option'] = {'PixelSuperSampling':super_sampling}
        # -------------------
        self.n_x = n_x
        self.n_y = n_y
        self.dwidth = dwidth
        self.n_a = angles.shape[0]
        self.rot_center = rot_center if rot_center else dwidth//2
        self.angles = angles
        self.cudafbp = cudafbp
        if not(cudafbp):
            _ramp = self.compute_ramp_filter(dwidth*2)*2.0
            self.rampfilter = np.abs(np.fft.fft(_ramp))
        else: self.rampfilter = None
开发者ID:pierrepaleo,项目名称:localtomo,代码行数:86,代码来源:tomography.py


示例20:

#along with PySIRT-FBP. If not, see <http://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------
import sirtfbp
import phantom
import astra
import numpy as np
import os

nd = 256
na = 32

# Create ASTRA geometries
vol_geom = astra.create_vol_geom(nd,nd)
proj_geom = astra.create_proj_geom('parallel',1.0,nd,np.linspace(0,np.pi,na,False))
pi = astra.create_projector('linear', proj_geom, vol_geom) # change 'linear' to 'cuda' for GPU
p = astra.OpTomo(pi)

# Load the phantom from disk
testPhantom = phantom.phantom(nd)

# Calculate the forward projection of the phantom
testSino = (p*testPhantom).reshape((na,nd))

# Add some noise to the sinogram
testSino = astra.add_noise_to_sino(testSino,10**3)

# Register plugin with ASTRA
astra.plugin.register(sirtfbp.plugin)

# Reconstruct the image using SIRT-FBP, FBP, and SIRT.
开发者ID:decarlof,项目名称:tomopy-recipes,代码行数:31,代码来源:ASTRAExample.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python astra.create_vol_geom函数代码示例发布时间:2022-05-24
下一篇:
Python astra.create_proj_geom函数代码示例发布时间: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