% smooth_interpolation.m
% Defines m, n, wknown, Zknown, Zunknown, Dx, Dy.

% Create an interesting image.
[X,Y] = meshgrid(-2:.15:2, -2:.15:2);
Uorig = sin(-X+Y-1).^2.*cos(X+Y+1) + 1;
[m, n] = size(Uorig);
Dx = [zeros(m*(n-1),m) eye(m*(n-1))] - [eye(m*(n-1)) zeros(m*(n-1),m)];
Dy = kron(eye(n), diff(eye(m)));

% Create and apply a mask to create Uboscured.
rand('seed', 263); W = rand(m,n) > 0.5;
Uboscured = W.*Uorig;

% Form Zunknown and Zknown.
tm = diag(1-W(:)); tminv = diag(W(:));
Zunknown = tm(find(sum(tm,2)~=0),:)';
Zknown = tminv(find(sum(tminv,2)~=0),:)';

wknown = Zknown'*Uboscured(:);

% Graph the original and obscured images.
figure;
subplot(221);
imagesc(Uorig)
title('Original image');

subplot(222);
imagesc(Uboscured);
title('Obscured image');
