Domanda

I've made two movies in MATLAB and I am attempting to get them both in the same figure and save the result as an AVI file.

I understand how to use the subplot() function, but for some reason it just won't display properly. My attempt so far is this;

f(count) = im2frame(uint8(newpic));
g(count) = im2frame(uint8(newpic));
subplot(1,2,1),movie(f,10,3); axis off; title('Damaged Image','fontweight','bold');
subplot(1,2,2),movie(g,10,3); axis off; title('Recreated Image','fontweight','bold');
movie2avi(f,'mov.avi','compression','None');
movie2avi(g,'mov.avi','compression','None');

But the figure generated isn't displaying properly, and I don't actually know how to save that figure as an AVI, I only know how to save the individual files.

Any help would be greatly appreciated, thanks in advance!

È stato utile?

Soluzione

You may capture the content of a figure using getframe and add it to a movie.
Using the example code of getframe

Z = peaks;
figure('Renderer','zbuffer');
subplot(1,2,1)
surf(Z);title('first plot')
axis tight;
set(gca,'NextPlot','replaceChildren');
subplot(1,2,2);
surf(-Z);title('second plot')
axis tight;
set(gca,'NextPlot','replaceChildren');
for jj = 1:20
    subplot(1,2,1);
    surf(sin(2*pi*jj/20)*Z,Z)
    subplot(1,2,2);
    surf( -sin(2*pi*jj/20)*Z,Z);
    F(jj) = getframe;
end
movie2avi(F, 'mymov.avi', 'Compression','none');
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top