필터 지우기
필터 지우기

Get figures and use them to build a video.avi

조회 수: 574 (최근 30일)
Davide Magnelli
Davide Magnelli 2018년 2월 26일
답변: Leostar90 2022년 3월 31일
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

채택된 답변

KSSV
KSSV 2018년 2월 26일
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
Nicole Feist
Nicole Feist 2020년 10월 20일
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 2020년 12월 28일
x=[0 0 199 99];
frame=getframe(gcf,x);

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Image Analyst
Image Analyst 2018년 9월 11일
For what it's worth, I'm attaching my demo for creating a video from different surfaces made with the surf() function.
  댓글 수: 2
John Hatrick
John Hatrick 2021년 1월 14일
Love it thank you!
Rohit Nandwani
Rohit Nandwani 2021년 8월 24일
Thank You! :-)

댓글을 달려면 로그인하십시오.


Leostar90
Leostar90 2022년 3월 31일
Thanks for such a perfect answer

Community Treasure Hunt

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

Start Hunting!

Translated by