function processing(reffile, directory, filespec)
% function processing(reffile, directory, filespec)
% $Id$
angle_inc = 4;

files = dir([directory filespec]);

disp(sprintf('Loading the reference image, ''%s''.',reffile));
ref = double(spi_read(reffile));
size(ref),

for n=1:length(files),
  filename = files(n).name;
  disp(sprintf('Processing ''%s''',filename));
  if (strcmp(filename,reffile)),
    disp('<!> This is the reference projection! skipping');
    continue;
  end
  if (length(dir([filename '.mat'])) > 0),
    disp('<!> Destination file already exists! skipping');
    continue;
  end
  data = double(spi_read([directory filename]));
  imsize = size(data);
  disp(sprintf('The data is %dx%d pixels',imsize(1),imsize(2)));
  [result, anti_result, best_angles ] =  cc_rotations(data, ref, angle_inc);
  disp('Saving the results to a .mat file');
  save([filename '.mat'],'data','ref','result','anti_result','best_angles');
  clear data result anti_result best_angles; 
end
