%  Compare the various methods of doing convolution on a randomly
%  generated image.
clear all
bigimnum = 256
for i=0:1:9
  i
  'Loading Images'
  S = Generate(bigimnum);
  %  Add some noise to the image to make things interesting.  We are
  %  adding random noise with 10% of the power of the image.
  'Adding Noise'
  S = S+(.1.*(rand(size(S))-.5.*ones(size(S))));
  t=cputime;
  flops(0)
  'Correlating, Method 1'
  cor(S);
  c1t = cputime-t
  c1f = flops
  t=cputime;
  flops(0)
  'Eliminating White Space'
  [W, Wmask] = WhiteSpace(Pad(S));
  'Correlating, Method 2'
  cor2(Pad(S), W);
  c2t = cputime-t
  c2f = flops
  t=cputime;
  flops(0)
  'Eliminating White Space'
  [W, Wmask] = WhiteSpace(Pad(S));
  'Correlating, Method 3'
  cor3(W, Wmask, Pad(S));
  c3t = cputime-t
  c3f = flops
  if i==0 
    flops1=[c1f];
    tocs1=[c1t];
    flops2=[c2f];
    tocs2=[c2t];
    flops3=[c3f];
    tocs3=[c3t];
  else
    flops1=[flops1;c1f];
    tocs1=[tocs1;c1t];
    flops2=[flops2;c2f];
    tocs2=[tocs2;c2t];
    flops3=[flops3;c3f];
    tocs3=[tocs3;c3t];
  end
end
%  Plot the results on bar graphs
subplot(211)
bar([6.*flops1,2.*flops2,flops3])
ylabel('flops')
title('A Comparison of the 3 Convolution Methods')
grid
subplot(212)
bar([6.*tocs1,2.*tocs2,tocs3])
grid     
ylabel('Cputime')
xlabel('each of the 3 methods for multiple trial runs on random snow scenes')

