예제 #1
0

def resize(r, d):
    # resizes the reconstruction to the desired size
    # r is the reconstruction
    # d is the desired size
    resized = np.zeros((d, d))
    start = int((r.shape[0] - d) / 2)
    resized = r[start + 2:start + d + 2, start:start + d]
    return resized


if __name__ == "__main__":

    # make offset jet
    ofsj = phantoms.offset_jet(48, 55)
    graphs.colourmap(ofsj)
    plt.title('Original phantom')

    # take projections and make sinogram
    offsino = astra1.sinogram(ofsj, np.pi / 2, 90)
    graphs.colourmap(offsino)
    plt.title('90 degrees sinogram')

    # straighten
    offsino = centre_sino(offsino)  #, np.pi/2, 48, 55)
    graphs.colourmap(offsino)
    plt.title('Line of symmetry through axis of rotation')

    # mirror
    offsino = mirror_sinogram(offsino)
    return sino_mirr


def resize(r, d):
    # resizes the reconstruction to the desired size
    # r is the reconstruction
    # d is the desired size
    resized = np.zeros((d, d))
    start = int((r.shape[0] - d) / 2)
    resized = r[start + 2:start + d + 2, start:start + d]
    return resized


if __name__ == "__main__":

    j = phantoms.offset_jet(0, 0)
    sino = astra1.sinogram(j, np.pi / 2, 180)

    # make offset jet
    ofsj = phantoms.offset_jet(48, 55)
    graphs.colourmap(ofsj)
    plt.title('Original phantom')

    # take projections and make sinogram
    offsino = astra1.sinogram(ofsj, np.pi / 2, 180)
    graphs.colourmap(offsino)
    plt.title('90 degrees sinogram')

    # straighten
    offsino = centre_sino(offsino)  #, np.pi/2, 48, 55)
    graphs.colourmap(offsino)
예제 #3
0
    # find difference and only keep values where phantom greater than 0.1
    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 = phantoms.offset_jet(48, 55)
phant_centr = phantoms.offset_jet(0, 55)

# the range of number of projections to reconstruct for:
n_projections = [int(a) for a in np.linspace(3,90,9)]
n_iterations = 40


# all six types to plot
fbp_noise_err = []
sirt_noise_err = []
fbp_clean_err = []
sirt_clean_err = []
fbp_90_err = []
sirt_90_err = []
fbp_90_noise_err = []