f=imread('~/Desktop/Teaching/Images/flower.tiff');
fg=rgb2gray(f);
fgn=double(fg)+15*randn(size(fg));
clf;
figure(1);
subplot(2,3,1);
imagesc(f);
subplot(2,3,2);
imagesc(fg);
colormap(gray);
subplot(2,3,3);
imagesc(fgn);
colormap(gray);

c=zeros(201,1);
for i=-100:100
  sf=circshift(fgn,[0 i]);
  subplot(2,3,4);
  imagesc(sf);
  colormap(gray);
  subplot(2,3,5);
  plot(fg(:),sf(:),'.');
  c(i+101)=corr(double(fg(:)),sf(:));
  subplot(2,3,6);
  axis([-100 100 -1 1]);
  plot(-100:100,c,'.');
  axis([-100 100 -1 1]);
  drawnow;
end
