Save frames while creating a video

조회 수: 4 (최근 30일)
U A
U A 2020년 8월 24일
편집: U A 2020년 8월 26일
I'm doing a video from a data array (ArrayVelocity). The data is composed the next way: files with Columns and rows (representing X and Y direction from the 2D image) and each file means an isntant of time.
The code goes as follows:
for i=1:size(ArrayVelocity,3) %Checks the lenght of the time vector
[x_1_range, x_2_range, matrixVmag] = buildMatrix(meanArray(:,1), meanArray(:,2), ArrayVelocity(:,colVmag,i)); %Brings the information from the array
txtTitle = "";
plotContour(time(i), x, y, matrixVmag, txtTitle); %Function to plot the data
%Creates the video
frame = getframe(gcf);
writeVideo(v,frame);
close
end
I want to get the image of each instant of time (or frame) and save them in a folder.
I'm stuck with that alrerady some time. I would appreciate your help!
Thanks :)
  댓글 수: 3
U A
U A 2020년 8월 25일
The code above does and saves the video correctly...I also want to save each frame separately.
Geoff Hayes
Geoff Hayes 2020년 8월 26일
From the frame structure, you can probably just use the cdata field to write to file as an image using imwrite so long as you know how to name the frame and where you want to write the file to.

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

채택된 답변

U A
U A 2020년 8월 26일
편집: U A 2020년 8월 26일
I solved the problem by adding two simple lines:
fname = 'R:\Frames\'; %Direction of where is going to be saved the each frame
saveas(gcf, fullfile(fname,['Frame' num2str(i).png'])) %saves frame with file name
Thanks :)

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by