% Two arguments: The file to be read (.mat file) and the file where the gif % will be saved. % Author: Magnus Lundstedt function saveImage(file,file2) a=open(file); iRaw = (double(a.raw))/a.factor; iAvg = (double(a.avg)); iBase = (double(a.base))/a.factor; for i = 1:1024 myImage(:,[i]) = iBase*iRaw(:,[i])+iAvg; end imwrite((reconstruct(myImage))*256,file2,'gif'); end