Created
November 25, 2019 19:20
-
-
Save jakeoung/92e7666f6ada918b72eccd3b6275b21a to your computer and use it in GitHub Desktop.
Get a forward operator as a sparse matrix in astra toolbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import astra | |
if 0: | |
data_corr = np.load('tomo_corr.npy') | |
vecs = np.load('vectors.npy') | |
else: | |
import scipy.io | |
data_mat = scipy.io.loadmat('../data/Fewer_Plastics_tomo_corr_low_high_vectors') | |
data_corr = data_mat['tomo_corr'] | |
vecs = data_mat['vectors'] | |
#omo_corr=data_corr[:,210:438,:] | |
detpixels = data_corr.shape[1] | |
height = detpixels | |
width = detpixels | |
angle_idx = np.arange(0, 360, 1) | |
#angle_idx=np.linspace(0, 359, data_corr.shape[0],endpoint=False, dtype=int) | |
vecs = vecs[angle_idx, :] | |
proj_geom = astra.create_proj_geom('fanflat_vec', detpixels, vecs) | |
vol_geom = astra.create_vol_geom(width) | |
proj_id = astra.create_projector('line_fanflat', proj_geom, vol_geom); | |
mat_id = astra.projector.matrix(proj_id) | |
A_forward = astra.matrix.get(mat_id) | |
from scipy.sparse import csr_matrix, bmat | |
A_coo = csr_matrix(A_forward) | |
A = bmat([[A_coo, None], [None, A_coo]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment