Last active
October 30, 2016 23:19
-
-
Save arccoder/0e12420ada9670881e318106cafcf68c to your computer and use it in GitHub Desktop.
Create gif using MATLAB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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