%
% Optical Imaging and Spectroscopy
%
% David J. Brady
% Duke University
% www.opticalimaging.org
%
% code used to generate figures 2.28, 2.29 and 2.30
%
%
% script to generate mura of dimension p
%
%
%
p=59;
qr=qres(p);
t=zeros(p);
t(2:p,1)=1;
for i=2:p
    for j=2:p
        if qr(i-1)==qr(j-1)
            t(i,j)=1;
        end
    end
end
tt=[t,t;t,t];
ht=2*(t-0.5);
ht(1,1)=1;
cp=circConv(t,ht);
figure(1);
set(gcf,'color','white');
clf;
subplot(2,2,1);
imagesc(t);
title('Base aperture pattern');
colormap(gray);
axis square;
subplot(2,2,2);
imagesc(tt);
title('Tiled aperture pattern');
colormap(gray);
axis square;
subplot(2,2,3);
surfl(cp);
title('Cross correlation with decoding pattern');
colormap(gray);
axis tight;
subplot(2,2,4);
axis off;
str=['Pinholes in code=' num2str(sum(sum(t)))];
text(0,0,str);
str=['MURA coded aperture pattern for p=' num2str(p)];
text(0,.5,str);


