54 #define KERNEL(r) (1.0-fabs((double)(r))/((double)R/2))
59 static int polar_grid(
int T,
int R,
double *x,
double *w)
62 double W=(double)T*(((
double)R/2.0)*((double)R/2.0)+1.0/4.0);
64 for(t=-T/2; t<T/2; t++)
66 for(r=-R/2; r<R/2; r++)
68 x[2*((t+T/2)*R+(r+R/2))+0] = (
double)r/R*cos(
PI*t/T);
69 x[2*((t+T/2)*R+(r+R/2))+1] = (
double)r/R*sin(
PI*t/T);
71 w[(t+T/2)*R+(r+R/2)] = 1.0/4.0/W;
73 w[(t+T/2)*R+(r+R/2)] = fabs((
double)r)/W;
86 double W=(double)T*(((
double)R/2.0)*((double)R/2.0)+1.0/4.0);
88 for(t=-T/2; t<T/2; t++)
90 for(r=-R/2; r<R/2; r++)
94 x[2*((t+T/2)*R+(r+R/2))+0] = (
double)r/R;
95 x[2*((t+T/2)*R+(r+R/2))+1] = (
double)4*(t+T/4)/T*r/R;
99 x[2*((t+T/2)*R+(r+R/2))+0] = -(
double)4*(t-T/4)/T*r/R;
100 x[2*((t+T/2)*R+(r+R/2))+1] = (
double)r/R;
103 w[(t+T/2)*R+(r+R/2)] = 1.0/4.0/W;
105 w[(t+T/2)*R+(r+R/2)] = fabs((
double)r)/W;
123 fftw_plan my_fftw_plan;
132 N[0]=NN; n[0]=2*N[0];
133 N[1]=NN; n[1]=2*N[1];
135 fft = (fftw_complex *)
nfft_malloc(R*
sizeof(fftw_complex));
136 my_fftw_plan = fftw_plan_dft_1d(R,fft,fft,FFTW_FORWARD,FFTW_MEASURE);
147 nfft_init_guru(&my_nfft_plan, 2, N, M, n, 4,
148 PRE_PHI_HUT| PRE_PSI| MALLOC_X | MALLOC_F_HAT| MALLOC_F| FFTW_INIT | FFT_OUT_OF_PLACE,
149 FFTW_MEASURE| FFTW_DESTROY_INPUT);
152 solver_init_advanced_complex(&my_infft_plan,(
nfft_mv_plan_complex*)(&my_nfft_plan), CGNR | PRECOMPUTE_WEIGHT);
156 for(j=0;j<my_nfft_plan.
M_total;j++)
158 my_nfft_plan.
x[2*j+0] = x[2*j+0];
159 my_nfft_plan.
x[2*j+1] = x[2*j+1];
161 my_infft_plan.
w[j] = w[j];
163 my_infft_plan.
w[j] = 0.0;
171 nfft_precompute_psi(&my_nfft_plan);
174 nfft_precompute_full_psi(&my_nfft_plan);
186 fft[r] = Rf[t*R+r] + _Complex_I*0.0;
189 fftw_execute(my_fftw_plan);
192 my_infft_plan.
y[t*R] = 0.0;
193 for(r=-R/2+1; r<R/2; r++)
194 my_infft_plan.
y[t*R+(r+R/2)] = fft[r+R/2]/
KERNEL(r);
198 for(k=0;k<my_nfft_plan.
N_total;k++)
199 my_infft_plan.
f_hat_iter[k] = 0.0 + _Complex_I*0.0;
202 solver_before_loop_complex(&my_infft_plan);
207 for(k=0;k<my_nfft_plan.
N_total;k++)
212 for(l=1;l<=
max_i;l++)
221 for(k=0;k<my_nfft_plan.
N_total;k++)
225 fftw_destroy_plan(my_fftw_plan);
228 nfft_finalize(&my_nfft_plan);
236 int main(
int argc,
char **argv)
247 printf(
"inverse_radon gridfcn N T R max_i\n");
249 printf(
"gridfcn \"polar\" or \"linogram\" \n");
250 printf(
"N image size NxN \n");
251 printf(
"T number of slopes \n");
252 printf(
"R number of offsets \n");
253 printf(
"max_i number of iterations \n");
257 if (strcmp(argv[1],
"polar") == 0)
266 max_i = atoi(argv[5]);
272 fp=fopen(
"sinogram_data.bin",
"rb");
275 fread(Rf,
sizeof(
double),T*R,fp);
282 fp=fopen(
"output_data.bin",
"wb+");
285 fwrite(iRf,
sizeof(
double),N*N,fp);