% Plot the result of XR09_TV_comp.m
%
% Samuli Siltanen Feb 2015

% Parameters for controlling the plot
fsize  = 12;

% Load precomputed data
load data/XR09 N recn T mncn

% Compute filtered back-projection for comparison
th = ([0:(T-1)]/T)*180;
fbprecon = iradon(mncn,th);
fbprecon = fbprecon(2:(end-1),2:(end-1));

% Calculate relative errors
target2 = phantom('Modified Shepp-Logan',2*N);
target  = MyDS2(target2);
relerr1 = norm(target(:)-recn)/norm(target(:));
relerr2 = norm(target(:)-fbprecon(:))/norm(target(:));

% Plot the results
figure(1)
clf
im = [target,reshape(recn,N,N)];
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,N,N);
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
