angles, det_num, det_w, dist_source_center=SourceOrig, dist_center_detector=OrigDetec) else: NotImplemented # Set up Operator object combining the ImageGeometry and AcquisitionGeometry # wrapping calls to ASTRA as well as specifying whether to use CPU or GPU. Aop = AstraProjectorSimple(ig, ag, 'gpu') # Forward and backprojection are available as methods direct and adjoint. Here # generate test data b and do simple backprojection to obtain z. b = Aop.direct(Phantom) z = Aop.adjoint(b) plt.imshow(b.array) plt.title('Simulated data') plt.show() plt.imshow(z.array) plt.title('Backprojected data') plt.colorbar() plt.show() # Using the test data b, different reconstruction methods can now be set up as # demonstrated in the rest of this file. In general all methods need an initial # guess and some algorithm options to be set: x_init = ig.allocate() opt = {'tol': 1e-4, 'iter': 100}
angles = np.linspace(0, 2 * np.pi, angles_num) ag = AcquisitionGeometry('cone', '2D', angles, detectors, det_w, dist_source_center=SourceOrig, dist_center_detector=OrigDetec) else: NotImplemented Aop = AstraProjectorSimple(ig, ag, dev) sin = Aop.direct(data) eta = 0 noisy_data = AcquisitionData(sin.as_array() + np.random.normal(0, 1, ag.shape)) back_proj = Aop.adjoint(noisy_data) # Define Least Squares f = FunctionOperatorComposition(L2NormSquared(b=noisy_data), Aop) # Allocate solution x_init = ig.allocate() # Run FISTA for least squares fista = FISTA(x_init=x_init, f=f, g=ZeroFunction()) fista.max_iteration = 10 fista.update_objective_interval = 2 fista.run(100, verbose=True) # Run FISTA for least squares with lower/upper bound fista0 = FISTA(x_init=x_init, f=f, g=IndicatorBox(lower=0, upper=1))