matlab中的gif动图
% 彩色图像,举个例子,n个图片
% 对于实际图形,常用到frame = getframe(fig);im(idx)=frame2im(frame); n = 100; for i = 1:n img{i} = im2uint8(rand(512,512,3)); end % 将图片组合成gif图 filename = 'test_rgb.gif'; for idx = 1:n [A, map] = rgb2ind(img{idx},256); % RGB图像转化为索引图像,A是索引,map是颜色图 if idx == 1 imwrite(A, map, filename,'gif','LoopCount',Inf,'DelayTime',1/25);
% LoopCount=Inf,动画连续循环;DelayTime表示每张图片之间的延迟 else imwrite(A, map, filename,'gif','WriteMode','append','DelayTime',1/25); end end
灰色图像gif动图则不需要求颜色图
for idx = 1:n if idx == 1 imwrite(img{idx},filename,'gif','LoopCount',Inf,'DelayTime',1/25); else imwrite(img{idx},filename,'gif','WriteMode','append','DelayTime',1/25); end end
标签:end,idx,filename,gif,DelayTime,matlab,动图 From: https://www.cnblogs.com/sharevent/p/17725916.html