-
Notifications
You must be signed in to change notification settings - Fork 0
/
coef_mat.m
56 lines (50 loc) · 1.76 KB
/
coef_mat.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
% GENERATING SYSTEM MATRIX (COEFFICIENT MATRIX) FOR PACT
% Author: Yunning Cao
% Version: 1.0
% Created date: 04/05/2019
% Last update: 07/28/2019
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
clear
clc
% Optional parameters
N = 128; % size of image [pixel]
sensor_radius = floor(N * sqrt(2) / 2 + 2) - 1; % sensor radius [pixel]
sensor_num = 128;
theta_start = 0; % [deg]
range = 360; % [deg]
theta_end = range-range/sensor_num; % [deg]
%%
theta = linspace(theta_start, theta_end, sensor_num); % angular distribution of sensors
I0 = zeros(N);
P = paradon(I0, theta, sensor_radius, 1); % spherical radon transform
[m, n] = size(P); % size of the sensor data (P)
% coefficient matrix
A = sparse(m*n, N*N);
% separate system matrix into batches to solve memory overflow
batch = 8;
%%
tic
for i = 1 : batch
% f = waitbar(0, 'Please wait...');
A1=zeros(m*n, N*N/batch); %coefficient matrix
for ii = 1:N*N/batch
tmp = zeros(N);
tmp(ii + (i-1)*N*N/batch) = 1;
A1(:,ii) = reshape(paradon(tmp,theta,sensor_radius,1),m*n, 1);
% A1(:,ii) = reshape(paradon(imfilter(temp,fspecial('gaussian')),theta,sensor_radius,1),m*n,1);
if ~mod(ii, 100)
% waitbar(ii / N^2, f, sprintf('%.2f%% finished',100 * ii / N^2));
ii/N/N+(i-1)/batch
end
end
% close(f);
A(:, (1+(i-1)*N*N/batch : i*N*N/batch)) = A1;
clear A1
i
end
toc
%save coef mat
filename = ['CoefMat_', num2str(N), '_', num2str(theta_start), '_', num2str(theta_end), '_', num2str(sensor_num), '.mat'];
save(['.\coef_mat\', filename], 'A');
%clearvars -except A