Matlab 为什么;“照明电话”;要成功创建aminated GIF/电影,必须这样做吗?
我有以下Matlab代码,用于gif和avi动画的创建; MatlabMatlab 为什么;“照明电话”;要成功创建aminated GIF/电影,必须这样做吗?,matlab,animation,matlab-figure,lighting,Matlab,Animation,Matlab Figure,Lighting,我有以下Matlab代码,用于gif和avi动画的创建; Matlabimwrite用于创建gif的帧;但我发现照明命令对于成功获取动画gif至关重要 close all clear all clc; % nFrames = 50; % Preallocate movie structure. mov(1:nFrames) = struct('cdata', [],'colormap', []); % Create movie. figure('color','white'); Z = pea
imwrite
用于创建gif的帧;但我发现照明
命令对于成功获取动画gif至关重要
close all
clear all
clc; %
nFrames = 50;
% Preallocate movie structure.
mov(1:nFrames) = struct('cdata', [],'colormap', []);
% Create movie.
figure('color','white');
Z = peaks(150); surf(Z,Z,'edgecolor','none');
view(3);
axis vis3d tight equal off;
v = axis;
%
for k = 1:nFrames
clf;
surf(1.5*sin(2*pi*k/20)*Z,Z,'edgecolor','none');
axis(v);
axis off
camlight;
lighting phong
mov(k) = getframe;
[Inx,cmap]=rgb2ind(mov(k).cdata,256);
if k==1
imwrite(Inx,cmap,'testoutx.gif','gif','DelayTime',0.25,'LoopCount',Inf) %
else
imwrite(Inx,cmap,'testoutx.gif','gif','WriteMode','append','DelayTime',0.25) %
end
end
% Create AVI file.
movie2avi(mov, 'myPeaks.avi', 'compression', 'None');
当我评论“lighting phong”时,获得的gif是静态的,而不是动画的。似乎只存储了一个帧。我还尝试在每个getframe
句子之前使用drawnow
,但这不起作用。为什么?如果不使用照明
,如何解决此问题
所需的gif(从上述代码中获得):
带有“lighting phong”的不需要的gif注释:
mhh即使使用phong点灯,它也能为我工作。你使用什么软件来可视化gif?可能是因为Matlab版本的不同?可能是因为我曾经在这里看到一个类似的问题,问题是用于可视化gif的web浏览器(即Chrome与Internet Explorer)。不管怎样,我使用R2013aCan你能用“lighting phong”发表你的gif文件吗?可能这是早期版本的Matlab错误;我正在使用R2010b@Benoit_11-该职位位于: