% Plot the results of routine XRMB_naive_comp.m. 
%
% Arguments:
% N    resolution of the image is N x N
%
% Samuli Siltanen March 2011

function XRMB_naive_plot(N)

% Plot parameters
fsize = 16;

% Load precomputed results at resolution N
loadcommand = ['load data/XRMB_', num2str(N), ' A measang target N naive_recon naive_recon2 relerr relerr2 m mn'];
eval(loadcommand)

% Take a look at the signal
figure(1)
clf
imagesc(target)
colormap gray
axis('equal')
axis('off')

% Take a look at the measurement matrix A
figure(2)
clf
spy(A)
axis square

% Take a look at the ideal measurement
figure(3)
clf
% Remove purely zero rows from the sinogram
sinogram = [];
for iii = 1:size(m,1)
    if sum(abs(m(iii,:)))>1e-8
        sinogram = [sinogram;m(iii,:)];
    end
end
imagesc(sinogram)
colormap gray
axis square
set(gca,'xtick',[1:length(measang)])


% Take a look at the naive reconstruction from ideal data
figure(4)
clf
imagesc(naive_recon)
colormap gray
axis off
axis square

% Take a look at the naive reconstruction from noisy data
figure(5)
clf
imagesc(naive_recon2)
colormap gray
axis off
axis square

% Display relative errors
disp(['Relative error (ideal data): ',num2str(100*relerr),'%'])
disp(['Relative error (noisy data): ',num2str(round(100*relerr2)),'%'])
