png2gif
for idx = 1:3
[A,map] = imread(strcat(num2str(idx),'.PNG')); %imwrite不能显示三维图像,因此要进行转换
if idx == 1
imwrite(A,map,'new.gif','LoopCount',Inf,'DelayTime',0.5); %Inf 无限循环
else
imwrite(A,map,'new.gif','WriteMode','append','DelayTime',0.8);
end
end
dirOutput=dir('*.png');
fileNames={dirOutput.name};
number = length(fileNames);
for i = 1:number
rgb = imread(fileNames{i});
[A, map]=rgb2ind(rgb, 256);
if i == 1
imwrite(A, map, 'new.gif', 'LoopCount', Inf, 'DelayTime', 0.5); %Inf 无限循环
else
imwrite(A, map, 'new.gif', 'WriteMode', 'append', 'DelayTime', 0.5);
end
end
png2avi
dirOutput=dir('*.png');
fileNames={dirOutput.name};
number = length(fileNames);
for i=1:number
rgb = importdata(fileNames{i});
%imresize
movie_data(i) = im2frame(rgb);
end
writerObj =VideoWriter('movie.avi');
writerObj.FrameRate=0.75;
open(writerObj);
writeVideo(writerObj, movie_data);
close(writerObj);
|