Get figures and use them to build a video.avi

680 visualizaciones (últimos 30 días)
Davide Magnelli
Davide Magnelli el 26 de Feb. de 2018
Respondida: Leostar90 el 31 de Mzo. de 2022
Hello, I have developed an algorithm that shows at every iteration a figure as follow:
figure
imshow(processo(:,:,1,i))
hold on
plot(X,Y,'o')
plot(X0,Y0,'o')
plot(X1,Y1,'o')
plot(X2,Y2,'o')
plot(X3,Y3,'o')
end
What I need is to save in an array each figure (i.e. imshow with each plot) and build an .avi video from them. Any suggestions?
Thanks in advance, Davide

Respuesta aceptada

KSSV
KSSV el 26 de Feb. de 2018
for i = 1:N
figure(1)
imshow(processo(:,:,1,i))
hold on
plot(X,Y,'o')
plot(X0,Y0,'o')
plot(X1,Y1,'o')
plot(X2,Y2,'o')
plot(X3,Y3,'o')
hold off
F(i) = getframe(gcf) ;
drawnow
end
% create the video writer with 1 fps
writerObj = VideoWriter('myVideo.avi');
writerObj.FrameRate = 10;
% set the seconds per image
% open the video writer
open(writerObj);
% write the frames to the video
for i=1:length(F)
% convert the image to a frame
frame = F(i) ;
writeVideo(writerObj, frame);
end
% close the writer object
close(writerObj);
  7 comentarios
Nicole Feist
Nicole Feist el 20 de Oct. de 2020
I get the error
```
Dot indexing is not supported for variables of this
type.
Error in alternateGetframe
Error in getframe (line 136)
x = alternateGetframe(parentFig, offsetRect,
scaledOffsetRect, includeDecorations);
Error in graph (line 41)
F(i) = getframe(gcf);
```
Yoseph Tereda
Yoseph Tereda el 28 de Dic. de 2020
x=[0 0 199 99];
frame=getframe(gcf,x);

Iniciar sesión para comentar.

Más respuestas (2)

Image Analyst
Image Analyst el 11 de Sept. de 2018
For what it's worth, I'm attaching my demo for creating a video from different surfaces made with the surf() function.
  2 comentarios
John Hatrick
John Hatrick el 14 de En. de 2021
Love it thank you!
Rohit Nandwani
Rohit Nandwani el 24 de Ag. de 2021
Thank You! :-)

Iniciar sesión para comentar.


Leostar90
Leostar90 el 31 de Mzo. de 2022
Thanks for such a perfect answer

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by