a=imread("s001.jpg","jpeg"); % read one image to determine size
total=zeros(size(a));
L=147; % there are 147 pictures (numbered 1-147) taken under the same conditions
for l=1:L
  %disp(sprintf("about to do file %03d.jpg\r",l))
  fprintf(stderr,"about to average in file %03d.jpg of %d files\r",l,L);
  fflush(stderr);
  eval(sprintf("total=total+imread(""s%03d.jpg"",""jpeg"");",l));
end
disp(sprintf("computing average of the %d files",L))
avg=total/L;

