Turning a sequence of images into a gif directly

5 views (last 30 days)
The process whereby one converts a figure to an image to a GIF is well-documented, but what if I instead have a sequence of images (actually, just a sequence of square arrays I would like to graphically represent in some way) and I want to turn them into a gif?
This is the process which I guessed would give me some success, and indeed the program doesn't spit out any errors. It also, as far as I'm aware, doesn't spit out any output (I've searched my computer for testAnimated.gif and it appears to not exist).
filename = 'testAnimated.gif';
for idx = 1:length(t)
Smap= [AN ARRAY OBTAINED IN SOME WAY]
A=image(Smap*20);
map=colormap(gray);
%[A,map] = rgb2ind(image(X); colormap(map));
if idx == 1
imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',1);
else
imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',1);
end
end
Any help would be appreciated.
  2 Comments
Aquatris
Aquatris on 31 Jul 2018
You are missing some code. Take a look at the answer to this question and modify your code accordingly.
KSSV
KSSV on 31 Jul 2018
YOur A is of class matlab.graphics.primitive.Image. YOu cannot write this using imwrite.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!