""" Compare the accuracy of reconstructions made from projections taken over 180 degrees with ones taken over 90 degrees. """ import astra1 import matplotlib.pyplot as plt import numpy as np import phantoms import offset90_v2 import graphs #create phantom jet = phantoms.shockjet(129, 800, 4, 2000, 6) s1 = astra1.sinogram(jet, np.pi, 180) s2 = astra1.sinogram(jet, np.pi / 2, 90) s3 = offset90_v2.mirror_sinogram(s2) graphs.colourmap(s1) graphs.colourmap(s2) graphs.colourmap(s3) graphs.colourmap(s1 - s3) # reconstruct for different amount of angles and plot the average discrepancy.. # .. from the phantom jet #ang_discrepancy = [] #angles = range(2,50,10) # range of different number of angles to take projections at #for a in angles: # s1 = astra1.sinogram(jet, np.pi, a) # r1 = astra1.reconstruct(s1, 'SIRT', 100)
diff = abs(p - r) for i in range(len(p)-1, -1, -1): if p[i] < 0.1: diff = np.delete(diff, i) p = np.delete(p, i) # calculate relative error as a percentage (relative to phantom) rel_err = diff / p * 100 return np.mean(rel_err) # return the mean so that it can be plotted # create the original phantom #phant_centr = phantoms.shockjet(129, 800, 4, 2000, 6) phant_centr = phantoms.shockjet(129, 800, 4, 2000, 6) #phant_centr2 = phantoms.shockjet(128, 800, 4, 1000, 12) #sino_noise = astra1.sinogram(phant_centr, np.pi, 180, gaussian_noise=True, s_and_p_noise=True) #reconstruction_noise = astra1.reconstruct(sino_noise,'SIRT', 100) """ sino_clean = astra1.sinogram(phant_centr, np.pi, 180) sino_noise = astra1.sinogram(phant_centr, np.pi, 180, gaussian_noise=True, s_and_p_noise=True) graphs.colourmap(phant_centr) graphs.colourmap(sino_clean)