% A test of smart.m using target1.m

% The tomography example requires the octave image package.
pkg load image

% Set up the various adjustable parameters
N = 128  % Size of object
angles = 9:9:180 % Projection angles in degrees
Niter = 40 % Number of iterations
a = 0.1 %Smoothing parameter (typically 0 < a < 1)
noise_model=0; %Not yet implemented.
mean_counts = 400000000 %mean counts in the data

% Preliminaries
M = numel(angles); % Number of projections
figure(1) %This is where I want to put the picture of the object.
hold off
object = target1(N);
hold on
orient tall
orient landscape
print('object.pdf','-dpdf')

% Create data
data = zeros(N,M);
for i=1:M
   data(:,i) = forward(object, angles(i));
end
data *= mean_counts / mean(vec(data));
data = poissrnd(data);

% Inversion.
result = smart(data, angles, noise_model, Niter, a);
figure(2)
colormap(gray(256))
hold off
imagesc(result)
hold on
xlabel('y')
ylabel('x')
axis('equal')
title('Reconstruction (final)')
print('reconstruction.pdf','-dpdfwrite')

