mmin = -0.3 # min data value mmax = 2 # max data value data[data < mmin] = mmin data[data > mmax] = mmax #data = (data-mmin)/(mmax-mmin) # initial guess u = np.zeros([det, det, det], dtype='float32') lamd = np.zeros([ntheta, det, det], dtype='float32') flow = np.zeros([ntheta, det, det, 2], dtype='float32') psi = data.copy() # optical flow parameters pars = [0.5, 0, 256, 4, 5, 1.1, 4] niter = 257 with lcg.SolverLam(det, det, det, det, ntheta, phi, float(sys.argv[1])) as tslv: with dc.SolverDeform(ntheta, det, det) as dslv: rho = 0.5 h0 = psi for k in range(niter): # registration tic() flow = dslv.registration_flow_batch(psi, data, mmin, mmax, flow.copy(), pars, nproc=42) t1 = toc() tic()
# initial guess u = np.zeros([det, det, det], dtype='float32') psi1 = data.copy() psi2 = np.zeros([3, det, det, det], dtype='float32') lamd1 = np.zeros([ntheta, det, det], dtype='float32') lamd2 = np.zeros([3, det, det, det], dtype='float32') flow = np.zeros([ntheta, det, det, 2], dtype='float32') # optical flow parameters pars = [0.5, 1, 1024, 4, 5, 1.1, 4] niter = 257 alpha = 8e-14 with lcg.SolverLam(det, det, det, det, ntheta, phi, 1e-2) as tslv: with dc.SolverDeform(ntheta, det, det, 42) as dslv: rho1 = 0.5 rho2 = 0.5 h01 = psi1 h02 = psi2 for k in range(niter): # registration tic() flow = dslv.registration_flow_batch(psi1, data, mmin, mmax,
F = np.ndarray.flatten(F) res = us2eq(-x, F, 1e-3, N) return res n0 = 16 n1 = 16 n2 = 8 det = 8 ntheta = 8 phi = np.pi/3 theta = np.linspace(0,2*np.pi,ntheta,endpoint=False).astype('float32') f = np.zeros([n0,n1,n2]).astype('complex64') f[n0//8:3*n0//8,n1//4:3*n1//4,n2//4:3*n2//4]=1 with lcg.SolverLam(n0, n1, n2, det, ntheta, phi,1e-3) as slv: g_gpu = slv.fwd_lam(f,theta) g = fwd_laminography(f, theta, phi, det, [n0,n1,n2]) print('fwd accuracy:', np.linalg.norm(g_gpu-g)/np.linalg.norm(g_gpu)) ff = adj_laminography(g, theta, phi, det, [n0,n1,n2]) ff_gpu = slv.adj_lam(g_gpu, theta) print('adj accuracy:', np.linalg.norm(ff_gpu-ff)/np.linalg.norm(ff_gpu)) print('Adj test 1') print(np.sum(f*np.conj(ff))) print(np.sum(g*np.conj(g))) print('Adj test 2') print(np.sum(f*np.conj(ff_gpu))) print(np.sum(g_gpu*np.conj(g_gpu))) gg_gpu = slv.fwd_lam(ff_gpu,theta) print('Norm test')