#%% ################################################################### # get numerical sinogram (ASTRA-toolbox) # initialise tomobar reconstruction class ONCE from tomobar.methodsDIR import RecToolsDIR Rectools = RecToolsDIR( DetectorsDimH=P, # DetectorsDimH # detector dimension (horizontal) DetectorsDimV= None, # DetectorsDimV # detector dimension (vertical) for 3D case only CenterRotOffset=0.0, # Center of Rotation (CoR) scalar (for 3D case only) AnglesVec=angles_rad, # array of angles in radians ObjSize=N_size, # a scalar to define reconstructed object dimensions device_projector='cpu') tic = timeit.default_timer() sino_num_ASTRA = Rectools.FORWPROJ(phantom_2D) # generate numerical sino (Ax) toc = timeit.default_timer() Run_time = toc - tic print("Numerical (ASTRA) sinogram has been generated in {} seconds".format( Run_time)) plt.figure() plt.rcParams.update({'font.size': 21}) plt.imshow(sino_num_ASTRA, vmin=0, vmax=150, cmap="BuPu") plt.colorbar(ticks=[0, 150, 250], orientation='vertical') plt.title('{}' '{}'.format('Numerical sinogram (ASTRA) of model no.', model)) #%% print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print("Reconstructing analytical sinogram using Fourier Slice method") print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
angles_num = int(np.pi * N_size) # angles number angles = np.linspace(0.0, 179.9, angles_num, dtype='float32') angles_rad = angles * (np.pi / 180.0) P = N_size #detectors Rectools = RecToolsDIR( DetectorsDimH=P, # Horizontal detector dimension DetectorsDimV=None, # Vertical detector dimension (3D case) CenterRotOffset=0.0, # Center of Rotation scalar AnglesVec=angles_rad, # A vector of projection angles in radians ObjSize=N_size, # Reconstructed object dimensions (scalar) device_projector='gpu') sino_num = Rectools.FORWPROJ(Object) _noise_ = {} _zingers_ = {} _sinoshifts_ = {} _stripes_ = { 'percentage': 0.75, 'maxthickness': 2.0, 'intensity': 0.15, 'type': 'mix', 'variability': 0.005 } sino_num_artifacts = _Artifacts_(sino_num, _noise_, _zingers_, _stripes_, _sinoshifts_)