Reputation: 1
How to convert images to GIF animation in matlab. Let's say that it's from C:\folder1 and images are inside that folder. Do I need to frame them or anything? And can it be done with a loop? (for now I need a simple GIF animaton).
THNX in advance.
Upvotes: 0
Views: 157
Reputation: 35525
Well, you can see how to in the link I have posted, but lets modify it so you can know how to do it with any image:
% Load, prepare, do whatever you need to create plots, imshow or something graphic
figure(1)
filename = 'test.gif';
fps=15 % change as you wish
for n = 1:framenumber
%%%%%%%%%%%%
% Plot here whatever you want ex: imshow(img{n});
%%%%%%%%%%%%
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if n == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf,'Delaytime',1/fps);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','Delaytime',1/fps);
end
end
Upvotes: 1