% Plot the result of tomo07_TV_comp.m
%
% Samuli Siltanen Feb 2017

% Parameters for controlling the plot
fsize  = 12;

% Load precomputed data
load data/tomo07 M recn Nang mncn angles

% Compute filtered back-projection for comparison
fbprecon = iradon(mncn,angles);
fbprecon = fbprecon(2:(end-1),2:(end-1));

% Calculate relative errors
%f2 = phantom('Modified Shepp-Logan',2*M);
%f2 = SqPhantom(2*M);
%f  = MyDS2(f2);
f = SqPhantom(M);
relerr1 = norm(f(:)-recn)/norm(f(:));
relerr2 = norm(f(:)-fbprecon(:))/norm(f(:));

% Plot the results
figure(1)
clf
im = [f,reshape(recn,M,M)];
im = im-min(im(:));
im = im/max(im(:));
imagesc(im.^(.5))
axis equal
colormap gray

figure(2)
clf
MAX = max(max(fbprecon(:)),max(recn));
MIN = min(min(fbprecon(:)),min(recn));
im1 = fbprecon;
im2 = reshape(recn,M,M);
im1 = im1-MIN;
im1 = im1/MAX;
im2 = im2-MIN;
im2 = im2/MAX;
subplot(1,2,1)
imagesc(im1.^(.5),[0,1])
title(['Filtered Back-projection ', num2str(round(relerr2*100)),'%'],'fontsize',fsize)
axis equal
axis off
colormap gray
subplot(1,2,2)
imagesc(im2.^(.5),[0,1])
title(['Total variation ', num2str(round(relerr1*100)),'%'],'fontsize',fsize)
axis equal
axis off
colormap gray
