clc;clear all;close all;
filename= 'face.gif';
for i=1:14 % 张数
str=sprintf('%d.jpg',i);
Img=imread(str);
Img=imresize(Img,[512,512]);
figure(i)
imshow(Img);
set(gcf,'color','w');
set(gca,'units','pixels','Visible','off');
q=get(gca,'position');
q(1)=0;%设置左边距离值为零
q(2)=0;%设置右边距离值为零
set(gca,'position',q);
frame=getframe(gcf,[1,1,512,512]);%
im=frame2im(frame);%制作gif文件,图像必须是index索引图像
imshow(im);
[I,map]=rgb2ind(im,256);
k=i-0;
if k==1
imwrite(I,map,filename,'gif','Loopcount',inf,...
'DelayTime',0.1);%loopcount只是在i==1的时候才有用
else
imwrite(I,map,filename,'gif','WriteMode','append',...
'DelayTime',0.1);%DelayTime用于设置gif文件的播放快慢
end
end
close all;
转载请注明原文地址:https://ipadbbs.8miu.com/read-52482.html