コード例 #1
0
    def test_tomobarDIR(self):
        model = 4  # select a model
        N_size = 64  # set dimension of the phantom

        # create sinogram analytically
        angles_num = int(0.5 * 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 = int(np.sqrt(2) * N_size)  # detectors
        sino_num = np.ones((P, angles_num))

        RectoolsDirect = 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
            AnglesVec=angles_rad,  # array of angles in radians
            ObjSize=N_size,  # a scalar to define reconstructed object dimensions
            device_projector='cpu')
        """
        RectoolsIterative = RecToolsIR(DetectorsDimH = P,  # DetectorsDimH # detector dimension (horizontal)
                            DetectorsDimV = None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
                            CenterRotOffset = 0.0, # Center of Rotation (CoR) scalar
                            AnglesVec = angles_rad, # array of angles in radians
                            ObjSize = N_size, # a scalar to define reconstructed object dimensions
                            datafidelity = 'LS',
                            device_projector = 'cpu')
        """
        RecFourier = RectoolsDirect.FOURIER(sino_num, 'linear')
コード例 #2
0
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("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")

RecFourier = Rectools.FOURIER(sino_an, 'linear')

plt.figure()
plt.imshow(RecFourier, vmin=0, vmax=1, cmap="BuPu")
plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('Fourier slice reconstruction')
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("Reconstructing analytical sinogram using FBP (tomobar)...")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
#x = Atools.backproj(sino_an) # generate backprojection (A'b)

plt.figure()
plt.subplot(121)
plt.imshow(sino_an, cmap="BuPu")
plt.title('Analytical sinogram')
コード例 #3
0
#%%
# initialise tomobar DIRECT reconstruction class ONCE
from tomobar.methodsDIR import RecToolsDIR
RectoolsDIR = RecToolsDIR(
    DetectorsDimH=P,  # DetectorsDimH # detector dimension (horizontal)
    DetectorsDimV=
    None,  # DetectorsDimV # detector dimension (vertical) for 3D case only
    CenterRotOffset=None,  # 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')
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("Reconstructing analytical sinogram using Fourier Slice method")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
RecFourier = RectoolsDIR.FOURIER(noisy_sino, 'linear')
plt.figure()
plt.imshow(RecFourier, vmin=0, vmax=1, cmap="BuPu")
plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('Fourier slice reconstruction')
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("Reconstructing analytical sinogram using FBP (tomobar)...")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
FBPrec = RectoolsDIR.FBP(noisy_sino)  # ideal reconstruction

plt.figure()
plt.imshow(FBPrec, vmin=0, vmax=1, cmap="gray")
plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
plt.title('FBP reconstruction')
#%%