Skip to content

Instantly share code, notes, and snippets.

@arccoder
Last active October 30, 2016 23:19
Show Gist options
  • Save arccoder/0e12420ada9670881e318106cafcf68c to your computer and use it in GitHub Desktop.
Save arccoder/0e12420ada9670881e318106cafcf68c to your computer and use it in GitHub Desktop.
Create gif using MATLAB
imageExt = '.png';
imagefiles = dir(['*' imageExt]);
outfilename = 'gifname.gif';
for n = 1:length(imagefiles)
im = imread(imagefiles(n).name);
[imind,cm] = rgb2ind(im,256);
% DelayTime in seconds
if n == 1
imwrite(imind,cm,outfilename,'gif','Loopcount',inf,'DelayTime',0.7);
else
imwrite(imind,cm,outfilename,'gif','WriteMode','append','DelayTime',0.7);
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment