% Example computations related to two-dimensional deconvolution.
%
% Samuli Siltanen September 2008
% Construct example signal (two-dimensional)
N = 16;
x = zeros(N,N);
x(round(N/4):round(N/2),round(N/4):round(N/2)) = 1;
% Construction of the measurement matrix A
A = oblur(N,3);
% Take a look at the signal and matrix A
figure(1)
clf
subplot(1,2,1)
imagesc(x)
set(gca,'xtick',[1 N/2 N])
set(gca,'ytick',[1 N/2 N])
colormap gray
title('Signal x')
axis square
subplot(1,2,2)
spy(A)
title('Nonzero elements of matrix A')
% Construct ideal and noisy measurements m and mn
m = A*x(:);
m = reshape(m,N,N);
mn = m+0.02*randn(size(m));
% Take a look at both measurements
figure(1)
clf
subplot(1,3,1)
imagesc(x)
colormap gray
axis off
title('Signal x')
axis square
subplot(1,3,2)
imagesc(m)
colormap gray
axis off
title('Ideal measurement')
axis square
subplot(1,3,3)
imagesc(mn)
colormap gray
axis off
title('Noisy measurement')
axis square
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Demonstration of unsuccessful naive inversion
% Reconstruct from ideal and noisy data
rec = inv(A)*m(:);
rec = reshape(rec,N,N);
recn = inv(A)*mn(:);
recn = reshape(recn,N,N);
% Take a look at both reconstructions
figure(3)
clf
subplot(1,3,1)
imagesc(x)
colormap gray
axis off
title('Signal x')
axis square
subplot(1,3,2)
imagesc(rec)
colormap gray
axis off
title('Naive reconstruction (ideal data)')
axis square
subplot(1,3,3)
imagesc(recn)
colormap gray
axis off
title('Naive reconstruction (noisy data)')
axis square