在播放影片之前缩放 movie() 的输出



我正在尝试在 matlab 中创建闪烁棋盘格的movie()。我使用以下代码来创建框架:

close all;
n=80; % length of checkerboard squares in pixels
p=5; % number of checkerboard rows
q=6; % number of checkerboard columns
loops=100;
A=zeros(p*n,q*n,2);
my_checkerboard=logical(checkerboard(n,p,q));
A(:,:,1)=double(my_checkerboard(1:p*n,1:q*n));
A(:,:,2)=ones(p*n,q*n);
%A(:,:,2)=double(~my_checkerboard(1:p*n,1:q*n));
F(loops)=struct('cdata',[],'colormap',[]);
h=figure;
for ii=1:1000
figure(h);
imshow(A(:,:,mod(ii,2)+1));
drawnow;
F(ii)=getframe;
end

现在如果我像这样播放电影

close all;
h=figure;
movie(h,F,1,10)

我将能够通过绘制图形的角落来缩放电影。但是如果我之前像这样缩放数字

close all;
h=figure('Position',[2640,280,960,800]);
movie(h,F,1,10)

电影不会与数字成比例。相反,电影将在图形的左下角播放。
我感觉这不仅可以通过缩放图形来完成,还可以通过缩放轴来完成,但是我不知道该怎么做。

编辑:如果有人可以在gif生成器或其他东西上链接我一些资源,我也很高兴,这可以轻松地创建一个可扩展的闪烁棋盘,其中包含可自定义数量的瓷砖。

我认为 MATLABmovie中存在错误......

以下代码在大多数情况下都有效:

close all;
n=80; % length of checkerboard squares in pixels
p=5; % number of checkerboard rows
q=6; % number of checkerboard columns
loops=100;
A=zeros(p*n,q*n,2);
my_checkerboard=logical(checkerboard(n,p,q));
A(:,:,1)=double(my_checkerboard(1:p*n,1:q*n));
A(:,:,2)=ones(p*n,q*n);
%A(:,:,2)=double(~my_checkerboard(1:p*n,1:q*n));
F(loops)=struct('cdata',[],'colormap',[]);
h=figure;
for ii=1:10
figure(h);
%imshow(A(:,:,mod(ii,2)+1));
imshow(A(:,:,mod(ii,2)+1), 'Border', 'tight'); %Show image without borders
drawnow;
F(ii)=getframe;
end
savefig(h, 'h.fig') %Save the figure to a file, (not the best solution).
%Playing the movie
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all;
h = openfig('h.fig'); %Load the figure
% h=figure;
movie(h,F,1,10)

保存和加载图形只是保持原始图形尺寸的简单方法。

最新更新