datadict = scipy.io.loadmat('../../../data/DendrRawData.mat') # extract data (print(datadict.keys())) dataRaw = datadict['data_raw3D'] angles = datadict['angles'] flats = datadict['flats_ar'] darks = datadict['darks_ar'] flats2 = np.zeros((1, np.size(flats, 0), np.size(flats, 1)), dtype='float32') flats2[0, :, :] = flats[:] darks2 = np.zeros((1, np.size(darks, 0), np.size(darks, 1)), dtype='float32') darks2[0, :, :] = darks[:] dataRaw = np.swapaxes(dataRaw, 0, 1) # normalise the data, required format is [Projections, detectorsHoriz, Slices] data_norm = normaliser(dataRaw, flats2, darks2, log='log') dataRaw = np.float32(np.divide(dataRaw, np.max(dataRaw).astype(float))) detectorHoriz = np.size(data_norm, 1) N_size = 1000 slice_to_recon = 19 # select which slice to reconstruct angles_rad = angles * (np.pi / 180.0) #%% print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print("%%%%%%%%%%%%Reconstructing with FBP method %%%%%%%%%%%%%%%%%") print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") from tomobar.methodsDIR import RecToolsDIR RectoolsDIR = RecToolsDIR( DetectorsDimH= detectorHoriz, # DetectorsDimH # detector dimension (horizontal)
jitter = 5.0,\ sigmasmooth = 3, flatsnum=flatsnum) plt.figure() plt.subplot(121) plt.imshow(projData3D_noisy[:, 0, :]) plt.title('2D Projection (before normalisation)') plt.subplot(122) plt.imshow(flatsSIM[:, 0, :]) plt.title('A selected simulated flat-field') plt.show() #%% print("Normalise projections using ToMoBAR software") # normalise the data, the required data format is [detectorsX, Projections, detectorsY] projData3D_norm = normaliser(projData3D_noisy, flatsSIM, darks=None, log='true', method='mean') intens_max = 0.15 * np.max(projData3D_norm) sliceSel = 150 plt.figure() plt.subplot(131) plt.imshow(projData3D_norm[:, sliceSel, :], vmin=0, vmax=intens_max) plt.title('Normalised 2D Projection (erroneous)') plt.subplot(132) plt.imshow(projData3D_norm[sliceSel, :, :], vmin=0, vmax=intens_max) plt.title('Sinogram view') plt.subplot(133) plt.imshow(projData3D_norm[:, :, sliceSel], vmin=0, vmax=intens_max) plt.title('Tangentogram view')
plt.figure() plt.subplot(121) plt.imshow(projData3D_noisy[:, 0, :]) plt.title('2D Projection (before normalisation)') plt.subplot(122) plt.imshow(flatsSIM[:, 0, :]) plt.title('A selected simulated flat-field') plt.show() #%% print("Normalise projections using ToMoBAR software") from tomobar.supp.suppTools import normaliser # normalise the data, the required format is [detectorsX, Projections, detectorsY] projData3D_norm = normaliser(projData3D_noisy, flatsSIM, darks=None, log='true', method='mean') del projData3D_noisy intens_max = np.max(projData3D_norm) * 0.5 sliceSel = 150 plt.figure() plt.subplot(131) plt.imshow(projData3D_norm[:, sliceSel, :], vmin=0, vmax=intens_max) plt.title('2D Projection (erroneous)') plt.subplot(132) plt.imshow(projData3D_norm[sliceSel, :, :], vmin=0, vmax=intens_max) plt.title('Sinogram view') plt.subplot(133) plt.imshow(projData3D_norm[:, :, sliceSel], vmin=0, vmax=intens_max)
# load dendritic data datadict = scipy.io.loadmat('../../data/DendrRawData.mat') # extract data (print(datadict.keys())) dataRaw = datadict['data_raw3D'] angles = datadict['angles'] flats = datadict['flats_ar'] darks= datadict['darks_ar'] flats2 = np.zeros((np.size(flats,0),1, np.size(flats,1)), dtype='float32') flats2[:,0,:] = flats[:] darks2 = np.zeros((np.size(darks,0),1, np.size(darks,1)), dtype='float32') darks2[:,0,:] = darks[:] # normalise the data, required format is [detectorsHoriz, Projections, Slices] data_norm = normaliser(dataRaw, flats2, darks2, log='log', method = 'mean') dataRaw = np.float32(np.divide(dataRaw, np.max(dataRaw).astype(float))) data_norm = np.swapaxes(data_norm,0,2) dataRaw = np.swapaxes(dataRaw,0,2) detectorHoriz = np.size(data_norm,2) N_size = 1000 slice_to_recon = 19 # select which slice to reconstruct angles_rad = angles[:,0]*(np.pi/180.0) #%% print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print ("%%%%%%%%%%%%Reconstructing with FBP method %%%%%%%%%%%%%%%%%") print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") from tomobar.methodsDIR import RecToolsDIR RectoolsDIR = RecToolsDIR(DetectorsDimH = detectorHoriz, # Horizontal detector dimension
darks = np.array(h5f["darks"], dtype=np.float64) phantom_tm = np.array(h5f["phantom"], dtype=np.float64) h5f.close() # Projection geometry related parameters: N_size = 256 # Define phantom dimensions using a scalar value (cubic phantom) Horiz_det = int(np.sqrt(2)*N_size) # detector column count (horizontal) Vert_det = N_size # detector row count (vertical) (no reason for it to be > N) angles_num = int(0.5*np.pi*N_size); # angles number angles = np.linspace(0.0,179.9,angles_num,dtype='float32') # in degrees angles_rad = angles*(np.pi/180.0) intens_max_clean = projData3D_analyt.max() #%% from tomobar.supp.suppTools import normaliser projData3D_norm = normaliser(projData3D_noisy, flats, darks, log='True', method='mean') intens_max = np.max(projData3D_norm) sliceSel = 150 plt.figure() plt.subplot(131) plt.imshow(projData3D_norm[:,sliceSel,:],vmin=0, vmax=intens_max) plt.title('2D Projection (erroneous)') plt.subplot(132) plt.imshow(projData3D_norm[sliceSel,:,:],vmin=0, vmax=intens_max) plt.title('Sinogram view') plt.subplot(133) plt.imshow(projData3D_norm[:,:,sliceSel],vmin=0, vmax=intens_max) plt.title('Tangentogram view') plt.show()
h5f = h5py.File("C:/Users/lqg38422/Desktop/PSI_Phantom/flats_corrected.h5", "r") flats_full = np.array(h5f["/flats"], dtype=np.float64) flats_full = np.swapaxes(flats_full, 1, 0) flats = flats_full[:N_cut, :, :] del flats_full plt.figure() plt.imshow(flats[:, 5, :], vmin=0, vmax=15000, cmap="gray") print("Done!") #%% # normalising projections: print("Mean normalisation...") projections_norm = normaliser(projections, flats, darks, log='true', method='mean') plt.figure() plt.axis('off') plt.imshow(projections_norm[:, 5, :], vmin=-0.1, vmax=0.4, cmap="gray") print("Done!") #%% import numpy as np import scipy from skimage.transform import downscale_local_mean import bm3d def DFFC(data, flats, darks, downsample=20):