def test_fresnel_filter(self): mat = np.random.rand(64, 64) mat1 = filt.fresnel_filter(mat, 10, dim=1) mat2 = filt.fresnel_filter(mat, 10, dim=2) num1 = np.sum(np.abs(mat - mat1)) num2 = np.sum(np.abs(mat - mat2)) num3 = np.sum(np.abs(mat1 - mat2)) self.assertTrue(num1 > self.eps and num2 > self.eps and num3 > self.eps)
print("2 -> Calculate the center-of-rotation...") sinogram = corr.flat_field_correction(data[0:num_proj, mid_slice, left:right], flat_field[mid_slice, left:right], dark_field[mid_slice, left:right]) center = calc.find_center_vo(sinogram) print("Center-of-rotation = {0}".format(center)) for i in range(num_tomo): folder_name = "tomo_" + ("0000" + str(i))[-5:] thetas = np.deg2rad(angles[i * num_proj:(i + 1) * num_proj]) for slice_idx in range(start_slice, stop_slice + 1, step_slice): sinogram = corr.flat_field_correction( data[i * num_proj:(i + 1) * num_proj, slice_idx, left:right], flat_field[slice_idx, left:right], dark_field[slice_idx, left:right]) sinogram = remo.remove_zinger(sinogram, 0.05, 1) sinogram = remo.remove_all_stripe(sinogram, 3.0, 51, 17) sinogram = filt.fresnel_filter(sinogram, 100) # img_rec = reco.dfi_reconstruction(sinogram, center, angles=thetas, apply_log=True) # img_rec = reco.gridrec_reconstruction(sinogram, center, angles=thetas, apply_log=True) img_rec = reco.fbp_reconstruction(sinogram, center, angles=thetas, apply_log=True) file_name = "rec_slice_" + ("0000" + str(slice_idx))[-5:] + ".tif" losa.save_image(output_base + "/" + folder_name + "/" + file_name, img_rec) print("Done tomograph {0}".format(i)) time_stop = timeit.default_timer() print("All done!!! Total time cost: {}".format(time_stop - time_start))
# Generate a sinogram with flat-field correction and blob removal. # Angles corresponding to this sinogram also is generated. index = max_index // 2 print("2 -> Generate a circular sinogram from the helical data") (sino_360, angle_sino) = conv.generate_sinogram_helical_scan(index, proj_data, num_proj, pixel_size, y_start, y_stop, pitch, scan_type=scan_type, angles=angles, flat=flat_field, dark=dark_field, mask=blob_mask, crop=(10,0,0,0)) print("3 -> Find the center of rotation, overlap-side, and overlap area between two halves of a 360-degree sinogram") (center0, overlap, side,_) = calc.find_center_360(sino_360, 100) print("Center-of-rotation: {0}. Side: {1} (0->'left', 1->'right'). Overlap: {2}".format(center0, side, overlap)) # Convert the 360-degree sinogram to the 180-degree sinogram. sino_180, center1 = conv.convert_sinogram_360_to_180(sino_360, center0) # Remove partial ring artifacts sino_180 = remo.remove_stripe_based_sorting(sino_180, 15) # Remove zingers sino_180 = remo.remove_zinger(sino_180, 0.08) # Denoising sino_180 = filt.fresnel_filter(sino_180, 250, 1) # Perform recosntruction img_rec = reco.dfi_reconstruction(sino_180, center1, apply_log=True) ## Use gpu for fast reconstruction # img_rec = reco.fbp_reconstruction(sino_180, center1, apply_log=True, gpu=True) losa.save_image(output_base + "/reconstruction/sino_360.tif", sino_360) losa.save_image(output_base + "/reconstruction/sino_180.tif", sino_180) losa.save_image(output_base + "/reconstruction/recon_image.tif", img_rec) print("!!! Done !!!")
"Center-of-rotation: {0}. Side: {1} (0->'left', 1->'right'). Overlap: {2}". format(center0, side, overlap)) t1 = timeit.default_timer() print("Time cost {}".format(t1 - t0)) # Remove artifacts. They also can be passed to flat_field_correction method above as parameters. # Remove zingers sino_360 = remo.remove_zinger(sino_360, 0.08) # Remove ring artifacts sino_360 = remo.remove_all_stripe(sino_360, 3, 51, 17) # 1st way: Convert the 360-degree sinogram to the 180-degree sinogram. sino_180, center1 = conv.convert_sinogram_360_to_180(sino_360, center0) losa.save_image(output_base + "/reconstruction/sino_180.tif", sino_180) ## Denoising sino_180 = filt.fresnel_filter(sino_180, 250, 1, apply_log=True) # Perform reconstruction img_rec = reco.dfi_reconstruction(sino_180, center1, apply_log=True) ## Using fbp with GPU for faster reconstruction # img_rec = reco.fbp_reconstruction(sino_180, center1, apply_log=True, gpu=True) losa.save_image(output_base + "/reconstruction/recon_image_1.tif", img_rec) # 2nd way: Extending the 360-degree sinogram (by weighting and padding). (sino_ext, center2) = conv.extend_sinogram(sino_360, center0) losa.save_image(output_base + "/reconstruction/sino_360_extened.tif", sino_ext) # Denoising sino_ext = filt.fresnel_filter(sino_ext, 250, 1, apply_log=False) # Perform reconstruction # img_rec = reco.dfi_reconstruction(sino_ext, center2, angles=angles*np.pi/180.0,apply_log=False) ## Using fbp with GPU for faster reconstruction img_rec = reco.fbp_reconstruction(sino_ext,