필터 지우기
필터 지우기

how to make a video out of sequenced images in order

조회 수: 4 (최근 30일)
Srinidhi Bindiganavile Ramadas
Srinidhi Bindiganavile Ramadas 2018년 10월 18일
I have this code to make video file from a set of images. I have a folder with 1240 images numbered in order from 1 to 1240. But the video from the code does not start from the image1 but from the image numbered 1000 and goes till 1240 and starts from 1 to 999 again. I know that the reading of images from folder to matlab is going wrong somehow, but how to correct that?
What should I change in order for the video to start from image1 and go till the end. Appreciate the help.
if true
% % Make an avi movie from a collection of PNG images in a folder.
% Specify the folder.
myFolder = 'H:\My Documents\windowbanktests\tudMAT50M\images';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
% Get a directory listing.
filePattern = fullfile(myFolder, '*.PNG');
pngFiles = dir(filePattern);
% Open the video writer object.
writerObj = VideoWriter('YourAVI.avi');
writerObj.FrameRate = 10;
open(writerObj);
% Go through image by image writing it out to the AVI file.
for frameNumber = 1 : length(pngFiles)
% Construct the full filename.
baseFileName = pngFiles(frameNumber).name;
fullFileName = fullfile(myFolder, baseFileName);
% Display image name in the command window.
fprintf(1, 'Now reading %s\n', fullFileName);
% Display image in an axes control.
thisimage = imread(fullFileName);
imshow(thisimage); % Display image.
drawnow; % Force display to update immediately.
% Write this frame out to the AVI file.
writeVideo(writerObj, thisimage);
end
% Close down the video writer object to finish the file.
close(writerObj);
end

채택된 답변

Image Analyst
Image Analyst 2018년 10월 18일
  댓글 수: 2
YT
YT 2018년 10월 18일
+1 this is actually pretty useful
Srinidhi Bindiganavile Ramadas
Srinidhi Bindiganavile Ramadas 2018년 10월 18일
thank you @Image Analyst. very helpfull. Solved my problem

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

추가 답변 (1개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by