clear all; close all;
source = 'hw9prob1data';

fid = fopen(source,'r');
A = fread(fid,[1 inf],'float');
fclose(fid);

A = reshape(A,[512 180]);
r = linspace(-1,1,512);

subplot(121);
imagesc(1:180,r,A);
xlabel('Projection angle (degrees)');
ylabel('Projection');
title(source);

[X Y] = meshgrid(r);
F = zeros(size(X));
for i = 1:180
    R = X*cosd(i) + Y*sind(i);
    f = interp1(r,A(:,i)',R,'linear',0);
    F = F + f;
end

subplot(122);
surf(X,Y,F);
shading interp;
view([0 90]);
xlabel('x (normalized)');
ylabel('y (normalized)');
title('Simple backprojection');